com.google.javascript.rhino.jstype.Visitor Java Examples

The following examples show how to use com.google.javascript.rhino.jstype.Visitor. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SemanticReverseAbstractInterpreter.java    From astor with GNU General Public License v2.0 6 votes vote down vote up
private FlowScope caseInstanceOf(Node left, Node right, FlowScope blindScope,
    boolean outcome) {
  JSType leftType = getTypeIfRefinable(left, blindScope);
  if (leftType == null) {
    return blindScope;
  }
  JSType rightType = right.getJSType();
  ObjectType targetType =
      typeRegistry.getNativeObjectType(JSTypeNative.UNKNOWN_TYPE);
  if (rightType != null && rightType.isFunctionType()) {
    targetType = rightType.toMaybeFunctionType();
  }
  Visitor<JSType> visitor;
  if (outcome) {
    visitor = new RestrictByTrueInstanceOfResultVisitor(targetType);
  } else {
    visitor = new RestrictByFalseInstanceOfResultVisitor(targetType);
  }
  return maybeRestrictName(
      blindScope, left, leftType, leftType.visit(visitor));
}