当前位置: 首页>>代码示例>>Java>>正文


Java ObjectType.isInstanceType方法代码示例

本文整理汇总了Java中com.google.javascript.rhino.jstype.ObjectType.isInstanceType方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectType.isInstanceType方法的具体用法?Java ObjectType.isInstanceType怎么用?Java ObjectType.isInstanceType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.javascript.rhino.jstype.ObjectType的用法示例。


在下文中一共展示了ObjectType.isInstanceType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: ensurePropertyDeclaredHelper

import com.google.javascript.rhino.jstype.ObjectType; //导入方法依赖的package包/类
/**
 * Declares a property on its owner, if necessary.
 * @return True if a property was declared.
 */
private boolean ensurePropertyDeclaredHelper(
    Node getprop, ObjectType objectType) {
  String propName = getprop.getLastChild().getString();
  String qName = getprop.getQualifiedName();
  if (qName != null) {
    Var var = syntacticScope.getVar(qName);
    if (var != null && !var.isTypeInferred()) {
      // Handle normal declarations that could not be addressed earlier.
      if (propName.equals("prototype") ||
      // Handle prototype declarations that could not be addressed earlier.
          (!objectType.hasOwnProperty(propName) &&
           (!objectType.isInstanceType() ||
               (var.isExtern() && !objectType.isNativeObjectType())))) {
        return objectType.defineDeclaredProperty(
            propName, var.getType(), var.isExtern());
      }
    }
  }
  return false;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:25,代码来源:TypeInference.java

示例2: ensurePropertyDefined

import com.google.javascript.rhino.jstype.ObjectType; //导入方法依赖的package包/类
/**
 * Defines a property if the property has not been defined yet.
 */
private void ensurePropertyDefined(Node getprop, JSType rightType) {
  ObjectType objectType = ObjectType.cast(
      getJSType(getprop.getFirstChild()).restrictByNotNullOrUndefined());
  if (objectType != null) {
    if (ensurePropertyDeclaredHelper(getprop, objectType)) {
      return;
    }

    String propName = getprop.getLastChild().getString();
    if (!objectType.isPropertyTypeDeclared(propName)) {
      // We do not want a "stray" assign to define an inferred property
      // for every object of this type in the program. So we use a heuristic
      // approach to determine whether to infer the propery.
      //
      // 1) If the property is already defined, join it with the previously
      //    inferred type.
      // 2) If this isn't an instance object, define it.
      // 3) If the property of an object is being assigned in the constructor,
      //    define it.
      // 4) If this is a stub, define it.
      // 5) Otherwise, do not define the type, but declare it in the registry
      //    so that we can use it for missing property checks.
      if (objectType.hasProperty(propName) ||
          !objectType.isInstanceType()) {
        if ("prototype".equals(propName)) {
          objectType.defineDeclaredProperty(propName, rightType, false);
        } else {
          objectType.defineInferredProperty(propName, rightType, false);
        }
      } else {
        if (getprop.getFirstChild().getType() == Token.THIS &&
            getJSType(syntacticScope.getRootNode()).isConstructor()) {
          objectType.defineInferredProperty(propName, rightType, false);
        } else {
          registry.registerPropertyOnType(propName, objectType);
        }
      }
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:44,代码来源:TypeInference.java


注:本文中的com.google.javascript.rhino.jstype.ObjectType.isInstanceType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。