use of org.ballerinalang.model.tree.expressions.ExpressionNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addAssignmentStatement.
public void addAssignmentStatement(DiagnosticPos pos, Set<Whitespace> ws, boolean isVarDeclaration, boolean safeAssignment) {
ExpressionNode rExprNode = exprNodeStack.pop();
ExpressionNode lExprNode = exprNodeStack.pop();
BLangAssignment assignmentNode = (BLangAssignment) TreeBuilder.createAssignmentNode();
assignmentNode.setExpression(rExprNode);
assignmentNode.setDeclaredWithVar(isVarDeclaration);
assignmentNode.pos = pos;
assignmentNode.addWS(ws);
assignmentNode.safeAssignment = safeAssignment;
assignmentNode.addVariable((BLangVariableReference) lExprNode);
addStmtToCurrentBlock(assignmentNode);
}
use of org.ballerinalang.model.tree.expressions.ExpressionNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addExprToExprNodeList.
private void addExprToExprNodeList(List<ExpressionNode> exprList, int n) {
if (exprNodeStack.empty()) {
throw new IllegalStateException("Expression stack cannot be empty in processing an ExpressionList");
}
ExpressionNode expr = exprNodeStack.pop();
if (n > 1) {
addExprToExprNodeList(exprList, n - 1);
}
exprList.add(expr);
}
use of org.ballerinalang.model.tree.expressions.ExpressionNode in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addTypeInitExpression.
public void addTypeInitExpression(DiagnosticPos pos, Set<Whitespace> ws, String initName, boolean typeAvailable, boolean exprAvailable) {
BLangTypeInit objectInitNode = (BLangTypeInit) TreeBuilder.createObjectInitNode();
objectInitNode.pos = pos;
objectInitNode.addWS(ws);
if (typeAvailable) {
objectInitNode.userDefinedType = (BLangUserDefinedType) typeNodeStack.pop();
}
BLangInvocation invocationNode = (BLangInvocation) TreeBuilder.createInvocationNode();
invocationNode.pos = pos;
invocationNode.addWS(ws);
if (exprAvailable) {
List<ExpressionNode> exprNodes = exprNodeListStack.pop();
Set<Whitespace> cws = commaWsStack.pop();
exprNodes.forEach(exprNode -> {
invocationNode.argExprs.add((BLangExpression) exprNode);
objectInitNode.argsExpr.add((BLangExpression) exprNode);
});
invocationNode.addWS(cws);
objectInitNode.addWS(cws);
}
// TODO check whether pkgName can be be empty
IdentifierNode pkgNameNode = TreeBuilder.createIdentifierNode();
IdentifierNode nameNode = createIdentifier(initName);
BLangNameReference nameReference = new BLangNameReference(pos, ws, pkgNameNode, nameNode);
invocationNode.name = (BLangIdentifier) nameReference.name;
invocationNode.addWS(nameReference.ws);
invocationNode.pkgAlias = (BLangIdentifier) nameReference.pkgAlias;
objectInitNode.objectInitInvocation = invocationNode;
this.addExpressionNode(objectInitNode);
}
Aggregations