2003/06/18 07:05:17
[org.ibex.core.git] / src / org / xwt / js / CompiledFunctionImpl.java
index 9d61a0f..9511333 100644 (file)
@@ -6,7 +6,7 @@ import java.io.*;
 
 // FIXME: could use some cleaning up
 /** a JavaScript function, compiled into bytecode */
-class CompiledFunctionImpl extends JS.Callable implements ByteCodes, Tokens {
+class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens {
 
     // Fields and Accessors ///////////////////////////////////////////////
 
@@ -347,14 +347,14 @@ class CompiledFunctionImpl extends JS.Callable implements ByteCodes, Tokens {
 
     // Helpers for Number, String, and Boolean ////////////////////////////////////////
 
-    private Object getFromString(final String o, final Object v) {
+    private static Object getFromString(final String o, final Object v) {
         if (v.equals("length")) return new Integer(((String)o).length());
         else if (v.equals("substring")) return new JS.Callable() {
                 public Object call(JS.Array args) {
                     if (args.length() == 1) return ((String)o).substring(JS.toNumber(args.elementAt(0)).intValue());
                     else if (args.length() == 2) return ((String)o).substring(JS.toNumber(args.elementAt(0)).intValue(),
                                                                               JS.toNumber(args.elementAt(1)).intValue());
-                    else throw je("String.substring() can only take one or two arguments");
+                    else throw new JS.Exn("String.substring() can only take one or two arguments");
                 }
             };
         else if (v.equals("toLowerCase")) return new JS.Callable() {
@@ -379,7 +379,7 @@ class CompiledFunctionImpl extends JS.Callable implements ByteCodes, Tokens {
                     if (args.length() != 1) return null;
                     return new Integer(((String)o).indexOf(args.elementAt(0).toString()));
                 } };
-        throw je("Not Implemented: propery " + v + " on String objects");
+        throw new JS.Exn("Not Implemented: propery " + v + " on String objects");
     }
 
 
@@ -425,3 +425,7 @@ class CompiledFunctionImpl extends JS.Callable implements ByteCodes, Tokens {
     }
 
 }
+
+abstract class JSCallable extends JS.Callable {
+        public abstract Object call(JS.Array args) throws JS.Exn;
+}