예제 #1
0
 @Override
 public Property getSlot(String name) {
   if ("prototype".equals(name)) {
     // Lazy initialization of the prototype field.
     getPrototype();
     return prototypeSlot;
   } else {
     return super.getSlot(name);
   }
 }
예제 #2
0
  /**
   * Given a constructor or an interface type and a property, finds the top-most superclass that has
   * the property defined (including this constructor).
   */
  public ObjectType getTopMostDefiningType(String propertyName) {
    Preconditions.checkState(isConstructor() || isInterface());
    Preconditions.checkArgument(getInstanceType().hasProperty(propertyName));
    FunctionType ctor = this;

    if (isInterface()) {
      return getTopDefiningInterface(getInstanceType(), propertyName);
    }

    ObjectType topInstanceType = null;
    do {
      topInstanceType = ctor.getInstanceType();
      ctor = ctor.getSuperClassConstructor();
    } while (ctor != null && ctor.getPrototype().hasProperty(propertyName));

    return topInstanceType;
  }