private FlowScope caseTypeOf(Node node, JSType type, String value, boolean resultEqualsValue, FlowScope blindScope) { return maybeRestrictName( blindScope, node, type, getRestrictedByTypeOfResult(type, value, resultEqualsValue)); }
@CheckReturnValue private FlowScope caseTypeOf( Node node, JSType type, String value, boolean resultEqualsValue, FlowScope blindScope) { return maybeRestrictName( blindScope, node, type, getRestrictedByTypeOfResult(type, value, resultEqualsValue)); }
@CheckReturnValue private FlowScope caseNameOrGetProp(Node name, FlowScope blindScope, boolean outcome) { JSType type = getTypeIfRefinable(name, blindScope); if (type != null) { return maybeRestrictName( blindScope, name, type, type.getRestrictedTypeGivenToBooleanOutcome(outcome)); } return blindScope; }
@CheckReturnValue private FlowScope caseIsArray(Node value, FlowScope blindScope, boolean outcome) { JSType type = getTypeIfRefinable(value, blindScope); if (type != null) { Visitor<JSType> visitor = outcome ? restrictToArrayVisitor : restrictToNotArrayVisitor; return maybeRestrictName(blindScope, value, type, type.visit(visitor)); } return blindScope; }
private FlowScope caseIsArray(Node value, FlowScope blindScope, boolean outcome) { JSType type = getTypeIfRefinable(value, blindScope); if (type != null) { Visitor<JSType> visitor = outcome ? restrictToArrayVisitor : restrictToNotArrayVisitor; return maybeRestrictName(blindScope, value, type, type.visit(visitor)); } return blindScope; }
private FlowScope caseNameOrGetProp(Node name, FlowScope blindScope, boolean outcome) { JSType type = getTypeIfRefinable(name, blindScope); if (type != null) { return maybeRestrictName( blindScope, name, type, type.getRestrictedTypeGivenToBooleanOutcome(outcome)); } return blindScope; }
right, blindScope, outcome); blindScope = maybeRestrictName(blindScope, left, leftType, leftIsRefineable ? restrictedLeftType : null); rightType.getRestrictedTypeGivenToBooleanOutcome(outcome); return maybeRestrictName(blindScope, right, rightType, rightIsRefineable ? restrictedRightType : null);
@CheckReturnValue 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)); }
right, blindScope, outcome); blindScope = maybeRestrictName(blindScope, left, leftType, leftIsRefineable ? restrictedLeftType : null); rightType.getRestrictedTypeGivenToBooleanOutcome(outcome); return maybeRestrictName(blindScope, right, rightType, rightIsRefineable ? restrictedRightType : null);
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)); }