01: /* Soot - a J*va Optimization Framework
02: * Copyright (C) 1997 Clark Verbrugge
03: *
04: * This library is free software; you can redistribute it and/or
05: * modify it under the terms of the GNU Lesser General Public
06: * License as published by the Free Software Foundation; either
07: * version 2.1 of the License, or (at your option) any later version.
08: *
09: * 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: * Modified by the Sable Research Group and others 1997-1999.
22: * See the 'credits' file distributed with Soot for the complete list of
23: * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
24: */
25:
26: package soot.coffi;
27:
28: /** A constant pool entry of type CONSTANT_Double.
29: * @see cp_info
30: * @author Clark Verbrugge
31: */
32: class CONSTANT_Double_info extends cp_info {
33: /** High-order 32 bits of the double. */
34: public long high;
35: /** High-order 32 bits of the double. */
36: public long low;
37:
38: /** Returns the size of this cp_info object.
39: * @return number of bytes occupied by this object.
40: * @see cp_info#size
41: */
42: public int size() {
43: return 9;
44: }
45:
46: /** Converts the internal representation (two ints) to a double. */
47: public double convert() {
48: return Double.longBitsToDouble(ints2long(high, low));
49: }
50:
51: /** Returns a String representation of this entry.
52: * @param constant_pool constant pool of ClassFile.
53: * @return String representation of this entry.
54: * @see cp_info#toString
55: */
56: public String toString(cp_info constant_pool[]) {
57: return Double.toString(convert());
58: }
59:
60: /** Returns a String description of what kind of entry this is.
61: * @return the String "double".
62: * @see cp_info#typeName
63: */
64: public String typeName() {
65: return "double";
66: }
67:
68: /** Compares this entry with another cp_info object (which may reside
69: * in a different constant pool).
70: * @param constant_pool constant pool of ClassFile for this.
71: * @param cp constant pool entry to compare against.
72: * @param cp_constant_pool constant pool of ClassFile for cp.
73: * @return a value <0, 0, or >0 indicating whether this is smaller,
74: * the same or larger than cp.
75: * @see cp_info#compareTo
76: */
77: public int compareTo(cp_info constant_pool[], cp_info cp,
78: cp_info cp_constant_pool[]) {
79: double d;
80: if (tag != cp.tag)
81: return tag - cp.tag;
82: CONSTANT_Double_info cu = (CONSTANT_Double_info) cp;
83: d = convert() - cu.convert();
84: return ((d > 0.0) ? 1 : ((d < 0.0) ? -1 : 0));
85: }
86: }
|