Makefile fixup
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / ast / PostfixExpression.java
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
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package org.eclipse.jdt.internal.compiler.ast;
12
13 import org.eclipse.jdt.internal.compiler.ASTVisitor;
14 import org.eclipse.jdt.internal.compiler.codegen.*;
15 import org.eclipse.jdt.internal.compiler.lookup.*;
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                  ((Reference) 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 StringBuffer printExpressionNoParenthesis(int indent, StringBuffer output) {
61
62                 return lhs.printExpression(indent, output).append(' ').append(operatorToString()); 
63         } 
64
65         public boolean restrainUsageToNumericTypes() {
66
67                 return true;
68         }
69         
70         public void traverse(ASTVisitor visitor, BlockScope scope) {
71
72                 if (visitor.visit(this, scope)) {
73                         lhs.traverse(visitor, scope);
74                 }
75                 visitor.endVisit(this, scope);
76         }
77 }