01: package sisc.exprs;
02:
03: import java.io.*;
04: import sisc.data.*;
05: import sisc.interpreter.*;
06: import sisc.ser.Serializer;
07: import sisc.ser.Deserializer;
08:
09: public class LocalReferenceExp extends Expression implements Immediate {
10:
11: public int idx;
12:
13: public LocalReferenceExp(int idx) {
14: this .idx = idx;
15: }
16:
17: public void eval(Interpreter r) throws ContinuationException {
18: r.acc = r.lcl[idx];
19: r.nxp = null;
20: //r.lc++;
21: }
22:
23: public final Value getValue(Interpreter r)
24: throws ContinuationException {
25: //r.lc++;
26: return r.lcl[idx];
27: }
28:
29: public Value express() {
30: return list(sym("lcl"), Quantity.valueOf(idx));
31: }
32:
33: public void serialize(Serializer s) throws IOException {
34: s.writeInt(idx);
35: }
36:
37: public LocalReferenceExp() {
38: }
39:
40: public void deserialize(Deserializer s) throws IOException {
41: idx = s.readInt();
42: }
43:
44: public boolean equals(Object o) {
45: if (!(o instanceof LocalReferenceExp))
46: return false;
47: return idx == ((LocalReferenceExp) o).idx;
48: }
49:
50: public int hashCode() {
51: return idx | 0xea000000;
52: }
53: }
54: /*
55: * The contents of this file are subject to the Mozilla Public
56: * License Version 1.1 (the "License"); you may not use this file
57: * except in compliance with the License. You may obtain a copy of
58: * the License at http://www.mozilla.org/MPL/
59: *
60: * Software distributed under the License is distributed on an "AS
61: * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
62: * implied. See the License for the specific language governing
63: * rights and limitations under the License.
64: *
65: * The Original Code is the Second Interpreter of Scheme Code (SISC).
66: *
67: * The Initial Developer of the Original Code is Scott G. Miller.
68: * Portions created by Scott G. Miller are Copyright (C) 2000-2007
69: * Scott G. Miller. All Rights Reserved.
70: *
71: * Contributor(s):
72: * Matthias Radestock
73: *
74: * Alternatively, the contents of this file may be used under the
75: * terms of the GNU General Public License Version 2 or later (the
76: * "GPL"), in which case the provisions of the GPL are applicable
77: * instead of those above. If you wish to allow use of your
78: * version of this file only under the terms of the GPL and not to
79: * allow others to use your version of this file under the MPL,
80: * indicate your decision by deleting the provisions above and
81: * replace them with the notice and other provisions required by
82: * the GPL. If you do not delete the provisions above, a recipient
83: * may use your version of this file under either the MPL or the
84: * GPL.
85: */
|