public class JTypeOracle extends Object implements Serializable
Since its entire responsibility is to be an index of type related information it should not directly perform any optimizations.
Modifier and Type | Class and Description |
---|---|
static class |
JTypeOracle.ImmediateTypeRelations
All authorative information about the current program.
|
static class |
JTypeOracle.StandardTypes
A collection of types that are required to correctly run JTypeOracle.
|
Modifier and Type | Field and Description |
---|---|
static com.google.gwt.thirdparty.guava.common.base.Function<JType,String> |
TYPE_TO_NAME |
Constructor and Description |
---|
JTypeOracle(ArrayTypeCreator arrayTypeCreator,
MinimalRebuildCache minimalRebuildCache,
boolean hasWholeWorldKnowledge)
Constructs a new JTypeOracle.
|
Modifier and Type | Method and Description |
---|---|
boolean |
canBeInstantiatedInJavascript(JType type)
True if the type is a JSO or interface implemented by a JSO, or a JsType.
|
boolean |
canBeJavaScriptObject(JType type)
True if the type is a JSO or interface implemented by JSO or a JsType without
prototype.
|
boolean |
canCrossCastLikeJso(JType type)
True if the type is a JSO or interface implemented by JSO or a JsType without prototype.
|
boolean |
canTheoreticallyCast(JReferenceType type,
JReferenceType qType) |
boolean |
canTriviallyCast(JReferenceType type,
JReferenceType qType) |
boolean |
canTriviallyCast(JType type,
JType qType) |
void |
computeBeforeAST(JTypeOracle.StandardTypes standardTypes,
Collection<JDeclaredType> declaredTypes,
Collection<JDeclaredType> moduleDeclaredTypes,
Collection<String> deletedTypeNames) |
void |
computeBeforeAST(JTypeOracle.StandardTypes standardTypes,
Collection<JDeclaredType> declaredTypes,
List<JDeclaredType> moduleDeclaredTypes) |
Set<JMethod> |
getAllOverriddenMethods(JMethod method)
References to any methods which this method implementation might override
or implement in any instantiable class, including strange cases where there
is no direct relationship between the methods except in a subclass that
inherits one and implements the other.
|
Set<JReferenceType> |
getCastableDestinationTypes(JReferenceType type) |
Set<JField> |
getExportedFields() |
Set<JMethod> |
getExportedMethods() |
JMethod |
getInstanceMethodBySignature(JClassType type,
String signature) |
Set<JReferenceType> |
getInstantiatedJsoTypesViaCast() |
JDeclaredType |
getNearestJsType(JType type,
boolean mustHavePrototype)
Get the nearest JS type.
|
JClassType |
getSingleJsoImpl(JReferenceType maybeSingleJsoIntf) |
Set<String> |
getSubTypeNames(String typeName) |
String |
getSuperTypeName(String className) |
JMethod |
getTopMostDefinition(JMethod method)
Returns the method definition where
method is first defined in a class. |
boolean |
hasLiveImplementors(JType type) |
boolean |
hasWholeWorldKnowledge()
Whether this type oracle has whole world knowledge or not.
|
boolean |
isDualJsoInterface(JType maybeDualImpl) |
boolean |
isEffectivelyJavaScriptObject(JType type)
True if either a JSO, or is an interface that is ONLY implemented by a JSO.
|
boolean |
isExportedField(JField field) |
boolean |
isExportedMethod(JMethod method) |
boolean |
isInstantiatedType(JDeclaredType type)
Determine whether a type is instantiated.
|
boolean |
isInstantiatedType(JReferenceType type)
Determine whether a type is instantiated.
|
boolean |
isInteropEnabled() |
boolean |
isJavaScriptObject(JType type) |
boolean |
isJsType(JType type)
Whether the type is a JS interface (does not check supertypes).
|
boolean |
isJsTypeMethod(JMethod x) |
boolean |
isOrExtendsJsType(JType type,
boolean mustHavePrototype)
Whether the type or any supertypes is a JS type, optionally, only return true if
one of the types has a js prototype.
|
boolean |
isSameOrSuper(JClassType type,
JClassType qType) |
boolean |
isSingleJsoImpl(JType type) |
boolean |
isSubClass(JClassType type,
JClassType possibleSubType)
Returns true if possibleSubType is a subclass of type, directly or indirectly.
|
boolean |
isSuperClass(JClassType type,
JClassType possibleSuperClass)
Returns true if possibleSuperClass is a superclass of type, directly or indirectly.
|
static boolean |
methodsDoMatch(JMethod method1,
JMethod method2)
Compare two methods based on name and original argument types
JMethod.getOriginalParamTypes() . |
boolean |
needsJsInteropBridgeMethod(JMethod x)
A method needs a JsInterop bridge if any of the following are true:
1) the method name conflicts with a method name of a non-JsType/JsExport method in a superclass
2) the method returns or accepts Single-Abstract-Method types
3) the method returns or accepts JsAware/JsConvert types.
|
void |
recomputeAfterOptimizations(Collection<JDeclaredType> declaredTypes)
This method should be called after altering the types that are live in the
associated JProgram.
|
void |
setInstantiatedJsoTypesViaCast(Set<JReferenceType> instantiatedJsoTypesViaCast) |
void |
setInstantiatedTypes(Set<JReferenceType> instantiatedTypes) |
void |
setJsInteropMode(OptionJsInteropMode.Mode jsInteropMode) |
void |
setOptimize(boolean optimize) |
boolean |
willCrossCastLikeJso(JType type)
True if the type is a JSO or JSO Interface that is not dually implemented, or is a JsType
without the prototype that is not implemented by a Java class.
|
public JTypeOracle(ArrayTypeCreator arrayTypeCreator, MinimalRebuildCache minimalRebuildCache, boolean hasWholeWorldKnowledge)
public void setInstantiatedJsoTypesViaCast(Set<JReferenceType> instantiatedJsoTypesViaCast)
public Set<JReferenceType> getInstantiatedJsoTypesViaCast()
public boolean needsJsInteropBridgeMethod(JMethod x)
public boolean isExportedField(JField field)
public boolean isExportedMethod(JMethod method)
public boolean isInteropEnabled()
public void setJsInteropMode(OptionJsInteropMode.Mode jsInteropMode)
public void setOptimize(boolean optimize)
public static boolean methodsDoMatch(JMethod method1, JMethod method2)
JMethod.getOriginalParamTypes()
. Note that nothing special is done
here regarding methods with type parameters in their argument lists. The
caller must be careful that this level of matching is sufficient.public boolean canBeJavaScriptObject(JType type)
public boolean canCrossCastLikeJso(JType type)
public boolean willCrossCastLikeJso(JType type)
public boolean hasLiveImplementors(JType type)
public boolean canBeInstantiatedInJavascript(JType type)
public boolean canTheoreticallyCast(JReferenceType type, JReferenceType qType)
public boolean canTriviallyCast(JReferenceType type, JReferenceType qType)
public void computeBeforeAST(JTypeOracle.StandardTypes standardTypes, Collection<JDeclaredType> declaredTypes, List<JDeclaredType> moduleDeclaredTypes)
public void computeBeforeAST(JTypeOracle.StandardTypes standardTypes, Collection<JDeclaredType> declaredTypes, Collection<JDeclaredType> moduleDeclaredTypes, Collection<String> deletedTypeNames)
public Set<JMethod> getAllOverriddenMethods(JMethod method)
interface IFoo { foo(); } class Unrelated { foo() { ... } } class Foo extends Unrelated implements IFoo { }In this case,
Unrelated.foo()
virtually implements
IFoo.foo()
in subclass Foo
.public JDeclaredType getNearestJsType(JType type, boolean mustHavePrototype)
public JMethod getInstanceMethodBySignature(JClassType type, String signature)
public JClassType getSingleJsoImpl(JReferenceType maybeSingleJsoIntf)
public Set<JReferenceType> getCastableDestinationTypes(JReferenceType type)
public boolean isDualJsoInterface(JType maybeDualImpl)
public JMethod getTopMostDefinition(JMethod method)
method
is first defined in a class.public boolean hasWholeWorldKnowledge()
public boolean isEffectivelyJavaScriptObject(JType type)
public boolean isJavaScriptObject(JType type)
public boolean isInstantiatedType(JDeclaredType type)
public boolean isInstantiatedType(JReferenceType type)
public boolean isJsTypeMethod(JMethod x)
public boolean isSameOrSuper(JClassType type, JClassType qType)
public boolean isSingleJsoImpl(JType type)
public boolean isJsType(JType type)
public boolean isOrExtendsJsType(JType type, boolean mustHavePrototype)
public boolean isSubClass(JClassType type, JClassType possibleSubType)
public boolean isSuperClass(JClassType type, JClassType possibleSuperClass)
public void recomputeAfterOptimizations(Collection<JDeclaredType> declaredTypes)
public void setInstantiatedTypes(Set<JReferenceType> instantiatedTypes)
Copyright © 2016. All rights reserved.