KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jode > expr > CompareToIntOperator


1 /* CompareToIntOperator 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: CompareToIntOperator.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.TabbedPrintWriter;
23
24 public class CompareToIntOperator extends Operator {
25     boolean allowsNaN;
26     boolean greaterOnNaN;
27     Type compareType;
28
29     public CompareToIntOperator(Type type, boolean greaterOnNaN) {
30         super(Type.tInt, 0);
31         compareType = type;
32     this.allowsNaN = (type == Type.tFloat || type == Type.tDouble);
33     this.greaterOnNaN = greaterOnNaN;
34     initOperands(2);
35     }
36
37     public int getPriority() {
38         return 499;
39     }
40
41     public void updateSubTypes() {
42     subExpressions[0].setType(Type.tSubType(compareType));
43     subExpressions[1].setType(Type.tSubType(compareType));
44     }
45
46     public void updateType() {
47     }
48
49     public boolean opEquals(Operator o) {
50     return (o instanceof CompareToIntOperator);
51     }
52
53     public void dumpExpression(TabbedPrintWriter writer)
54     throws java.io.IOException JavaDoc
55     {
56         subExpressions[0].dumpExpression(writer, 550);
57     writer.breakOp();
58     writer.print(" <=>");
59     if (allowsNaN)
60         writer.print(greaterOnNaN ? "g" : "l");
61     writer.print(" ");
62         subExpressions[1].dumpExpression(writer, 551);
63     }
64 }
65
Popular Tags