/** * @see org.eclipse.jdt.internal.compiler.ASTVisitor#visit(org.eclipse.jdt.internal.compiler.ast.PostfixExpression, org.eclipse.jdt.internal.compiler.lookup.BlockScope) */ public boolean visit( PostfixExpression postfixExpression, BlockScope scope) { final int numberOfParens = (postfixExpression.bits & ASTNode.ParenthesizedMASK) >> ASTNode.ParenthesizedSHIFT; if (numberOfParens > 0) { manageOpeningParenthesizedExpression(postfixExpression, numberOfParens); } postfixExpression.lhs.traverse(this, scope); int operator = postfixExpression.operator == OperatorIds.PLUS ? TerminalTokens.TokenNamePLUS_PLUS : TerminalTokens.TokenNameMINUS_MINUS; this.scribe.printNextToken(operator, this.preferences.insert_space_before_postfix_operator); if (this.preferences.insert_space_after_postfix_operator) { this.scribe.space(); } if (numberOfParens > 0) { manageClosingParenthesizedExpression(postfixExpression, numberOfParens); } return false; }
@Override public void endVisit(PostfixExpression x, BlockScope scope) { try { SourceInfo info = makeSourceInfo(x); JUnaryOperator op; switch (x.operator) { case OperatorIds.MINUS: op = JUnaryOperator.DEC; break; case OperatorIds.PLUS: op = JUnaryOperator.INC; break; default: throw new InternalCompilerException("Unexpected postfix operator"); } JExpression lhs = pop(x.lhs); push(new JPostfixOperation(info, op, lhs)); } catch (Throwable e) { throw translateException(x, e); } }
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 { 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); } }
@Override public boolean visit(PostfixExpression node, BlockScope scope) { fixPositions(setGeneratedBy(node, source)); return super.visit(node, scope); }
public boolean visit( PostfixExpression postfixExpression, BlockScope scope) { addRealFragment(postfixExpression); return false; }
@Override public boolean visit(PostfixExpression node, BlockScope scope) { setGeneratedBy(node, source); applyOffsetExpression(node); return super.visit(node, scope); }