01: package sisc.compiler;
02:
03: import java.util.*;
04: import sisc.data.*;
05: import sisc.util.Util;
06:
07: class ARecord extends Util {
08: static final Symbol program = Symbol.get("program");
09:
10: Map references = new HashMap();
11: Map sets = new HashMap();
12: Set frees = new HashSet();
13: Value body;
14:
15: public ARecord(Value v) {
16: body = v;
17: }
18:
19: public String toString() {
20: return "{refs: " + references + ", sets: " + sets + ", frees:"
21: + frees + "}";
22: }
23:
24: protected static final Pair mapToAssoc(Map m) {
25: Pair rv = EMPTYLIST;
26: for (Iterator i = m.keySet().iterator(); i.hasNext();) {
27: Value key = (Value) i.next();
28: rv = new Pair(new Pair(key, Quantity.valueOf(((Integer) m
29: .get(key)).intValue())), rv);
30: }
31: return rv;
32: }
33:
34: protected static final Pair setToList(Set s) {
35: Pair rv = EMPTYLIST;
36: for (Iterator i = s.iterator(); i.hasNext();) {
37: rv = new Pair((Value) i.next(), rv);
38: }
39: return rv;
40: }
41:
42: public Expression asExpression() {
43: return new Pair(program, new Pair(mapToAssoc(references), list(
44: mapToAssoc(sets), setToList(frees), body)));
45: }
46: }
47: /*
48: * The contents of this file are subject to the Mozilla Public
49: * License Version 1.1 (the "License"); you may not use this file
50: * except in compliance with the License. You may obtain a copy of
51: * the License at http://www.mozilla.org/MPL/
52: *
53: * Software distributed under the License is distributed on an "AS
54: * IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or
55: * implied. See the License for the specific language governing
56: * rights and limitations under the License.
57: *
58: * The Original Code is the Second Interpreter of Scheme Code (SISC).
59: *
60: * The Initial Developer of the Original Code is Scott G. Miller.
61: * Portions created by Scott G. Miller are Copyright (C) 2000-2007
62: * Scott G. Miller. All Rights Reserved.
63: *
64: * Contributor(s):
65: * Matthias Radestock
66: *
67: * Alternatively, the contents of this file may be used under the
68: * terms of the GNU General Public License Version 2 or later (the
69: * "GPL"), in which case the provisions of the GPL are applicable
70: * instead of those above. If you wish to allow use of your
71: * version of this file only under the terms of the GPL and not to
72: * allow others to use your version of this file under the MPL,
73: * indicate your decision by deleting the provisions above and
74: * replace them with the notice and other provisions required by
75: * the GPL. If you do not delete the provisions above, a recipient
76: * may use your version of this file under either the MPL or the
77: * GPL.
78: */
|