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));
}
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()));
}
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);
}
}
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);
}
}
}
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);
}
Aggregations