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