KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > dava > internal > javaRep > DNotExpr


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 2005 Nomair A. Naeem
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20
21
22 /*
23   Nomair A. Naeem
24   Used to represent !value in Dava AST
25 */

26
27 package soot.dava.internal.javaRep;
28
29 import soot.*;
30 import soot.util.*;
31 import soot.grimp.*;
32 //import soot.jimple.*;
33
import soot.jimple.internal.*;
34
35 public class DNotExpr extends AbstractUnopExpr
36 {
37     public DNotExpr(Value op)
38     {
39         super(Grimp.v().newExprBox(op));
40     }
41       
42     public Object JavaDoc clone()
43     {
44         return new DNotExpr(Grimp.cloneIfNecessary(getOpBox().getValue()));
45     }
46
47     public void toString( UnitPrinter up ) {
48         up.literal( " ! (" );
49         getOpBox().toString(up);
50         up.literal( ")" );
51     }
52
53     public String JavaDoc toString()
54     {
55     return " ! (" + ( getOpBox().getValue()).toString() +")";
56     }
57
58     
59     public Type getType(){
60     Value op = getOpBox().getValue();
61     
62     if(op.getType().equals(IntType.v()) || op.getType().equals(ByteType.v()) ||
63        op.getType().equals(ShortType.v()) || op.getType().equals(BooleanType.v()) ||
64        op.getType().equals(CharType.v()))
65             return IntType.v();
66         else if(op.getType().equals(LongType.v()))
67             return LongType.v();
68         else if(op.getType().equals(DoubleType.v()))
69             return DoubleType.v();
70         else if(op.getType().equals(FloatType.v()))
71             return FloatType.v();
72         else
73             return UnknownType.v();
74     }
75
76     /*
77       NOTE THIS IS AN EMPTY IMPLEMENTATION OF APPLY METHOD
78     */

79     public void apply(Switch sw){
80     }
81
82
83
84
85
86
87
88
89
90
91     /** Compares the specified object with this one for structural equality. */
92     public boolean equivTo(Object JavaDoc o)
93     {
94         if (o instanceof DNotExpr)
95         {
96             return getOpBox().getValue().equivTo(((DNotExpr)o).getOpBox().getValue());
97         }
98         return false;
99     }
100
101     /** Returns a hash code for this object, consistent with structural equality. */
102     public int equivHashCode()
103     {
104         return getOpBox().getValue().equivHashCode();
105     }
106 }
107
Popular Tags