1 /*******************************************************************************
2 * Copyright (c) 2000, 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v10.html
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.ast;
13 import org.eclipse.jdt.internal.compiler.ASTVisitor;
14 import org.eclipse.jdt.internal.compiler.codegen.*;
15 import org.eclipse.jdt.internal.compiler.lookup.*;
17 public class PostfixExpression extends CompoundAssignment {
19 public PostfixExpression(Expression l, Expression e, int op, int pos) {
22 this.sourceStart = l.sourceStart;
27 * Code generation for PostfixExpression
29 * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
30 * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
31 * @param valueRequired boolean
33 public void generateCode(
34 BlockScope currentScope,
35 CodeStream codeStream,
36 boolean valueRequired) {
38 // various scenarii are possible, setting an array reference,
39 // a field reference, a blank final field reference, a field of an enclosing instance or
40 // just a local variable.
42 int pc = codeStream.position;
43 ((Reference) lhs).generatePostIncrement(currentScope, codeStream, this, valueRequired);
45 codeStream.generateImplicitConversion(implicitConversion);
47 codeStream.recordPositionsFrom(pc, this.sourceStart);
50 public String operatorToString() {
53 return "++"; //$NON-NLS-1$
55 return "--"; //$NON-NLS-1$
57 return "unknown operator"; //$NON-NLS-1$
60 public StringBuffer printExpressionNoParenthesis(int indent, StringBuffer output) {
62 return lhs.printExpression(indent, output).append(' ').append(operatorToString());
65 public boolean restrainUsageToNumericTypes() {
70 public void traverse(ASTVisitor visitor, BlockScope scope) {
72 if (visitor.visit(this, scope)) {
73 lhs.traverse(visitor, scope);
75 visitor.endVisit(this, scope);