deleted: export="true"
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / PostfixExpression.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  ******************************************************************************/
11 package net.sourceforge.phpdt.internal.compiler.ast;
12
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;
16
17 public class PostfixExpression extends CompoundAssignment {
18
19         public PostfixExpression(Expression l, Expression e, int op, int pos) {
20                 
21                 super(l, e, op, pos);
22                 this.sourceStart = l.sourceStart;
23                 this.sourceEnd = pos;
24         }
25         
26         /**
27          * Code generation for PostfixExpression
28          *
29          * @param currentScope org.eclipse.jdt.internal.compiler.lookup.BlockScope
30          * @param codeStream org.eclipse.jdt.internal.compiler.codegen.CodeStream
31          * @param valueRequired boolean
32          */
33         public void generateCode(
34                 BlockScope currentScope,
35                 CodeStream codeStream,
36                 boolean valueRequired) {
37
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.
41
42                 int pc = codeStream.position;
43                 lhs.generatePostIncrement(currentScope, codeStream, this, valueRequired);
44                 if (valueRequired) {
45                         codeStream.generateImplicitConversion(implicitConversion);
46                 }
47                 codeStream.recordPositionsFrom(pc, this.sourceStart);
48         }
49
50         public String operatorToString() {
51                 switch (operator) {
52                         case PLUS :
53                                 return "++"; //$NON-NLS-1$
54                         case MINUS :
55                                 return "--"; //$NON-NLS-1$
56                 } 
57                 return "unknown operator"; //$NON-NLS-1$
58         }
59         
60         public boolean restrainUsageToNumericTypes() {
61
62                 return true;
63         }
64         
65         public String toStringExpressionNoParenthesis() {
66
67                 return lhs.toStringExpression() + " " + operatorToString(); //$NON-NLS-1$
68         } 
69
70         public void traverse(IAbstractSyntaxTreeVisitor visitor, BlockScope scope) {
71
72                 if (visitor.visit(this, scope)) {
73                         lhs.traverse(visitor, scope);
74                 }
75                 visitor.endVisit(this, scope);
76         }
77 }