Search in sources :

Example 26 with BInvokableSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol in project ballerina by ballerina-lang.

the class SymbolEnter method visit.

@Override
public void visit(BLangWorker workerNode) {
    BInvokableSymbol workerSymbol = Symbols.createWorkerSymbol(Flags.asMask(workerNode.flagSet), names.fromIdNode(workerNode.name), env.enclPkg.symbol.pkgID, null, env.scope.owner);
    workerNode.symbol = workerSymbol;
    defineSymbolWithCurrentEnvOwner(workerNode.pos, workerSymbol);
}
Also used : BInvokableSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol)

Example 27 with BInvokableSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol in project ballerina by ballerina-lang.

the class SymbolEnter method visit.

@Override
public void visit(BLangFunction funcNode) {
    boolean validAttachedFunc = validateFuncReceiver(funcNode);
    BInvokableSymbol funcSymbol = Symbols.createFunctionSymbol(Flags.asMask(funcNode.flagSet), getFuncSymbolName(funcNode), env.enclPkg.symbol.pkgID, null, env.scope.owner);
    SymbolEnv invokableEnv = SymbolEnv.createFunctionEnv(funcNode, funcSymbol.scope, env);
    defineInvokableSymbol(funcNode, funcSymbol, invokableEnv);
    // Define function receiver if any.
    if (funcNode.receiver != null) {
        defineAttachedFunctions(funcNode, funcSymbol, invokableEnv, validAttachedFunc);
    }
}
Also used : BInvokableSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol) SymbolEnv(org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)

Example 28 with BInvokableSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol in project ballerina by ballerina-lang.

the class SemanticAnalyzer method visit.

// Streaming related methods.
public void visit(BLangForever foreverStatement) {
    for (StreamingQueryStatementNode streamingQueryStatement : foreverStatement.gettreamingQueryStatements()) {
        analyzeStmt((BLangStatement) streamingQueryStatement, env);
    }
    List<BLangVariable> globalVariableList = this.env.enclPkg.globalVars;
    if (globalVariableList != null) {
        for (BLangVariable variable : globalVariableList) {
            if (((variable).type.tsymbol) != null) {
                if ("stream".equals((((variable).type.tsymbol)).name.value)) {
                    foreverStatement.addGlobalVariable(variable);
                }
            }
        }
    }
    List<BVarSymbol> functionParameterList = ((BInvokableSymbol) this.env.scope.owner).getParameters();
    for (BVarSymbol varSymbol : functionParameterList) {
        if ("stream".equals((((varSymbol).type.tsymbol)).name.value)) {
            foreverStatement.addFunctionVariable(varSymbol);
        }
    }
}
Also used : StreamingQueryStatementNode(org.ballerinalang.model.tree.statements.StreamingQueryStatementNode) BInvokableSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable) BVarSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)

Example 29 with BInvokableSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol in project ballerina by ballerina-lang.

the class CodeGenerator method visit.

public void visit(BLangTransformerInvocation iExpr) {
    BInvokableSymbol transformerSymbol = (BInvokableSymbol) iExpr.symbol;
    int pkgRefCPIndex = addPackageRefCPEntry(currentPkgInfo, transformerSymbol.pkgID);
    int transformerNameCPIndex = addUTF8CPEntry(currentPkgInfo, transformerSymbol.name.value);
    TransformerRefCPEntry transformerRefCPEntry = new TransformerRefCPEntry(pkgRefCPIndex, transformerNameCPIndex);
    int transformerRefCPIndex = currentPkgInfo.addCPEntry(transformerRefCPEntry);
    Operand[] operands = getFuncOperands(iExpr, transformerRefCPIndex);
    emit(InstructionCodes.TCALL, operands);
}
Also used : TransformerRefCPEntry(org.wso2.ballerinalang.programfile.cpentries.TransformerRefCPEntry) Operand(org.wso2.ballerinalang.programfile.Instruction.Operand) BInvokableSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Example 30 with BInvokableSymbol

use of org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol in project ballerina by ballerina-lang.

the class CodeGenerator method visit.

public void visit(BLangActionInvocation aIExpr) {
    BInvokableSymbol actionSymbol = (BInvokableSymbol) aIExpr.symbol;
    int pkgRefCPIndex = addPackageRefCPEntry(currentPkgInfo, actionSymbol.pkgID);
    int actionNameCPIndex = addUTF8CPEntry(currentPkgInfo, actionSymbol.name.value);
    ActionRefCPEntry actionRefCPEntry = new ActionRefCPEntry(pkgRefCPIndex, actionNameCPIndex);
    int actionRefCPIndex = currentPkgInfo.addCPEntry(actionRefCPEntry);
    Operand[] operands = getFuncOperands(aIExpr, actionRefCPIndex);
    emit(InstructionCodes.ACALL, operands);
}
Also used : Operand(org.wso2.ballerinalang.programfile.Instruction.Operand) ActionRefCPEntry(org.wso2.ballerinalang.programfile.cpentries.ActionRefCPEntry) BInvokableSymbol(org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol) BLangEndpoint(org.wso2.ballerinalang.compiler.tree.BLangEndpoint)

Aggregations

BInvokableSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol)31 BInvokableType (org.wso2.ballerinalang.compiler.semantics.model.types.BInvokableType)14 ArrayList (java.util.ArrayList)12 BVarSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)11 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)10 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)9 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)8 SymbolInfo (org.ballerinalang.langserver.completions.SymbolInfo)7 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)7 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)7 BPackageSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol)6 BTypeSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BTypeSymbol)6 List (java.util.List)5 Collectors (java.util.stream.Collectors)5 HashMap (java.util.HashMap)4 BStructSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BStructSymbol)4 BAttachedFunction (org.wso2.ballerinalang.compiler.semantics.model.symbols.BStructSymbol.BAttachedFunction)4 BLangInvocation (org.wso2.ballerinalang.compiler.tree.expressions.BLangInvocation)4 BLangExpressionStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt)4 CompilerContext (org.wso2.ballerinalang.compiler.util.CompilerContext)4