polyglot.types
Interface TypeSystem

All Known Subinterfaces:
CofferTypeSystem, PaoTypeSystem, ParamTypeSystem
All Known Implementing Classes:
CofferTypeSystem_c, PaoTypeSystem_c, ParamTypeSystem_c, TypeSystem_c

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

initialize

public void initialize(LoadedClassResolver resolver,
                       ExtensionInfo extInfo)
                throws SemanticException
Initialize the type system with the compiler. This method must be called before any other type system method is called.

Parameters:
resolver - The resolver to use for loading types from class files or other source files.
extInfo - The ExtensionInfo the TypeSystem is being created for.
Throws:
SemanticException

systemResolver

public TopLevelResolver systemResolver()
Returns the system resolver. This resolver can load top-level classes with fully qualified names from the class path and the source path.


parsedResolver

public TableResolver parsedResolver()
Return the type system's table resolver. This resolver contains types parsed from source files.


loadedResolver

public LoadedClassResolver loadedResolver()
Return the type system's loaded resolver. This resolver contains types loaded from class files.


importTable

public ImportTable importTable(java.lang.String sourceName,
                               Package pkg)
Create an import table for the source file.

Parameters:
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

public ImportTable importTable(Package pkg)
Create an import table for the source file.

Parameters:
pkg - The package of the source file in which to import.

defaultPackageImports

public java.util.List defaultPackageImports()
Return a list of the packages names that will be imported by default. A list of Strings is returned, not a list of Packages.


packageExists

public boolean packageExists(java.lang.String name)
Returns true if the package named name exists.


forName

public Named forName(java.lang.String name)
              throws SemanticException
Get the named type object with the following name.

Parameters:
name - The name of the type object to look for.
Throws:
SemanticException - when object is not found.

typeForName

public Type typeForName(java.lang.String name)
                 throws SemanticException
Get the type with the following name.

Parameters:
name - The name to create the type for.
Throws:
SemanticException - when type is not found.

initializerInstance

public InitializerInstance initializerInstance(Position pos,
                                               ClassType container,
                                               Flags flags)
Create an initailizer instance.

Parameters:
pos - Position of the initializer.
container - Containing class of the initializer.
flags - The initializer's flags.

constructorInstance

public ConstructorInstance constructorInstance(Position pos,
                                               ClassType container,
                                               Flags flags,
                                               java.util.List argTypes,
                                               java.util.List excTypes)
Create a constructor instance.

Parameters:
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

public 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.

Parameters:
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

public FieldInstance fieldInstance(Position pos,
                                   ReferenceType container,
                                   Flags flags,
                                   Type type,
                                   java.lang.String name)
Create a field instance.

Parameters:
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

public LocalInstance localInstance(Position pos,
                                   Flags flags,
                                   Type type,
                                   java.lang.String name)
Create a local variable instance.

Parameters:
pos - Position of the local variable.
flags - The local variable's flags.
type - The local variable's type.
name - The local variable's name.

defaultConstructor

public ConstructorInstance defaultConstructor(Position pos,
                                              ClassType container)
Create a default constructor instance.

Parameters:
pos - Position of the constructor.
container - Containing class of the constructor.

unknownType

public UnknownType unknownType(Position pos)
Get an unknown type.


unknownPackage

public UnknownPackage unknownPackage(Position pos)
Get an unknown package.


unknownQualifier

public UnknownQualifier unknownQualifier(Position pos)
Get an unknown type qualifier.


isSubtype

public boolean isSubtype(Type child,
                         Type ancestor)
Returns true iff child descends from ancestor or child == ancestor. This is equivalent to:
    descendsFrom(child, ancestor) || equals(child, ancestor)
 


descendsFrom

public boolean descendsFrom(Type child,
                            Type ancestor)
Returns true iff child is not ancestor, but child descends from ancestor.


isCastValid

public 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.


isImplicitCastValid

public 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.


equals

public boolean equals(TypeObject type1,
                      TypeObject type2)
Returns true iff type1 and type2 represent the same type object.


numericConversionValid

public boolean numericConversionValid(Type t,
                                      long value)
Returns true if value can be implicitly cast to type t. This method should be removed. It is kept for backward compatibility.


numericConversionValid

public boolean numericConversionValid(Type t,
                                      java.lang.Object value)
Returns true if value can be implicitly cast to type t.


leastCommonAncestor

public Type leastCommonAncestor(Type type1,
                                Type type2)
                         throws SemanticException
Returns the least common ancestor of type1 and type2

Throws:
SemanticException - if the LCA does not exist

isCanonical

public boolean isCanonical(Type type)
Returns true iff type is a canonical (fully qualified) type.


isAccessible

public boolean isAccessible(MemberInstance mi,
                            Context context)
Checks whether a class member can be accessed from Context context.


classAccessible

public boolean classAccessible(ClassType ct,
                               Context context)
Checks whether a class can be accessed from Context context.


classAccessibleFromPackage

public boolean classAccessibleFromPackage(ClassType ct,
                                          Package pkg)
Checks whether a top-level or member class can be accessed from the package pkg. Returns false for local and anonymous classes.


isEnclosed

public boolean isEnclosed(ClassType inner,
                          ClassType outer)
Returns whether inner is enclosed within outer


hasEnclosingInstance

public boolean hasEnclosingInstance(ClassType inner,
                                    ClassType encl)
Returns whether an object of the inner class inner has an enclosing instance of class encl.


canCoerceToString

public boolean canCoerceToString(Type t,
                                 Context c)
Returns true iff the type t can be coerced to a String in the given Context. If a type can be coerced to a String then it can be concatenated with Strings, e.g. if o is of type T, then the code snippet "" + o would be allowed.


isThrowable

public boolean isThrowable(Type type)
Returns true iff an object of type type may be thrown.


isUncheckedException

public boolean isUncheckedException(Type type)
Returns a true iff the type or a supertype is in the list returned by uncheckedExceptions().


uncheckedExceptions

public java.util.Collection uncheckedExceptions()
Returns a collection of the Throwable types that need not be declared in method and constructor signatures.


promote

public PrimitiveType promote(Type t)
                      throws SemanticException
Unary promotion for numeric types.

Throws:
SemanticException - if the type cannot be promoted.

promote

public PrimitiveType promote(Type t1,
                             Type t2)
                      throws SemanticException
Binary promotion for numeric types.

Throws:
SemanticException - if the types cannot be promoted.

findField

public FieldInstance findField(ReferenceType container,
                               java.lang.String name,
                               Context c)
                        throws SemanticException
Deprecated.  

Deprecated version of the findField method.

Throws:
SemanticException

findField

public FieldInstance findField(ReferenceType container,
                               java.lang.String name,
                               ClassType currClass)
                        throws SemanticException
Returns the field named 'name' defined on 'type'. We check if the field is accessible from the class currClass.

Throws:
SemanticException - if the field cannot be found or is inaccessible.

findField

public FieldInstance findField(ReferenceType container,
                               java.lang.String name)
                        throws SemanticException
Returns the field named 'name' defined on 'type'.

Throws:
SemanticException - if the field cannot be found or is inaccessible.

findMethod

public MethodInstance findMethod(ReferenceType container,
                                 java.lang.String name,
                                 java.util.List argTypes,
                                 ClassType currClass)
                          throws SemanticException
Find a method. We need to pass the class from which the method is being found because the method we find depends on whether the method is accessible from that class. We also check if the field is accessible from the context 'c'.

Throws:
SemanticException - if the method cannot be found or is inaccessible.

findMethod

public MethodInstance findMethod(ReferenceType container,
                                 java.lang.String name,
                                 java.util.List argTypes,
                                 Context c)
                          throws SemanticException
Deprecated.  

Deprecated version of the findMethod method.

Throws:
SemanticException

findConstructor

public ConstructorInstance findConstructor(ClassType container,
                                           java.util.List argTypes,
                                           ClassType currClass)
                                    throws SemanticException
Find a constructor. We need to pass the class from which the constructor is being found because the constructor we find depends on whether the constructor is accessible from that class.

Throws:
SemanticException - if the constructor cannot be found or is inaccessible.

findConstructor

public ConstructorInstance findConstructor(ClassType container,
                                           java.util.List argTypes,
                                           Context c)
                                    throws SemanticException
Deprecated.  

Deprecated version of the findConstructor method.

Throws:
SemanticException

findMemberClass

public ClassType findMemberClass(ClassType container,
                                 java.lang.String name,
                                 ClassType currClass)
                          throws SemanticException
Find a member class. We check if the field is accessible from the class currClass.

Throws:
SemanticException - if the class cannot be found or is inaccessible.

findMemberClass

public ClassType findMemberClass(ClassType container,
                                 java.lang.String name,
                                 Context c)
                          throws SemanticException
Deprecated.  

Deprecated version of the findMemberClass method.

Throws:
SemanticException

findMemberClass

public ClassType findMemberClass(ClassType container,
                                 java.lang.String name)
                          throws SemanticException
Find a member class.

Throws:
SemanticException - if the class cannot be found or is inaccessible.

superType

public Type superType(ReferenceType type)
Returns the immediate supertype of type, or null if type has no supertype.


interfaces

public java.util.List interfaces(ReferenceType type)
Returns an immutable list of all the interface types which type implements.


throwsSubset

public boolean throwsSubset(ProcedureInstance m1,
                            ProcedureInstance m2)
Returns true iff m1 throws fewer exceptions than m2.


hasMethod

public boolean hasMethod(ReferenceType t,
                         MethodInstance mi)
Returns true iff t has the method mi.


hasMethodNamed

public 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.


isSameMethod

public boolean isSameMethod(MethodInstance m1,
                            MethodInstance m2)
Returns true iff m1 is the same method as m2.


moreSpecific

public boolean moreSpecific(ProcedureInstance m1,
                            ProcedureInstance m2)
Returns true iff m1 is more specific than m2.


hasFormals

public boolean hasFormals(ProcedureInstance p,
                          java.util.List formalTypes)
Returns true iff p has exactly the formal arguments formalTypes.


Null

public NullType Null()
The type of null.


Void

public PrimitiveType Void()
void


Boolean

public PrimitiveType Boolean()
boolean


Char

public PrimitiveType Char()
char


Byte

public PrimitiveType Byte()
byte


Short

public PrimitiveType Short()
short


Int

public PrimitiveType Int()
int


Long

public PrimitiveType Long()
long


Float

public PrimitiveType Float()
float


Double

public PrimitiveType Double()
double


Object

public ClassType Object()
java.lang.Object


String

public ClassType String()
java.lang.String


Class

public ClassType Class()
java.lang.Class


Throwable

public ClassType Throwable()
java.lang.Throwable


Error

public ClassType Error()
java.lang.Error


Exception

public ClassType Exception()
java.lang.Exception


RuntimeException

public ClassType RuntimeException()
java.lang.RuntimeException


Cloneable

public ClassType Cloneable()
java.lang.Cloneable


Serializable

public ClassType Serializable()
java.io.Serializable


NullPointerException

public ClassType NullPointerException()
java.lang.NullPointerException


ClassCastException

public ClassType ClassCastException()
java.lang.ClassCastException


OutOfBoundsException

public ClassType OutOfBoundsException()
java.lang.ArrayIndexOutOfBoundsException


ArrayStoreException

public ClassType ArrayStoreException()
java.lang.ArrayStoreException


ArithmeticException

public ClassType ArithmeticException()
java.lang.ArithmeticException


arrayOf

public ArrayType arrayOf(Type type)
Return an array of type


arrayOf

public ArrayType arrayOf(Position pos,
                         Type type)
Return an array of type


arrayOf

public ArrayType arrayOf(Type type,
                         int dims)
Return a dims-array of type


arrayOf

public ArrayType arrayOf(Position pos,
                         Type type,
                         int dims)
Return a dims-array of type


packageForName

public Package packageForName(java.lang.String name)
                       throws SemanticException
Return a package by name. Fail if the package does not exists.

Throws:
SemanticException

packageForName

public Package packageForName(Package prefix,
                              java.lang.String name)
                       throws SemanticException
Return a package by name with the given outer package. Fail if the package does not exists.

Throws:
SemanticException

createPackage

public Package createPackage(java.lang.String name)
Return a package by name.


createPackage

public Package createPackage(Package prefix,
                             java.lang.String name)
Return a package by name with the given outer package.


createContext

public Context createContext()
Create a new context object for looking up variables, types, etc.


packageContextResolver

public Resolver packageContextResolver(Resolver resolver,
                                       Package pkg)
Get a resolver for looking up a type in a package.


classContextResolver

public Resolver classContextResolver(ClassType ct)
Get a resolver for looking up a type in a class context.


defaultClassInitializer

public LazyClassInitializer defaultClassInitializer()
The default lazy class initializer.


createClassType

public ParsedClassType createClassType(LazyClassInitializer init)
Create a new empty class.


createClassType

public ParsedClassType createClassType()
Create a new empty class.


createClassType

public ParsedClassType createClassType(LazyClassInitializer init,
                                       Source fromSource)
Create a new empty class.


createClassType

public ParsedClassType createClassType(Source fromSource)
Create a new empty class.


getTypeEncoderRootSet

public java.util.Set getTypeEncoderRootSet(Type clazz)
Return the set of objects that should be serialized into the type information for the given ClassType. Usually only the clazz itself should get encoded, and references to other classes should just have their name written out. If it makes sense for additional types to be fully encoded, (ie, they're necessary to correctly reconstruct the given clazz, and the usual class resolvers can't otherwise find them) they should be returned in the set in addition to clazz.


getTransformedClassName

public java.lang.String getTransformedClassName(ClassType ct)
Get the transformed class name of a class. This utility method returns the "mangled" name of the given class, whereby all periods ('.') following the toplevel class name are replaced with dollar signs ('$'). If any of the containing classes is not a member class or a top level class, then null is returned.


placeHolder

public java.lang.Object placeHolder(TypeObject o,
                                    java.util.Set roots)
Get a place-holder for serializing a type object.

Parameters:
o - The object to get the place-holder for.
roots - The root objects for the serialization. Place holders are not created for these.

placeHolder

public java.lang.Object placeHolder(TypeObject o)
Get a place-holder for serializing a type object.

Parameters:
o - The object to get the place-holder for.

translatePackage

public java.lang.String translatePackage(Resolver c,
                                         Package p)
Translate a package.


translatePrimitive

public java.lang.String translatePrimitive(Resolver c,
                                           PrimitiveType t)
Translate a primitive type.


translateArray

public java.lang.String translateArray(Resolver c,
                                       ArrayType t)
Translate an array type.


translateClass

public java.lang.String translateClass(Resolver c,
                                       ClassType t)
Translate a top-level class type.


wrapperTypeString

public java.lang.String wrapperTypeString(PrimitiveType t)
Return the boxed version of t.


methodCallValid

public 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.


callValid

public boolean callValid(ProcedureInstance mi,
                         java.util.List argTypes)
Return true if pi can be called with actual parameters of types actualTypes.


overrides

public 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.


canOverride

public boolean canOverride(MethodInstance mi,
                           MethodInstance mj)
Return true if mi can override mj.


checkOverride

public void checkOverride(MethodInstance mi,
                          MethodInstance mj)
                   throws SemanticException
Throw a SemanticException if mi cannot override mj.

Throws:
SemanticException

implemented

public java.util.List implemented(MethodInstance mi)
Get the list of methods mi implements, in no specified order.


primitiveForName

public PrimitiveType primitiveForName(java.lang.String name)
                               throws SemanticException
Return the primitive with the given name.

Throws:
SemanticException

checkMethodFlags

public void checkMethodFlags(Flags f)
                      throws SemanticException
Assert if the flags f are legal method flags.

Throws:
SemanticException

checkLocalFlags

public void checkLocalFlags(Flags f)
                     throws SemanticException
Assert if the flags f are legal local variable flags.

Throws:
SemanticException

checkFieldFlags

public void checkFieldFlags(Flags f)
                     throws SemanticException
Assert if the flags f are legal field flags.

Throws:
SemanticException

checkConstructorFlags

public void checkConstructorFlags(Flags f)
                           throws SemanticException
Assert if the flags f are legal constructor flags.

Throws:
SemanticException

checkInitializerFlags

public void checkInitializerFlags(Flags f)
                           throws SemanticException
Assert if the flags f are legal initializer flags.

Throws:
SemanticException

checkTopLevelClassFlags

public void checkTopLevelClassFlags(Flags f)
                             throws SemanticException
Assert if the flags f are legal top-level class flags.

Throws:
SemanticException

checkMemberClassFlags

public void checkMemberClassFlags(Flags f)
                           throws SemanticException
Assert if the flags f are legal member class flags.

Throws:
SemanticException

checkLocalClassFlags

public void checkLocalClassFlags(Flags f)
                          throws SemanticException
Assert if the flags f are legal local class flags.

Throws:
SemanticException

checkAccessFlags

public void checkAccessFlags(Flags f)
                      throws SemanticException
Assert if the flags f are legal access flags.

Throws:
SemanticException

checkCycles

public void checkCycles(ReferenceType t)
                 throws SemanticException
Assert that t has no cycles in the super type+nested class graph starting at t.

Throws:
SemanticException

checkClassConformance

public void checkClassConformance(ClassType ct)
                           throws SemanticException
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.

Throws:
SemanticException

staticTarget

public Type staticTarget(Type t)
Returns t, modified as necessary to make it a legal static target.


flagsForBits

public Flags flagsForBits(int bits)
Given the JVM encoding of a set of flags, returns the Flags object for that encoding.


createNewFlag

public Flags createNewFlag(java.lang.String name,
                           Flags print_after)
Create a new unique Flags object.

Parameters:
name - the name of the flag
print_after - print the new flag after these flags

NoFlags

public Flags NoFlags()

Public

public Flags Public()

Protected

public Flags Protected()

Private

public Flags Private()

Static

public Flags Static()

Final

public Flags Final()

Synchronized

public Flags Synchronized()

Transient

public Flags Transient()

Native

public Flags Native()

Interface

public Flags Interface()

Abstract

public Flags Abstract()

Volatile

public Flags Volatile()

StrictFP

public Flags StrictFP()