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