Ejemplo n.º 1
0
 @Override
 public boolean hasInstance(Scriptable instance) {
   Scriptable proto = instance.getPrototype();
   while (proto != null) {
     if (proto.equals(this)) return true;
     proto = proto.getPrototype();
   }
   return false;
 }
 /**
  * Implements the instanceof operator.
  *
  * @param instance The value that appeared on the LHS of the instanceof operator
  * @return true if "this" appears in value's prototype chain
  */
 public boolean hasInstance(Scriptable instance) {
   // Default for JS objects (other than Function) is to do prototype
   // chasing.
   Scriptable proto = instance.getPrototype();
   while (proto != null) {
     if (proto.equals(this)) return true;
     proto = proto.getPrototype();
   }
   return false;
 }