1 /*******************************************************************************
2 * Copyright (c) 2000, 2001, 2002 International Business Machines Corp. and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Common Public License v0.5
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/cpl-v05.html
9 * IBM Corporation - initial API and implementation
10 ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
13 import net.sourceforge.phpdt.internal.compiler.IAbstractSyntaxTreeVisitor;
14 import net.sourceforge.phpdt.internal.compiler.codegen.CodeStream;
15 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
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 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 boolean restrainUsageToNumericTypes() {
65 public String toStringExpressionNoParenthesis() {
67 return lhs.toStringExpression() + " " + operatorToString(); //$NON-NLS-1$
70 public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
72 if (visitor.visit(this, scope)) {
73 lhs.traverse(visitor, scope);
75 visitor.endVisit(this, scope);