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;
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 */