Search in sources :

Example 1 with BLangAction

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();
}
Also used : BSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 2 with BLangAction

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;
}
Also used : BLangAction(org.wso2.ballerinalang.compiler.tree.BLangAction)

Example 3 with BLangAction

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);
}
Also used : BInvokableSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv) BLangIdentifier(org.wso2.ballerinalang.compiler.tree.BLangIdentifier) BInvokableType(org.wso2.ballerinalang.compiler.semantics.model.types.BInvokableType) BVarSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)

Example 4 with BLangAction

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);
}
Also used : ActionInfo(org.wso2.ballerinalang.programfile.ActionInfo) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 5 with BLangAction

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);
}
Also used : BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) BInvokableSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol) ActionInfo(org.wso2.ballerinalang.programfile.ActionInfo) BInvokableType(org.wso2.ballerinalang.compiler.semantics.model.types.BInvokableType) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Aggregations

BLangAction (org.wso2.ballerinalang.compiler.tree.BLangAction)11 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)8 BLangConnector (org.wso2.ballerinalang.compiler.tree.BLangConnector)6 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)6 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)5 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)5 ArrayList (java.util.ArrayList)4 BInvokableSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol)4 BInvokableType (org.wso2.ballerinalang.compiler.semantics.model.types.BInvokableType)4 BLangPackage (org.wso2.ballerinalang.compiler.tree.BLangPackage)4 List (java.util.List)3 BLangFunction (org.wso2.ballerinalang.compiler.tree.BLangFunction)3 BLangStruct (org.wso2.ballerinalang.compiler.tree.BLangStruct)3 IOException (java.io.IOException)2 HashMap (java.util.HashMap)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 Variable (org.ballerinalang.docgen.model.Variable)2 DocumentServiceKeys (org.ballerinalang.langserver.DocumentServiceKeys)2 TextDocumentServiceContext (org.ballerinalang.langserver.TextDocumentServiceContext)2