Search in sources :

Example 26 with BLangVariableReference

use of org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference 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);
}
Also used : ExpressionNode(org.ballerinalang.model.tree.expressions.ExpressionNode) SelectExpressionNode(org.ballerinalang.model.tree.clauses.SelectExpressionNode) BLangAssignment(org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment)

Example 27 with BLangVariableReference

use of org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference in project ballerina by ballerina-lang.

the class Desugar method visit.

public void visit(BLangCompoundAssignment compoundAssignment) {
    BLangAssignment assignStmt = (BLangAssignment) TreeBuilder.createAssignmentNode();
    assignStmt.pos = compoundAssignment.pos;
    assignStmt.addVariable(rewriteExpr((BLangVariableReference) compoundAssignment.varRef));
    assignStmt.expr = rewriteExpr(compoundAssignment.modifiedExpr);
    result = assignStmt;
}
Also used : BLangVariableReference(org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference) BLangAssignment(org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment)

Aggregations

BLangVariableReference (org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference)16 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)8 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)8 BLangAssignment (org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment)7 ArrayList (java.util.ArrayList)6 BLangFieldBasedAccess (org.wso2.ballerinalang.compiler.tree.expressions.BLangFieldBasedAccess)6 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)6 BSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BSymbol)5 SelectExpressionNode (org.ballerinalang.model.tree.clauses.SelectExpressionNode)4 ExpressionNode (org.ballerinalang.model.tree.expressions.ExpressionNode)4 SymbolEnv (org.wso2.ballerinalang.compiler.semantics.model.SymbolEnv)4 BPackageSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BPackageSymbol)4 BLangBlockStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt)4 Arrays (java.util.Arrays)3 List (java.util.List)3 Map (java.util.Map)3 Stack (java.util.Stack)3 Collectors (java.util.stream.Collectors)3 CompilerPhase (org.ballerinalang.compiler.CompilerPhase)3 TreeBuilder (org.ballerinalang.model.TreeBuilder)3