use of org.wso2.ballerinalang.compiler.tree.statements.BLangPostIncrement in project ballerina by ballerina-lang.
the class TaintAnalyzer method visit.
public void visit(BLangPostIncrement postIncrement) {
BLangExpression varRefExpr = postIncrement.varRef;
varRefExpr.accept(this);
boolean varTaintedStatus = getObservedTaintedStatus();
visitAssignment(varRefExpr, varTaintedStatus, postIncrement.pos);
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangPostIncrement in project ballerina by ballerina-lang.
the class Desugar method visit.
public void visit(BLangPostIncrement postIncrement) {
BLangAssignment assignStmt = (BLangAssignment) TreeBuilder.createAssignmentNode();
assignStmt.pos = postIncrement.pos;
assignStmt.addVariable(rewriteExpr((BLangVariableReference) postIncrement.varRef));
assignStmt.expr = rewriteExpr(postIncrement.modifiedExpr);
result = assignStmt;
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangPostIncrement in project ballerina by ballerina-lang.
the class BLangPackageBuilder method addPostIncrementStatement.
public void addPostIncrementStatement(DiagnosticPos pos, Set<Whitespace> ws, String operator) {
BLangPostIncrement postIncrement = (BLangPostIncrement) TreeBuilder.createPostIncrementNode();
postIncrement.setVariable((BLangVariableReference) exprNodeStack.pop());
postIncrement.pos = pos;
postIncrement.addWS(ws);
addLiteralValue(pos, ws, TypeTags.INT, Long.parseLong("1"));
postIncrement.increment = (BLangExpression) exprNodeStack.pop();
postIncrement.opKind = OperatorKind.valueFrom(operator);
addStmtToCurrentBlock(postIncrement);
}
use of org.wso2.ballerinalang.compiler.tree.statements.BLangPostIncrement in project ballerina by ballerina-lang.
the class SemanticAnalyzer method visit.
public void visit(BLangPostIncrement postIncrement) {
BLangExpression varRef = postIncrement.varRef;
if (varRef.getKind() != NodeKind.SIMPLE_VARIABLE_REF && varRef.getKind() != NodeKind.INDEX_BASED_ACCESS_EXPR && varRef.getKind() != NodeKind.FIELD_BASED_ACCESS_EXPR && varRef.getKind() != NodeKind.XML_ATTRIBUTE_ACCESS_EXPR) {
if (postIncrement.opKind == OperatorKind.ADD) {
dlog.error(varRef.pos, DiagnosticCode.OPERATOR_NOT_ALLOWED_VARIABLE, OperatorKind.INCREMENT, varRef);
} else {
dlog.error(varRef.pos, DiagnosticCode.OPERATOR_NOT_ALLOWED_VARIABLE, OperatorKind.DECREMENT, varRef);
}
return;
} else {
this.typeChecker.checkExpr(varRef, env).get(0);
}
this.typeChecker.checkExpr(postIncrement.increment, env).get(0);
if (varRef.type == symTable.intType || varRef.type == symTable.floatType) {
BSymbol opSymbol = this.symResolver.resolveBinaryOperator(postIncrement.opKind, varRef.type, postIncrement.increment.type);
postIncrement.modifiedExpr = getBinaryExpr(varRef, postIncrement.increment, postIncrement.opKind, opSymbol);
} else {
if (postIncrement.opKind == OperatorKind.ADD) {
dlog.error(varRef.pos, DiagnosticCode.OPERATOR_NOT_SUPPORTED, OperatorKind.INCREMENT, varRef.type);
} else {
dlog.error(varRef.pos, DiagnosticCode.OPERATOR_NOT_SUPPORTED, OperatorKind.DECREMENT, varRef.type);
}
}
}
Aggregations