|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface TypeSystem
The TypeSystem
defines the types of the language and
how they are related.
Method Summary | |
---|---|
Flags |
Abstract()
|
ClassType |
ArithmeticException()
java.lang.ArithmeticException |
ArrayType |
arrayOf(Position pos,
Type type)
Return an array of type |
ArrayType |
arrayOf(Position pos,
Type type,
int dims)
Return a dims -array of type |
ArrayType |
arrayOf(Type type)
Return an array of type |
ArrayType |
arrayOf(Type type,
int dims)
Return a dims -array of type |
ClassType |
ArrayStoreException()
java.lang.ArrayStoreException |
PrimitiveType |
Boolean()
boolean |
PrimitiveType |
Byte()
byte |
boolean |
callValid(ProcedureInstance mi,
java.util.List argTypes)
Return true if pi can be called with
actual parameters of types actualTypes . |
boolean |
canCoerceToString(Type t,
Context c)
Returns true iff the type t can be coerced to a String in the given Context. |
boolean |
canOverride(MethodInstance mi,
MethodInstance mj)
Return true if mi can override mj . |
PrimitiveType |
Char()
char |
void |
checkAccessFlags(Flags f)
Assert if the flags f are legal access flags. |
void |
checkClassConformance(ClassType ct)
Assert that ct implements all abstract methods that it
has to; that is, if it is a concrete class, then it must implement all
interfaces and abstract methods that it or its superclasses declare. |
void |
checkConstructorFlags(Flags f)
Assert if the flags f are legal constructor flags. |
void |
checkCycles(ReferenceType t)
Assert that t has no cycles in the super type+nested class
graph starting at t . |
void |
checkFieldFlags(Flags f)
Assert if the flags f are legal field flags. |
void |
checkInitializerFlags(Flags f)
Assert if the flags f are legal initializer flags. |
void |
checkLocalClassFlags(Flags f)
Assert if the flags f are legal local class flags. |
void |
checkLocalFlags(Flags f)
Assert if the flags f are legal local variable flags. |
void |
checkMemberClassFlags(Flags f)
Assert if the flags f are legal member class flags. |
void |
checkMethodFlags(Flags f)
Assert if the flags f are legal method flags. |
void |
checkOverride(MethodInstance mi,
MethodInstance mj)
Throw a SemanticException if mi cannot override
mj . |
void |
checkTopLevelClassFlags(Flags f)
Assert if the flags f are legal top-level class flags. |
ClassType |
Class()
java.lang.Class |
boolean |
classAccessible(ClassType ct,
Context context)
Checks whether a class can be accessed from Context context. |
boolean |
classAccessibleFromPackage(ClassType ct,
Package pkg)
Checks whether a top-level or member class can be accessed from the package pkg. |
ClassType |
ClassCastException()
java.lang.ClassCastException |
Resolver |
classContextResolver(ClassType ct)
Get a resolver for looking up a type in a class context. |
ClassType |
Cloneable()
java.lang.Cloneable |
ConstructorInstance |
constructorInstance(Position pos,
ClassType container,
Flags flags,
java.util.List argTypes,
java.util.List excTypes)
Create a constructor instance. |
ParsedClassType |
createClassType()
Create a new empty class. |
ParsedClassType |
createClassType(LazyClassInitializer init)
Create a new empty class. |
ParsedClassType |
createClassType(LazyClassInitializer init,
Source fromSource)
Create a new empty class. |
ParsedClassType |
createClassType(Source fromSource)
Create a new empty class. |
Context |
createContext()
Create a new context object for looking up variables, types, etc. |
Flags |
createNewFlag(java.lang.String name,
Flags print_after)
Create a new unique Flags object. |
Package |
createPackage(Package prefix,
java.lang.String name)
Return a package by name with the given outer package. |
Package |
createPackage(java.lang.String name)
Return a package by name. |
LazyClassInitializer |
defaultClassInitializer()
The default lazy class initializer. |
ConstructorInstance |
defaultConstructor(Position pos,
ClassType container)
Create a default constructor instance. |
java.util.List |
defaultPackageImports()
Return a list of the packages names that will be imported by default. |
boolean |
descendsFrom(Type child,
Type ancestor)
Returns true iff child is not ancestor, but child descends from ancestor. |
PrimitiveType |
Double()
double |
boolean |
equals(TypeObject type1,
TypeObject type2)
Returns true iff type1 and type2 represent the same type object. |
ClassType |
Error()
java.lang.Error |
ClassType |
Exception()
java.lang.Exception |
FieldInstance |
fieldInstance(Position pos,
ReferenceType container,
Flags flags,
Type type,
java.lang.String name)
Create a field instance. |
Flags |
Final()
|
ConstructorInstance |
findConstructor(ClassType container,
java.util.List argTypes,
ClassType currClass)
Find a constructor. |
ConstructorInstance |
findConstructor(ClassType container,
java.util.List argTypes,
Context c)
Deprecated. |
FieldInstance |
findField(ReferenceType container,
java.lang.String name)
Returns the field named 'name' defined on 'type'. |
FieldInstance |
findField(ReferenceType container,
java.lang.String name,
ClassType currClass)
Returns the field named 'name' defined on 'type'. |
FieldInstance |
findField(ReferenceType container,
java.lang.String name,
Context c)
Deprecated. |
ClassType |
findMemberClass(ClassType container,
java.lang.String name)
Find a member class. |
ClassType |
findMemberClass(ClassType container,
java.lang.String name,
ClassType currClass)
Find a member class. |
ClassType |
findMemberClass(ClassType container,
java.lang.String name,
Context c)
Deprecated. |
MethodInstance |
findMethod(ReferenceType container,
java.lang.String name,
java.util.List argTypes,
ClassType currClass)
Find a method. |
MethodInstance |
findMethod(ReferenceType container,
java.lang.String name,
java.util.List argTypes,
Context c)
Deprecated. |
Flags |
flagsForBits(int bits)
Given the JVM encoding of a set of flags, returns the Flags object for that encoding. |
PrimitiveType |
Float()
float |
Named |
forName(java.lang.String name)
Get the named type object with the following name. |
java.lang.String |
getTransformedClassName(ClassType ct)
Get the transformed class name of a class. |
java.util.Set |
getTypeEncoderRootSet(Type clazz)
Return the set of objects that should be serialized into the type information for the given ClassType. |
boolean |
hasEnclosingInstance(ClassType inner,
ClassType encl)
Returns whether an object of the inner class inner has an
enclosing instance of class encl . |
boolean |
hasFormals(ProcedureInstance p,
java.util.List formalTypes)
Returns true iff p has exactly the formal arguments
formalTypes . |
boolean |
hasMethod(ReferenceType t,
MethodInstance mi)
Returns true iff t has the method mi . |
boolean |
hasMethodNamed(ReferenceType t,
java.lang.String name)
Returns true iff t has a method with name name
either defined in t or inherited into it. |
java.util.List |
implemented(MethodInstance mi)
Get the list of methods mi implements, in no
specified order. |
ImportTable |
importTable(Package pkg)
Create an import table for the source file. |
ImportTable |
importTable(java.lang.String sourceName,
Package pkg)
Create an import table for the source file. |
void |
initialize(LoadedClassResolver resolver,
ExtensionInfo extInfo)
Initialize the type system with the compiler. |
InitializerInstance |
initializerInstance(Position pos,
ClassType container,
Flags flags)
Create an initailizer instance. |
PrimitiveType |
Int()
int |
Flags |
Interface()
|
java.util.List |
interfaces(ReferenceType type)
Returns an immutable list of all the interface types which type implements. |
boolean |
isAccessible(MemberInstance mi,
Context context)
Checks whether a class member can be accessed from Context context. |
boolean |
isCanonical(Type type)
Returns true iff type is a canonical
(fully qualified) type. |
boolean |
isCastValid(Type fromType,
Type toType)
Returns true iff a cast from fromType to toType is valid; in other words, some non-null members of fromType are also members of toType. |
boolean |
isEnclosed(ClassType inner,
ClassType outer)
Returns whether inner is enclosed within outer |
boolean |
isImplicitCastValid(Type fromType,
Type toType)
Returns true iff an implicit cast from fromType to toType is valid; in other words, every member of fromType is member of toType. |
boolean |
isSameMethod(MethodInstance m1,
MethodInstance m2)
Returns true iff m1 is the same method as m2 . |
boolean |
isSubtype(Type child,
Type ancestor)
Returns true iff child descends from ancestor or child == ancestor. |
boolean |
isThrowable(Type type)
Returns true iff an object of type type may be thrown. |
boolean |
isUncheckedException(Type type)
Returns a true iff the type or a supertype is in the list returned by uncheckedExceptions(). |
Type |
leastCommonAncestor(Type type1,
Type type2)
Returns the least common ancestor of type1 and type2 |
LoadedClassResolver |
loadedResolver()
Return the type system's loaded resolver. |
LocalInstance |
localInstance(Position pos,
Flags flags,
Type type,
java.lang.String name)
Create a local variable instance. |
PrimitiveType |
Long()
long |
boolean |
methodCallValid(MethodInstance mi,
java.lang.String name,
java.util.List argTypes)
Return true if mi can be called with name name
and actual parameters of types actualTypes . |
MethodInstance |
methodInstance(Position pos,
ReferenceType container,
Flags flags,
Type returnType,
java.lang.String name,
java.util.List argTypes,
java.util.List excTypes)
Create a method instance. |
boolean |
moreSpecific(ProcedureInstance m1,
ProcedureInstance m2)
Returns true iff m1 is more specific than m2 . |
Flags |
Native()
|
Flags |
NoFlags()
|
NullType |
Null()
The type of null . |
ClassType |
NullPointerException()
java.lang.NullPointerException |
boolean |
numericConversionValid(Type t,
long value)
Returns true if value can be implicitly cast to type
t . |
boolean |
numericConversionValid(Type t,
java.lang.Object value)
Returns true if value can be implicitly cast to
type t . |
ClassType |
Object()
java.lang.Object |
ClassType |
OutOfBoundsException()
java.lang.ArrayIndexOutOfBoundsException |
java.util.List |
overrides(MethodInstance mi)
Get the list of methods mi (potentially) overrides, in
order from this class (that is, including this ) to super
classes. |
Resolver |
packageContextResolver(Resolver resolver,
Package pkg)
Get a resolver for looking up a type in a package. |
boolean |
packageExists(java.lang.String name)
Returns true if the package named name exists. |
Package |
packageForName(Package prefix,
java.lang.String name)
Return a package by name with the given outer package. |
Package |
packageForName(java.lang.String name)
Return a package by name. |
TableResolver |
parsedResolver()
Return the type system's table resolver. |
java.lang.Object |
placeHolder(TypeObject o)
Get a place-holder for serializing a type object. |
java.lang.Object |
placeHolder(TypeObject o,
java.util.Set roots)
Get a place-holder for serializing a type object. |
PrimitiveType |
primitiveForName(java.lang.String name)
Return the primitive with the given name. |
Flags |
Private()
|
PrimitiveType |
promote(Type t)
Unary promotion for numeric types. |
PrimitiveType |
promote(Type t1,
Type t2)
Binary promotion for numeric types. |
Flags |
Protected()
|
Flags |
Public()
|
ClassType |
RuntimeException()
java.lang.RuntimeException |
ClassType |
Serializable()
java.io.Serializable |
PrimitiveType |
Short()
short |
Flags |
Static()
|
Type |
staticTarget(Type t)
Returns t , modified as necessary to make it a legal
static target. |
Flags |
StrictFP()
|
ClassType |
String()
java.lang.String |
Type |
superType(ReferenceType type)
Returns the immediate supertype of type, or null if type has no supertype. |
Flags |
Synchronized()
|
TopLevelResolver |
systemResolver()
Returns the system resolver. |
ClassType |
Throwable()
java.lang.Throwable |
boolean |
throwsSubset(ProcedureInstance m1,
ProcedureInstance m2)
Returns true iff m1 throws fewer exceptions than
m2 . |
Flags |
Transient()
|
java.lang.String |
translateArray(Resolver c,
ArrayType t)
Translate an array type. |
java.lang.String |
translateClass(Resolver c,
ClassType t)
Translate a top-level class type. |
java.lang.String |
translatePackage(Resolver c,
Package p)
Translate a package. |
java.lang.String |
translatePrimitive(Resolver c,
PrimitiveType t)
Translate a primitive type. |
Type |
typeForName(java.lang.String name)
Get the type with the following name. |
java.util.Collection |
uncheckedExceptions()
Returns a collection of the Throwable types that need not be declared in method and constructor signatures. |
UnknownPackage |
unknownPackage(Position pos)
Get an unknown package. |
UnknownQualifier |
unknownQualifier(Position pos)
Get an unknown type qualifier. |
UnknownType |
unknownType(Position pos)
Get an unknown type. |
PrimitiveType |
Void()
void |
Flags |
Volatile()
|
java.lang.String |
wrapperTypeString(PrimitiveType t)
Return the boxed version of t . |
Method Detail |
---|
void initialize(LoadedClassResolver resolver, ExtensionInfo extInfo) throws SemanticException
resolver
- The resolver to use for loading types from class files
or other source files.extInfo
- The ExtensionInfo the TypeSystem is being created for.
SemanticException
TopLevelResolver systemResolver()
TableResolver parsedResolver()
LoadedClassResolver loadedResolver()
ImportTable importTable(java.lang.String sourceName, Package pkg)
sourceName
- Name of the source file to import into. This is used
mainly for error messages and for debugging.pkg
- The package of the source file in which to import.ImportTable importTable(Package pkg)
pkg
- The package of the source file in which to import.java.util.List defaultPackageImports()
boolean packageExists(java.lang.String name)
name
exists.
Named forName(java.lang.String name) throws SemanticException
name
- The name of the type object to look for.
SemanticException
- when object is not found.Type typeForName(java.lang.String name) throws SemanticException
name
- The name to create the type for.
SemanticException
- when type is not found.InitializerInstance initializerInstance(Position pos, ClassType container, Flags flags)
pos
- Position of the initializer.container
- Containing class of the initializer.flags
- The initializer's flags.ConstructorInstance constructorInstance(Position pos, ClassType container, Flags flags, java.util.List argTypes, java.util.List excTypes)
pos
- Position of the constructor.container
- Containing class of the constructor.flags
- The constructor's flags.argTypes
- The constructor's formal parameter types.excTypes
- The constructor's exception throw types.MethodInstance methodInstance(Position pos, ReferenceType container, Flags flags, Type returnType, java.lang.String name, java.util.List argTypes, java.util.List excTypes)
pos
- Position of the method.container
- Containing type of the method.flags
- The method's flags.returnType
- The method's return type.name
- The method's name.argTypes
- The method's formal parameter types.excTypes
- The method's exception throw types.FieldInstance fieldInstance(Position pos, ReferenceType container, Flags flags, Type type, java.lang.String name)
pos
- Position of the field.container
- Containing type of the field.flags
- The field's flags.type
- The field's type.name
- The field's name.LocalInstance localInstance(Position pos, Flags flags, Type type, java.lang.String name)
pos
- Position of the local variable.flags
- The local variable's flags.type
- The local variable's type.name
- The local variable's name.ConstructorInstance defaultConstructor(Position pos, ClassType container)
pos
- Position of the constructor.container
- Containing class of the constructor.UnknownType unknownType(Position pos)
UnknownPackage unknownPackage(Position pos)
UnknownQualifier unknownQualifier(Position pos)
boolean isSubtype(Type child, Type ancestor)
descendsFrom(child, ancestor) || equals(child, ancestor)
boolean descendsFrom(Type child, Type ancestor)
boolean isCastValid(Type fromType, Type toType)
boolean isImplicitCastValid(Type fromType, Type toType)
boolean equals(TypeObject type1, TypeObject type2)
boolean numericConversionValid(Type t, long value)
value
can be implicitly cast to type
t
. This method should be removed. It is kept for backward
compatibility.
boolean numericConversionValid(Type t, java.lang.Object value)
value
can be implicitly cast to
type t
.
Type leastCommonAncestor(Type type1, Type type2) throws SemanticException
SemanticException
- if the LCA does not existboolean isCanonical(Type type)
type
is a canonical
(fully qualified) type.
boolean isAccessible(MemberInstance mi, Context context)
boolean classAccessible(ClassType ct, Context context)
boolean classAccessibleFromPackage(ClassType ct, Package pkg)
boolean isEnclosed(ClassType inner, ClassType outer)
boolean hasEnclosingInstance(ClassType inner, ClassType encl)
inner
has an
enclosing instance of class encl
.
boolean canCoerceToString(Type t, Context c)
boolean isThrowable(Type type)
type
may be thrown.
boolean isUncheckedException(Type type)
java.util.Collection uncheckedExceptions()
PrimitiveType promote(Type t) throws SemanticException
SemanticException
- if the type cannot be promoted.PrimitiveType promote(Type t1, Type t2) throws SemanticException
SemanticException
- if the types cannot be promoted.FieldInstance findField(ReferenceType container, java.lang.String name, Context c) throws SemanticException
SemanticException
FieldInstance findField(ReferenceType container, java.lang.String name, ClassType currClass) throws SemanticException
SemanticException
- if the field cannot be found or is
inaccessible.FieldInstance findField(ReferenceType container, java.lang.String name) throws SemanticException
SemanticException
- if the field cannot be found or is
inaccessible.MethodInstance findMethod(ReferenceType container, java.lang.String name, java.util.List argTypes, ClassType currClass) throws SemanticException
SemanticException
- if the method cannot be found or is
inaccessible.MethodInstance findMethod(ReferenceType container, java.lang.String name, java.util.List argTypes, Context c) throws SemanticException
SemanticException
ConstructorInstance findConstructor(ClassType container, java.util.List argTypes, ClassType currClass) throws SemanticException
SemanticException
- if the constructor cannot be found or is
inaccessible.ConstructorInstance findConstructor(ClassType container, java.util.List argTypes, Context c) throws SemanticException
SemanticException
ClassType findMemberClass(ClassType container, java.lang.String name, ClassType currClass) throws SemanticException
SemanticException
- if the class cannot be found or is
inaccessible.ClassType findMemberClass(ClassType container, java.lang.String name, Context c) throws SemanticException
SemanticException
ClassType findMemberClass(ClassType container, java.lang.String name) throws SemanticException
SemanticException
- if the class cannot be found or is
inaccessible.Type superType(ReferenceType type)
java.util.List interfaces(ReferenceType type)
boolean throwsSubset(ProcedureInstance m1, ProcedureInstance m2)
m1
throws fewer exceptions than
m2
.
boolean hasMethod(ReferenceType t, MethodInstance mi)
t
has the method mi
.
boolean hasMethodNamed(ReferenceType t, java.lang.String name)
t
has a method with name name
either defined in t
or inherited into it.
boolean isSameMethod(MethodInstance m1, MethodInstance m2)
m1
is the same method as m2
.
boolean moreSpecific(ProcedureInstance m1, ProcedureInstance m2)
m1
is more specific than m2
.
boolean hasFormals(ProcedureInstance p, java.util.List formalTypes)
p
has exactly the formal arguments
formalTypes
.
NullType Null()
null
.
PrimitiveType Void()
void
PrimitiveType Boolean()
boolean
PrimitiveType Char()
char
PrimitiveType Byte()
byte
PrimitiveType Short()
short
PrimitiveType Int()
int
PrimitiveType Long()
long
PrimitiveType Float()
float
PrimitiveType Double()
double
ClassType Object()
java.lang.Object
ClassType String()
java.lang.String
ClassType Class()
java.lang.Class
ClassType Throwable()
java.lang.Throwable
ClassType Error()
java.lang.Error
ClassType Exception()
java.lang.Exception
ClassType RuntimeException()
java.lang.RuntimeException
ClassType Cloneable()
java.lang.Cloneable
ClassType Serializable()
java.io.Serializable
ClassType NullPointerException()
java.lang.NullPointerException
ClassType ClassCastException()
java.lang.ClassCastException
ClassType OutOfBoundsException()
java.lang.ArrayIndexOutOfBoundsException
ClassType ArrayStoreException()
java.lang.ArrayStoreException
ClassType ArithmeticException()
java.lang.ArithmeticException
ArrayType arrayOf(Type type)
type
ArrayType arrayOf(Position pos, Type type)
type
ArrayType arrayOf(Type type, int dims)
dims
-array of type
ArrayType arrayOf(Position pos, Type type, int dims)
dims
-array of type
Package packageForName(java.lang.String name) throws SemanticException
SemanticException
Package packageForName(Package prefix, java.lang.String name) throws SemanticException
SemanticException
Package createPackage(java.lang.String name)
Package createPackage(Package prefix, java.lang.String name)
Context createContext()
Resolver packageContextResolver(Resolver resolver, Package pkg)
Resolver classContextResolver(ClassType ct)
LazyClassInitializer defaultClassInitializer()
ParsedClassType createClassType(LazyClassInitializer init)
ParsedClassType createClassType()
ParsedClassType createClassType(LazyClassInitializer init, Source fromSource)
ParsedClassType createClassType(Source fromSource)
java.util.Set getTypeEncoderRootSet(Type clazz)
java.lang.String getTransformedClassName(ClassType ct)
java.lang.Object placeHolder(TypeObject o, java.util.Set roots)
o
- The object to get the place-holder for.roots
- The root objects for the serialization. Place holders
are not created for these.java.lang.Object placeHolder(TypeObject o)
o
- The object to get the place-holder for.java.lang.String translatePackage(Resolver c, Package p)
java.lang.String translatePrimitive(Resolver c, PrimitiveType t)
java.lang.String translateArray(Resolver c, ArrayType t)
java.lang.String translateClass(Resolver c, ClassType t)
java.lang.String wrapperTypeString(PrimitiveType t)
t
.
boolean methodCallValid(MethodInstance mi, java.lang.String name, java.util.List argTypes)
mi
can be called with name name
and actual parameters of types actualTypes
.
boolean callValid(ProcedureInstance mi, java.util.List argTypes)
pi
can be called with
actual parameters of types actualTypes
.
java.util.List overrides(MethodInstance mi)
mi
(potentially) overrides, in
order from this class (that is, including this
) to super
classes.
boolean canOverride(MethodInstance mi, MethodInstance mj)
mi
can override mj
.
void checkOverride(MethodInstance mi, MethodInstance mj) throws SemanticException
mi
cannot override
mj
.
SemanticException
java.util.List implemented(MethodInstance mi)
mi
implements, in no
specified order.
PrimitiveType primitiveForName(java.lang.String name) throws SemanticException
SemanticException
void checkMethodFlags(Flags f) throws SemanticException
f
are legal method flags.
SemanticException
void checkLocalFlags(Flags f) throws SemanticException
f
are legal local variable flags.
SemanticException
void checkFieldFlags(Flags f) throws SemanticException
f
are legal field flags.
SemanticException
void checkConstructorFlags(Flags f) throws SemanticException
f
are legal constructor flags.
SemanticException
void checkInitializerFlags(Flags f) throws SemanticException
f
are legal initializer flags.
SemanticException
void checkTopLevelClassFlags(Flags f) throws SemanticException
f
are legal top-level class flags.
SemanticException
void checkMemberClassFlags(Flags f) throws SemanticException
f
are legal member class flags.
SemanticException
void checkLocalClassFlags(Flags f) throws SemanticException
f
are legal local class flags.
SemanticException
void checkAccessFlags(Flags f) throws SemanticException
f
are legal access flags.
SemanticException
void checkCycles(ReferenceType t) throws SemanticException
t
has no cycles in the super type+nested class
graph starting at t
.
SemanticException
void checkClassConformance(ClassType ct) throws SemanticException
ct
implements all abstract methods that it
has to; that is, if it is a concrete class, then it must implement all
interfaces and abstract methods that it or its superclasses declare.
SemanticException
Type staticTarget(Type t)
t
, modified as necessary to make it a legal
static target.
Flags flagsForBits(int bits)
Flags createNewFlag(java.lang.String name, Flags print_after)
name
- the name of the flagprint_after
- print the new flag after these flagsFlags NoFlags()
Flags Public()
Flags Protected()
Flags Private()
Flags Static()
Flags Final()
Flags Synchronized()
Flags Transient()
Flags Native()
Flags Interface()
Flags Abstract()
Flags Volatile()
Flags StrictFP()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |