Merged xdebug from 1.3.x
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / compiler / ast / PostfixExpression.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 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
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.ASTVisitor;
14 import net.sourceforge.phpdt.internal.compiler.lookup.BlockScope;
15
16 public class PostfixExpression extends CompoundAssignment {
17
18         public PostfixExpression(Expression l, Expression e, int op, int pos) {
19
20                 super(l, e, op, pos);
21                 this.sourceStart = l.sourceStart;
22                 this.sourceEnd = pos;
23         }
24
25         /**
26          * Code generation for PostfixExpression
27          * 
28          * @param currentScope
29          *            net.sourceforge.phpdt.internal.compiler.lookup.BlockScope
30          * @param codeStream
31          *            net.sourceforge.phpdt.internal.compiler.codegen.CodeStream
32          * @param valueRequired
33          *            boolean
34          */
35         // public void generateCode(
36         // BlockScope currentScope,
37         // CodeStream codeStream,
38         // boolean valueRequired) {
39         //
40         // // various scenarii are possible, setting an array reference,
41         // // a field reference, a blank final field reference, a field of an
42         // enclosing instance or
43         // // just a local variable.
44         //
45         // int pc = codeStream.position;
46         // ((Reference) lhs).generatePostIncrement(currentScope, codeStream, this,
47         // valueRequired);
48         // if (valueRequired) {
49         // codeStream.generateImplicitConversion(implicitConversion);
50         // }
51         // codeStream.recordPositionsFrom(pc, this.sourceStart);
52         // }
53         public String operatorToString() {
54                 switch (operator) {
55                 case PLUS:
56                         return "++"; //$NON-NLS-1$
57                 case MINUS:
58                         return "--"; //$NON-NLS-1$
59                 }
60                 return "unknown operator"; //$NON-NLS-1$
61         }
62
63         public boolean restrainUsageToNumericTypes() {
64
65                 return true;
66         }
67
68         public String toStringExpressionNoParenthesis() {
69
70                 return lhs.toStringExpression() + " " + operatorToString(); //$NON-NLS-1$
71         }
72
73         public void traverse(ASTVisitor visitor, BlockScope scope) {
74
75                 if (visitor.visit(this, scope)) {
76                         lhs.traverse(visitor, scope);
77                 }
78                 visitor.endVisit(this, scope);
79         }
80 }