- public boolean has(Object key) throws JSExn { return super.get(key) != null; }
- public void put(Object key, Object val) throws JSExn {
- if (parentScope != null && !has(key)) parentScope.put(key, val);
- else super.put(key, val == null ? NULL_PLACEHOLDER : val);
+ public static class Top extends JSScope {
+ private final JS global;
+ public Top(JS global) { super(null,0,0); this.global = global; }
+ JS get(int i) throws JSExn { throw new JSExn("scope index out of range"); }
+ void put(int i, JS o) throws JSExn { throw new JSExn("scope index out of range"); }
+ JS getGlobal() { return global; }
+ };
+
+ // NOTE: We can't just set base to parent.base + parent.vars.length
+ // sometimes we only access part of a parent's scope
+ public JSScope(JSScope parent, int base, int size) {
+ this.parent = parent;
+ this.base = base;
+ this.vars = new JS[size];