new js api
[org.ibex.core.git] / src / org / ibex / js / JSScope.java
index 663e24d..51cc33a 100644 (file)
@@ -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;
         }
-    }
+    }*/
 }