Search in sources :

Example 31 with BLangAssignment

use of org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment 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 32 with BLangAssignment

use of org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment 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

BLangAssignment (org.wso2.ballerinalang.compiler.tree.statements.BLangAssignment)29 DiagnosticPos (org.wso2.ballerinalang.compiler.util.diagnotic.DiagnosticPos)13 BLangVariable (org.wso2.ballerinalang.compiler.tree.BLangVariable)11 BLangExpression (org.wso2.ballerinalang.compiler.tree.expressions.BLangExpression)10 BLangSimpleVarRef (org.wso2.ballerinalang.compiler.tree.expressions.BLangSimpleVarRef)9 BLangBinaryExpr (org.wso2.ballerinalang.compiler.tree.expressions.BLangBinaryExpr)7 BLangBlockStmt (org.wso2.ballerinalang.compiler.tree.statements.BLangBlockStmt)7 BLangVariableDef (org.wso2.ballerinalang.compiler.tree.statements.BLangVariableDef)7 ArrayList (java.util.ArrayList)6 BVarSymbol (org.wso2.ballerinalang.compiler.semantics.model.symbols.BVarSymbol)6 BLangVariableReference (org.wso2.ballerinalang.compiler.tree.expressions.BLangVariableReference)6 BLangIndexBasedAccess (org.wso2.ballerinalang.compiler.tree.expressions.BLangIndexBasedAccess)5 BType (org.wso2.ballerinalang.compiler.semantics.model.types.BType)4 BLangForeach (org.wso2.ballerinalang.compiler.tree.statements.BLangForeach)4 BLangIf (org.wso2.ballerinalang.compiler.tree.statements.BLangIf)4 BLangEndpoint (org.wso2.ballerinalang.compiler.tree.BLangEndpoint)3 BLangRecordLiteral (org.wso2.ballerinalang.compiler.tree.expressions.BLangRecordLiteral)3 BLangReturn (org.wso2.ballerinalang.compiler.tree.statements.BLangReturn)3 BLangStatement (org.wso2.ballerinalang.compiler.tree.statements.BLangStatement)3 Arrays (java.util.Arrays)2