KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jode > expr > NopOperator


1 /* NopOperator 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: NopOperator.java,v 2.15.4.1 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 NopOperator takes one arguments and returns it again. It is used
26  * as placeholder when the real operator is not yet known (e.g. in
27  * SwitchBlock, but also in every other Operator).
28  *
29  * A Nop operator doesn't have subExpressions; getSubExpressions() simply
30  * returns zero.
31  *
32  * @author Jochen Hoenicke */

33 public class NopOperator extends Expression {
34     public NopOperator(Type type) {
35     super(type);
36     }
37
38     public int getFreeOperandCount() {
39     return 1;
40     }
41
42     public int getPriority() {
43         return 1000;
44     }
45
46     public void updateSubTypes() {
47     }
48     public void updateType() {
49     }
50
51     public Expression addOperand(Expression op) {
52     op.setType(type);
53     op.parent = parent;
54     return op;
55     }
56
57     public boolean isConstant() {
58     return false;
59     }
60
61     public boolean equals(Object JavaDoc o) {
62     return (o instanceof NopOperator);
63     }
64
65     public Expression simplify() {
66     return this;
67     }
68
69     public void dumpExpression(TabbedPrintWriter writer)
70     throws java.io.IOException JavaDoc {
71     writer.print("POP");
72     }
73 }
74
Popular Tags