01: package kawa.standard;
02:
03: import kawa.lang.*;
04: import gnu.expr.*;
05: import gnu.lists.*;
06:
07: public class module_static extends Syntax {
08: public static final module_static module_static = new module_static();
09: static {
10: module_static.setName("module-static");
11: }
12:
13: public boolean scanForDefinitions(Pair st, java.util.Vector forms,
14: ScopeExp defs, Translator tr) {
15: Object list = st.cdr;
16: if (!(defs instanceof ModuleExp)) {
17: tr.error('e', "\'" + getName() + "\' not at module level");
18: return true;
19: }
20: if (list instanceof Pair
21: && (st = (Pair) list).cdr == LList.Empty
22: && st.car instanceof Boolean) {
23: if (st.car == Boolean.FALSE)
24: ((ModuleExp) defs)
25: .setFlag(ModuleExp.NONSTATIC_SPECIFIED);
26: else
27: ((ModuleExp) defs).setFlag(ModuleExp.STATIC_SPECIFIED);
28: } else if (list instanceof Pair
29: && (st = (Pair) list).cdr == LList.Empty
30: && st.car instanceof Pair
31: && tr.matches((st = (Pair) st.car).car,
32: Scheme.quote_sym)) {
33: if ((st = (Pair) st.cdr) != LList.Empty
34: && st.car == "init-run") {
35: // (module-static 'init-run) implies (module-static #t)
36: ((ModuleExp) defs).setFlag(ModuleExp.STATIC_SPECIFIED);
37: ((ModuleExp) defs)
38: .setFlag(ModuleExp.STATIC_RUN_SPECIFIED);
39: } else {
40: tr.error('e', "invalid quoted symbol for '" + getName()
41: + '\'');
42: return false;
43: }
44: } else {
45: ((ModuleExp) defs).setFlag(ModuleExp.NONSTATIC_SPECIFIED);
46:
47: while (list != LList.Empty) {
48: if (!(list instanceof Pair)
49: || !((st = (Pair) list).car instanceof String)) {
50: tr.error('e', "invalid syntax in '" + getName()
51: + '\'');
52: return false;
53: }
54: String symbol = (String) st.car;
55: Declaration decl = defs.getNoDefine(symbol);
56: if (decl.getFlag(Declaration.NOT_DEFINING))
57: Translator.setLine(decl, st);
58: decl.setFlag(Declaration.STATIC_SPECIFIED);
59: list = st.cdr;
60: }
61: }
62: return true;
63: }
64:
65: public Expression rewriteForm(Pair form, Translator tr) {
66: return null;
67: }
68: }
|