KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jode > expr > UnaryOperator


1 /* UnaryOperator 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: UnaryOperator.java,v 2.13.4.2 2002/05/28 17:34:06 hoenicke Exp $
18  */

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