01: /* PrePostFixOperator Copyright (C) 1998-2002 Jochen Hoenicke.
02: *
03: * This program is free software; you can redistribute it and/or modify
04: * it under the terms of the GNU Lesser General Public License as published by
05: * the Free Software Foundation; either version 2, or (at your option)
06: * any later version.
07: *
08: * This program is distributed in the hope that it will be useful,
09: * 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:
22: import jode.type.Type;
23: import jode.decompiler.TabbedPrintWriter;
24:
25: /**
26: * A PrePostFixOperator has one subexpression, namely the StoreInstruction.
27: */
28: public class PrePostFixOperator extends Operator {
29: boolean postfix;
30:
31: public PrePostFixOperator(Type type, int operatorIndex,
32: LValueExpression lvalue, boolean postfix) {
33: super (type);
34: this .postfix = postfix;
35: setOperatorIndex(operatorIndex);
36: initOperands(1);
37: setSubExpressions(0, (Operator) lvalue);
38: }
39:
40: public int getPriority() {
41: return postfix ? 800 : 700;
42: }
43:
44: public void updateSubTypes() {
45: if (!isVoid())
46: subExpressions[0].setType(type);
47: }
48:
49: public void updateType() {
50: if (!isVoid())
51: updateParentType(subExpressions[0].getType());
52: }
53:
54: public void dumpExpression(TabbedPrintWriter writer)
55: throws java.io.IOException {
56: if (!postfix)
57: writer.print(getOperatorString());
58: writer.startOp(writer.NO_PAREN, 2);
59: subExpressions[0].dumpExpression(writer);
60: writer.endOp();
61: if (postfix)
62: writer.print(getOperatorString());
63: }
64: }
|