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


Java JSType.autoboxesTo方法代码示例

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


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

示例1: maybeAddAutoboxes

import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
private ConcreteType maybeAddAutoboxes(
    ConcreteType cType, JSType jsType, String prop) {
  jsType = jsType.restrictByNotNullOrUndefined();
  if (jsType instanceof UnionType) {
    for (JSType alt : ((UnionType) jsType).getAlternates()) {
      return maybeAddAutoboxes(cType, alt, prop);
    }
  }

  if (jsType.autoboxesTo() != null) {
    JSType autoboxed = jsType.autoboxesTo();
    return cType.unionWith(tt.getConcreteInstance((ObjectType) autoboxed));
  } else if (jsType.unboxesTo() != null) {
    return cType.unionWith(tt.getConcreteInstance((ObjectType) jsType));
  }

  return cType;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:19,代码来源:DisambiguateProperties.java

示例2: isPrototypeNameReference

import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
/**
 * @return true if n MUST be a prototype name reference.
 */
private boolean isPrototypeNameReference(Node n) {
  if (!NodeUtil.isGetProp(n)) {
    return false;
  }
  JSType type = getType(n.getFirstChild());
  if (type.isUnknownType() || type.isUnionType()) {
    return false;
  }
  return (type instanceof InstanceObjectType || type.autoboxesTo() != null);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:14,代码来源:NameReferenceGraphConstruction.java

示例3: recordPrototypePropUse

import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
private void recordPrototypePropUse(
    NodeTraversal t, Node n, Node parent) {
  Preconditions.checkArgument(NodeUtil.isGetProp(n));
  Node instance = n.getFirstChild();
  JSType instanceType = getType(instance);
  JSType boxedType = instanceType.autoboxesTo();
  instanceType = boxedType != null ? boxedType : instanceType;

  // Retrieves the property.
  ObjectType objType = instanceType.toObjectType();
  Preconditions.checkState(objType != null);

  if (!isExtern) {
    // Don't count reference in extern as a use.
    Reference ref = new Reference(n, parent);

    FunctionType constructor = objType.getConstructor();
    if (constructor != null) {
      String propName = n.getLastChild().getString();
      if (!constructor.getPrototype().hasOwnProperty(propName)) {
        recordSuperClassPrototypePropUse(constructor, propName, ref);
      }

      // TODO(user): TightenType can help a whole lot here.
      recordSubclassPrototypePropUse(constructor, propName, ref);
    } else {
      recordUnknownUse(t, n, parent);
    }
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:31,代码来源:NameReferenceGraphConstruction.java

示例4: expectSwitchMatchesCase

import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
/**
 * Expect that the type of a switch condition matches the type of its
 * case condition.
 */
void expectSwitchMatchesCase(NodeTraversal t, Node n, JSType switchType,
    JSType caseType) {
  // ECMA-262, page 68, step 3 of evaluation of CaseBlock,
  // but allowing extra autoboxing.
  // TODO(user): remove extra conditions when type annotations
  // in the code base have adapted to the change in the compiler.
  if (!switchType.canTestForShallowEqualityWith(caseType) &&
      (caseType.autoboxesTo() == null ||
          !caseType.autoboxesTo().isSubtype(switchType))) {
    mismatch(t, n.getFirstChild(),
        "case expression doesn't match switch",
        caseType, switchType);
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:19,代码来源:TypeValidator.java

示例5: getTypeWithProperty

import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
@Override public ObjectType getTypeWithProperty(String field, JSType type) {
  if (!(type instanceof ObjectType)) {
    if (type.autoboxesTo() != null) {
      type = type.autoboxesTo();
    } else {
      return null;
    }
  }

  // Ignore the prototype itself at all times.
  if ("prototype".equals(field)) {
    return null;
  }

  // We look up the prototype chain to find the highest place (if any) that
  // this appears.  This will make references to overriden properties look
  // like references to the initial property, so they are renamed alike.
  ObjectType foundType = null;
  ObjectType objType = ObjectType.cast(type);
  while (objType != null && objType.getImplicitPrototype() != objType) {
    if (objType.hasOwnProperty(field)) {
      foundType = objType;
    }
    objType = objType.getImplicitPrototype();
  }
  // If the property does not exist on the referenced type but the original
  // type is an object type, see if any subtype has the property.
  if (foundType == null) {
    ObjectType maybeType = ObjectType.cast(
        registry.getGreatestSubtypeWithProperty(type, field));
    // getGreatestSubtypeWithProperty does not guarantee that the property
    // is defined on the returned type, it just indicates that it might be,
    // so we have to double check.
    if (maybeType != null && maybeType.hasOwnProperty(field)) {
      foundType = maybeType;
    }
  }
  return foundType;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:40,代码来源:DisambiguateProperties.java

示例6: isTypeToSkip

import com.google.javascript.rhino.jstype.JSType; //导入方法依赖的package包/类
@Override public boolean isTypeToSkip(JSType type) {
  return type.isEnumType() || (type.autoboxesTo() != null);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:4,代码来源:DisambiguateProperties.java


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