use of org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addTupleDestructuringStatement.
public void addTupleDestructuringStatement(DiagnosticPos pos, Set<Whitespace> ws, boolean isVarsExist, boolean varDeclaration) {
BLangTupleDestructure stmt = (BLangTupleDestructure) TreeBuilder.createTupleDestructureStatementNode();
stmt.pos = pos;
stmt.addWS(ws);
if (isVarsExist) {
stmt.setDeclaredWithVar(varDeclaration);
stmt.expr = (BLangExpression) exprNodeStack.pop();
List<ExpressionNode> lExprList = exprNodeListStack.pop();
lExprList.forEach(expressionNode -> stmt.varRefs.add((BLangVariableReference) expressionNode));
}
// TODO: handle ParamList Destructue.
addStmtToCurrentBlock(stmt);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addCompoundAssignmentStatement.
public void addCompoundAssignmentStatement(DiagnosticPos pos, Set<Whitespace> ws, String operator) {
BLangCompoundAssignment assignmentNode = (BLangCompoundAssignment) TreeBuilder.createCompoundAssignmentNode();
assignmentNode.setExpression(exprNodeStack.pop());
assignmentNode.setVariable((BLangVariableReference) exprNodeStack.pop());
assignmentNode.pos = pos;
assignmentNode.addWS(ws);
assignmentNode.opKind = OperatorKind.valueFrom(operator);
addStmtToCurrentBlock(assignmentNode);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference in project ballerina by ballerina-lang.
the class BLangPackageBuilder method createXmlAttributesRefExpr.
public void createXmlAttributesRefExpr(DiagnosticPos pos, Set<Whitespace> ws, boolean singleAttribute) {
BLangXMLAttributeAccess xmlAttributeAccess = (BLangXMLAttributeAccess) TreeBuilder.createXMLAttributeAccessNode();
xmlAttributeAccess.pos = pos;
xmlAttributeAccess.addWS(ws);
if (singleAttribute) {
xmlAttributeAccess.indexExpr = (BLangExpression) exprNodeStack.pop();
}
xmlAttributeAccess.expr = (BLangVariableReference) exprNodeStack.pop();
addExpressionNode(xmlAttributeAccess);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addForeachStatement.
public void addForeachStatement(DiagnosticPos pos, Set<Whitespace> ws) {
BLangForeach foreach = (BLangForeach) TreeBuilder.createForeachNode();
foreach.addWS(ws);
foreach.pos = pos;
foreach.setCollection(exprNodeStack.pop());
foreach.addWS(commaWsStack.pop());
List<ExpressionNode> lExprList = exprNodeListStack.pop();
lExprList.forEach(expressionNode -> foreach.addVariable((BLangVariableReference) expressionNode));
BLangBlockStmt foreachBlock = (BLangBlockStmt) this.blockNodeStack.pop();
foreachBlock.pos = pos;
foreach.setBody(foreachBlock);
addStmtToCurrentBlock(foreach);
}
use of org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference in project ballerina by ballerina-lang.
the class BLangPackageBuilder method createInvocationNode.
public void createInvocationNode(DiagnosticPos pos, Set<Whitespace> ws, String invocation, boolean argsAvailable) {
BLangInvocation invocationNode = (BLangInvocation) TreeBuilder.createInvocationNode();
invocationNode.pos = pos;
invocationNode.addWS(ws);
invocationNode.addWS(invocationWsStack.pop());
if (argsAvailable) {
List<ExpressionNode> exprNodes = exprNodeListStack.pop();
exprNodes.forEach(exprNode -> invocationNode.argExprs.add((BLangExpression) exprNode));
invocationNode.addWS(commaWsStack.pop());
}
invocationNode.expr = (BLangVariableReference) exprNodeStack.pop();
invocationNode.name = (BLangIdentifier) createIdentifier(invocation);
invocationNode.pkgAlias = (BLangIdentifier) createIdentifier(null);
addExpressionNode(invocationNode);
}
Aggregations