1 11 package org.eclipse.jdt.internal.compiler.ast; 12 13 import org.eclipse.jdt.internal.compiler.ASTVisitor; 14 import org.eclipse.jdt.internal.compiler.codegen.*; 15 import org.eclipse.jdt.internal.compiler.lookup.*; 16 17 public class PostfixExpression extends CompoundAssignment { 18 19 public PostfixExpression(Expression lhs, Expression expression, int operator, int pos) { 20 super(lhs, expression, operator, pos); 21 this.sourceStart = lhs.sourceStart; 22 this.sourceEnd = pos; 23 } 24 25 32 public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { 33 37 int pc = codeStream.position; 38 ((Reference) this.lhs).generatePostIncrement(currentScope, codeStream, this, valueRequired); 39 if (valueRequired) { 40 codeStream.generateImplicitConversion(this.implicitConversion); 41 } 42 codeStream.recordPositionsFrom(pc, this.sourceStart); 43 } 44 45 public String operatorToString() { 46 switch (this.operator) { 47 case PLUS : 48 return "++"; case MINUS : 50 return "--"; } 52 return "unknown operator"; } 54 55 public StringBuffer printExpressionNoParenthesis(int indent, StringBuffer output) { 56 return this.lhs.printExpression(indent, output).append(' ').append(operatorToString()); 57 } 58 59 public boolean restrainUsageToNumericTypes() { 60 return true; 61 } 62 63 public void traverse(ASTVisitor visitor, BlockScope scope) { 64 65 if (visitor.visit(this, scope)) { 66 this.lhs.traverse(visitor, scope); 67 } 68 visitor.endVisit(this, scope); 69 } 70 } 71 | Popular Tags |