KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > jode > jvm > Value


1 /* Value Copyright (C) 1999-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: Value.java,v 1.5.2.1 2002/05/28 17:34:12 hoenicke Exp $
18  */

19
20 package jode.jvm;
21 import jode.bytecode.*;
22
23 /**
24  * This class represents a stack value.
25  *
26  * @author Jochen Hoenicke
27  */

28 class Value {
29     Object JavaDoc value;
30     NewObject newObj;
31
32     public Value() {
33     }
34
35     public void setObject(Object JavaDoc obj) {
36     newObj = null;
37     value = obj;
38     }
39
40     public Object JavaDoc objectValue() {
41     if (newObj != null)
42         return newObj.objectValue();
43     return value;
44     }
45
46     public void setInt(int i) {
47     newObj = null;
48     value = new Integer JavaDoc(i);
49     }
50
51     public int intValue() {
52     return ((Integer JavaDoc)value).intValue();
53     }
54
55     public void setLong(long i) {
56     newObj = null;
57     value = new Long JavaDoc(i);
58     }
59
60     public long longValue() {
61     return ((Long JavaDoc)value).longValue();
62     }
63
64     public void setFloat(float i) {
65     newObj = null;
66     value = new Float JavaDoc(i);
67     }
68
69     public float floatValue() {
70     return ((Float JavaDoc)value).floatValue();
71     }
72
73     public void setDouble(double i) {
74     newObj = null;
75     value = new Double JavaDoc(i);
76     }
77
78     public double doubleValue() {
79     return ((Double JavaDoc)value).doubleValue();
80     }
81
82     public void setNewObject(NewObject n) {
83     newObj = n;
84     }
85
86     public NewObject getNewObject() {
87     return newObj;
88     }
89
90     public void setValue(Value val) {
91     value = val.value;
92     newObj = val.newObj;
93     }
94
95     public String JavaDoc toString() {
96     return newObj != null ? newObj.toString() : ""+value;
97     }
98 }
99
Popular Tags