Modifier and Type | Field and Description |
---|---|
private static JSType |
ALMOST_TOP |
static JSType |
BOOLEAN |
protected static int |
BOOLEAN_MASK |
static JSType |
BOTTOM |
protected static int |
BOTTOM_MASK |
private static JSTypes |
commonTypes |
protected static int |
END_MASK |
protected static int |
ENUM_MASK |
protected static int |
FALSE_MASK |
static JSType |
FALSE_TYPE |
static JSType |
FALSY |
protected static int |
FALSY_MASK |
(package private) static java.util.Map<java.lang.String,JSType> |
MAP_TO_UNKNOWN |
static boolean |
mockToString |
protected static int |
NON_SCALAR_MASK |
static JSType |
NULL |
protected static int |
NULL_MASK |
static JSType |
NULL_OR_UNDEF |
static JSType |
NUM_OR_STR |
static JSType |
NUMBER |
protected static int |
NUMBER_MASK |
private static com.google.common.base.Joiner |
PIPE_JOINER
For use in
typeToString(java.lang.StringBuilder) |
static JSType |
STRING |
protected static int |
STRING_MASK |
static JSType |
TOP |
static JSType |
TOP_DICT |
protected static int |
TOP_MASK |
static JSType |
TOP_OBJECT |
static JSType |
TOP_SCALAR |
protected static int |
TOP_SCALAR_MASK |
static JSType |
TOP_STRUCT |
protected static int |
TRUE_MASK |
static JSType |
TRUE_TYPE |
static JSType |
TRUTHY |
protected static int |
TRUTHY_MASK |
protected static int |
TYPEVAR_MASK |
static JSType |
UNDEFINED |
protected static int |
UNDEFINED_MASK |
static JSType |
UNKNOWN |
protected static int |
UNKNOWN_MASK |
Constructor and Description |
---|
JSType() |
Modifier and Type | Method and Description |
---|---|
java.lang.StringBuilder |
appendTo(java.lang.StringBuilder builder) |
JSType |
autobox() |
boolean |
equals(java.lang.Object o) |
(package private) static JSType |
fromEnum(EnumType e) |
(package private) static JSType |
fromFunctionType(FunctionType fn,
NominalType fnNominal) |
static JSType |
fromObjectType(ObjectType obj) |
static JSType |
fromTypeVar(java.lang.String typevarName) |
JSType |
getDeclaredProp(QualifiedName qname) |
JSType |
getEnumeratedType() |
protected abstract com.google.common.collect.ImmutableSet<EnumType> |
getEnums() |
FunctionType |
getFunType() |
FunctionType |
getFunTypeIfSingletonObj() |
JSType |
getIndexedType() |
JSType |
getIndexType() |
protected abstract int |
getMask() |
NominalType |
getNominalTypeIfSingletonObj() |
(package private) abstract com.google.common.collect.ImmutableSet<ObjectType> |
getObjs() |
(package private) ObjectType |
getObjTypeIfSingletonObj() |
JSType |
getProp(QualifiedName qname) |
protected abstract java.lang.String |
getTypeVar() |
boolean |
hasConstantProp(QualifiedName pname) |
private boolean |
hasFalsyMask() |
int |
hashCode() |
boolean |
hasNonScalar() |
boolean |
hasProp(QualifiedName qname) |
(package private) boolean |
hasScalar() |
private boolean |
hasTruthyMask() |
boolean |
hasTypeVariable() |
static boolean |
haveCommonSubtype(JSType lhs,
JSType rhs) |
boolean |
isAnyFalsyType() |
boolean |
isAnyTruthyType() |
boolean |
isBoolean() |
boolean |
isBottom() |
boolean |
isConstructor() |
boolean |
isDict() |
boolean |
isEnumElement() |
boolean |
isEquivalentTo(TypeI type) |
boolean |
isFalseOrFalsy() |
boolean |
isFunctionType() |
boolean |
isFunctionWithProperties() |
private static boolean |
isInhabitable(java.util.Set<ObjectType> objs) |
boolean |
isInterface() |
boolean |
isInterfaceDefinition() |
boolean |
isLoose() |
boolean |
isNamespace() |
boolean |
isNonClassyObject() |
boolean |
isNonLooseSubtypeOf(JSType other) |
boolean |
isNullable() |
boolean |
isNullOrUndef() |
boolean |
isNumber() |
boolean |
isScalar() |
boolean |
isSingletonObj() |
(package private) boolean |
isSingletonObjWithNull() |
boolean |
isString() |
boolean |
isStruct() |
boolean |
isSubtypeOf(TypeI other) |
(package private) boolean |
isSubtypeOf(TypeI other,
SubtypeCache subSuperMap) |
private boolean |
isSubtypeOfHelper(boolean keepLoosenessOfThis,
JSType other,
SubtypeCache subSuperMap) |
boolean |
isTop() |
boolean |
isTrueOrTruthy() |
boolean |
isTypeVariable() |
boolean |
isUndefined() |
boolean |
isUnion() |
boolean |
isUnknown() |
boolean |
isUnknownType() |
(package private) boolean |
isValidType() |
static JSType |
join(JSType lhs,
JSType rhs) |
private JSType |
makeFalsy() |
private JSType |
makeTruthy() |
private static JSType |
makeType(int mask) |
private static JSType |
makeType(int mask,
com.google.common.collect.ImmutableSet<ObjectType> objs,
java.lang.String typeVar,
com.google.common.collect.ImmutableSet<EnumType> enums) |
boolean |
mayBeDict() |
boolean |
mayBeStruct() |
boolean |
mayHaveProp(QualifiedName qname) |
static JSType |
meet(JSType lhs,
JSType rhs) |
private static JSType |
meetEnums(int newMask,
int unionMask,
com.google.common.collect.ImmutableSet<ObjectType> newObjs,
java.lang.String newTypevar,
com.google.common.collect.ImmutableSet<ObjectType> objs1,
com.google.common.collect.ImmutableSet<ObjectType> objs2,
com.google.common.collect.ImmutableSet<EnumType> enums1,
com.google.common.collect.ImmutableSet<EnumType> enums2)
Both
meet and specialize do the same computation for enums. |
private static JSType |
meetHelper(JSType lhs,
JSType rhs) |
JSType |
negate() |
(package private) static JSType |
nullAcceptingJoin(JSType t1,
JSType t2) |
static JSType |
plus(JSType lhs,
JSType rhs) |
private static int |
promoteBoolean(int mask) |
JSType |
removeType(JSType other) |
TypeI |
restrictByNotNullOrUndefined() |
static void |
setCommonTypes(JSTypes commonTypes) |
JSType |
specialize(JSType other) |
private JSType |
specializeHelper(JSType other) |
JSType |
substituteGenerics(java.util.Map<java.lang.String,JSType> concreteTypes) |
JSType |
substituteGenericsWithUnknown() |
JSType |
toBoolean() |
FunctionTypeI |
toMaybeFunctionType() |
ObjectTypeI |
toMaybeObjectType() |
java.lang.String |
toString() |
private java.lang.StringBuilder |
typeToString(java.lang.StringBuilder builder) |
(package private) static JSType |
unifyUnknowns(JSType t1,
JSType t2)
Unify the two types symmetrically, given that we have already instantiated
the type variables of interest in
t1 and t2 , treating
JSType.UNKNOWN as a "hole" to be filled. |
boolean |
unifyWith(JSType other,
java.util.List<java.lang.String> typeParameters,
com.google.common.collect.Multimap<java.lang.String,JSType> typeMultimap)
Unify
this , which may contain free type variables,
with other , a concrete subtype, modifying the supplied
typeMultimap to add any new template variable type bindings. |
(package private) boolean |
unifyWithSubtype(JSType other,
java.util.List<java.lang.String> typeParameters,
com.google.common.collect.Multimap<java.lang.String,JSType> typeMultimap,
SubtypeCache subSuperMap) |
private static void |
updateTypemap(com.google.common.collect.Multimap<java.lang.String,JSType> typeMultimap,
java.lang.String typeParam,
JSType type) |
JSType |
withDeclaredProperty(QualifiedName qname,
JSType type,
boolean isConstant) |
JSType |
withFunction(FunctionType ft,
NominalType fnNominal) |
JSType |
withLoose()
Turns the class-less object of this type (if any) into a loose object
|
JSType |
withoutProperty(QualifiedName qname) |
JSType |
withProperty(QualifiedName qname,
JSType type) |
JSType |
withPropertyRequired(java.lang.String pname) |
protected static final int BOTTOM_MASK
protected static final int TYPEVAR_MASK
protected static final int NON_SCALAR_MASK
protected static final int ENUM_MASK
protected static final int TRUE_MASK
protected static final int FALSE_MASK
protected static final int NULL_MASK
protected static final int NUMBER_MASK
protected static final int STRING_MASK
protected static final int UNDEFINED_MASK
protected static final int END_MASK
protected static final int TRUTHY_MASK
protected static final int FALSY_MASK
protected static final int UNKNOWN_MASK
protected static final int TOP_MASK
protected static final int BOOLEAN_MASK
protected static final int TOP_SCALAR_MASK
private static JSTypes commonTypes
static final java.util.Map<java.lang.String,JSType> MAP_TO_UNKNOWN
public static boolean mockToString
public static final JSType BOOLEAN
public static final JSType BOTTOM
public static final JSType FALSE_TYPE
public static final JSType FALSY
public static final JSType NULL
public static final JSType NUMBER
public static final JSType STRING
public static final JSType TOP
public static final JSType TOP_SCALAR
public static final JSType TRUE_TYPE
public static final JSType TRUTHY
public static final JSType UNDEFINED
public static final JSType UNKNOWN
public static final JSType TOP_OBJECT
public static final JSType TOP_STRUCT
public static final JSType TOP_DICT
public static final JSType NULL_OR_UNDEF
public static final JSType NUM_OR_STR
private static final JSType ALMOST_TOP
private static final com.google.common.base.Joiner PIPE_JOINER
typeToString(java.lang.StringBuilder)
private static JSType makeType(int mask, com.google.common.collect.ImmutableSet<ObjectType> objs, java.lang.String typeVar, com.google.common.collect.ImmutableSet<EnumType> enums)
private static JSType makeType(int mask)
protected abstract int getMask()
abstract com.google.common.collect.ImmutableSet<ObjectType> getObjs()
protected abstract java.lang.String getTypeVar()
protected abstract com.google.common.collect.ImmutableSet<EnumType> getEnums()
static JSType fromFunctionType(FunctionType fn, NominalType fnNominal)
public static JSType fromObjectType(ObjectType obj)
public static JSType fromTypeVar(java.lang.String typevarName)
boolean isValidType()
public boolean isTop()
public boolean isUndefined()
public boolean isUnknown()
public boolean isTrueOrTruthy()
private boolean hasTruthyMask()
public boolean isFalseOrFalsy()
public boolean isAnyTruthyType()
public boolean isAnyFalsyType()
private boolean hasFalsyMask()
public boolean isBoolean()
public boolean isString()
public boolean isNumber()
public boolean isNullOrUndef()
public boolean isScalar()
private static boolean isInhabitable(java.util.Set<ObjectType> objs)
public static void setCommonTypes(JSTypes commonTypes)
boolean hasScalar()
public boolean hasNonScalar()
public boolean isNullable()
public boolean isTypeVariable()
public boolean hasTypeVariable()
public boolean isStruct()
public boolean mayBeStruct()
public boolean isLoose()
public boolean isDict()
public JSType getIndexType()
public JSType getIndexedType()
public boolean mayBeDict()
public boolean isEnumElement()
public boolean isUnion()
public boolean isFunctionWithProperties()
public boolean isNamespace()
public JSType getEnumeratedType()
public JSType autobox()
public JSType substituteGenerics(java.util.Map<java.lang.String,JSType> concreteTypes)
public JSType substituteGenericsWithUnknown()
private static void updateTypemap(com.google.common.collect.Multimap<java.lang.String,JSType> typeMultimap, java.lang.String typeParam, JSType type)
private static int promoteBoolean(int mask)
static JSType unifyUnknowns(JSType t1, JSType t2)
t1
and t2
, treating
JSType.UNKNOWN as a "hole" to be filled.public boolean unifyWith(JSType other, java.util.List<java.lang.String> typeParameters, com.google.common.collect.Multimap<java.lang.String,JSType> typeMultimap)
this
, which may contain free type variables,
with other
, a concrete subtype, modifying the supplied
typeMultimap
to add any new template variable type bindings.
Note that if this
is a union type, some of the union members may
be ignored if they are not present in other
.boolean unifyWithSubtype(JSType other, java.util.List<java.lang.String> typeParameters, com.google.common.collect.Multimap<java.lang.String,JSType> typeMultimap, SubtypeCache subSuperMap)
private static JSType meetEnums(int newMask, int unionMask, com.google.common.collect.ImmutableSet<ObjectType> newObjs, java.lang.String newTypevar, com.google.common.collect.ImmutableSet<ObjectType> objs1, com.google.common.collect.ImmutableSet<ObjectType> objs2, com.google.common.collect.ImmutableSet<EnumType> enums1, com.google.common.collect.ImmutableSet<EnumType> enums2)
meet
and specialize
do the same computation for enums.
They don't just compute the set of enums; they may modify mask and objs.
So, both methods finish off by calling this one.private JSType makeTruthy()
private JSType makeFalsy()
public JSType negate()
public JSType toBoolean()
public boolean isNonLooseSubtypeOf(JSType other)
public boolean isSubtypeOf(TypeI other)
isSubtypeOf
in interface TypeI
boolean isSubtypeOf(TypeI other, SubtypeCache subSuperMap)
private boolean isSubtypeOfHelper(boolean keepLoosenessOfThis, JSType other, SubtypeCache subSuperMap)
public JSType withFunction(FunctionType ft, NominalType fnNominal)
public boolean isSingletonObj()
boolean isSingletonObjWithNull()
ObjectType getObjTypeIfSingletonObj()
public FunctionType getFunTypeIfSingletonObj()
public FunctionType getFunType()
public NominalType getNominalTypeIfSingletonObj()
public boolean isNonClassyObject()
public boolean isInterfaceDefinition()
public JSType withLoose()
public JSType getProp(QualifiedName qname)
public JSType getDeclaredProp(QualifiedName qname)
public boolean mayHaveProp(QualifiedName qname)
public boolean hasProp(QualifiedName qname)
public boolean hasConstantProp(QualifiedName pname)
public JSType withoutProperty(QualifiedName qname)
public JSType withProperty(QualifiedName qname, JSType type)
public JSType withDeclaredProperty(QualifiedName qname, JSType type, boolean isConstant)
public JSType withPropertyRequired(java.lang.String pname)
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.StringBuilder appendTo(java.lang.StringBuilder builder)
private java.lang.StringBuilder typeToString(java.lang.StringBuilder builder)
public boolean isConstructor()
isConstructor
in interface TypeI
public boolean isEquivalentTo(TypeI type)
isEquivalentTo
in interface TypeI
public boolean isFunctionType()
isFunctionType
in interface TypeI
public boolean isInterface()
isInterface
in interface TypeI
public boolean isUnknownType()
isUnknownType
in interface TypeI
public TypeI restrictByNotNullOrUndefined()
restrictByNotNullOrUndefined
in interface TypeI
public FunctionTypeI toMaybeFunctionType()
toMaybeFunctionType
in interface TypeI
public ObjectTypeI toMaybeObjectType()
toMaybeObjectType
in interface TypeI
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object