2003/10/15 21:43:01
[org.ibex.core.git] / src / org / xwt / Res.java
index 228b289..896220b 100644 (file)
@@ -143,6 +143,7 @@ public abstract class Res extends JS {
         public Res graft(Object newResource) { return new Graft(parent, key, newResource); }
     }
 
+    // FEATURE: eliminate code duplication with JS.Graft
     /** shadow resource which replaces the graft */
     public static class Graft extends Res {
         Res graftee;
@@ -155,6 +156,16 @@ public abstract class Res extends JS {
         public Object get(Object key) { return replaced_key.equals(key) ? replaced_val : graftee.get(key); }
         public String getDescriptiveName() { return graftee.getDescriptiveName(); }
         public Res getParent() { return graftee.getParent(); }
+        public Object callMethod(Object method, Array args, boolean checkOnly) throws JS.Exn {
+            if (!replaced_key.equals(method)) return graftee.callMethod(method, args, checkOnly);
+            if (replaced_val instanceof Callable) return checkOnly ? Boolean.TRUE : ((Callable)replaced_val).call(args);
+            if (checkOnly) return Boolean.FALSE;
+            throw new JS.Exn("attempt to call non-function");
+        }
+        public Number coerceToNumber() { return graftee.coerceToNumber(); }
+        public String coerceToString() { return graftee.coerceToString(); }
+        public boolean coerceToBoolean() { return graftee.coerceToBoolean(); }
+        public String typeName() { return graftee.typeName(); }
     }
 
     /** shadow resource which replaces the graft */