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