Search in sources :

Example 1 with BConnectorType

use of org.ballerinalang.model.types.BConnectorType in project ballerina by ballerina-lang.

the class GetActionAnnotations method execute.

@Override
public void execute(Context context) {
    BTypeDescValue bTypeValue = (BTypeDescValue) context.getRefArgument(0);
    if (!(bTypeValue.value() instanceof BConnectorType)) {
        context.setReturnValues((BValue) null);
    }
    BConnectorType connectorType = (BConnectorType) bTypeValue.value();
    String key = connectorType.getName() + DOT + context.getStringArgument(0);
    context.setReturnValues(getAnnotationValue(context, connectorType.getPackagePath(), key));
}
Also used : BTypeDescValue(org.ballerinalang.model.values.BTypeDescValue) BConnectorType(org.ballerinalang.model.types.BConnectorType)

Example 2 with BConnectorType

use of org.ballerinalang.model.types.BConnectorType in project ballerina by ballerina-lang.

the class GetConnectorAnnotations method execute.

@Override
public void execute(Context context) {
    BTypeDescValue bTypeValue = (BTypeDescValue) context.getRefArgument(0);
    if (!(bTypeValue.value() instanceof BConnectorType)) {
        context.setReturnValues((BValue) null);
    }
    BConnectorType connectorType = (BConnectorType) bTypeValue.value();
    context.setReturnValues(getAnnotationValue(context, connectorType.getPackagePath(), connectorType.getName()));
}
Also used : BTypeDescValue(org.ballerinalang.model.values.BTypeDescValue) BConnectorType(org.ballerinalang.model.types.BConnectorType)

Example 3 with BConnectorType

use of org.ballerinalang.model.types.BConnectorType in project ballerina by ballerina-lang.

the class ProgramFileReader method readConnectorInfoEntries.

private void readConnectorInfoEntries(DataInputStream dataInStream, PackageInfo packageInfo) throws IOException {
    int connectorCount = dataInStream.readShort();
    for (int i = 0; i < connectorCount; i++) {
        // Read connector name cp index
        int connectorNameCPIndex = dataInStream.readInt();
        UTF8CPEntry connectorNameUTF8Entry = (UTF8CPEntry) packageInfo.getCPEntry(connectorNameCPIndex);
        int flags = dataInStream.readInt();
        // Create connector info
        String connectorName = connectorNameUTF8Entry.getValue();
        ConnectorInfo connectorInfo = new ConnectorInfo(packageInfo.getPkgNameCPIndex(), packageInfo.getPkgPath(), connectorNameCPIndex, connectorName, flags);
        packageInfo.addConnectorInfo(connectorName, connectorInfo);
        // Set connector type
        BConnectorType bConnectorType = new BConnectorType(connectorName, packageInfo.getPkgPath());
        connectorInfo.setType(bConnectorType);
    }
}
Also used : UTF8CPEntry(org.ballerinalang.util.codegen.cpentries.UTF8CPEntry) BConnectorType(org.ballerinalang.model.types.BConnectorType)

Example 4 with BConnectorType

use of org.ballerinalang.model.types.BConnectorType in project ballerina by ballerina-lang.

the class ProgramFileReader method resolveConnectorMethodTables.

private void resolveConnectorMethodTables(PackageInfo packageInfo) {
    ConnectorInfo[] connectorInfoEntries = packageInfo.getConnectorInfoEntries();
    for (ConnectorInfo connectorInfo : connectorInfoEntries) {
        BConnectorType connectorType = connectorInfo.getType();
        VarTypeCountAttributeInfo attributeInfo = (VarTypeCountAttributeInfo) connectorInfo.getAttributeInfo(AttributeInfo.Kind.VARIABLE_TYPE_COUNT_ATTRIBUTE);
        connectorType.setFieldTypeCount(attributeInfo.getVarTypeCount());
        Map<Integer, Integer> methodTableInteger = connectorInfo.getMethodTableIndex();
        Map<BConnectorType, ConnectorInfo> methodTableType = new HashMap<>();
        for (Integer key : methodTableInteger.keySet()) {
            int keyType = methodTableInteger.get(key);
            TypeRefCPEntry typeRefCPEntry = (TypeRefCPEntry) packageInfo.getCPEntry(key);
            StructureRefCPEntry structureRefCPEntry = (StructureRefCPEntry) packageInfo.getCPEntry(keyType);
            ConnectorInfo connectorInfoType = (ConnectorInfo) structureRefCPEntry.getStructureTypeInfo();
            methodTableType.put((BConnectorType) typeRefCPEntry.getType(), connectorInfoType);
        }
        connectorInfo.setMethodTableType(methodTableType);
        for (ActionInfo actionInfo : connectorInfo.getActionInfoEntries()) {
            setCallableUnitSignature(actionInfo, actionInfo.getSignature(), packageInfo);
        }
    }
}
Also used : VarTypeCountAttributeInfo(org.ballerinalang.util.codegen.attributes.VarTypeCountAttributeInfo) HashMap(java.util.HashMap) TypeRefCPEntry(org.ballerinalang.util.codegen.cpentries.TypeRefCPEntry) BConnectorType(org.ballerinalang.model.types.BConnectorType) StructureRefCPEntry(org.ballerinalang.util.codegen.cpentries.StructureRefCPEntry)

Example 5 with BConnectorType

use of org.ballerinalang.model.types.BConnectorType in project ballerina by ballerina-lang.

the class CPU method invokeAction.

private static WorkerExecutionContext invokeAction(WorkerExecutionContext ctx, String actionName, int[] argRegs, int[] retRegs, int flags) {
    BConnector connector = (BConnector) ctx.workerLocal.refRegs[argRegs[0]];
    if (connector == null) {
        ctx.setError(BLangVMErrors.createNullRefException(ctx));
        handleError(ctx);
        return null;
    }
    BConnectorType actualCon = (BConnectorType) connector.getConnectorType();
    ActionInfo actionInfo = ctx.programFile.getPackageInfo(actualCon.getPackagePath()).getConnectorInfo(actualCon.getName()).getActionInfo(actionName);
    return BLangFunctions.invokeCallable(actionInfo, ctx, argRegs, retRegs, false, flags);
}
Also used : BConnector(org.ballerinalang.model.values.BConnector) BConnectorType(org.ballerinalang.model.types.BConnectorType) ActionInfo(org.ballerinalang.util.codegen.ActionInfo)

Aggregations

BConnectorType (org.ballerinalang.model.types.BConnectorType)5 BTypeDescValue (org.ballerinalang.model.values.BTypeDescValue)2 HashMap (java.util.HashMap)1 BConnector (org.ballerinalang.model.values.BConnector)1 ActionInfo (org.ballerinalang.util.codegen.ActionInfo)1 VarTypeCountAttributeInfo (org.ballerinalang.util.codegen.attributes.VarTypeCountAttributeInfo)1 StructureRefCPEntry (org.ballerinalang.util.codegen.cpentries.StructureRefCPEntry)1 TypeRefCPEntry (org.ballerinalang.util.codegen.cpentries.TypeRefCPEntry)1 UTF8CPEntry (org.ballerinalang.util.codegen.cpentries.UTF8CPEntry)1