X-Git-Url: http://git.megacz.com/?p=org.ibex.core.git;a=blobdiff_plain;f=src%2Forg%2Fibex%2Fjs%2FJSScope.java;fp=src%2Forg%2Fibex%2Fjs%2FJSScope.java;h=51cc33a0f1ef82d82bacdbd829b7b9afaf57f0fe;hp=663e24d494bf046c94b426dc13c9e9bb0ae292a6;hb=ce791e4058158295bce9cf7b6698c2b565d571d7;hpb=fffcafc33aa4066bdf85da7a32e1a1cdb9db2d6f diff --git a/src/org/ibex/js/JSScope.java b/src/org/ibex/js/JSScope.java index 663e24d..51cc33a 100644 --- a/src/org/ibex/js/JSScope.java +++ b/src/org/ibex/js/JSScope.java @@ -4,25 +4,25 @@ package org.ibex.js; // FIXME: should allow parentScope to be a JS, not a JSScope // FIXME: Index local vars by number and lookup in an array /** Implementation of a JavaScript Scope */ -// HACK = JSScope doesn't really need the BT, this is just for Box.java +// HACK: JSScope doesn't really need the BT, this is just for Box.java public class JSScope extends JS.BT { private JSScope parentScope; - private static final Object NULL_PLACEHOLDER = new Object(); + private static final JS NULL_PLACEHOLDER = new JS() { }; public JSScope(JSScope parentScope) { this.parentScope = parentScope; } - public void declare(String s) throws JSExn { super.put(s, NULL_PLACEHOLDER); } + public void declare(JS s) throws JSExn { super.put(s, NULL_PLACEHOLDER); } public JSScope getParentScope() { return parentScope; } - public Object get(Object key) throws JSExn { - Object o = super.get(key); + public JS get(JS key) throws JSExn { + JS o = super.get(key); if (o != null) return o == NULL_PLACEHOLDER ? null : o; else return parentScope == null ? null : parentScope.get(key); } - public boolean has(Object key) throws JSExn { return super.get(key) != null; } - public void put(Object key, Object val) throws JSExn { + public boolean has(JS key) throws JSExn { return super.get(key) != null; } + public void put(JS key, JS val) throws JSExn { if (parentScope != null && !has(key)) parentScope.put(key, val); else super.put(key, val == null ? NULL_PLACEHOLDER : val); } @@ -33,7 +33,8 @@ public class JSScope extends JS.BT { return s; } - public static class Global extends JSScope { + // FIXME: Update this for new API, it also has some other problems + /*public static class Global extends JSScope { private final static Double NaN = new Double(Double.NaN); private final static Double POSITIVE_INFINITY = new Double(Double.POSITIVE_INFINITY); @@ -151,6 +152,6 @@ public class JSScope extends JS.BT { } return NaN; } - } + }*/ }