• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java StaticSlot类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



StaticSlot类属于com.google.javascript.rhino.jstype包,在下文中一共展示了StaticSlot类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: caseAndOrMaybeShortCircuiting

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
private FlowScope caseAndOrMaybeShortCircuiting(Node left, Node right,
    FlowScope blindScope, boolean condition) {
  FlowScope leftScope = firstPreciserScopeKnowingConditionOutcome(
      left, blindScope, !condition);
  StaticSlot<JSType> leftVar = leftScope.findUniqueRefinedSlot(blindScope);
  if (leftVar == null) {
    return blindScope;
  }
  FlowScope rightScope = firstPreciserScopeKnowingConditionOutcome(
      left, blindScope, condition);
  rightScope = firstPreciserScopeKnowingConditionOutcome(
      right, rightScope, !condition);
  StaticSlot<JSType> rightVar = rightScope.findUniqueRefinedSlot(blindScope);
  if (rightVar == null || !leftVar.getName().equals(rightVar.getName())) {
    return blindScope;
  }
  JSType type = leftVar.getType().getLeastSupertype(rightVar.getType());
  FlowScope informed = blindScope.createChildFlowScope();
  informed.inferSlotType(leftVar.getName(), type);
  return informed;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:22,代码来源:SemanticReverseAbstractInterpreter.java


示例2: findUniqueRefinedSlot

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
/**
 * Iterate through all the linked flow scopes before this one.
 * If there's one and only one slot defined between this scope
 * and the blind scope, return it.
 */
@Override
public StaticSlot<JSType> findUniqueRefinedSlot(FlowScope blindScope) {
  StaticSlot<JSType> result = null;

  for (LinkedFlowScope currentScope = this;
       currentScope != blindScope;
       currentScope = currentScope.parent) {
    for (LinkedFlowSlot currentSlot = currentScope.lastSlot;
         currentSlot != null &&
         (currentScope.parent == null ||
          currentScope.parent.lastSlot != currentSlot);
         currentSlot = currentSlot.parent) {
      if (result == null) {
        result = currentSlot;
      } else if (!currentSlot.getName().equals(result.getName())) {
        return null;
      }
    }
  }

  return result;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:28,代码来源:LinkedFlowScope.java


示例3: diffSlots

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
/**
 * Determines whether two slots are meaningfully different for the
 * purposes of data flow analysis.
 */
private boolean diffSlots(StaticSlot<JSType> slotA,
                          StaticSlot<JSType> slotB) {
  boolean aIsNull = slotA == null || slotA.getType() == null;
  boolean bIsNull = slotB == null || slotB.getType() == null;
  if (aIsNull && bIsNull) {
    return false;
  } else if (aIsNull ^ bIsNull) {
    return true;
  }

  // Both slots must be non-null.
  JSType aType = slotA.getType();
  JSType bType = slotB.getType();
  if (aType.isNoType() || bType.isNoType()) {
    return false;
  }

  // Both types must be non-null.
  return aType.differsFrom(bType);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:25,代码来源:LinkedFlowScope.java


示例4: findBestDeclToAdd

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
/** Helper for addSymbolsFrom, to determine the best declaration spot. */
private <S extends StaticSlot<JSType>, R extends StaticReference<JSType>>
StaticReference<JSType> findBestDeclToAdd(
    StaticSymbolTable<S, R> otherSymbolTable, S slot) {
  StaticReference<JSType> decl = slot.getDeclaration();
  if (isGoodRefToAdd(decl)) {
    return decl;
  }

  for (R ref : otherSymbolTable.getReferences(slot)) {
    if (isGoodRefToAdd(ref)) {
      return ref;
    }
  }

  return null;
}
 
开发者ID:SpoonLabs,项目名称:astor,代码行数:18,代码来源:SymbolTable.java


示例5: caseAndOrMaybeShortCircuiting

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
private FlowScope caseAndOrMaybeShortCircuiting(Node left, Node right,
    FlowScope blindScope, boolean outcome) {
  FlowScope leftScope = firstPreciserScopeKnowingConditionOutcome(
      left, blindScope, !outcome);
  StaticSlot<JSType> leftVar = leftScope.findUniqueRefinedSlot(blindScope);
  if (leftVar == null) {
    // If we did create a more precise scope, blindScope has a child and
    // it is frozen. We can't just throw it away to return it. So we
    // must create a child instead.
    return blindScope == leftScope ?
        blindScope : blindScope.createChildFlowScope();
  }
  FlowScope rightScope = firstPreciserScopeKnowingConditionOutcome(
      left, blindScope, outcome);
  rightScope = firstPreciserScopeKnowingConditionOutcome(
      right, rightScope, !outcome);
  StaticSlot<JSType> rightVar = rightScope.findUniqueRefinedSlot(blindScope);
  if (rightVar == null || !leftVar.getName().equals(rightVar.getName())) {
    return blindScope == rightScope ?
        blindScope : blindScope.createChildFlowScope();
  }
  JSType type = leftVar.getType().getLeastSupertype(rightVar.getType());
  FlowScope informed = blindScope.createChildFlowScope();
  informed.inferSlotType(leftVar.getName(), type);
  return informed;
}
 
开发者ID:nicks,项目名称:closure-compiler-old,代码行数:27,代码来源:SemanticReverseAbstractInterpreter.java


示例6: caseAndOrMaybeShortCircuiting

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
private FlowScope caseAndOrMaybeShortCircuiting(Node left, Node right,
    FlowScope blindScope, boolean condition) {
  FlowScope leftScope = firstPreciserScopeKnowingConditionOutcome(
      left, blindScope, !condition);
  StaticSlot<JSType> leftVar = leftScope.findUniqueRefinedSlot(blindScope);
  if (leftVar == null) {
    // If we did create a more precise scope, blindScope has a child and
    // it is frozen. We can't just throw it away to return it. So we
    // must create a child instead.
    return blindScope == leftScope ?
        blindScope : blindScope.createChildFlowScope();
  }
  FlowScope rightScope = firstPreciserScopeKnowingConditionOutcome(
      left, blindScope, condition);
  rightScope = firstPreciserScopeKnowingConditionOutcome(
      right, rightScope, !condition);
  StaticSlot<JSType> rightVar = rightScope.findUniqueRefinedSlot(blindScope);
  if (rightVar == null || !leftVar.getName().equals(rightVar.getName())) {
    return blindScope == rightScope ?
        blindScope : blindScope.createChildFlowScope();
  }
  JSType type = leftVar.getType().getLeastSupertype(rightVar.getType());
  FlowScope informed = blindScope.createChildFlowScope();
  informed.inferSlotType(leftVar.getName(), type);
  return informed;
}
 
开发者ID:Robbert,项目名称:closure-compiler-copy,代码行数:27,代码来源:SemanticReverseAbstractInterpreter.java


示例7: getSlot

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
/**
 * Get the slot for the given symbol.
 */
public StaticSlot<JSType> getSlot(String name) {
  if (cache.dirtySymbols.contains(name)) {
    for (LinkedFlowSlot slot = lastSlot;
         slot != null; slot = slot.parent) {
      if (slot.getName().equals(name)) {
        return slot;
      }
    }
  }
  return cache.getSlot(name);
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:15,代码来源:LinkedFlowScope.java


示例8: getParameterSlots

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
/** Returns the (non-null) index-th parameters of functions in this set. */
List<StaticSlot<ConcreteType>> getParameterSlots(final int index) {
  return getMatchingTypes(new TypeFilter<StaticSlot<ConcreteType>>(NO_SLOTS) {
    @Override public StaticSlot<ConcreteType> filter(ConcreteType type) {
      return type.isFunction()
          && toFunction().getParameterSlot(index) != null
          ? toFunction().getParameterSlot(index) : null;
    }
  });
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:11,代码来源:ConcreteType.java


示例9: getPropertySlots

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
/**
 * Returns the (non-null) slots for properties with the given name in all
 * instance types in this set.
 */
List<StaticSlot<ConcreteType>> getPropertySlots(final String name) {
  return getMatchingTypes(new TypeFilter<StaticSlot<ConcreteType>>(NO_SLOTS) {
    @Override public StaticSlot<ConcreteType> filter(ConcreteType type) {
      StaticSlot<ConcreteType> slot = null;
      if (type.isInstance()) {
        slot = type.toInstance().getPropertySlot(name);
      }
      return slot;
    }
  });
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:16,代码来源:ConcreteType.java


示例10: getPropertyType

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
/**
 * Returns the concrete type for the given property from the given type.
 * If the given type is a union type, returns the union of types for the slots
 * of the property.
 */
ConcreteType getPropertyType(final String name) {
  ConcreteType ret = NONE;
  for (StaticSlot<ConcreteType> slot : getPropertySlots(name)) {
    ret = ret.unionWith(slot.getType());
  }
  return ret;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:13,代码来源:ConcreteType.java


示例11: toString

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
/**
 * Informally, a function is represented by
 * {@code function (params): returnType} where the {@code params} is a comma
 * separated list of types, the first one being a special
 * {@code this:T} if the function expects a known type for {@code this}.
 */
@Override public String toString() {
  StringBuilder b = new StringBuilder(32);
  b.append("function (");
  boolean hasKnownTypeOfThis = !getThisSlot().getType().isNone();
  if (hasKnownTypeOfThis) {
    b.append("this:");
    b.append(getThisSlot().getType().toString());
  }

  Node n = getFirstParameter();
  if (hasKnownTypeOfThis && n != null) {
    b.append(", ");
  }
  for (int i = 0; n != null; ++i, n = n.getNext()) {
    String paramName = n.getString();
    StaticSlot<ConcreteType> var = getScope().getOwnSlot(paramName);
    b.append(var.getType());
    getParameterSlot(i).getType();
    if (n.getNext() != null) {
      b.append(", ");
    }
  }

  b.append(")");
  if (getReturnSlot().getType() != null) {
    b.append(": ");
    b.append(getReturnSlot().getType().toString());
  }
  return b.toString();
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:37,代码来源:ConcreteType.java


示例12: getSlot

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
@Override
public StaticSlot<ConcreteType> getSlot(String name) {
  StaticSlot<ConcreteType> var = getOwnSlot(name);
  if (var != null) {
    return var;
  } else if (parent != null) {
    return parent.getSlot(name);
  } else {
    return null;
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:12,代码来源:TightenTypes.java


示例13: getAssignments

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
/**
 * Returns all assignments that could occur as a result of this property
 * assign action. Each type in the receiver is checked for a property
 * {@code propName}, and if that property exists, it is assigned the type
 * of {@code expression}.
 */
public Collection<Assignment> getAssignments(ConcreteScope scope) {
  ConcreteType recvType = inferConcreteType(scope, receiver);
  ConcreteType exprType = inferConcreteType(scope, expression);

  List<Assignment> assigns = Lists.newArrayList();
  for (StaticSlot<ConcreteType> prop
       : recvType.getPropertySlots(propName)) {
    assigns.add(new Assignment((ConcreteSlot) prop, exprType));
  }
  return assigns;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:18,代码来源:TightenTypes.java


示例14: getTypeIfRefinable

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
/**
 * Returns the type of a node in the given scope if the node corresponds to a
 * name whose type is capable of being refined.
 * @return The current type of the node if it can be refined, null otherwise.
 */
JSType getTypeIfRefinable(Node node, FlowScope scope) {
  switch (node.getType()) {
    case Token.NAME:
      StaticSlot<JSType> nameVar = scope.getSlot(node.getString());
      if (nameVar != null) {
        JSType nameVarType = nameVar.getType();
        if (nameVarType == null) {
          nameVarType = node.getJSType();
        }
        return nameVarType;
      }
      return null;

    case Token.GETPROP:
      String qualifiedName = node.getQualifiedName();
      if (qualifiedName == null) {
        return null;
      }
      StaticSlot<JSType> propVar = scope.getSlot(qualifiedName);
      JSType propVarType = null;
      if (propVar != null) {
        propVarType = propVar.getType();
      }
      if (propVarType == null) {
        propVarType = node.getJSType();
      }
      if (propVarType == null) {
        propVarType = getNativeType(UNKNOWN_TYPE);
      }
      return propVarType;
  }
  return null;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:39,代码来源:ChainableReverseAbstractInterpreter.java


示例15: traverseName

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
private FlowScope traverseName(Node n, FlowScope scope) {
  String varName = n.getString();
  Node value = n.getFirstChild();
  JSType type = n.getJSType();
  if (value != null) {
    scope = traverse(value, scope);
    updateScopeForTypeChange(scope, n, n.getJSType() /* could be null */,
        getJSType(value));
    return scope;
  } else {
    StaticSlot<JSType> var = scope.getSlot(varName);
    if (var != null) {
      // There are two situations where we don't want to use type information
      // from the scope, even if we have it.

      // 1) The var is escaped in a weird way, e.g.,
      // function f() { var x = 3; function g() { x = null } (x); }
      boolean isInferred = var.isTypeInferred();
      boolean unflowable =
          isInferred && unflowableVarNames.contains(varName);

      // 2) We're reading type information from another scope for an
      // inferred variable.
      // var t = null; function f() { (t); }
      boolean nonLocalInferredSlot =
          isInferred &&
          syntacticScope.getParent() != null &&
          var == syntacticScope.getParent().getSlot(varName);

      if (!unflowable && !nonLocalInferredSlot) {
        type = var.getType();
        if (type == null) {
          type = getNativeType(UNKNOWN_TYPE);
        }
      }
    }
  }
  n.setJSType(type);
  return scope;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:41,代码来源:TypeInference.java


示例16: getPropertyType

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
private JSType getPropertyType(JSType objType, String propName,
    Node n, FlowScope scope) {
  // Scopes sometimes contain inferred type info about qualified names.
  String qualifiedName = n.getQualifiedName();
  StaticSlot<JSType> var = scope.getSlot(qualifiedName);
  if (var != null) {
    JSType varType = var.getType();
    if (varType != null) {
      if (varType.equals(getNativeType(UNKNOWN_TYPE)) &&
          var != syntacticScope.getSlot(qualifiedName)) {
        // If the type of this qualified name has been checked in this scope,
        // then use CHECKED_UNKNOWN_TYPE instead to indicate that.
        return getNativeType(CHECKED_UNKNOWN_TYPE);
      } else {
        return varType;
      }
    }
  }

  JSType propertyType = null;
  if (objType != null) {
    propertyType = objType.findPropertyType(propName);
  }

  if ((propertyType == null || propertyType.isUnknownType()) &&
      qualifiedName != null) {
    // If we find this node in the registry, then we can infer its type.
    ObjectType regType = ObjectType.cast(registry.getType(qualifiedName));
    if (regType != null) {
      propertyType = regType.getConstructor();
    }
  }

  return propertyType;
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:36,代码来源:TypeInference.java


示例17: getType

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
private JSType getType(String name) {
  assertTrue("The return scope should not be null.", returnScope != null);
  StaticSlot<JSType> var = returnScope.getSlot(name);
  assertTrue("The variable " + name + " is missing from the scope.",
      var != null);
  return var.getType();
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:8,代码来源:TypeInferenceTest.java


示例18: getSlot

import com.google.javascript.rhino.jstype.StaticSlot; //导入依赖的package包/类
/** @inheritDoc */
public StaticSlot<ConcreteType> getSlot(String name) {
  if (slots.containsKey(name)) {
    return slots.get(name);
  } else if (parent != null) {
    return parent.getSlot(name);
  } else {
    return null;
  }
}
 
开发者ID:andyjko,项目名称:feedlack,代码行数:11,代码来源:ConcreteTypeTest.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java TransportRequestOptions类代码示例发布时间:2022-05-22
下一篇:
Java SimpleEvent类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap