List of usage examples for org.eclipse.jdt.internal.compiler.ast PrefixExpression PrefixExpression
public PrefixExpression(Expression lhs, Expression expression, int operator, int pos)
From source file:lombok.eclipse.handlers.ast.EclipseASTMaker.java
License:Open Source License
@Override public ASTNode visitUnary(final lombok.ast.Unary node, final Void p) { final String operator = node.getOperator(); final int opCode; if (UNARY_OPERATORS.containsKey(operator)) { opCode = UNARY_OPERATORS.get(operator); } else {/*from www. j a va 2 s .co m*/ throw new IllegalStateException(String.format("Unknown unary operator '%s'", operator)); } final Expression unaryExpression; if (Is.oneOf(operator, "++X", "--X")) { unaryExpression = new PrefixExpression(build(node.getExpression(), Expression.class), IntLiteral.One, opCode, 0); } else if (Is.oneOf(operator, "X++", "X--")) { unaryExpression = new PostfixExpression(build(node.getExpression(), Expression.class), IntLiteral.One, opCode, 0); } else { unaryExpression = new UnaryExpression(build(node.getExpression(), Expression.class), opCode); } setGeneratedByAndCopyPos(unaryExpression, source, posHintOf(node)); return unaryExpression; }
From source file:org.eclipse.jdt.internal.compiler.parser.Parser.java
License:Open Source License
protected void consumeUnaryExpression(int op, boolean post) { // PreIncrementExpression ::= '++' PushPosition UnaryExpression // PreDecrementExpression ::= '--' PushPosition UnaryExpression // ++ and -- operators //optimize the push/pop //this.intStack has the position of the operator when prefix Expression leftHandSide = this.expressionStack[this.expressionPtr]; if (leftHandSide instanceof Reference) { // ++foo()++ is unvalid if (post) { this.expressionStack[this.expressionPtr] = new PostfixExpression(leftHandSide, IntLiteral.One, op, this.endStatementPosition); } else {//w ww .java 2s . c om this.expressionStack[this.expressionPtr] = new PrefixExpression(leftHandSide, IntLiteral.One, op, this.intStack[this.intPtr--]); } } else { //the ++ or the -- is NOT taken into account if code gen proceeds if (!post) { this.intPtr--; } if (!this.statementRecoveryActivated) problemReporter().invalidUnaryExpression(leftHandSide); } }
From source file:org.nabucco.framework.mda.template.java.extract.statement.JavaAstStatementExtractorVisitor.java
License:Open Source License
@Override public boolean visit(PrefixExpression prefixExpression, BlockScope scope) { Expression lhs = copy(prefixExpression.lhs, scope); Expression expression = copy(prefixExpression.expression, scope); PrefixExpression prefixCopy = new PrefixExpression(lhs, expression, prefixExpression.operator, prefixExpression.sourceStart); this.statement = prefixCopy; return false; }