Makefile fixup
[org.ibex.tool.git] / src / org / eclipse / jdt / internal / compiler / ast / PrefixExpression.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.lookup.*;
15
16 public class PrefixExpression extends CompoundAssignment {
17
18         /**
19          * PrefixExpression constructor comment.
20          * @param l org.eclipse.jdt.internal.compiler.ast.Expression
21          * @param e org.eclipse.jdt.internal.compiler.ast.Expression
22          * @param op int
23          */
24         public PrefixExpression(Expression l, Expression e, int op, int pos) {
25
26                 super(l, e, op, l.sourceEnd);
27                 this.sourceStart = pos;
28                 this.sourceEnd = l.sourceEnd;
29         }
30
31         public String operatorToString() {
32
33                 switch (operator) {
34                         case PLUS :
35                                 return "++"; //$NON-NLS-1$
36                         case MINUS :
37                                 return "--"; //$NON-NLS-1$
38                 } 
39                 return "unknown operator"; //$NON-NLS-1$
40         }
41
42         public StringBuffer printExpressionNoParenthesis(int indent, StringBuffer output) {
43
44                 output.append(operatorToString()).append(' ');
45                 return lhs.printExpression(0, output); 
46         } 
47         
48         public boolean restrainUsageToNumericTypes() {
49
50                 return true;
51         }
52
53         public void traverse(ASTVisitor visitor, BlockScope scope) {
54
55                 if (visitor.visit(this, scope)) {
56                         lhs.traverse(visitor, scope);
57                 }
58                 visitor.endVisit(this, scope);
59         }
60 }