final class ObjectType extends java.lang.Object implements TypeWithProperties
Modifier and Type | Field and Description |
---|---|
private static PersistentMap<java.lang.String,Property> |
BOTTOM_MAP |
private static ObjectType |
BOTTOM_OBJECT |
private static NominalType |
builtinObject |
private FunctionType |
fn |
private boolean |
isLoose |
private NominalType |
nominalType |
private Namespace |
ns |
private ObjectKind |
objectKind |
private PersistentMap<java.lang.String,Property> |
props |
(package private) static ObjectType |
TOP_DICT |
(package private) static ObjectType |
TOP_OBJECT |
(package private) static ObjectType |
TOP_STRUCT |
private static Property |
UNKNOWN_PROP |
Modifier | Constructor and Description |
---|---|
private |
ObjectType(NominalType nominalType,
PersistentMap<java.lang.String,Property> props,
FunctionType fn,
Namespace ns,
boolean isLoose,
ObjectKind objectKind) |
Modifier and Type | Method and Description |
---|---|
private static PersistentMap<java.lang.String,Property> |
addOrRemoveProp(boolean specializeProps1,
PersistentMap<java.lang.String,Property> props,
java.lang.String pname,
Property nomProp,
Property objProp) |
(package private) java.lang.StringBuilder |
appendTo(java.lang.StringBuilder builder) |
private boolean |
arePropertiesSubtypes(ObjectType other,
java.util.Set<java.lang.String> otherPropNames,
SubtypeCache subSuperMap) |
private static boolean |
areRelatedNominalTypes(NominalType c1,
NominalType c2) |
(package private) static boolean |
containsBottomProp(PersistentMap<java.lang.String,Property> props) |
boolean |
equals(java.lang.Object o) |
(package private) static ObjectType |
fromFunction(FunctionType fn,
NominalType fnNominal) |
(package private) static ObjectType |
fromNominalType(NominalType cl) |
(package private) static ObjectType |
fromProperties(java.util.Map<java.lang.String,Property> oldProps)
Construct an object with the given declared properties.
|
JSType |
getDeclaredProp(QualifiedName qname)
Get the declared type of the given property
|
(package private) FunctionType |
getFunType() |
private Property |
getLeftmostProp(QualifiedName qname) |
(package private) NominalType |
getNominalType() |
private static Property |
getProp(java.util.Map<java.lang.String,Property> props,
NominalType nom,
java.lang.String pname) |
JSType |
getProp(QualifiedName qname)
Get the inferred type of the given property
|
private static Property |
getPropHelper(java.lang.String pname,
Namespace ns,
NominalType nt) |
boolean |
hasConstantProp(QualifiedName qname)
Return whether this type contains a constant property
|
int |
hashCode() |
private boolean |
hasNonPrototypeProperties() |
boolean |
hasProp(QualifiedName qname)
Return whether this type contains a required property
|
(package private) boolean |
isDict() |
(package private) boolean |
isFunctionWithProperties() |
(package private) boolean |
isInhabitable() |
(package private) boolean |
isInterfaceInstance() |
(package private) boolean |
isLoose() |
(package private) boolean |
isLooseSubtypeOf(ObjectType other,
SubtypeCache subSuperMap) |
(package private) boolean |
isNamespace() |
private static boolean |
isPropertySubtype(Property prop1,
Property prop2,
SubtypeCache subSuperMap) |
(package private) boolean |
isStruct() |
(package private) boolean |
isSubtypeOf(ObjectType obj2,
SubtypeCache subSuperMap) |
private boolean |
isSubtypeOfHelper(boolean keepLoosenessOfThis,
ObjectType other,
SubtypeCache subSuperMap)
Required properties are acceptable where an optional is required,
but not vice versa.
|
(package private) static boolean |
isUnionSubtype(boolean keepLoosenessOfThis,
java.util.Set<ObjectType> objs1,
java.util.Set<ObjectType> objs2,
SubtypeCache subSuperMap) |
private static ObjectType |
join(ObjectType obj1,
ObjectType obj2) |
private static PersistentMap<java.lang.String,Property> |
joinProps(java.util.Map<java.lang.String,Property> props1,
java.util.Map<java.lang.String,Property> props2,
NominalType nom1,
NominalType nom2) |
private static PersistentMap<java.lang.String,Property> |
joinPropsLoosely(java.util.Map<java.lang.String,Property> props1,
java.util.Map<java.lang.String,Property> props2) |
(package private) static com.google.common.collect.ImmutableSet<ObjectType> |
joinSets(com.google.common.collect.ImmutableSet<ObjectType> objs1,
com.google.common.collect.ImmutableSet<ObjectType> objs2) |
private static PersistentMap<java.lang.String,Property> |
loosenProps(PersistentMap<java.lang.String,Property> props) |
(package private) static ObjectType |
makeObjectType(NominalType nominalType,
PersistentMap<java.lang.String,Property> props,
FunctionType fn,
Namespace ns,
boolean isLoose,
ObjectKind ok) |
boolean |
mayHaveProp(QualifiedName qname)
Return whether this type contains any form of property
|
(package private) static ObjectType |
meet(ObjectType obj1,
ObjectType obj2) |
private static PersistentMap<java.lang.String,Property> |
meetPropsHelper(boolean specializeProps1,
NominalType resultNominalType,
Namespace resultNs,
PersistentMap<java.lang.String,Property> props1,
PersistentMap<java.lang.String,Property> props2) |
(package private) static com.google.common.collect.ImmutableSet<ObjectType> |
meetSets(java.util.Set<ObjectType> objs1,
java.util.Set<ObjectType> objs2) |
(package private) static com.google.common.collect.ImmutableSet<ObjectType> |
meetSetsHelper(boolean specializeObjs1,
java.util.Set<ObjectType> objs1,
java.util.Set<ObjectType> objs2) |
(package private) static void |
setObjectType(NominalType builtinObject) |
(package private) ObjectType |
specialize(ObjectType other) |
(package private) static com.google.common.collect.ImmutableSet<ObjectType> |
specializeSet(java.util.Set<ObjectType> objs1,
java.util.Set<ObjectType> objs2) |
(package private) ObjectType |
substituteGenerics(java.util.Map<java.lang.String,JSType> concreteTypes) |
java.lang.String |
toString() |
private boolean |
unifyPropsWithSubtype(ObjectType other,
java.util.Set<java.lang.String> thisProps,
java.util.List<java.lang.String> typeParameters,
com.google.common.collect.Multimap<java.lang.String,JSType> typeMultimap,
SubtypeCache subSuperMap) |
(package private) static ObjectType |
unifyUnknowns(ObjectType t1,
ObjectType 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. |
(package private) boolean |
unifyWithSubtype(ObjectType other,
java.util.List<java.lang.String> typeParameters,
com.google.common.collect.Multimap<java.lang.String,JSType> typeMultimap,
SubtypeCache subSuperMap)
Unify
this , which may contain free type variables,
with other , a concrete type, modifying the supplied
typeMultimap to add any new template varaible type bindings. |
(package private) static com.google.common.collect.ImmutableSet<ObjectType> |
withDeclaredProperty(java.util.Set<ObjectType> objs,
QualifiedName qname,
JSType type,
boolean isConstant) |
(package private) ObjectType |
withFunction(FunctionType ft,
NominalType fnNominal) |
private ObjectType |
withLoose() |
(package private) static com.google.common.collect.ImmutableSet<ObjectType> |
withLooseObjects(java.util.Set<ObjectType> objs) |
(package private) static com.google.common.collect.ImmutableSet<ObjectType> |
withoutProperty(java.util.Set<ObjectType> objs,
QualifiedName qname) |
(package private) ObjectType |
withProperty(QualifiedName qname,
JSType type) |
(package private) static com.google.common.collect.ImmutableSet<ObjectType> |
withProperty(java.util.Set<ObjectType> objs,
QualifiedName qname,
JSType type) |
private ObjectType |
withPropertyHelper(QualifiedName qname,
JSType type,
boolean isDeclared,
boolean isConstant) |
(package private) static com.google.common.collect.ImmutableSet<ObjectType> |
withPropertyRequired(java.util.Set<ObjectType> objs,
java.lang.String pname) |
private ObjectType |
withPropertyRequired(java.lang.String pname) |
private final NominalType nominalType
private final Namespace ns
private final FunctionType fn
private final boolean isLoose
private final PersistentMap<java.lang.String,Property> props
private final ObjectKind objectKind
static final ObjectType TOP_OBJECT
static final ObjectType TOP_STRUCT
static final ObjectType TOP_DICT
private static final PersistentMap<java.lang.String,Property> BOTTOM_MAP
private static final ObjectType BOTTOM_OBJECT
private static final Property UNKNOWN_PROP
private static NominalType builtinObject
private ObjectType(NominalType nominalType, PersistentMap<java.lang.String,Property> props, FunctionType fn, Namespace ns, boolean isLoose, ObjectKind objectKind)
private static PersistentMap<java.lang.String,Property> loosenProps(PersistentMap<java.lang.String,Property> props)
static ObjectType makeObjectType(NominalType nominalType, PersistentMap<java.lang.String,Property> props, FunctionType fn, Namespace ns, boolean isLoose, ObjectKind ok)
static ObjectType fromFunction(FunctionType fn, NominalType fnNominal)
static ObjectType fromNominalType(NominalType cl)
static ObjectType fromProperties(java.util.Map<java.lang.String,Property> oldProps)
static void setObjectType(NominalType builtinObject)
boolean isInhabitable()
static boolean containsBottomProp(PersistentMap<java.lang.String,Property> props)
boolean isStruct()
boolean isLoose()
boolean isDict()
boolean isFunctionWithProperties()
boolean isInterfaceInstance()
boolean isNamespace()
private boolean hasNonPrototypeProperties()
static com.google.common.collect.ImmutableSet<ObjectType> withLooseObjects(java.util.Set<ObjectType> objs)
private ObjectType withLoose()
ObjectType withFunction(FunctionType ft, NominalType fnNominal)
static com.google.common.collect.ImmutableSet<ObjectType> withoutProperty(java.util.Set<ObjectType> objs, QualifiedName qname)
private ObjectType withPropertyHelper(QualifiedName qname, JSType type, boolean isDeclared, boolean isConstant)
ObjectType withProperty(QualifiedName qname, JSType type)
static com.google.common.collect.ImmutableSet<ObjectType> withProperty(java.util.Set<ObjectType> objs, QualifiedName qname, JSType type)
static com.google.common.collect.ImmutableSet<ObjectType> withDeclaredProperty(java.util.Set<ObjectType> objs, QualifiedName qname, JSType type, boolean isConstant)
private ObjectType withPropertyRequired(java.lang.String pname)
static com.google.common.collect.ImmutableSet<ObjectType> withPropertyRequired(java.util.Set<ObjectType> objs, java.lang.String pname)
private static PersistentMap<java.lang.String,Property> meetPropsHelper(boolean specializeProps1, NominalType resultNominalType, Namespace resultNs, PersistentMap<java.lang.String,Property> props1, PersistentMap<java.lang.String,Property> props2)
private static PersistentMap<java.lang.String,Property> addOrRemoveProp(boolean specializeProps1, PersistentMap<java.lang.String,Property> props, java.lang.String pname, Property nomProp, Property objProp)
private static Property getProp(java.util.Map<java.lang.String,Property> props, NominalType nom, java.lang.String pname)
private static PersistentMap<java.lang.String,Property> joinProps(java.util.Map<java.lang.String,Property> props1, java.util.Map<java.lang.String,Property> props2, NominalType nom1, NominalType nom2)
private static PersistentMap<java.lang.String,Property> joinPropsLoosely(java.util.Map<java.lang.String,Property> props1, java.util.Map<java.lang.String,Property> props2)
static boolean isUnionSubtype(boolean keepLoosenessOfThis, java.util.Set<ObjectType> objs1, java.util.Set<ObjectType> objs2, SubtypeCache subSuperMap)
boolean isSubtypeOf(ObjectType obj2, SubtypeCache subSuperMap)
private boolean isSubtypeOfHelper(boolean keepLoosenessOfThis, ObjectType other, SubtypeCache subSuperMap)
private boolean arePropertiesSubtypes(ObjectType other, java.util.Set<java.lang.String> otherPropNames, SubtypeCache subSuperMap)
private static boolean isPropertySubtype(Property prop1, Property prop2, SubtypeCache subSuperMap)
boolean isLooseSubtypeOf(ObjectType other, SubtypeCache subSuperMap)
ObjectType specialize(ObjectType other)
static ObjectType meet(ObjectType obj1, ObjectType obj2)
private static ObjectType join(ObjectType obj1, ObjectType obj2)
static com.google.common.collect.ImmutableSet<ObjectType> joinSets(com.google.common.collect.ImmutableSet<ObjectType> objs1, com.google.common.collect.ImmutableSet<ObjectType> objs2)
private static boolean areRelatedNominalTypes(NominalType c1, NominalType c2)
static com.google.common.collect.ImmutableSet<ObjectType> meetSetsHelper(boolean specializeObjs1, java.util.Set<ObjectType> objs1, java.util.Set<ObjectType> objs2)
static com.google.common.collect.ImmutableSet<ObjectType> meetSets(java.util.Set<ObjectType> objs1, java.util.Set<ObjectType> objs2)
static com.google.common.collect.ImmutableSet<ObjectType> specializeSet(java.util.Set<ObjectType> objs1, java.util.Set<ObjectType> objs2)
FunctionType getFunType()
NominalType getNominalType()
public JSType getProp(QualifiedName qname)
TypeWithProperties
getProp
in interface TypeWithProperties
public JSType getDeclaredProp(QualifiedName qname)
TypeWithProperties
getDeclaredProp
in interface TypeWithProperties
private static Property getPropHelper(java.lang.String pname, Namespace ns, NominalType nt)
private Property getLeftmostProp(QualifiedName qname)
public boolean mayHaveProp(QualifiedName qname)
TypeWithProperties
mayHaveProp
in interface TypeWithProperties
public boolean hasProp(QualifiedName qname)
TypeWithProperties
hasProp
in interface TypeWithProperties
public boolean hasConstantProp(QualifiedName qname)
TypeWithProperties
hasConstantProp
in interface TypeWithProperties
static ObjectType unifyUnknowns(ObjectType t1, ObjectType t2)
t1
and t2
, treating
JSType.UNKNOWN as a "hole" to be filled.boolean unifyWithSubtype(ObjectType other, java.util.List<java.lang.String> typeParameters, com.google.common.collect.Multimap<java.lang.String,JSType> typeMultimap, SubtypeCache subSuperMap)
this
, which may contain free type variables,
with other
, a concrete type, modifying the supplied
typeMultimap
to add any new template varaible type bindings.private boolean unifyPropsWithSubtype(ObjectType other, java.util.Set<java.lang.String> thisProps, java.util.List<java.lang.String> typeParameters, com.google.common.collect.Multimap<java.lang.String,JSType> typeMultimap, SubtypeCache subSuperMap)
ObjectType substituteGenerics(java.util.Map<java.lang.String,JSType> concreteTypes)
public java.lang.String toString()
toString
in class java.lang.Object
java.lang.StringBuilder appendTo(java.lang.StringBuilder builder)
public boolean equals(java.lang.Object o)
equals
in class java.lang.Object
public int hashCode()
hashCode
in class java.lang.Object