KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > eclipse > jdt > internal > compiler > ast > PrefixExpression


1 /*******************************************************************************
2  * Copyright (c) 2000, 2006 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials
4  * are made available under the terms of the Eclipse Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/epl-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 lhs org.eclipse.jdt.internal.compiler.ast.Expression
21  * @param expression org.eclipse.jdt.internal.compiler.ast.Expression
22  * @param operator int
23  */

24 public PrefixExpression(Expression lhs, Expression expression, int operator, int pos) {
25     super(lhs, expression, operator, lhs.sourceEnd);
26     this.sourceStart = pos;
27     this.sourceEnd = lhs.sourceEnd;
28 }
29
30 public String JavaDoc operatorToString() {
31     switch (this.operator) {
32         case PLUS :
33             return "++"; //$NON-NLS-1$
34
case MINUS :
35             return "--"; //$NON-NLS-1$
36
}
37     return "unknown operator"; //$NON-NLS-1$
38
}
39
40 public StringBuffer JavaDoc printExpressionNoParenthesis(int indent, StringBuffer JavaDoc output) {
41
42     output.append(operatorToString()).append(' ');
43     return this.lhs.printExpression(0, output);
44 }
45
46 public boolean restrainUsageToNumericTypes() {
47     return true;
48 }
49
50 public void traverse(ASTVisitor visitor, BlockScope scope) {
51     if (visitor.visit(this, scope)) {
52         this.lhs.traverse(visitor, scope);
53     }
54     visitor.endVisit(this, scope);
55 }
56 }
57
Popular Tags