2003/06/28 06:57:08
[org.ibex.core.git] / src / org / xwt / js / CompiledFunctionImpl.java
index 6bcff6e..c31c84e 100644 (file)
@@ -223,7 +223,7 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens {
                 }
                 Object ret = null;
                 if (o == null) throw je("tried to get property \"" + v + "\" from the null value");
-                if (v == null) throw je("tried to get the null key from " + v);
+                if (v == null) throw je("tried to get the null key from " + o);
                 if (o instanceof String) {
                     ret = getFromString((String)o, v);
                 } else if (o instanceof Boolean) {
@@ -331,6 +331,7 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens {
                     boolean ret;
                     if (l == null) { Object tmp = r; r = l; l = tmp; }
                     if (l == null && r == null) ret = true;
+                    else if (r == null) ret = false; // l != null, so its false
                     else if (l instanceof Boolean) ret = new Boolean(JS.toBoolean(r)).equals(l);
                     else if (l instanceof Number) ret = JS.toNumber(r).doubleValue() == JS.toNumber(l).doubleValue();
                     else if (l instanceof String) ret = r != null && l.equals(r.toString());
@@ -379,6 +380,24 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens {
                     if (args.length() != 1) return null;
                     return new Integer(((String)o).indexOf(args.elementAt(0).toString()));
                 } };
+        else if(v.equals("match")) return new JS.Callable() {
+                public Object call(JS.Array args) {
+                    return Regexp.stringMatch(o,args);
+                } };
+        else if(v.equals("search")) return new JS.Callable() {
+                public Object call(JS.Array args) {
+                    return Regexp.stringSearch(o,args);
+                } };
+        else if(v.equals("replace")) return new JS.Callable() {
+                public Object call(JS.Array args) {
+                    return Regexp.stringReplace(o,args);
+                } };
+        else if(v.equals("split")) return new JS.Callable() {
+                public Object call(JS.Array args) {
+                    return Regexp.stringSplit(o,args);
+                } };
+                        
+                        
         throw new JS.Exn("Not Implemented: propery " + v + " on String objects");
     }
 
@@ -426,6 +445,7 @@ class CompiledFunctionImpl extends JSCallable implements ByteCodes, Tokens {
 
 }
 
-class JSCallable extends JS.Callable {
+/** this class exists solely to work around a GCJ bug */
+abstract class JSCallable extends JS.Callable {
         public abstract Object call(JS.Array args) throws JS.Exn;
 }