use of org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt in project ballerina by ballerina-lang.
the class SymbolEnter method createInitFuncInvocationStmt.
private BLangExpressionStmt createInitFuncInvocationStmt(BLangImportPackage importPackage, BInvokableSymbol initFunctionSymbol) {
BLangInvocation invocationNode = (BLangInvocation) TreeBuilder.createInvocationNode();
invocationNode.pos = importPackage.pos;
invocationNode.addWS(importPackage.getWS());
BLangIdentifier funcName = (BLangIdentifier) TreeBuilder.createIdentifierNode();
funcName.value = initFunctionSymbol.name.value;
invocationNode.name = funcName;
invocationNode.pkgAlias = importPackage.alias;
BLangExpressionStmt exprStmt = (BLangExpressionStmt) TreeBuilder.createExpressionStatementNode();
exprStmt.pos = importPackage.pos;
exprStmt.addWS(importPackage.getWS());
exprStmt.expr = invocationNode;
return exprStmt;
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt in project ballerina by ballerina-lang.
the class TaintAnalyzer method visit.
public void visit(BLangExpressionStmt exprStmtNode) {
SymbolEnv stmtEnv = new SymbolEnv(exprStmtNode, this.env.scope);
this.env.copyTo(stmtEnv);
analyzeNode(exprStmtNode.expr, stmtEnv);
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt 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.BLangExpressionStmt in project ballerina by ballerina-lang.
the class EndpointDesugar method generateEndpointStartOrStop.
private BLangBlockStmt generateEndpointStartOrStop(BLangEndpoint endpoint, BInvokableSymbol funSymbol, SymbolEnv env, BSymbol encSymbol) {
BLangBlockStmt temp = new BLangBlockStmt();
if (funSymbol == null || endpoint.configurationExpr == null || endpoint.configurationExpr.getKind() != NodeKind.RECORD_LITERAL_EXPR) {
// 2: If endpoint in initialized
return temp;
}
final DiagnosticPos pos = endpoint.pos;
final String epName = endpoint.name.value;
final BLangVariable epVariable = ASTBuilderUtil.createVariable(pos, epName, endpoint.symbol.type);
final Name name = names.fromIdNode(endpoint.name);
epVariable.symbol = (BVarSymbol) symResolver.lookupMemberSymbol(pos, encSymbol.scope, env, name, SymTag.VARIABLE);
List<BLangVariable> args = new ArrayList<>();
if (funSymbol.params.size() == 1) {
// Endpoint is already desugared. Fix this correctly.
args.add(0, epVariable);
}
final BLangExpressionStmt expressionStmt = ASTBuilderUtil.createExpressionStmt(pos, temp);
final BLangInvocation iExpr = ASTBuilderUtil.createInvocationExpr(pos, funSymbol, args, symResolver);
if (funSymbol.params.size() != 1) {
iExpr.expr = ASTBuilderUtil.createVariableRef(epVariable.pos, epVariable.symbol);
}
expressionStmt.expr = iExpr;
return temp;
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangExpressionStmt in project ballerina by ballerina-lang.
the class EndpointDesugar method generateEndpointInitFunctionCall.
private BLangBlockStmt generateEndpointInitFunctionCall(BLangEndpoint endpoint, SymbolEnv env, BSymbol encSymbol, BSymbol varEncSymbol) {
BLangBlockStmt temp = new BLangBlockStmt();
if (endpoint.configurationExpr == null || endpoint.configurationExpr.getKind() != NodeKind.RECORD_LITERAL_EXPR) {
return temp;
}
final String epName = endpoint.name.value;
final DiagnosticPos pos = endpoint.pos;
final BLangVariable epVariable = ASTBuilderUtil.createVariable(pos, epName, endpoint.symbol.type);
epVariable.symbol = (BVarSymbol) symResolver.lookupMemberSymbol(pos, encSymbol.scope, env, names.fromString(epName), SymTag.VARIABLE);
// EPConfigType ep_nameConf = { ep-config-expr };
final BLangVariableDef epConfigNewStmt = ASTBuilderUtil.createVariableDefStmt(pos, temp);
epConfigNewStmt.var = ASTBuilderUtil.createVariable(pos, epName + "Conf", endpoint.configurationExpr.type);
epConfigNewStmt.var.expr = endpoint.configurationExpr;
ASTBuilderUtil.defineVariable(epConfigNewStmt.var, varEncSymbol, names);
List<BLangVariable> args = Lists.of(epConfigNewStmt.var);
if (endpoint.symbol.initFunction != null && endpoint.symbol.initFunction.params.size() == 2) {
// Endpoint is already desugared. Fix this correctly.
args.add(0, epVariable);
}
// epName.init(ep_nameConf);
final BLangExpressionStmt expressionStmt = ASTBuilderUtil.createExpressionStmt(pos, temp);
final BLangInvocation iExpr = ASTBuilderUtil.createInvocationExpr(pos, endpoint.symbol.initFunction, args, symResolver);
if (endpoint.symbol.initFunction != null && endpoint.symbol.initFunction.params.size() != 2) {
iExpr.expr = ASTBuilderUtil.createVariableRef(epVariable.pos, epVariable.symbol);
}
expressionStmt.expr = iExpr;
return temp;
}
Aggregations