use of org.wso2.ballerinalang.compiler.tree.BLangAction in project ballerina by ballerina-lang.
the class SignatureTreeVisitor method visit.
@Override
public void visit(BLangAction actionNode) {
BSymbol actionSymbol = actionNode.symbol;
SymbolEnv actionEnv = SymbolEnv.createResourceActionSymbolEnv(actionNode, actionSymbol.scope, symbolEnv);
actionNode.workers.forEach(w -> this.acceptNode(w, actionEnv));
this.blockOwnerStack.push(actionNode);
acceptNode(actionNode.body, actionEnv);
this.blockOwnerStack.pop();
}
use of org.wso2.ballerinalang.compiler.tree.BLangAction in project ballerina by ballerina-lang.
the class SymbolEnter method createNativeInitAction.
private BLangAction createNativeInitAction(DiagnosticPos pos) {
BLangAction initAction = (BLangAction) TreeBuilder.createActionNode();
initAction.setName(createIdentifier(Names.INIT_ACTION_SUFFIX.getValue()));
initAction.flagSet = EnumSet.of(Flag.NATIVE, Flag.PUBLIC);
initAction.pos = pos;
return initAction;
}
use of org.wso2.ballerinalang.compiler.tree.BLangAction in project ballerina by ballerina-lang.
the class SymbolEnter method visit.
@Override
public void visit(BLangAction actionNode) {
BInvokableSymbol actionSymbol = Symbols.createActionSymbol(Flags.asMask(actionNode.flagSet), names.fromIdNode(actionNode.name), env.enclPkg.symbol.pkgID, null, env.scope.owner);
SymbolEnv invokableEnv = SymbolEnv.createResourceActionSymbolEnv(actionNode, actionSymbol.scope, env);
defineInvokableSymbol(actionNode, actionSymbol, invokableEnv);
actionNode.endpoints.forEach(ep -> defineNode(ep, invokableEnv));
// TODO check below as it create a new symbol for the connector
BVarSymbol varSymbol = new BVarSymbol(Flags.asMask(EnumSet.noneOf(Flag.class)), names.fromIdNode((BLangIdentifier) createIdentifier(Names.CONNECTOR.getValue())), env.enclPkg.symbol.pkgID, actionSymbol.owner.type, invokableEnv.scope.owner);
actionSymbol.receiverSymbol = varSymbol;
((BInvokableType) actionSymbol.type).setReceiverType(varSymbol.type);
}
use of org.wso2.ballerinalang.compiler.tree.BLangAction in project ballerina by ballerina-lang.
the class CodeGenerator method visit.
public void visit(BLangAction actionNode) {
ActionInfo actionInfo = currentConnectorInfo.actionInfoMap.get(actionNode.name.getValue());
currentCallableUnitInfo = actionInfo;
SymbolEnv actionEnv = SymbolEnv.createResourceActionSymbolEnv(actionNode, actionNode.symbol.scope, this.env);
visitInvokableNode(actionNode, currentCallableUnitInfo, actionEnv);
}
use of org.wso2.ballerinalang.compiler.tree.BLangAction in project ballerina by ballerina-lang.
the class CodeGenerator method createActionInfoEntry.
private void createActionInfoEntry(BLangAction actionNode, ConnectorInfo connectorInfo) {
BInvokableSymbol actionSymbol = actionNode.symbol;
BInvokableType actionType = (BInvokableType) actionSymbol.type;
// Add action name as an UTFCPEntry to the constant pool
int actionNameCPIndex = addUTF8CPEntry(currentPkgInfo, actionNode.name.value);
ActionInfo actionInfo = new ActionInfo(currentPackageRefCPIndex, actionNameCPIndex);
actionInfo.paramTypes = actionType.paramTypes.toArray(new BType[0]);
actionInfo.retParamTypes = actionType.retTypes.toArray(new BType[0]);
actionInfo.flags = actionSymbol.flags;
// setParameterNames(actionNode, actionInfo);
actionInfo.signatureCPIndex = addUTF8CPEntry(currentPkgInfo, generateFunctionSig(actionInfo.paramTypes, actionInfo.retParamTypes));
// Add worker info
this.addWorkerInfoEntries(actionInfo, actionNode.getWorkers());
// Add parameter default value info
addParameterDefaultValues(actionNode, actionInfo);
// Add action info to the connector info
connectorInfo.actionInfoMap.put(actionNode.name.getValue(), actionInfo);
}
Aggregations