KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jode > expr > PrePostFixOperator


1 /* PrePostFixOperator Copyright (C) 1998-2002 Jochen Hoenicke.
2  *
3  * This program is free software; you can redistribute it and/or modify
4  * it under the terms of the GNU Lesser General Public License as published by
5  * the Free Software Foundation; either version 2, or (at your option)
6  * any later version.
7  *
8  * This program is distributed in the hope that it will be useful,
9  * but WITHOUT ANY WARRANTY; without even the implied warranty of
10  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11  * GNU General Public License for more details.
12  *
13  * You should have received a copy of the GNU Lesser General Public License
14  * along with this program; see the file COPYING.LESSER. If not, write to
15  * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
16  *
17  * $Id: PrePostFixOperator.java,v 3.10.2.2 2002/05/28 17:34:06 hoenicke Exp $
18  */

19
20 package jode.expr;
21 import jode.type.Type;
22 import jode.decompiler.TabbedPrintWriter;
23
24 /**
25  * A PrePostFixOperator has one subexpression, namely the StoreInstruction.
26  */

27 public class PrePostFixOperator extends Operator {
28     boolean postfix;
29
30     public PrePostFixOperator(Type type, int operatorIndex,
31                   LValueExpression lvalue, boolean postfix) {
32         super(type);
33         this.postfix = postfix;
34     setOperatorIndex(operatorIndex);
35     initOperands(1);
36     setSubExpressions(0, (Operator) lvalue);
37     }
38     
39     public int getPriority() {
40         return postfix ? 800 : 700;
41     }
42
43     public void updateSubTypes() {
44     if (!isVoid())
45         subExpressions[0].setType(type);
46     }
47
48     public void updateType() {
49     if (!isVoid())
50         updateParentType(subExpressions[0].getType());
51     }
52
53     public void dumpExpression(TabbedPrintWriter writer)
54     throws java.io.IOException JavaDoc {
55     if (!postfix)
56         writer.print(getOperatorString());
57     writer.startOp(writer.NO_PAREN, 2);
58     subExpressions[0].dumpExpression(writer);
59     writer.endOp();
60         if (postfix)
61         writer.print(getOperatorString());
62     }
63 }
64
Popular Tags