Search in sources :

Example 1 with BLangForever

use of org.wso2.ballerinalang.compiler.tree.statements.BLangForever in project ballerina by ballerina-lang.

the class Desugar method visit.

public void visit(BLangForever foreverStatement) {
    siddhiQueryBuilder.visit(foreverStatement);
    BLangExpressionStmt stmt = (BLangExpressionStmt) TreeBuilder.createExpressionStatementNode();
    stmt.expr = createInvocationForForeverBlock(foreverStatement);
    stmt.pos = foreverStatement.pos;
    stmt.addWS(foreverStatement.getWS());
    result = rewrite(stmt, env);
}
Also used : BLangExpressionStmt(org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt)

Example 2 with BLangForever

use of org.wso2.ballerinalang.compiler.tree.statements.BLangForever in project ballerina by ballerina-lang.

the class Desugar method createInvocationForForeverBlock.

private BLangInvocation createInvocationForForeverBlock(BLangForever forever) {
    List<BLangExpression> args = new ArrayList<>();
    List<BType> retTypes = new ArrayList<>();
    retTypes.add(symTable.noType);
    BLangLiteral streamingQueryLiteral = ASTBuilderUtil.createLiteral(forever.pos, symTable.stringType, forever.getSiddhiQuery());
    args.add(streamingQueryLiteral);
    addReferenceVariablesToArgs(args, siddhiQueryBuilder.getInStreamRefs());
    addReferenceVariablesToArgs(args, siddhiQueryBuilder.getInTableRefs());
    addReferenceVariablesToArgs(args, siddhiQueryBuilder.getOutStreamRefs());
    addReferenceVariablesToArgs(args, siddhiQueryBuilder.getOutTableRefs());
    addFunctionPointersToArgs(args, forever.gettreamingQueryStatements());
    return createInvocationNode(CREATE_FOREVER, args, retTypes);
}
Also used : BLangLiteral(org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral) BType(org.wso2.ballerinalang.compiler.semantics.model.types.BType) ArrayList(java.util.ArrayList) BLangExpression(org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)

Example 3 with BLangForever

use of org.wso2.ballerinalang.compiler.tree.statements.BLangForever in project ballerina by ballerina-lang.

the class SiddhiQueryBuilder method visit.

public void visit(BLangForever foreverStatement) {
    siddhiQuery = new StringBuilder();
    streamDefinitionQuery = new StringBuilder();
    streamIds = new HashSet<>();
    inStreamRefs = new ArrayList<>();
    outStreamRefs = new ArrayList<>();
    inTableRefs = new ArrayList<>();
    outTableRefs = new ArrayList<>();
    binaryExpr = null;
    setExpr = null;
    orderByClause = null;
    whereClause = null;
    windowClause = null;
    joinStreamingInputClause = null;
    streamingInputClause = null;
    selectExprClause = null;
    selectExpr = null;
    setAssignmentClause = null;
    groupByClause = null;
    havingClause = null;
    patternStreamingClause = null;
    streamActionClause = null;
    intRangeExpr = null;
    List<VariableNode> globalVariables = foreverStatement.getGlobalVariables();
    if (globalVariables != null) {
        for (VariableNode variable : globalVariables) {
            ((BLangVariable) variable).accept(this);
        }
    }
    List<VariableSymbol> functionVariables = foreverStatement.getFunctionVariables();
    if (functionVariables != null) {
        for (VariableSymbol variable : functionVariables) {
            getStreamDefintionForFuntionVariable((BVarSymbol) variable);
        }
    }
    List<? extends StatementNode> statementNodes = foreverStatement.gettreamingQueryStatements();
    for (StatementNode statementNode : statementNodes) {
        ((BLangStatement) statementNode).accept(this);
    }
    foreverStatement.setSiddhiQuery(this.getSiddhiQuery());
    foreverStatement.setStreamIdsAsString(String.join(",", streamIds));
}
Also used : VariableNode(org.ballerinalang.model.tree.VariableNode) BLangStatement(org.wso2.ballerinalang.compiler.tree.statements.BLangStatement) StatementNode(org.ballerinalang.model.tree.statements.StatementNode) VariableSymbol(org.ballerinalang.model.symbols.VariableSymbol) BLangVariable(org.wso2.ballerinalang.compiler.tree.BLangVariable)

Example 4 with BLangForever

use of org.wso2.ballerinalang.compiler.tree.statements.BLangForever 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)

Aggregations

BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)2 ArrayList (java.util.ArrayList)1 VariableSymbol (org.ballerinalang.model.symbols.VariableSymbol)1 VariableNode (org.ballerinalang.model.tree.VariableNode)1 StatementNode (org.ballerinalang.model.tree.statements.StatementNode)1 StreamingQueryStatementNode (org.ballerinalang.model.tree.statements.StreamingQueryStatementNode)1 BInvokableSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BInvokableSymbol)1 BVarSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)1 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)1 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)1 BLangLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangLiteral)1 BLangExpressionStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt)1 BLangStatement (org.wso2.ballerinalang.compiler.tree.statements.BLangStatement)1