use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class EndpointDesugar method generateEndpointInit.
private BLangBlockStmt generateEndpointInit(BLangEndpoint endpoint, SymbolEnv env, BSymbol encSymbol) {
final String epName = endpoint.name.value;
final DiagnosticPos pos = endpoint.pos;
BLangBlockStmt temp = new BLangBlockStmt();
final BLangVariable epVariable = ASTBuilderUtil.createVariable(pos, epName, endpoint.symbol.type);
epVariable.symbol = (BVarSymbol) symResolver.lookupMemberSymbol(pos, encSymbol.scope, env, names.fromString(epName), SymTag.VARIABLE);
final BLangExpression newExpr;
if (endpoint.configurationExpr != null && endpoint.configurationExpr.getKind() != NodeKind.RECORD_LITERAL_EXPR) {
// Handle Endpoint Assignment.
newExpr = endpoint.configurationExpr;
} else if (endpoint.configurationExpr != null && endpoint.configurationExpr.getKind() == NodeKind.RECORD_LITERAL_EXPR) {
// Handle Endpoint initialization.
newExpr = ASTBuilderUtil.createEmptyRecordLiteral(pos, endpoint.symbol.type);
} else {
newExpr = null;
}
// EPType ep_name = {};
if (env.enclInvokable != null) {
// In callable unit, endpoint is same scope variable.
final BLangVariableDef epNewStmt = ASTBuilderUtil.createVariableDefStmt(pos, temp);
epNewStmt.var = epVariable;
epNewStmt.var.expr = newExpr;
} else {
// This is an init function. ep variable is defined in outside.
if (env.enclService != null) {
// Add to endpoint variable to relevant location
final BLangVariableDef epVarDef = ASTBuilderUtil.createVariableDef(pos);
epVarDef.var = epVariable;
env.enclService.vars.add(epVarDef);
}
final BLangAssignment assignmentStmt = ASTBuilderUtil.createAssignmentStmt(pos, temp);
assignmentStmt.varRefs.add(ASTBuilderUtil.createVariableRef(pos, epVariable.symbol));
assignmentStmt.expr = newExpr;
}
return temp;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class SiddhiQueryBuilder method visit.
@Override
public void visit(BLangStreamingInput streamingInput) {
streamingInputClause = new StringBuilder();
streamingInputClause.append(((BLangSimpleVarRef) streamingInput.getStreamReference()).getVariableName().value);
WhereNode beforeWhereNode = streamingInput.getBeforeStreamingCondition();
WhereNode afterWhereNode = streamingInput.getAfterStreamingCondition();
WindowClauseNode windowClauseNode = streamingInput.getWindowClause();
if (beforeWhereNode != null) {
((BLangWhere) beforeWhereNode).accept(this);
streamingInputClause.append(" ").append(whereClause);
}
if (windowClauseNode != null) {
((BLangWindow) windowClauseNode).accept(this);
streamingInputClause.append(" ").append(windowClause);
}
if (afterWhereNode != null) {
((BLangWhere) afterWhereNode).accept(this);
streamingInputClause.append(" ").append(whereClause);
}
if (streamingInput.getAlias() != null) {
streamingInputClause.append(" as ").append(streamingInput.getAlias()).append(" ");
}
BLangExpression streamReference = (BLangExpression) streamingInput.getStreamReference();
if (streamReference != null) {
streamReference.accept(this);
streamIds.add(varRef);
varRef = "";
addInRefs(streamReference);
}
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class SiddhiQueryBuilder method visit.
@Override
public void visit(BLangSelectExpression selectExpression) {
BLangExpression expr = (BLangExpression) selectExpression.getExpression();
selectExpr = new StringBuilder();
addVarRefToClauseBuilder(expr, selectExpr);
String identifier = selectExpression.getIdentifier();
if (identifier != null) {
selectExpr.append(" as ").append(identifier);
}
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class BLangPackageBuilder method createBracedOrTupleExpression.
public void createBracedOrTupleExpression(DiagnosticPos pos, Set<Whitespace> ws, int numberOfExpressions) {
final BLangBracedOrTupleExpr expr = (BLangBracedOrTupleExpr) TreeBuilder.createBracedOrTupleExpression();
expr.pos = pos;
expr.addWS(ws);
for (int i = 0; i < numberOfExpressions; i++) {
expr.expressions.add(0, (BLangExpression) exprNodeStack.pop());
}
addExpressionNode(expr);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression in project ballerina by ballerina-lang.
the class BLangPackageBuilder method createTypeCastExpr.
public void createTypeCastExpr(DiagnosticPos pos, Set<Whitespace> ws) {
BLangTypeCastExpr typeCastNode = (BLangTypeCastExpr) TreeBuilder.createTypeCastNode();
typeCastNode.pos = pos;
typeCastNode.addWS(ws);
typeCastNode.expr = (BLangExpression) exprNodeStack.pop();
typeCastNode.typeNode = (BLangType) typeNodeStack.pop();
addExpressionNode(typeCastNode);
}
Aggregations