update core for recent js changes
[org.ibex.core.git] / src / org / ibex / core / Ibex.java
index ccc6afb..447ee1d 100644 (file)
@@ -185,7 +185,7 @@ public final class Ibex extends JS implements JS.Cloneable {
                         throw new JSExn("invalid resource specifier " + url);
                     }
                     case "thread.sleep": sleep(JS.toInt(a)); return null;
-                    case "regexp": return JS.newRegexp(a, null);
+                    case "regexp": return new JSRegexp(a, null);
                     case "net.rpc.xml": return new XMLRPC(JS.toString(a), "");
                     case "crypto.rsa": /* FEATURE */ return null;
                     case "crypto.md5": /* FEATURE */ return null;
@@ -202,7 +202,7 @@ public final class Ibex extends JS implements JS.Cloneable {
                 case 2:
                     //#jswitch(name)
                     case "stream.watch": return new Stream.ProgressWatcher(a, b);
-                    case "regexp": return JS.newRegexp(a, b);
+                    case "regexp": return new JSRegexp(a, b);
                     //#end
                 case 3:
                     //#jswitch(name)
@@ -345,16 +345,16 @@ public final class Ibex extends JS implements JS.Cloneable {
 
     // FEATURE: move this into builtin.xwar
     public Blessing bless(JS b) throws JSExn { return new Ibex.Blessing(b, this, null, null); }
-    // FIXME: Does this really need to extends JS.Clone?
-    // FEATURE: Mandate that Blessings use only String keys?
-    public static class Blessing extends JS.Clone {
+    // JS:FIXME: This doesn't properly handle traps
+    public static class Blessing extends JS.O {
         private Ibex ibex;
         private Template t = null;
         public JS parentkey = null;
         public Blessing parent = null;
+        public JS clonee;
         private Hash cache = new Hash();
         public Blessing(JS clonee, Ibex ibex, Blessing parent, JS parentkey) throws JSExn {
-            super(clonee); this.ibex = ibex; this.parentkey = parentkey; this.parent = parent; }
+            this.clonee = clonee; this.ibex = ibex; this.parentkey = parentkey; this.parent = parent; }
         public JS get(JS key) throws JSExn {
             if (JS.isString(key) && JS.toString(key).equals("")) return getStatic();
             if (cache.get(key) != null) return (JS)cache.get(key);
@@ -381,14 +381,14 @@ public final class Ibex extends JS implements JS.Cloneable {
                 } catch (IOException f) { /* DELIBERATE */ }
             return null;
         }
-        public JSScope getStatic() throws JSExn {
+        public JS getStatic() throws JSExn {
             try {
                 if (t == null) {
                     // FEATURE: Might want to handle the ".t" part better
                     JS res = parent.get(JS.S(JS.toString(parentkey) + ".t"));
                     t = Template.buildTemplate(description(), res, ibex);
                 }
-                return t != null ? t.staticScope : null;
+                return t != null ? t.staticObject : null;
             } catch (Exception e) {
                 Log.error(this, e);
                 return null;
@@ -396,7 +396,7 @@ public final class Ibex extends JS implements JS.Cloneable {
         }
         private String description() {
             String s = JS.debugToString(parentkey);
-            for(Blessing b = parent; b != null; b = b.parent) s = JS.debugToString(parentkey) + "." + s;
+            for(Blessing b = parent; b.parentkey != null; b = b.parent) s = JS.debugToString(b.parentkey) + "." + s;
             return s;
         }
         public JS call(JS a, JS b, JS c, JS[] rest, int nargs) throws JSExn {
@@ -413,6 +413,8 @@ public final class Ibex extends JS implements JS.Cloneable {
             if (t == null) throw new JSExn("No such template " + JS.debugToString(parentkey));
             return t;
         }
+        // JS:FIXME: Blessing shouldn't need to roll its own JS.Clone implementation
+        public InputStream getInputStream() throws IOException { return clonee.getInputStream(); }
     }
 
 }