use of org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef in project ballerina by ballerina-lang.
the class Desugar method createInvocationFromTableExpr.
private BLangInvocation createInvocationFromTableExpr(BLangTableQueryExpression tableQueryExpression) {
List<BLangExpression> args = new ArrayList<>();
List<BType> retTypes = new ArrayList<>();
String functionName = QUERY_TABLE_WITHOUT_JOIN_CLAUSE;
// Order matters, because these are the args for a function invocation.
args.add(getSQLPreparedStatement(tableQueryExpression));
args.add(getFromTableVarRef(tableQueryExpression));
// BLangTypeofExpr
retTypes.add(tableQueryExpression.type);
BLangSimpleVarRef joinTable = getJoinTableVarRef(tableQueryExpression);
if (joinTable != null) {
args.add(joinTable);
functionName = QUERY_TABLE_WITH_JOIN_CLAUSE;
}
args.add(getSQLStatementParameters(tableQueryExpression));
args.add(getReturnType(tableQueryExpression));
return createInvocationNode(functionName, args, retTypes);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef in project ballerina by ballerina-lang.
the class Desugar method createAssignmentStmt.
// TODO: Same function is used in symbol enter. Refactor this to reuse the same function.
private StatementNode createAssignmentStmt(BLangVariable variable) {
BLangSimpleVarRef varRef = (BLangSimpleVarRef) TreeBuilder.createSimpleVariableReferenceNode();
varRef.pos = variable.pos;
varRef.variableName = variable.name;
varRef.symbol = variable.symbol;
varRef.type = variable.type;
varRef.pkgAlias = (BLangIdentifier) TreeBuilder.createIdentifierNode();
BLangAssignment assignmentStmt = (BLangAssignment) TreeBuilder.createAssignmentNode();
assignmentStmt.expr = variable.expr;
assignmentStmt.pos = variable.pos;
assignmentStmt.addVariable(varRef);
return assignmentStmt;
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef in project ballerina by ballerina-lang.
the class Desugar method addArgInitExpr.
private void addArgInitExpr(BLangTransformer transformerNode, BLangVariable var) {
BLangSimpleVarRef varRef = new BLangLocalVarRef(var.symbol);
varRef.lhsVar = true;
varRef.pos = var.pos;
varRef.type = var.type;
BLangExpression initExpr = null;
switch(var.type.tag) {
case TypeTags.MAP:
initExpr = new BLangMapLiteral(new ArrayList<>(), var.type);
break;
case TypeTags.JSON:
initExpr = new BLangJSONLiteral(new ArrayList<>(), var.type);
break;
case TypeTags.STRUCT:
initExpr = new BLangStructLiteral(new ArrayList<>(), var.type);
break;
case TypeTags.INT:
case TypeTags.FLOAT:
case TypeTags.STRING:
case TypeTags.BOOLEAN:
case TypeTags.BLOB:
case TypeTags.XML:
return;
case TypeTags.TABLE:
case TypeTags.STREAM:
// TODO: add this once the able initializing is supported.
return;
default:
return;
}
initExpr.pos = var.pos;
BLangAssignment assignStmt = (BLangAssignment) TreeBuilder.createAssignmentNode();
assignStmt.pos = var.pos;
assignStmt.addVariable(varRef);
assignStmt.expr = initExpr;
transformerNode.body.stmts.add(0, assignStmt);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addServiceEndpointAttachments.
public void addServiceEndpointAttachments(int size, Set<Whitespace> ws) {
ServiceNode serviceNode = serviceNodeStack.peek();
serviceNode.addWS(ws);
for (int i = 0; i < size; i++) {
BLangNameReference nameReference = nameReferenceStack.pop();
BLangSimpleVarRef varRef = (BLangSimpleVarRef) TreeBuilder.createSimpleVariableReferenceNode();
varRef.pos = nameReference.pos;
varRef.addWS(nameReference.ws);
varRef.pkgAlias = (BLangIdentifier) nameReference.pkgAlias;
varRef.variableName = (BLangIdentifier) nameReference.name;
serviceNode.bindToEndpoint(varRef);
}
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef in project ballerina by ballerina-lang.
the class BLangPackageBuilder method createActionInvocationNode.
public void createActionInvocationNode(DiagnosticPos pos, Set<Whitespace> ws, boolean async) {
BLangInvocation invocationExpr = (BLangInvocation) exprNodeStack.pop();
invocationExpr.actionInvocation = true;
invocationExpr.pos = pos;
invocationExpr.addWS(ws);
invocationExpr.async = async;
BLangNameReference nameReference = nameReferenceStack.pop();
BLangSimpleVarRef varRef = (BLangSimpleVarRef) TreeBuilder.createSimpleVariableReferenceNode();
varRef.pos = nameReference.pos;
varRef.addWS(nameReference.ws);
varRef.pkgAlias = (BLangIdentifier) nameReference.pkgAlias;
varRef.variableName = (BLangIdentifier) nameReference.name;
invocationExpr.expr = varRef;
exprNodeStack.push(invocationExpr);
}
Aggregations