01: /* UnaryOperator 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: UnaryOperator.java,v 2.13.4.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.Options;
24: import jode.decompiler.TabbedPrintWriter;
25:
26: public class UnaryOperator extends Operator {
27: public UnaryOperator(Type type, int op) {
28: super (type, op);
29: initOperands(1);
30: }
31:
32: public int getPriority() {
33: return 700;
34: }
35:
36: public Expression negate() {
37: if (getOperatorIndex() == LOG_NOT_OP) {
38: if (subExpressions != null)
39: return subExpressions[0];
40: else
41: return new NopOperator(Type.tBoolean);
42: }
43: return super .negate();
44: }
45:
46: public void updateSubTypes() {
47: subExpressions[0].setType(Type.tSubType(type));
48: }
49:
50: public void updateType() {
51: updateParentType(Type.tSuperType(subExpressions[0].getType()));
52: }
53:
54: public boolean opEquals(Operator o) {
55: return (o instanceof UnaryOperator)
56: && o.operatorIndex == operatorIndex;
57: }
58:
59: public void dumpExpression(TabbedPrintWriter writer)
60: throws java.io.IOException {
61: writer.print(getOperatorString());
62: if ((Options.outputStyle & Options.GNU_SPACING) != 0)
63: writer.print(" ");
64: subExpressions[0].dumpExpression(writer, 700);
65: }
66: }
|