removed NPE in XMLPreferenceInitializer
[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 net.sourceforge.phpdt.internal.compiler.lookup.BlockScope
29          * @param codeStream net.sourceforge.phpdt.internal.compiler.codegen.CodeStream
30          * @param valueRequired boolean
31          */
32 //      public void generateCode(
33 //              BlockScope currentScope,
34 //              CodeStream codeStream,
35 //              boolean valueRequired) {
36 //
37 //              // various scenarii are possible, setting an array reference, 
38 //              // a field reference, a blank final field reference, a field of an enclosing instance or 
39 //              // just a local variable.
40 //
41 //              int pc = codeStream.position;
42 //               ((Reference) lhs).generatePostIncrement(currentScope, codeStream, this, valueRequired);
43 //              if (valueRequired) {
44 //                      codeStream.generateImplicitConversion(implicitConversion);
45 //              }
46 //              codeStream.recordPositionsFrom(pc, this.sourceStart);
47 //      }
48
49         public String operatorToString() {
50                 switch (operator) {
51                         case PLUS :
52                                 return "++"; //$NON-NLS-1$
53                         case MINUS :
54                                 return "--"; //$NON-NLS-1$
55                 } 
56                 return "unknown operator"; //$NON-NLS-1$
57         }
58         
59         public boolean restrainUsageToNumericTypes() {
60
61                 return true;
62         }
63         
64         public String toStringExpressionNoParenthesis() {
65
66                 return lhs.toStringExpression() + " " + operatorToString(); //$NON-NLS-1$
67         } 
68
69         public void traverse(ASTVisitor visitor, BlockScope scope) {
70
71                 if (visitor.visit(this, scope)) {
72                         lhs.traverse(visitor, scope);
73                 }
74                 visitor.endVisit(this, scope);
75         }
76 }