move static function references to Script.java
authorcrawshaw <crawshaw@ibex.org>
Wed, 5 Jan 2005 13:49:38 +0000 (13:49 +0000)
committercrawshaw <crawshaw@ibex.org>
Wed, 5 Jan 2005 13:49:38 +0000 (13:49 +0000)
darcs-hash:20050105134938-2eb37-f8e03cd84be502e3e761731a8fbfb4f95695db0f.gz

13 files changed:
src/org/ibex/js/Directory.java
src/org/ibex/js/Interpreter.java
src/org/ibex/js/JSArray.java
src/org/ibex/js/JSDate.java
src/org/ibex/js/JSFunction.java
src/org/ibex/js/JSMath.java
src/org/ibex/js/JSPrimitive.java
src/org/ibex/js/JSReflection.java
src/org/ibex/js/JSRegexp.java
src/org/ibex/js/Parser.java
src/org/ibex/js/SOAP.java
src/org/ibex/js/Test.java
src/org/ibex/js/XMLRPC.java

index 645de0d..07ef38a 100644 (file)
@@ -102,7 +102,7 @@ public class Directory extends JS {
             Reader r = new InputStreamReader(new FileInputStream(f2));
             while(true) {
                 int numread = r.read(chars, numchars, chars.length - numchars);
-                if (numread == -1) return JS.S(new String(chars, 0, numchars));
+                if (numread == -1) return Script.S(new String(chars, 0, numchars));
                 numchars += numread;
             }
         } catch (IOException ioe) {
@@ -115,7 +115,7 @@ public class Directory extends JS {
         return new Enumeration(null) {
                 int i = 0;
                 public boolean _hasMoreElements() { return i < elements.length; }
-                public JS _nextElement() { return JS.S(FileNameEncoder.decode(elements[i++])); }
+                public JS _nextElement() { return Script.S(FileNameEncoder.decode(elements[i++])); }
             };
     }
 }
index 7bb8bbe..9899a14 100644 (file)
@@ -106,17 +106,17 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
             }
             switch(op) {
             case LITERAL: stack.push((JS)arg); break;
-            case OBJECT: stack.push(new JS.O()); break;
-            case ARRAY: stack.push(new JSArray(JS.toInt((JS)arg))); break;
+            case OBJECT: stack.push(new JS.Obj()); break;
+            case ARRAY: stack.push(new JSArray(Script.toInt((JS)arg))); break;
             //case DECLARE: scope.declare((JS)(arg==null ? stack.peek() : arg)); if(arg != null) stack.push((JS)arg); break;
-            case JT: if (JS.toBoolean(stack.pop())) pc += JS.toInt((JS)arg) - 1; break;
-            case JF: if (!JS.toBoolean(stack.pop())) pc += JS.toInt((JS)arg) - 1; break;
-            case JMP: pc += JS.toInt((JS)arg) - 1; break;
+            case JT: if (Script.toBoolean(stack.pop())) pc += Script.toInt((JS)arg) - 1; break;
+            case JF: if (!Script.toBoolean(stack.pop())) pc += Script.toInt((JS)arg) - 1; break;
+            case JMP: pc += Script.toInt((JS)arg) - 1; break;
             case POP: stack.pop(); break;
             case SWAP: stack.swap(); break;
             case DUP: stack.push(stack.peek()); break;
             case NEWSCOPE: {
-                int n = JS.toInt((JS)arg);
+                int n = Script.toInt((JS)arg);
                 scope = new JSScope(scope,(n>>>16)&0xffff,(n>>>0)&0xffff);
                 break;
             }
@@ -124,19 +124,19 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
             case GLOBALSCOPE: stack.push(scope.getGlobal()); break;
             case SCOPEGET: stack.push(scope.get((JS)arg)); break;
             case SCOPEPUT: scope.put((JS)arg,stack.peek()); break;
-            case ASSERT: if (!JS.toBoolean(stack.pop())) throw je("ibex.assertion.failed"); break;
-            case BITNOT: stack.push(JS.N(~JS.toLong(stack.pop()))); break;
-            case BANG: stack.push(JS.B(!JS.toBoolean(stack.pop()))); break;
+            case ASSERT: if (!Script.toBoolean(stack.pop())) throw je("ibex.assertion.failed"); break;
+            case BITNOT: stack.push(Script.N(~Script.toLong(stack.pop()))); break;
+            case BANG: stack.push(Script.B(!Script.toBoolean(stack.pop()))); break;
             case NEWFUNCTION: stack.push(((JSFunction)arg)._cloneWithNewParentScope(scope)); break;
             case LABEL: break;
 
             case TYPEOF: {
                 Object o = stack.pop();
                 if (o == null) stack.push(null);
-                else if (o instanceof JSString) stack.push(JS.S("string"));
-                else if (o instanceof JSNumber.B) stack.push(JS.S("boolean"));
-                else if (o instanceof JSNumber) stack.push(JS.S("number"));
-                else stack.push(JS.S("object"));
+                else if (o instanceof JSString) stack.push(Script.S("string"));
+                else if (o instanceof JSNumber.B) stack.push(Script.S("boolean"));
+                else if (o instanceof JSNumber) stack.push(Script.S("number"));
+                else stack.push(Script.S("object"));
                 break;
             }
 
@@ -166,7 +166,7 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
                     if (o instanceof LoopMarker) {
                         if (arg == null || arg.equals(((LoopMarker)o).label)) {
                             int loopInstructionLocation = ((LoopMarker)o).location;
-                            int endOfLoop = JS.toInt((JS)f.arg[loopInstructionLocation]) + loopInstructionLocation;
+                            int endOfLoop = Script.toInt((JS)f.arg[loopInstructionLocation]) + loopInstructionLocation;
                             scope = ((LoopMarker)o).scope;
                             if (op == CONTINUE) { stack.push(o); stack.push(JS.F); }
                             pc = op == BREAK ? endOfLoop - 1 : loopInstructionLocation;
@@ -200,7 +200,7 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
                         boolean didTrapPut = false;
                         if (o instanceof TrapMarker) { // handles return component of a write trap
                             TrapMarker tm = (TrapMarker) o;
-                            boolean cascade = tm.t.isWriteTrap() && !tm.cascadeHappened && !JS.toBoolean(retval);
+                            boolean cascade = tm.t.isWriteTrap() && !tm.cascadeHappened && !Script.toBoolean(retval);
                             if(cascade) {
                                 JS.Trap t = tm.t.nextWrite();
                                 if(t == null && tm.t.target() instanceof JS.Clone) {
@@ -236,7 +236,7 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
             }
                 
             case CASCADE: {
-                boolean write = JS.toBoolean((JS)arg);
+                boolean write = Script.toBoolean((JS)arg);
                 JS val = write ? stack.pop() : null;
                 CallMarker o = stack.findCall();
                 if(!(o instanceof TrapMarker)) throw new JSExn("tried to CASCADE while not in a trap");
@@ -312,8 +312,8 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
                     stack.push(key);
                 }
                 JS ret = null;
-                if (key == null) throw je("tried to get the null key from " + JS.debugToString(target));
-                if (target == null) throw je("tried to get property \"" + JS.debugToString(key) + "\" from the null object");
+                if (key == null) throw je("tried to get the null key from " + Script.str(target));
+                if (target == null) throw je("tried to get property \"" + Script.str(key) + "\" from the null object");
                 
                 JS.Trap t = target.getTrap(key);
                 if(t != null) t = t.read();
@@ -421,13 +421,13 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
                     JS left = (JS)stack.pop();
                     JS ret;
                     if(left instanceof JSString || right instanceof JSString)
-                        ret = JS.S(JS.toString(left).concat(JS.toString(right)));
+                        ret = Script.S(Script.toString(left).concat(Script.toString(right)));
                     else if(left instanceof JSNumber.D || right instanceof JSNumber.D)
-                        ret = JS.N(JS.toDouble(left) + JS.toDouble(right));
+                        ret = Script.N(Script.toDouble(left) + Script.toDouble(right));
                     else {
-                        long l = JS.toLong(left) + JS.toLong(right);
-                        if(l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) ret = JS.N(l);
-                        ret = JS.N((int)l);
+                        long l = Script.toLong(left) + Script.toLong(right);
+                        if(l < Integer.MIN_VALUE || l > Integer.MAX_VALUE) ret = Script.N(l);
+                        ret = Script.N((int)l);
                     }
                     stack.push(ret);
                 } else {
@@ -435,27 +435,27 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
                     while(--count >= 0) args[count] = (JS)stack.pop();
                     if(args[0] instanceof JSString) {
                         StringBuffer sb = new StringBuffer(64);
-                        for(int i=0;i<args.length;i++) sb.append(JS.toString(args[i]));
-                        stack.push(JS.S(sb.toString()));
+                        for(int i=0;i<args.length;i++) sb.append(Script.toString(args[i]));
+                        stack.push(Script.S(sb.toString()));
                     } else {
                         int numStrings = 0;
                         for(int i=0;i<args.length;i++) if(args[i] instanceof JSString) numStrings++;
                         if(numStrings == 0) {
                             double d = 0.0;
-                            for(int i=0;i<args.length;i++) d += JS.toDouble(args[i]);
-                            stack.push(JS.N(d));
+                            for(int i=0;i<args.length;i++) d += Script.toDouble(args[i]);
+                            stack.push(Script.N(d));
                         } else {
                             int i=0;
                             StringBuffer sb = new StringBuffer(64);
                             if(!(args[0] instanceof JSString || args[1] instanceof JSString)) {
                                 double d=0.0;
                                 do {
-                                    d += JS.toDouble(args[i++]);
+                                    d += Script.toDouble(args[i++]);
                                 } while(!(args[i] instanceof JSString));
-                                sb.append(JS.toString(JS.N(d)));
+                                sb.append(Script.toString(Script.N(d)));
                             }
-                            while(i < args.length) sb.append(JS.toString(args[i++]));
-                            stack.push(JS.S(sb.toString()));
+                            while(i < args.length) sb.append(Script.toString(args[i++]));
+                            stack.push(Script.S(sb.toString()));
                         }
                     }
                 }
@@ -467,25 +467,25 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
                 JS left = (JS)stack.pop();
                 switch(op) {
                         
-                case BITOR: stack.push(JS.N(JS.toLong(left) | JS.toLong(right))); break;
-                case BITXOR: stack.push(JS.N(JS.toLong(left) ^ JS.toLong(right))); break;
-                case BITAND: stack.push(JS.N(JS.toLong(left) & JS.toLong(right))); break;
-
-                case SUB: stack.push(JS.N(JS.toDouble(left) - JS.toDouble(right))); break;
-                case MUL: stack.push(JS.N(JS.toDouble(left) * JS.toDouble(right))); break;
-                case DIV: stack.push(JS.N(JS.toDouble(left) / JS.toDouble(right))); break;
-                case MOD: stack.push(JS.N(JS.toDouble(left) % JS.toDouble(right))); break;
+                case BITOR: stack.push(Script.N(Script.toLong(left) | Script.toLong(right))); break;
+                case BITXOR: stack.push(Script.N(Script.toLong(left) ^ Script.toLong(right))); break;
+                case BITAND: stack.push(Script.N(Script.toLong(left) & Script.toLong(right))); break;
+
+                case SUB: stack.push(Script.N(Script.toDouble(left) - Script.toDouble(right))); break;
+                case MUL: stack.push(Script.N(Script.toDouble(left) * Script.toDouble(right))); break;
+                case DIV: stack.push(Script.N(Script.toDouble(left) / Script.toDouble(right))); break;
+                case MOD: stack.push(Script.N(Script.toDouble(left) % Script.toDouble(right))); break;
                         
-                case LSH: stack.push(JS.N(JS.toLong(left) << JS.toLong(right))); break;
-                case RSH: stack.push(JS.N(JS.toLong(left) >> JS.toLong(right))); break;
-                case URSH: stack.push(JS.N(JS.toLong(left) >>> JS.toLong(right))); break;
+                case LSH: stack.push(Script.N(Script.toLong(left) << Script.toLong(right))); break;
+                case RSH: stack.push(Script.N(Script.toLong(left) >> Script.toLong(right))); break;
+                case URSH: stack.push(Script.N(Script.toLong(left) >>> Script.toLong(right))); break;
                         
                 //#repeat </<=/>/>= LT/LE/GT/GE
                 case LT: {
                     if(left instanceof JSString && right instanceof JSString)
-                        stack.push(JS.B(JS.toString(left).compareTo(JS.toString(right)) < 0));
+                        stack.push(Script.B(Script.toString(left).compareTo(Script.toString(right)) < 0));
                     else
-                        stack.push(JS.B(JS.toDouble(left) < JS.toDouble(right)));
+                        stack.push(Script.B(Script.toDouble(left) < Script.toDouble(right)));
                 }
                 //#end
                     
@@ -495,7 +495,7 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
                     if(left == null && right == null) ret = true;
                     else if(left == null || right == null) ret = false;
                     else ret = left.jsequals(right);
-                    stack.push(JS.B(op == EQ ? ret : !ret)); break;
+                    stack.push(Script.B(op == EQ ? ret : !ret)); break;
                 }
 
                 default: throw new Error("unknown opcode " + op);
@@ -671,7 +671,7 @@ class Interpreter implements ByteCodes, Tokens, Pausable {
                     if(cm.f == null) break;
                     String s = cm.f.sourceName + ":" + cm.f.line[cm.pc-1];
                     if(cm instanceof Interpreter.TrapMarker) 
-                        s += " (trap on " + JS.debugToString(((Interpreter.TrapMarker)cm).t.key) + ")";
+                        s += " (trap on " + Script.str(((Interpreter.TrapMarker)cm).t.key) + ")";
                     e.addBacktrace(s);
                 }
             }
index cb06d0d..ae2478f 100644 (file)
@@ -112,7 +112,7 @@ class JSArray extends Basket.Array implements JS, Basket.CompareFunc {
 
     private JS join(String sep) throws JSExn {
         int length = size();
-        if(length == 0) return JS.S("");
+        if(length == 0) return Script.S("");
         StringBuffer sb = new StringBuffer(64);
         int i=0;
         while(true) {
@@ -121,7 +121,7 @@ class JSArray extends Basket.Array implements JS, Basket.CompareFunc {
             if(++i == length) break;
             sb.append(sep);
         }
-        return JS.S(sb.toString());
+        return Script.S(sb.toString());
     }
  
     private JS slice(int start, int end) {
index 203fdc5..b90da68 100644 (file)
@@ -61,62 +61,62 @@ public class JSDate extends JS.Immutable {
     public JS call(JS method, JS[] args) throws JSExn {
         switch(args.length) {
             case 0: {
-                //#switch(JS.toString(method))
-                case "toString": return JS.S(date_format(date, FORMATSPEC_FULL));
-                case "toTimeString": return JS.S(date_format(date, FORMATSPEC_TIME));
-                case "toDateString": return JS.S(date_format(date, FORMATSPEC_DATE));
-                case "toLocaleString": return JS.S(toLocaleString(date));
-                case "toLocaleTimeString": return JS.S(toLocaleTimeString(date));
-                case "toLocaleDateString": return JS.S(toLocaleDateString(date));
-                case "toUTCString": return JS.S(toUTCString(date));
-                case "valueOf": return N(this.date);
-                case "getTime": return N(this.date);
-                case "getYear": return N(getYear(date));
-                case "getFullYear": return N(YearFromTime(LocalTime(date)));
-                case "getUTCFullYear": return N(YearFromTime(date));
-                case "getMonth": return N(MonthFromTime(LocalTime(date)));
-                case "getUTCMonth": return N(MonthFromTime(date));
-                case "getDate": return N(DateFromTime(LocalTime(date)));
-                case "getUTCDate": return N(DateFromTime(date));
-                case "getDay": return N(WeekDay(LocalTime(date)));
-                case "getUTCDay": return N(WeekDay(date));
-                case "getHours": return N(HourFromTime(LocalTime(date)));
-                case "getUTCHours": return N(HourFromTime(date));
-                case "getMinutes": return N(MinFromTime(LocalTime(date)));
-                case "getUTCMinutes": return N(MinFromTime(date));
-                case "getSeconds": return N(SecFromTime(LocalTime(date)));
-                case "getUTCSeconds": return N(SecFromTime(date));
-                case "getMilliseconds": return N(msFromTime(LocalTime(date)));
-                case "getUTCMilliseconds": return N(msFromTime(date));
-                case "getTimezoneOffset": return N(getTimezoneOffset(date));
+                //#switch(Script.toString(method))
+                case "toString": return Script.S(date_format(date, FORMATSPEC_FULL));
+                case "toTimeString": return Script.S(date_format(date, FORMATSPEC_TIME));
+                case "toDateString": return Script.S(date_format(date, FORMATSPEC_DATE));
+                case "toLocaleString": return Script.S(toLocaleString(date));
+                case "toLocaleTimeString": return Script.S(toLocaleTimeString(date));
+                case "toLocaleDateString": return Script.S(toLocaleDateString(date));
+                case "toUTCString": return Script.S(toUTCString(date));
+                case "valueOf": return Script.N(this.date);
+                case "getTime": return Script.N(this.date);
+                case "getYear": return Script.N(getYear(date));
+                case "getFullYear": return Script.N(YearFromTime(LocalTime(date)));
+                case "getUTCFullYear": return Script.N(YearFromTime(date));
+                case "getMonth": return Script.N(MonthFromTime(LocalTime(date)));
+                case "getUTCMonth": return Script.N(MonthFromTime(date));
+                case "getDate": return Script.N(DateFromTime(LocalTime(date)));
+                case "getUTCDate": return Script.N(DateFromTime(date));
+                case "getDay": return Script.N(WeekDay(LocalTime(date)));
+                case "getUTCDay": return Script.N(WeekDay(date));
+                case "getHours": return Script.N(HourFromTime(LocalTime(date)));
+                case "getUTCHours": return Script.N(HourFromTime(date));
+                case "getMinutes": return Script.N(MinFromTime(LocalTime(date)));
+                case "getUTCMinutes": return Script.N(MinFromTime(date));
+                case "getSeconds": return Script.N(SecFromTime(LocalTime(date)));
+                case "getUTCSeconds": return Script.N(SecFromTime(date));
+                case "getMilliseconds": return Script.N(msFromTime(LocalTime(date)));
+                case "getUTCMilliseconds": return Script.N(msFromTime(date));
+                case "getTimezoneOffset": return Script.N(getTimezoneOffset(date));
                 //#end
                 return super.call(method, args);
             }
             case 1: {
-                //#switch(JS.toString(method))
-                case "setTime": return N(this.setTime(toDouble(a0)));
-                case "setYear": return N(this.setYear(toDouble(a0)));
+                //#switch(Script.toString(method))
+                case "setTime": return Script.N(this.setTime(Script.toDouble(args[0])));
+                case "setYear": return Script.N(this.setYear(Script.toDouble(args[0])));
                 //#end
                 // fall through
             }
             default: {
                 JS[] args = new JS[nargs];
                 for(int i=0; i<nargs; i++) args[i] = i==0 ? a0 : i==1 ? a1 : i==2 ? a2 : rest[i-3];
-                //#switch(JS.toString(method))
-                case "setMilliseconds": return N(this.makeTime(args, 1, true));
-                case "setUTCMilliseconds": return N(this.makeTime(args, 1, false));
-                case "setSeconds": return N(this.makeTime(args, 2, true));
-                case "setUTCSeconds": return N(this.makeTime(args, 2, false));
-                case "setMinutes": return N(this.makeTime(args, 3, true));
-                case "setUTCMinutes": return N(this.makeTime(args, 3, false));
-                case "setHours": return N(this.makeTime(args, 4, true));
-                case "setUTCHours": return N(this.makeTime(args, 4, false));
-                case "setDate": return N(this.makeDate(args, 1, true));
-                case "setUTCDate": return N(this.makeDate(args, 1, false));
-                case "setMonth": return N(this.makeDate(args, 2, true));
-                case "setUTCMonth": return N(this.makeDate(args, 2, false));
-                case "setFullYear": return N(this.makeDate(args, 3, true));
-                case "setUTCFullYear": return N(this.makeDate(args, 3, false));
+                //#switch(Script.toString(method))
+                case "setMilliseconds": return Script.N(this.makeTime(args, 1, true));
+                case "setUTCMilliseconds": return Script.N(this.makeTime(args, 1, false));
+                case "setSeconds": return Script.N(this.makeTime(args, 2, true));
+                case "setUTCSeconds": return Script.N(this.makeTime(args, 2, false));
+                case "setMinutes": return Script.N(this.makeTime(args, 3, true));
+                case "setUTCMinutes": return Script.N(this.makeTime(args, 3, false));
+                case "setHours": return Script.N(this.makeTime(args, 4, true));
+                case "setUTCHours": return Script.N(this.makeTime(args, 4, false));
+                case "setDate": return Script.N(this.makeDate(args, 1, true));
+                case "setUTCDate": return Script.N(this.makeDate(args, 1, false));
+                case "setMonth": return Script.N(this.makeDate(args, 2, true));
+                case "setUTCMonth": return Script.N(this.makeDate(args, 2, false));
+                case "setFullYear": return Script.N(this.makeDate(args, 3, true));
+                case "setUTCFullYear": return Script.N(this.makeDate(args, 3, false));
                 //#end
             }
         }
@@ -124,7 +124,7 @@ public class JSDate extends JS.Immutable {
     }
 
     public JS get(JS key) throws JSExn {
-        //#switch(JS.toString(key))
+        //#switch(Script.toString(key))
         case "toString": return METHOD;
         case "toTimeString": return METHOD;
         case "toDateString": return METHOD;
@@ -540,7 +540,7 @@ public class JSDate extends JS.Immutable {
                 if (d != d || Double.isInfinite(d)) {
                     return Double.NaN;
                 }
-                array[loop] = toDouble(args[loop]);
+                array[loop] = Script.toDouble(args[loop]);
             } else {
                 array[loop] = 0;
             }
@@ -559,7 +559,7 @@ public class JSDate extends JS.Immutable {
                               array[3], array[4], array[5], array[6]);
         d = TimeClip(d);
         return d;
-        //        return N(d);
+        //        return Script.N(d);
     }
 
     /*
@@ -889,9 +889,8 @@ public class JSDate extends JS.Immutable {
         return result.toString();
     }
 
-    private static double _toNumber(JS o) throws JSExn { return JS.toDouble(o); }
-    private static double _toNumber(JS[] o, int index) throws JSExn { return JS.toDouble(o[index]); }
-    private static double toDouble(double d) { return d; }
+    private static double _toNumber(JS o) throws JSExn { return Script.toDouble(o); }
+    private static double _toNumber(JS[] o, int index) throws JSExn { return Script.toDouble(o[index]); }
 
     public JSDate(JS[] args) throws JSExn {
 
@@ -903,8 +902,8 @@ public class JSDate extends JS.Immutable {
             }
             case 1: {
                 double date;
-                if(isString(a0))
-                    date = date_parseString(JS.toString(a0));
+                if(Script.isString(a0))
+                    date = date_parseString(Script.toString(a0));
                 else
                     date = _toNumber(args[0]);
                 obj.date = TimeClip(date);
@@ -1084,7 +1083,6 @@ public class JSDate extends JS.Immutable {
                 this.date = Double.NaN;
                 return this.date;
             }
-            conv[i] = toDouble(conv[i]);
         }
 
         if (local)
@@ -1155,7 +1153,6 @@ public class JSDate extends JS.Immutable {
                 this.date = Double.NaN;
                 return this.date;
             }
-            conv[i] = toDouble(conv[i]);
         }
 
         /* return NaN if date is NaN and we're not setting the year,
index e32839a..03508b7 100644 (file)
@@ -97,7 +97,7 @@ class JSFunction extends JS.Immutable implements ByteCodes, Tokens {
             if (op[i] < 0) sb.append(bytecodeToString[-op[i]]);
             else sb.append(codeToString[op[i]]);
             sb.append(" ");
-            sb.append(arg[i] == null ? "(no arg)" : arg[i] instanceof JS ? JS.debugToString((JS)arg[i]) : arg[i]);
+            sb.append(arg[i] == null ? "(no arg)" : arg[i] instanceof JS ? Script.str((JS)arg[i]) : arg[i]);
             if((op[i] == JF || op[i] == JT || op[i] == JMP) && arg[i] != null && arg[i] instanceof Number) {
                 sb.append(" jump to ").append(i+((Number) arg[i]).intValue());
             } else  if(op[i] == TRY) {
index 6b092e0..a0edb1a 100644 (file)
@@ -6,47 +6,47 @@ package org.ibex.js;
 
 /** The JavaScript Math object */
 class JSMath extends JS {
-    private static final JS E       = JS.N(java.lang.Math.E);
-    private static final JS PI      = JS.N(java.lang.Math.PI);
-    private static final JS LN10    = JS.N(java.lang.Math.log(10));
-    private static final JS LN2     = JS.N(java.lang.Math.log(2));
-    private static final JS LOG10E  = JS.N(1/java.lang.Math.log(10));
-    private static final JS LOG2E   = JS.N(1/java.lang.Math.log(2));
-    private static final JS SQRT1_2 = JS.N(1/java.lang.Math.sqrt(2));
-    private static final JS SQRT2   = JS.N(java.lang.Math.sqrt(2));
+    private static final JS E       = Script.N(java.lang.Math.E);
+    private static final JS PI      = Script.N(java.lang.Math.PI);
+    private static final JS LN10    = Script.N(java.lang.Math.log(10));
+    private static final JS LN2     = Script.N(java.lang.Math.log(2));
+    private static final JS LOG10E  = Script.N(1/java.lang.Math.log(10));
+    private static final JS LOG2E   = Script.N(1/java.lang.Math.log(2));
+    private static final JS SQRT1_2 = Script.N(1/java.lang.Math.sqrt(2));
+    private static final JS SQRT2   = Script.N(java.lang.Math.sqrt(2));
 
-    public JS callMethod(JS method, JS a0, JS a1, JS a2, JS[] rest, int nargs) throws JSExn {
-        switch(nargs) {
+    public JS callMethod(JS method, JS[] args) throws JSExn {
+        switch(args.length) {
             case 0: {
-                //#switch(JS.toString(method))
-                case "random": return JS.N(java.lang.Math.random());
+                //#switch(Script.toString(method))
+                case "random": return Script.N(java.lang.Math.random());
                 //#end
                 break;
             }
             case 1: {
-                //#switch(JS.toString(method))
-                case "ceil": return JS.N((long)java.lang.Math.ceil(toDouble(a0)));
-                case "floor": return JS.N((long)java.lang.Math.floor(toDouble(a0)));
-                case "round": return JS.N((long)java.lang.Math.round(toDouble(a0)));
-                case "abs": return JS.N(java.lang.Math.abs(toDouble(a0)));
-                case "sin": return JS.N(java.lang.Math.sin(toDouble(a0)));
-                case "cos": return JS.N(java.lang.Math.cos(toDouble(a0)));
-                case "tan": return JS.N(java.lang.Math.tan(toDouble(a0)));
-                case "asin": return JS.N(java.lang.Math.asin(toDouble(a0)));
-                case "acos": return JS.N(java.lang.Math.acos(toDouble(a0)));
-                case "atan": return JS.N(java.lang.Math.atan(toDouble(a0)));
-                case "sqrt": return JS.N(java.lang.Math.sqrt(toDouble(a0)));
-                case "exp": return JS.N(java.lang.Math.exp(toDouble(a0)));
-                case "log": return JS.N(java.lang.Math.log(toDouble(a0)));
+                //#switch(Script.toString(method))
+                case "ceil": return Script.N((long)java.lang.Math.ceil(Script.toDouble(args[0])));
+                case "floor": return Script.N((long)java.lang.Math.floor(Script.toDouble(args[0])));
+                case "round": return Script.N((long)java.lang.Math.round(Script.toDouble(args[0])));
+                case "abs": return Script.N(java.lang.Math.abs(Script.toDouble(args[0])));
+                case "sin": return Script.N(java.lang.Math.sin(Script.toDouble(args[0])));
+                case "cos": return Script.N(java.lang.Math.cos(Script.toDouble(args[0])));
+                case "tan": return Script.N(java.lang.Math.tan(Script.toDouble(args[0])));
+                case "asin": return Script.N(java.lang.Math.asin(Script.toDouble(args[0])));
+                case "acos": return Script.N(java.lang.Math.acos(Script.toDouble(args[0])));
+                case "atan": return Script.N(java.lang.Math.atan(Script.toDouble(args[0])));
+                case "sqrt": return Script.N(java.lang.Math.sqrt(Script.toDouble(args[0])));
+                case "exp": return Script.N(java.lang.Math.exp(Script.toDouble(args[0])));
+                case "log": return Script.N(java.lang.Math.log(Script.toDouble(args[0])));
                 //#end
                 break;
             }
             case 2: {
-                //#switch(JS.toString(method))
-                case "min": return JS.N(java.lang.Math.min(toDouble(a0), toDouble(a1)));
-                case "max": return JS.N(java.lang.Math.max(toDouble(a0), toDouble(a1)));
-                case "pow": return JS.N(java.lang.Math.pow(toDouble(a0), toDouble(a1)));
-                case "atan2": return JS.N(java.lang.Math.atan2(toDouble(a0), toDouble(a1)));
+                //#switch(Script.toString(method))
+                case "min": return Script.N(java.lang.Math.min(Script.toDouble(args[0]), Script.toDouble(args[1])));
+                case "max": return Script.N(java.lang.Math.max(Script.toDouble(args[0]), Script.toDouble(args[1])));
+                case "pow": return Script.N(java.lang.Math.pow(Script.toDouble(args[0]), Script.toDouble(args[1])));
+                case "atan2": return Script.N(java.lang.Math.atan2(Script.toDouble(args[0]), Script.toDouble(args[1])));
                 //#end
                 break;
             }
@@ -55,7 +55,7 @@ class JSMath extends JS {
     }
 
     public JS get(JS key) throws JSExn {
-        //#switch(JS.toString(key))
+        //#switch(Script.toString(key))
         case "E": return E;
         case "LN10": return LN10;
         case "LN2": return LN2;
index 4d6bcba..71155f3 100644 (file)
@@ -12,42 +12,42 @@ class JSPrimitive extends JS.Immutable {
         case "toFixed": throw new JSExn("toFixed() not implemented");
         case "toExponential": throw new JSExn("toExponential() not implemented");
         case "toPrecision": throw new JSExn("toPrecision() not implemented");
-        case "toString": return this instanceof JSString ? this : JS.S(JS.toString(this));
+        case "toString": return this instanceof JSString ? this : Script.S(Script.toString(this));
         //#end
             
         String s = coerceToString();
         int slength = s.length();
             
-        //#switch(JS.toString(method))
+        //#switch(Script.toString(method))
         case "substring": {
-            int a = alength >= 1 ? JS.toInt(arg0) : 0;
-            int b = alength >= 2 ? JS.toInt(arg1) : slength;
+            int a = alength >= 1 ? Script.toInt(arg0) : 0;
+            int b = alength >= 2 ? Script.toInt(arg1) : slength;
             if (a > slength) a = slength;
             if (b > slength) b = slength;
             if (a < 0) a = 0;
             if (b < 0) b = 0;
             if (a > b) { int tmp = a; a = b; b = tmp; }
-            return JS.S(s.substring(a,b));
+            return Script.S(s.substring(a,b));
         }
         case "substr": {
-            int start = alength >= 1 ? JS.toInt(arg0) : 0;
-            int len = alength >= 2 ? JS.toInt(arg1) : Integer.MAX_VALUE;
+            int start = alength >= 1 ? Script.toInt(arg0) : 0;
+            int len = alength >= 2 ? Script.toInt(arg1) : Integer.MAX_VALUE;
             if (start < 0) start = slength + start;
             if (start < 0) start = 0;
             if (len < 0) len = 0;
             if (len > slength - start) len = slength - start;
-            if (len <= 0) return JS.S("");
-            return JS.S(s.substring(start,start+len));
+            if (len <= 0) return Script.S("");
+            return Script.S(s.substring(start,start+len));
         }
         case "charAt": {
-            int p = alength >= 1 ? JS.toInt(arg0) : 0;
-            if (p < 0 || p >= slength) return JS.S("");
-            return JS.S(s.substring(p,p+1));
+            int p = alength >= 1 ? Script.toInt(arg0) : 0;
+            if (p < 0 || p >= slength) return Script.S("");
+            return Script.S(s.substring(p,p+1));
         }
         case "charCodeAt": {
-            int p = alength >= 1 ? JS.toInt(arg0) : 0;
-            if (p < 0 || p >= slength) return JS.N(Double.NaN);
-            return JS.N(s.charAt(p));
+            int p = alength >= 1 ? Script.toInt(arg0) : 0;
+            if (p < 0 || p >= slength) return Script.N(Double.NaN);
+            return Script.N(s.charAt(p));
         }
         case "concat": {
             StringBuffer sb = new StringBuffer(slength*2).append(s);
@@ -55,42 +55,42 @@ class JSPrimitive extends JS.Immutable {
             return Script.S(sb.toString());
         }
         case "indexOf": {
-            String search = alength >= 1 ? JS.toString(arg0) : "null";
-            int start = alength >= 2 ? JS.toInt(arg1) : 0;
+            String search = alength >= 1 ? Script.toString(arg0) : "null";
+            int start = alength >= 2 ? Script.toInt(arg1) : 0;
             // Java's indexOf handles an out of bounds start index, it'll return -1
-            return JS.N(s.indexOf(search,start));
+            return Script.N(s.indexOf(search,start));
         }
         case "lastIndexOf": {
-            String search = alength >= 1 ? JS.toString(arg0) : "null";
-            int start = alength >= 2 ? JS.toInt(arg1) : 0;
+            String search = alength >= 1 ? Script.toString(arg0) : "null";
+            int start = alength >= 2 ? Script.toInt(arg1) : 0;
             // Java's indexOf handles an out of bounds start index, it'll return -1
-            return JS.N(s.lastIndexOf(search,start));            
+            return Script.N(s.lastIndexOf(search,start));            
         }
         case "match": return JSRegexp.stringMatch(this,arg0);
         case "replace": return JSRegexp.stringReplace(this,arg0,arg1);
         case "search": return JSRegexp.stringSearch(this,arg0);
         case "split": return JSRegexp.stringSplit(this,arg0,arg1,alength);
-        case "toLowerCase": return JS.S(s.toLowerCase());
-        case "toUpperCase": return JS.S(s.toUpperCase());
+        case "toLowerCase": return Script.S(s.toLowerCase());
+        case "toUpperCase": return Script.S(s.toUpperCase());
         case "slice": {
-            int a = alength >= 1 ? JS.toInt(arg0) : 0;
-            int b = alength >= 2 ? JS.toInt(arg1) : slength;
+            int a = alength >= 1 ? Script.toInt(arg0) : 0;
+            int b = alength >= 2 ? Script.toInt(arg1) : slength;
             if (a < 0) a = slength + a;
             if (b < 0) b = slength + b;
             if (a < 0) a = 0;
             if (b < 0) b = 0;
             if (a > slength) a = slength;
             if (b > slength) b = slength;
-            if (a > b) return JS.S("");
-            return JS.S(s.substring(a,b));
+            if (a > b) return Script.S("");
+            return Script.S(s.substring(a,b));
         }
         //#end
         return super.call(method, args);
     }
     
     public JS get(JS key) throws JSExn {
-        //#switch(JS.toString(key))
-        case "length": return JS.N(JS.toString(this).length());
+        //#switch(Script.toString(key))
+        case "length": return Script.N(Script.toString(this).length());
         case "substring": return METHOD;
         case "charAt": return METHOD;
         case "charCodeAt": return METHOD;
index a1db9a8..4d6ec04 100644 (file)
@@ -14,9 +14,9 @@ public class JSReflection extends JS {
 
     public static JS wrap(Object o) throws JSExn {
         if (o == null) return null;
-        if (o instanceof String) return JS.S((String)o);
-        if (o instanceof Boolean) return JS.B(((Boolean)o).booleanValue());
-        if (o instanceof Number) return JS.N((Number)o);
+        if (o instanceof String) return Script.S((String)o);
+        if (o instanceof Boolean) return Script.B(((Boolean)o).booleanValue());
+        if (o instanceof Number) return Script.N((Number)o);
         if (o instanceof JS) return (JS)o;
         if (o instanceof Object[]) {
             // FIXME: get element type here
@@ -33,7 +33,7 @@ public class JSReflection extends JS {
                 private int n = 0;
                 public boolean _hasMoreElements() { return n < arr.length; }
                 public JS _nextElement() {
-                    return n >= arr.length ? null : JS.N(n++);
+                    return n >= arr.length ? null : Script.N(n++);
                 }
             };
         }
@@ -84,7 +84,7 @@ public class JSReflection extends JS {
         } catch (InvocationTargetException it) {
             Throwable ite = it.getTargetException();
             if (ite instanceof JSExn) throw ((JSExn)ite);
-            JS.warn(ite);
+            Script.warn(ite);
             throw new JSExn("unhandled reflected exception: " + ite.toString());
         } catch (SecurityException nfe) { }
         throw new JSExn("called a reflection method with the wrong number of arguments");
index a987921..40afb01 100644 (file)
@@ -24,10 +24,10 @@ public class JSRegexp extends JS.Immutable {
             this.pattern = r.pattern;
             this.flags = r.flags;
         } else {
-            String pattern = JS.toString(arg0);
+            String pattern = Script.toString(arg0);
             String sFlags = null;
             int flags = 0;
-            if(arg1 != null) sFlags = JS.toString(arg1);
+            if(arg1 != null) sFlags = Script.toString(arg1);
             if(sFlags == null) sFlags = "";
             for(int i=0;i<sFlags.length();i++) {
                 switch(sFlags.charAt(i)) {
@@ -38,7 +38,7 @@ public class JSRegexp extends JS.Immutable {
                 }
             }
             re = newRE(pattern,flags);
-            this.pattern = JS.S(pattern);
+            this.pattern = Script.S(pattern);
             this.flags = flags;
         }
     }
@@ -46,9 +46,9 @@ public class JSRegexp extends JS.Immutable {
     public JS call(JS method, JS[] args) throws JSExn {
         switch(args.length) {
             case 1: {
-                //#switch(JS.str(method))
+                //#switch(Script.str(method))
                 case "exec": {
-                    String s = JS.toString(a0);
+                    String s = Script.toString(a0);
                     int start = global ? lastIndex : 0;
                     if(start < 0 || start >= s.length()) { lastIndex = 0; return null; }
                     GnuRegexp.REMatch match = re.getMatch(s,start);
@@ -56,7 +56,7 @@ public class JSRegexp extends JS.Immutable {
                     return match == null ? null : matchToExecResult(match,re,s);
                 }
                 case "test": {
-                    String s = JS.toString(a0);
+                    String s = Script.toString(a0);
                     if (!global) return B(re.getMatch(s) != null);
                     int start = global ? lastIndex : 0;
                     if(start < 0 || start >= s.length()) { lastIndex = 0; return null; }
@@ -64,19 +64,19 @@ public class JSRegexp extends JS.Immutable {
                     lastIndex = match != null ? s.length() : match.getEndIndex();
                     return B(match != null);
                 }
-                case "toString": return JS.S(args[0].coerceToString());
+                case "toString": return Script.S(args[0].coerceToString());
                 //#end
                 break;
             }
             case 2: {
-                //#switch(JS.str(method))
+                //#switch(Script.str(method))
                 case "stringMatch": return stringMatch(args[0], args[1]);
                 case "stringSearch": return stringSearch(args[0], args[1]);
                 //#end
                 break;
             }
             case 3: {
-                //#switch(JS.str(method))
+                //#switch(Script.str(method))
                 case "stringReplace": return stringReplace(args[0], args[1], args[2]);
                 //#end
                 break;
@@ -86,23 +86,23 @@ public class JSRegexp extends JS.Immutable {
     }
     
     public JS get(JS key) throws JSExn {
-        //#switch(JS.str(key))
+        //#switch(Script.str(key))
         case "exec": return METHOD;
         case "test": return METHOD;
         case "toString": return METHOD;
-        case "lastIndex": return JS.N(lastIndex);
+        case "lastIndex": return Script.N(lastIndex);
         case "source": return pattern;
-        case "global": return JS.B(global);
-        case "ignoreCase": return JS.B(flags & GnuRegexp.RE.REG_ICASE);
-        case "multiline": return JS.B(flags & GnuRegexp.RE.REG_MULTILINE);
+        case "global": return Script.B(global);
+        case "ignoreCase": return Script.B(flags & GnuRegexp.RE.REG_ICASE);
+        case "multiline": return Script.B(flags & GnuRegexp.RE.REG_MULTILINE);
         //#end
         return super.get(key);
     }
     
     public void put(JS key, JS value) throws JSExn {
-        if(JS.isString(key)) {
-            if(JS.toString(key).equals("lastIndex")) {
-                lastIndex = JS.toInt(value);
+        if(Script.isString(key)) {
+            if(Script.toString(key).equals("lastIndex")) {
+                lastIndex = Script.toInt(value);
                 return;
             }
         }
@@ -112,12 +112,12 @@ public class JSRegexp extends JS.Immutable {
     private static JS matchToExecResult(GnuRegexp.REMatch match, GnuRegexp.RE re, String s) {
         try {
             JS ret = new JS.Obj();
-            ret.put(JS.S("index"), JS.N(match.getStartIndex()));
-            ret.put(JS.S("input"), JS.S(s));
+            ret.put(Script.S("index"), Script.N(match.getStartIndex()));
+            ret.put(Script.S("input"), Script.S(s));
             int n = re.getNumSubs();
-            ret.put(JS.S("length"), JS.N(n+1));
-            ret.put(ZERO,JS.S(match.toString()));
-            for(int i=1;i<=n;i++) ret.put(JS.N(i),JS.S(match.toString(i)));
+            ret.put(Script.S("length"), Script.N(n+1));
+            ret.put(Script.ZERO, Script.S(match.toString()));
+            for(int i=1;i<=n;i++) ret.put(Script.N(i),Script.S(match.toString(i)));
             return ret;
         } catch (JSExn e) {
             throw new Error("this should never happen");
@@ -137,14 +137,14 @@ public class JSRegexp extends JS.Immutable {
     
     private static final JS[] execarg = new JS[1];
     static JS stringMatch(JS o, JS arg0) throws JSExn {
-        String s = JS.toString(o);
+        String s = Script.toString(o);
         GnuRegexp.RE re;
         JSRegexp regexp = null;
         if(arg0 instanceof JSRegexp) {
             regexp = (JSRegexp) arg0;
             re = regexp.re;
         } else {
-            re = newRE(JS.toString(arg0),0);
+            re = newRE(Script.toString(arg0),0);
         }
         
         if(regexp == null) {
@@ -153,25 +153,25 @@ public class JSRegexp extends JS.Immutable {
         }
         try {
             execarg[0] = o;
-            if(!regexp.global) return regexp.call(JS.S("exec"), execarg);
+            if(!regexp.global) return regexp.call(Script.S("exec"), execarg);
         } finally { execarg[0] = null; }
 
         GnuRegexp.REMatch[] matches = re.getAllMatches(s);
         JSArray ret = new JSArray(matches.length);
-        for(int i=0;i<matches.length;i++) ret.add(JS.S(matches[i].toString()));
+        for(int i=0;i<matches.length;i++) ret.add(Script.S(matches[i].toString()));
         regexp.lastIndex = matches.length > 0 ? matches[matches.length-1].getEndIndex() : s.length();
         return ret;
     }
     
     static JS stringSearch(JS o, JS arg0) throws JSExn  {
-        String s = JS.toString(o);
-        GnuRegexp.RE re = arg0 instanceof JSRegexp ? ((JSRegexp)arg0).re : newRE(JS.toString(arg0),0);
+        String s = Script.toString(o);
+        GnuRegexp.RE re = arg0 instanceof JSRegexp ? ((JSRegexp)arg0).re : newRE(Script.toString(arg0),0);
         GnuRegexp.REMatch match = re.getMatch(s);
-        return match == null ? JS.N(-1) : JS.N(match.getStartIndex());
+        return match == null ? Script.N(-1) : Script.N(match.getStartIndex());
     }
     
     static JS stringReplace(JS o, JS arg0, JS arg1) throws JSExn {
-        String s = JS.toString(o);
+        String s = Script.toString(o);
         GnuRegexp.RE re;
         JSFunction replaceFunc = null;
         String replaceString = null;
@@ -185,7 +185,7 @@ public class JSRegexp extends JS.Immutable {
         if(arg1 instanceof JSFunction)
             replaceFunc = (JSFunction) arg1;
         else
-            replaceString = JS.toString(arg1);
+            replaceString = Script.toString(arg1);
         GnuRegexp.REMatch[] matches;
         if(regexp != null && regexp.global) {
             matches = re.getAllMatches(s);
@@ -214,15 +214,15 @@ public class JSRegexp extends JS.Immutable {
                 int n = (regexp == null ? 0 : re.getNumSubs());
                 int numArgs = 3 + n;
                 JS[] args = new JS[3 + n];
-                args[0] = JS.S(match.toString());
+                args[0] = Script.S(match.toString());
                 args[1] = null;
                 args[2] = null;
-                for(int j=1;j<=n;j++) args[j] = JS.S(match.toString(j));
-                args[args.length - 2] = JS.N(match.getStartIndex());
-                args[args.length - 1] = JS.S(s);
+                for(int j=1;j<=n;j++) args[j] = Script.S(match.toString(j));
+                args[args.length - 2] = Script.N(match.getStartIndex());
+                args[args.length - 1] = Script.S(s);
 
                 // note: can't perform pausing operations in here
-                sb.append(JS.toString(replaceFunc.call(args)));
+                sb.append(Script.toString(replaceFunc.call(args)));
 
             } else {
                 sb.append(mySubstitute(match,replaceString,s));
@@ -230,7 +230,7 @@ public class JSRegexp extends JS.Immutable {
         }
         int end = matches.length == 0 ? 0 : matches[matches.length-1].getEndIndex();
         sb.append(sa,end,sa.length-end);
-        return JS.S(sb.toString());
+        return Script.S(sb.toString());
     }
     
     private static String mySubstitute(GnuRegexp.REMatch match, String s, String source) {
@@ -276,8 +276,8 @@ public class JSRegexp extends JS.Immutable {
                     
     
     static JS stringSplit(JS s_, JS arg0, JS arg1, int nargs) throws JSExn {
-        String s = JS.toString(s_);
-        int limit = nargs < 2 ? Integer.MAX_VALUE : JS.toInt(arg1);
+        String s = Script.toString(s_);
+        int limit = nargs < 2 ? Integer.MAX_VALUE : Script.toInt(arg1);
         if(limit < 0) limit = Integer.MAX_VALUE;
         if(limit == 0) return new JSArray(0);
         
@@ -291,7 +291,7 @@ public class JSRegexp extends JS.Immutable {
             regexp = (JSRegexp) arg0;
             re = regexp.re;
         } else {
-            sep = JS.toString(arg0);
+            sep = Script.toString(arg0);
         }
         
         // special case this for speed. additionally, the code below doesn't properly handle
@@ -299,7 +299,7 @@ public class JSRegexp extends JS.Immutable {
         if(sep != null && sep.length()==0) {
             int len = s.length();
             for(int i=0;i<len;i++)
-                ret.addElement(JS.S(s.substring(i,i+1)));
+                ret.addElement(Script.S(s.substring(i,i+1)));
             return ret;
         }
         
@@ -308,24 +308,24 @@ public class JSRegexp extends JS.Immutable {
                 GnuRegexp.REMatch m = re.getMatch(s,p);
                 if(m == null) break OUTER;
                 boolean zeroLength = m.getStartIndex() == m.getEndIndex();
-                ret.addElement(JS.S(s.substring(p,zeroLength ? m.getStartIndex()+1 : m.getStartIndex())));
+                ret.addElement(Script.S(s.substring(p,zeroLength ? m.getStartIndex()+1 : m.getStartIndex())));
                 p = zeroLength ? p + 1 : m.getEndIndex();
                 if(!zeroLength) {
                     for(int i=1;i<=re.getNumSubs();i++) {
-                        ret.addElement(JS.S(m.toString(i)));
+                        ret.addElement(Script.S(m.toString(i)));
                         if(ret.length() == limit) break OUTER;
                     }
                 }
             } else {
                 int x = s.indexOf(sep,p);
                 if(x == -1) break OUTER;
-                ret.addElement(JS.S(s.substring(p,x)));
+                ret.addElement(Script.S(s.substring(p,x)));
                 p = x + sep.length();
             }
             if(ret.length() == limit) break;
         }
         if(p < s.length() && ret.length() != limit)
-            ret.addElement(JS.S(s.substring(p)));
+            ret.addElement(Script.S(s.substring(p)));
         return ret;
     }
    
index 9bd1791..6b3f640 100644 (file)
@@ -77,7 +77,7 @@ class Parser extends Lexer implements ByteCodes {
 
     /** for debugging */
     public static void main(String[] s) throws IOException {
-        JS block = JS.fromReader("stdin", 0, new InputStreamReader(System.in));
+        JS block = Script.fromReader("stdin", 0, new InputStreamReader(System.in));
         if (block == null) return;
         System.out.println(block);
     }
@@ -157,7 +157,7 @@ class Parser extends Lexer implements ByteCodes {
     void scopeDeclare(String name) throws IOException {
         ScopeInfo si = (ScopeInfo) scopeStack.peek();
         if(si.mapping.get(name) != null) throw pe("" + name + " already declared in this scope");
-        si.mapping.put(name,JS.N(si.end++));
+        si.mapping.put(name,Script.N(si.end++));
         globalCache.put(name,null);
     }
     void scopePush(JSFunction b) {
@@ -172,7 +172,7 @@ class Parser extends Lexer implements ByteCodes {
     void scopePop(JSFunction b) {
         ScopeInfo si = (ScopeInfo) scopeStack.pop();
         b.add(parserLine, OLDSCOPE);
-        b.set(si.newScopeInsn,JS.N((si.base<<16)|((si.end-si.base)<<0))); 
+        b.set(si.newScopeInsn,Script.N((si.base<<16)|((si.end-si.base)<<0))); 
     }
     
     
@@ -232,28 +232,28 @@ class Parser extends Lexer implements ByteCodes {
         case -1: throw pe("expected expression");
 
         // all of these simply push values onto the stack
-        case NUMBER: b.add(parserLine, LITERAL, JS.N(number)); break;
+        case NUMBER: b.add(parserLine, LITERAL, Script.N(number)); break;
         case STRING: b.add(parserLine, LITERAL, JSString.intern(string)); break;
         case NULL: b.add(parserLine, LITERAL, null); break;
-        case TRUE: case FALSE: b.add(parserLine, LITERAL, tok == TRUE ? JS.T : JS.F); break;
+        case TRUE: case FALSE: b.add(parserLine, LITERAL, tok == TRUE ? Script.T : Script.F); break;
 
         // (.foo) syntax
         case DOT: {
             consume(NAME);
             b.add(parserLine, GLOBALSCOPE);
-            b.add(parserLine, GET, JS.S("",true));
-            b.add(parserLine, LITERAL, JS.S(string,true));
+            b.add(parserLine, GET, Script.S("",true));
+            b.add(parserLine, LITERAL, Script.S(string,true));
             continueExprAfterAssignable(b,minPrecedence,null);
             break;
         }
 
         case LB: {
-            b.add(parserLine, ARRAY, JS.ZERO);                       // push an array onto the stack
+            b.add(parserLine, ARRAY, Script.ZERO);                       // push an array onto the stack
             int size0 = b.size;
             int i = 0;
             if (peekToken() != RB)
                 while(true) {                                               // iterate over the initialization values
-                    b.add(parserLine, LITERAL, JS.N(i++));           // push the index in the array to place it into
+                    b.add(parserLine, LITERAL, Script.N(i++));           // push the index in the array to place it into
                     if (peekToken() == COMMA || peekToken() == RB)
                         b.add(parserLine, LITERAL, null);                   // for stuff like [1,,2,]
                     else
@@ -263,19 +263,19 @@ class Parser extends Lexer implements ByteCodes {
                     if (peekToken() == RB) break;
                     consume(COMMA);
                 }
-            b.set(size0 - 1, JS.N(i));                               // back at the ARRAY instruction, write the size of the array
+            b.set(size0 - 1, Script.N(i));                               // back at the ARRAY instruction, write the size of the array
             consume(RB);
             break;
         }
         case SUB: case ADD: {
             if(peekToken() == NUMBER) {   // literal
                 consume(NUMBER);
-                b.add(parserLine, LITERAL, JS.N(number.doubleValue() * (tok == SUB ? -1 : 1)));
+                b.add(parserLine, LITERAL, Script.N(number.doubleValue() * (tok == SUB ? -1 : 1)));
             } else { // unary +/- operator
-                if(tok == SUB) b.add(parserLine, LITERAL, JS.ZERO);
+                if(tok == SUB) b.add(parserLine, LITERAL, Script.ZERO);
                 // BITNOT has the same precedence as the unary +/- operators
                 startExpr(b,precedence[BITNOT]);
-                if(tok == ADD) b.add(parserLine, LITERAL, JS.ZERO); // HACK to force expr into a numeric context
+                if(tok == ADD) b.add(parserLine, LITERAL, Script.ZERO); // HACK to force expr into a numeric context
                 b.add(parserLine, SUB);
             }
             break;
@@ -296,8 +296,8 @@ class Parser extends Lexer implements ByteCodes {
             else if(!sg)
                 throw pe("prefixed increment/decrement can only be performed on a valid assignment target");
             if(!sg) b.add(parserLine, GET_PRESERVE, Boolean.TRUE);
-            b.add(parserLine, LITERAL, JS.N(1));
-            b.add(parserLine, tok == INC ? ADD : SUB, JS.N(2));
+            b.add(parserLine, LITERAL, Script.N(1));
+            b.add(parserLine, tok == INC ? ADD : SUB, Script.N(2));
             if(sg) {
                 b.add(parserLine, SCOPEPUT, b.getArg(prev));
             } else {
@@ -344,9 +344,9 @@ class Parser extends Lexer implements ByteCodes {
             if(peekToken() == ASSIGN) {
                 consume(ASSIGN);
                 startExpr(b, precedence[ASSIGN]);
-                b.add(parserLine, CASCADE, JS.T);
+                b.add(parserLine, CASCADE, Script.T);
             } else {
-                b.add(parserLine, CASCADE, JS.F);
+                b.add(parserLine, CASCADE, Script.F);
             }
             break;
         }
@@ -368,7 +368,7 @@ class Parser extends Lexer implements ByteCodes {
                     consume(NAME);                                        // a named argument
                     
                     b2.add(parserLine, DUP);                              // dup the args array 
-                    b2.add(parserLine, GET, JS.N(numArgs - 1));   // retrieve it from the arguments array
+                    b2.add(parserLine, GET, Script.N(numArgs - 1));   // retrieve it from the arguments array
                     scopeDeclare(string);
                     b2.add(parserLine, SCOPEPUT, scopeKey(string));
                     b2.add(parserLine, POP);
@@ -473,7 +473,7 @@ class Parser extends Lexer implements ByteCodes {
             
             if (tok != ADD_TRAP && tok != DEL_TRAP) {
                 // tok-1 is always s/^ASSIGN_// (0 is BITOR, 1 is ASSIGN_BITOR, etc) 
-                b.add(parserLine, tok - 1, tok-1==ADD ? JS.N(2) : null);
+                b.add(parserLine, tok - 1, tok-1==ADD ? Script.N(2) : null);
                 if(varKey == null) {
                     b.add(parserLine, PUT);
                     b.add(parserLine, SWAP);
@@ -490,18 +490,18 @@ class Parser extends Lexer implements ByteCodes {
         case INC: case DEC: { // postfix
             if(varKey == null) {
                 b.add(parserLine, GET_PRESERVE, Boolean.TRUE);
-                b.add(parserLine, LITERAL, JS.N(1));
-                b.add(parserLine, tok == INC ? ADD : SUB, JS.N(2));
+                b.add(parserLine, LITERAL, Script.N(1));
+                b.add(parserLine, tok == INC ? ADD : SUB, Script.N(2));
                 b.add(parserLine, PUT, null);
                 b.add(parserLine, SWAP, null);
                 b.add(parserLine, POP, null);
-                b.add(parserLine, LITERAL, JS.N(1));
-                b.add(parserLine, tok == INC ? SUB : ADD, JS.N(2));   // undo what we just did, since this is postfix
+                b.add(parserLine, LITERAL, Script.N(1));
+                b.add(parserLine, tok == INC ? SUB : ADD, Script.N(2));   // undo what we just did, since this is postfix
             } else {
                 b.add(parserLine, SCOPEGET, varKey);
                 b.add(parserLine, DUP);
-                b.add(parserLine, LITERAL, JS.ONE);
-                b.add(parserLine, tok == INC ? ADD : SUB, JS.N(2));
+                b.add(parserLine, LITERAL, Script.ONE);
+                b.add(parserLine, tok == INC ? ADD : SUB, Script.N(2));
                 b.add(parserLine, SCOPEPUT, varKey);
             }
             break;
@@ -523,7 +523,7 @@ class Parser extends Lexer implements ByteCodes {
             // return JS.METHOD
             b.add(parserLine, varKey == null ? GET_PRESERVE : SCOPEGET, varKey);
             int n = parseArgs(b);
-            b.add(parserLine, varKey == null ? CALLMETHOD : CALL, JS.N(n));
+            b.add(parserLine, varKey == null ? CALLMETHOD : CALL, Script.N(n));
             break;
         }
         default: {
@@ -568,7 +568,7 @@ class Parser extends Lexer implements ByteCodes {
         switch (tok) {
         case LP: {  // invocation (not grouping)
             int n = parseArgs(b);
-            b.add(parserLine, CALL, JS.N(n));
+            b.add(parserLine, CALL, Script.N(n));
             break;
         }
         case BITOR: case BITXOR: case BITAND: case SHEQ: case SHNE: case LSH:
@@ -587,17 +587,17 @@ class Parser extends Lexer implements ByteCodes {
                 nextTok = getToken();
             } while(nextTok == tok);
             pushBackToken();
-            b.add(parserLine, tok, JS.N(count));
+            b.add(parserLine, tok, Script.N(count));
             break;
         }
         case OR: case AND: {
-            b.add(parserLine, tok == AND ? JSFunction.JF : JSFunction.JT, JS.ZERO);       // test to see if we can short-circuit
+            b.add(parserLine, tok == AND ? JSFunction.JF : JSFunction.JT, Script.ZERO);       // test to see if we can short-circuit
             int size = b.size;
             startExpr(b, precedence[tok]);                                     // otherwise check the second value
-            b.add(parserLine, JMP, JS.N(2));                            // leave the second value on the stack and jump to the end
+            b.add(parserLine, JMP, Script.N(2));                            // leave the second value on the stack and jump to the end
             b.add(parserLine, LITERAL, tok == AND ?
-                  JS.B(false) : JS.B(true));                     // target of the short-circuit jump is here
-            b.set(size - 1, JS.N(b.size - size));                     // write the target of the short-circuit jump
+                  Script.B(false) : Script.B(true));                     // target of the short-circuit jump is here
+            b.set(size - 1, Script.N(b.size - size));                     // write the target of the short-circuit jump
             break;
         }
         case DOT: {
@@ -618,15 +618,15 @@ class Parser extends Lexer implements ByteCodes {
             break;
         }
         case HOOK: {
-            b.add(parserLine, JF, JS.ZERO);                // jump to the if-false expression
+            b.add(parserLine, JF, Script.ZERO);                // jump to the if-false expression
             int size = b.size;
             startExpr(b, minPrecedence);                          // write the if-true expression
-            b.add(parserLine, JMP, JS.ZERO);               // if true, jump *over* the if-false expression     
-            b.set(size - 1, JS.N(b.size - size + 1));    // now we know where the target of the jump is
+            b.add(parserLine, JMP, Script.ZERO);               // if true, jump *over* the if-false expression     
+            b.set(size - 1, Script.N(b.size - size + 1));    // now we know where the target of the jump is
             consume(COLON);
             size = b.size;
             startExpr(b, minPrecedence);                          // write the if-false expression
-            b.set(size - 1, JS.N(b.size - size + 1));    // this is the end; jump to here
+            b.set(size - 1, Script.N(b.size - size + 1));    // this is the end; jump to here
             break;
         }
         case COMMA: {
@@ -724,18 +724,18 @@ class Parser extends Lexer implements ByteCodes {
             startExpr(b, -1);
             consume(RP);
             
-            b.add(parserLine, JF, JS.ZERO);                    // if false, jump to the else-block
+            b.add(parserLine, JF, Script.ZERO);                    // if false, jump to the else-block
             int size = b.size;
             parseStatement(b, null);
             
             if (peekToken() == ELSE) {
                 consume(ELSE);
-                b.add(parserLine, JMP, JS.ZERO);               // if we took the true-block, jump over the else-block
-                b.set(size - 1, JS.N(b.size - size + 1));
+                b.add(parserLine, JMP, Script.ZERO);               // if we took the true-block, jump over the else-block
+                b.set(size - 1, Script.N(b.size - size + 1));
                 size = b.size;
                 parseStatement(b, null);
             }
-            b.set(size - 1, JS.N(b.size - size + 1));        // regardless of which branch we took, b[size] needs to point here
+            b.set(size - 1, Script.N(b.size - size + 1));        // regardless of which branch we took, b[size] needs to point here
             break;
         }
         case WHILE: {
@@ -745,12 +745,12 @@ class Parser extends Lexer implements ByteCodes {
             int size = b.size;
             b.add(parserLine, POP);                                   // discard the first-iteration indicator
             startExpr(b, -1);
-            b.add(parserLine, JT, JS.N(2));                    // if the while() clause is true, jump over the BREAK
+            b.add(parserLine, JT, Script.N(2));                    // if the while() clause is true, jump over the BREAK
             b.add(parserLine, BREAK);
             consume(RP);
             parseStatement(b, null);
             b.add(parserLine, CONTINUE);                              // if we fall out of the end, definately continue
-            b.set(size - 1, JS.N(b.size - size + 1));        // end of the loop
+            b.set(size - 1, Script.N(b.size - size + 1));        // end of the loop
             break;
         }
         case SWITCH: {
@@ -768,10 +768,10 @@ class Parser extends Lexer implements ByteCodes {
                     startExpr(b, -1);
                     consume(COLON);
                     b.add(parserLine, EQ);                         // check if we should do this case-block
-                    b.add(parserLine, JF, JS.ZERO);         // if not, jump to the next one
+                    b.add(parserLine, JF, Script.ZERO);         // if not, jump to the next one
                     int size = b.size;
                     while(peekToken() != CASE && peekToken() != DEFAULT && peekToken() != RC) parseStatement(b, null);
-                    b.set(size - 1, JS.N(1 + b.size - size));
+                    b.set(size - 1, Script.N(1 + b.size - size));
                 } else if (peekToken() == DEFAULT) {
                     consume(DEFAULT);
                     consume(COLON);
@@ -783,7 +783,7 @@ class Parser extends Lexer implements ByteCodes {
                 } else {
                     throw pe("expected CASE, DEFAULT, or RC; got " + codeToString[peekToken()]);
                 }
-            b.set(size0 - 1, JS.N(b.size - size0 + 1));      // end of the loop
+            b.set(size0 - 1, Script.N(b.size - size0 + 1));      // end of the loop
             break;
         }
             
@@ -795,12 +795,12 @@ class Parser extends Lexer implements ByteCodes {
             consume(WHILE);
             consume(LP);
             startExpr(b, -1);
-            b.add(parserLine, JT, JS.N(2));                  // check the while() clause; jump over the BREAK if true
+            b.add(parserLine, JT, Script.N(2));                  // check the while() clause; jump over the BREAK if true
             b.add(parserLine, BREAK);
             b.add(parserLine, CONTINUE);
             consume(RP);
             consume(SEMI);
-            b.set(size - 1, JS.N(b.size - size + 1));      // end of the loop; write this location to the LOOP instruction
+            b.set(size - 1, Script.N(b.size - size + 1));      // end of the loop; write this location to the LOOP instruction
             break;
         }
             
@@ -879,7 +879,7 @@ class Parser extends Lexer implements ByteCodes {
                     b.add(parserLine, JMP);
                     catchEnds.add(new Integer(b.size-1));
                     
-                    for(int i=0; i<3; i++) if (writebacks[i] != -1) b.set(writebacks[i], JS.N(b.size-writebacks[i]));
+                    for(int i=0; i<3; i++) if (writebacks[i] != -1) b.set(writebacks[i], Script.N(b.size-writebacks[i]));
                     b.add(parserLine, POP); // pop the element thats on the stack from the compare
                 }
                 
@@ -888,7 +888,7 @@ class Parser extends Lexer implements ByteCodes {
                 
                 for(int i=0;i<catchEnds.size();i++) {
                     int n = ((Integer)catchEnds.get(i)).intValue();
-                    b.set(n, JS.N(b.size-n));
+                    b.set(n, Script.N(b.size-n));
                 }
                 
                 // pop the try and catch markers
@@ -897,7 +897,7 @@ class Parser extends Lexer implements ByteCodes {
             }
                         
             // jump here if no exception was thrown
-            b.set(successJMPInsn, JS.N(b.size - successJMPInsn)); 
+            b.set(successJMPInsn, Script.N(b.size - successJMPInsn)); 
                         
             int finallyJMPDistance = -1;
             if (peekToken() == FINALLY) {
@@ -938,14 +938,14 @@ class Parser extends Lexer implements ByteCodes {
                 
                 b.add(parserLine,SWAP); // get the keys enumeration object on top
                 b.add(parserLine,DUP);
-                b.add(parserLine,GET,JS.S("hasMoreElements"));
+                b.add(parserLine,GET,Script.S("hasMoreElements"));
                 int size2 = b.size;
                 b.add(parserLine,JT);
                 b.add(parserLine,SWAP);
                 b.add(parserLine,BREAK);
-                b.set(size2, JS.N(b.size - size2));
+                b.set(size2, Script.N(b.size - size2));
                 b.add(parserLine,DUP);
-                b.add(parserLine,GET,JS.S("nextElement"));
+                b.add(parserLine,GET,Script.S("nextElement"));
 
                 scopePush(b);
                 
@@ -970,7 +970,7 @@ class Parser extends Lexer implements ByteCodes {
                 scopePop(b);
                 b.add(parserLine, CONTINUE);
                 // jump here on break
-                b.set(size, JS.N(b.size - size));
+                b.set(size, Script.N(b.size - size));
                 
                 b.add(parserLine, POP);
             } else {
@@ -983,27 +983,27 @@ class Parser extends Lexer implements ByteCodes {
                 if (peekToken() != SEMI)
                     startExpr(e2, -1);
                 else
-                    e2.add(parserLine, JSFunction.LITERAL, JS.T);         // handle the for(foo;;foo) case
+                    e2.add(parserLine, JSFunction.LITERAL, Script.T);         // handle the for(foo;;foo) case
                 consume(SEMI);
                 if (label != null) b.add(parserLine, LABEL, label);
                 b.add(parserLine, LOOP);
                 int size2 = b.size;
                     
-                b.add(parserLine, JT, JS.ZERO);                   // if we're on the first iteration, jump over the incrementor
+                b.add(parserLine, JT, Script.ZERO);                   // if we're on the first iteration, jump over the incrementor
                 int size = b.size;
                 if (peekToken() != RP) {                                 // do the increment thing
                     startExpr(b, -1);
                     b.add(parserLine, POP);
                 }
-                b.set(size - 1, JS.N(b.size - size + 1));
+                b.set(size - 1, Script.N(b.size - size + 1));
                 consume(RP);
                     
                 b.paste(e2);                                             // ok, *now* test if we're done yet
-                b.add(parserLine, JT, JS.N(2));                   // break out if we don't meet the test
+                b.add(parserLine, JT, Script.N(2));                   // break out if we don't meet the test
                 b.add(parserLine, BREAK);
                 parseStatement(b, null);
                 b.add(parserLine, CONTINUE);                             // if we fall out the bottom, CONTINUE
-                b.set(size2 - 1, JS.N(b.size - size2 + 1));     // end of the loop
+                b.set(size2 - 1, Script.N(b.size - size2 + 1));     // end of the loop
                     
                 scopePop(b);                            // get our scope back
             }
index 8315755..632a0a6 100644 (file)
@@ -52,16 +52,16 @@ public class SOAP extends XMLRPC {
             if (key.endsWith("ype")) {
                 if (value.endsWith("boolean")) {
                     objects.removeElementAt(objects.size() - 1);
-                    objects.addElement(JS.B(true));
+                    objects.addElement(Script.B(true));
                 } else if (value.endsWith("int")) {
                     objects.removeElementAt(objects.size() - 1);
-                    objects.addElement(JS.N(0));
+                    objects.addElement(Script.N(0));
                 } else if (value.endsWith("double")) {
                     objects.removeElementAt(objects.size() - 1);
-                    objects.addElement(JS.N(0.0));
+                    objects.addElement(Script.N(0.0));
                 } else if (value.endsWith("string")) {
                     objects.removeElementAt(objects.size() - 1);
-                    objects.addElement(JS.S(""));
+                    objects.addElement(Script.S(""));
                 } else if (value.endsWith("base64")) {
                     objects.removeElementAt(objects.size() - 1);
                     objects.addElement(new byte[] { });
@@ -155,7 +155,7 @@ public class SOAP extends XMLRPC {
         } else if (parent != null && parent instanceof JS) {
             objects.removeElementAt(objects.size() - 1);
             try {
-                ((JS)parent).put(JS.S(name), me);
+                ((JS)parent).put(Script.S(name), me);
             } catch (JSExn e) {
                 throw new Error("this should never happen");
             }
index ea436b9..fe138bc 100644 (file)
@@ -16,8 +16,8 @@ public class Test extends JS.Obj {
         JS f = JS.fromReader(args[0],1,new FileReader(args[0]));
         System.out.println(((JSFunction)f).dump());
         JS s = new JS.O();
-        s.put(JS.S("sys"),new Test());
-        f = JS.cloneWithNewGlobalScope(f,s);
+        s.put(Script.S("sys"),new Test());
+        f = Script.cloneWithNewGlobalScope(f,s);
         //JS ret = f.call(null,null,null,null,0);
         Interpreter i = new Interpreter((JSFunction)f, true, new JS[0]);
         JS ret = (JS)i.run(null);
@@ -50,8 +50,8 @@ public class Test extends JS.Obj {
     }
         
     public void put(JS key, JS val) throws JSExn {
-        if("bgput".equals(JS.toString(key))) {
-            action = JS.toString(val);
+        if("bgput".equals(Script.toString(key))) {
+            action = Script.toString(val);
             try {
                 Script.pause();
             } catch(Pausable.NotPausableException e) {
@@ -59,8 +59,8 @@ public class Test extends JS.Obj {
             }
             return;
         }   
-        if("exit".equals(JS.toString(key))) {
-            System.exit(JS.toInt(val));
+        if("exit".equals(Script.toString(key))) {
+            System.exit(Script.toInt(val));
             return;
         }
         super.put(key,val);
@@ -68,18 +68,18 @@ public class Test extends JS.Obj {
     
     public JS callMethod(JS method, JS a0, JS a1, JS a2, JS[] rest, int nargs) throws JSExn {
         if(!JS.isString(method)) return null;
-        if("print".equals(JS.toString(method))) {
-            System.out.println(JS.debugToString(a0));
+        if("print".equals(Script.toString(method))) {
+            System.out.println(Script.str(a0));
             return null;
         }
-        if("clone".equals(JS.toString(method))) return a0 == null ? null : a0.jsclone();
-        if("firethis".equals(JS.toString(method))) {
-            String action = JS.toString(a0);
+        if("clone".equals(Script.toString(method))) return a0 == null ? null : a0.jsclone();
+        if("firethis".equals(Script.toString(method))) {
+            String action = Script.toString(a0);
             JS target = a1;
             JS key = a2;
             if(action.equals("get")) return a1.getAndTriggerTraps(key);
-            else if(action.equals("put")) a1.putAndTriggerTraps(key,JS.S("some value"));
-            else if(action.equals("trigger")) return target.justTriggerTraps(key,JS.S("some trigger value"));
+            else if(action.equals("put")) a1.putAndTriggerTraps(key,Script.S("some value"));
+            else if(action.equals("trigger")) return target.justTriggerTraps(key,Script.S("some trigger value"));
             return null;
         }
         return null;
index a902508..a3dc331 100644 (file)
@@ -42,7 +42,7 @@ public class XMLRPC extends JS {
     public XMLRPC(String url, String method, XMLRPC httpSource) {
         this.http = httpSource.http; this.url = url; this.method = method; }
     public JS get(JS name) throws JSExn {
-        return new XMLRPC(url, (method.equals("") ? "" : method + ".") + JS.toString(name), this); }
+        return new XMLRPC(url, (method.equals("") ? "" : method + ".") + Script.toString(name), this); }
 
 
     /** this holds character content as we read it in -- since there is only one per instance, we don't support mixed content */
@@ -146,7 +146,7 @@ public class XMLRPC extends JS {
                 for(i=objects.size() - 1; objects.elementAt(i) != null; i--);
                 JSArray arr = new JSArray();
                 try {
-                    for(int j = i + 1; j<objects.size(); j++) arr.put(JS.N(j - i - 1), (JS)objects.elementAt(j));
+                    for(int j = i + 1; j<objects.size(); j++) arr.put(Script.N(j - i - 1), (JS)objects.elementAt(j));
                 } catch (JSExn e) {
                     throw new Error("this should never happen");
                 }
@@ -275,7 +275,7 @@ public class XMLRPC extends JS {
 
         } else if (o instanceof JSArray) {
             if (tracker.get(o) != null) throw new JSExn("attempted to send multi-ref data structure via XML-RPC");
-            tracker.put(o, JS.B(true));
+            tracker.put(o, Script.B(true));
             sb.append("                <value><array><data>\n");
             JSArray a = (JSArray)o;
             for(int i=0; i<a.length(); i++) appendObject(a.elementAt(i), sb);
@@ -283,7 +283,7 @@ public class XMLRPC extends JS {
 
         } else if (o instanceof JS) {
             if (tracker.get(o) != null) throw new JSExn("attempted to send multi-ref data structure via XML-RPC");
-            tracker.put(o, JS.B(true));
+            tracker.put(o, Script.B(true));
             JS j = (JS)o;
             sb.append("                <value><struct>\n");
             Enumeration e = j.keys();