jltools.types
Interface TypeSystem

All Known Subinterfaces:
JifTypeSystem
All Known Implementing Classes:
TypeSystem_c

public interface TypeSystem

The TypeSystem defines the types of the language and how they are related.


Method Summary
 ParsedAnonClassType anonClassType(Job job)
           
 ClassType ArithmeticException()
           
 ArrayType arrayOf(Position pos, Type type)
           
 ArrayType arrayOf(Position pos, Type type, int dims)
           
 ArrayType arrayOf(Type type)
          Returns a type identical to , but with more array dimensions.
 ArrayType arrayOf(Type type, int dims)
           
 ClassType ArrayStoreException()
           
 PrimitiveType Boolean()
           
 PrimitiveType Byte()
           
 PrimitiveType Char()
           
 void checkAccessFlags(Flags f)
           
 void checkConstructorFlags(Flags f)
           
 void checkCycles(ReferenceType t)
           
 void checkFieldFlags(Flags f)
           
 void checkInitializerFlags(Flags f)
           
 void checkLocalClassFlags(Flags f)
           
 void checkLocalFlags(Flags f)
           
 void checkMemberClassFlags(Flags f)
           
 void checkMethodFlags(Flags f)
           
 void checkTopLevelClassFlags(Flags f)
           
 ClassType Class()
           
 ClassType ClassCastException()
           
 Resolver classContextResolver(ClassType ct)
          Get a resolver for looking up a type in a class context.
 ClassType Cloneable()
           
 Compiler compiler()
          Return the compiler associated with this type system.
 ConstructorInstance constructorInstance(Position pos, ClassType container, Flags flags, java.util.List argTypes, java.util.List excTypes)
          Create a constructor instance.
 Context createContext(ImportTable it)
           
 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()
           
 ClassType Error()
           
 ClassType Exception()
           
 FieldInstance fieldInstance(Position pos, ReferenceType container, Flags flags, Type type, java.lang.String name)
          Create a field instance.
 ConstructorInstance findConstructor(ClassType container, java.util.List argTypes, Context c)
          Find a constructor.
 FieldInstance findField(ReferenceType container, java.lang.String name, Context c)
          Returns the field named 'name' defined on 'type'.
 MemberClassType findMemberClass(ClassType container, java.lang.String name, Context c)
          Find a member class.
 MethodInstance findMethod(ReferenceType container, java.lang.String name, java.util.List argTypes, Context c)
          Find a method.
 PrimitiveType Float()
           
 ClassType forClass(java.lang.Class clazz)
          Return a class type for the Class object.
 java.util.Set getTypeEncoderRootSet(Type clazz)
          return the set of objects that should be serialized into the type information for the given ClassType.
 boolean hasSameArguments(ProcedureInstance m1, ProcedureInstance m2)
          Returns true iff has the same arguments as
 void initialize(Compiler compiler)
          Initialize the type system with the compiler.
 InitializerInstance initializerInstance(Position pos, ClassType container, Flags flags)
          Create an initailizer instance.
 PrimitiveType Int()
           
 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 method or field within target with access flags 'flags' can be accessed from Context context.
 boolean isAssignableSubtype(Type child, Type ancestor)
          Returns true iff child and ancestor are non-primitive types, and a variable of type child may be legally assigned to a variable of type ancestor.
 boolean isCanonical(Type type)
          Returns true iff is a canonical (fully qualified) type.
 boolean isCastValid(Type fromType, Type toType)
          Requires: all type arguments are canonical.
 boolean isEnclosed(ClassType inner, ClassType outer)
          Returns whether inner is enclosed within outer
 boolean isImplicitCastValid(Type fromType, Type toType)
          Requires: all type arguments are canonical.
 boolean isSame(Type type1, Type type2)
          Requires: all type arguments are canonical.
 boolean isSubtype(Type child, Type ancestor)
          Returns true iff child descends from ancestor or child == ancestor.
 boolean isThrowable(Type type)
          Requires: all type arguments are canonical.
 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)
          Requires: all type arguments are canonical.
 ParsedLocalClassType localClassType(Job job)
           
 LocalInstance localInstance(Position pos, Flags flags, Type type, java.lang.String name)
          Create a local variable instance.
 PrimitiveType Long()
           
 ParsedMemberClassType memberClassType(Job job)
           
 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.
 NullType Null()
           
 ClassType NullPointerException()
           
 boolean numericConversionValid(Type t, long value)
          Returns true if value can be implicitly cast to Primitive type t.
 ClassType Object()
           
 ClassType OutOfBoundsException()
           
 Resolver packageContextResolver(Resolver resolver, Package pkg)
          Get a resolver for looking up a type in a package.
 Package packageForName(Package prefix, java.lang.String name)
           
 Package packageForName(java.lang.String name)
           
 TypeObject placeHolder(TypeObject o)
           
 TypeObject placeHolder(TypeObject o, java.util.Set roots)
          Get a place-holder for serializing a type object.
 PrimitiveType primitiveForName(java.lang.String name)
           
 PrimitiveType promote(Type t)
          Unary promotion for numeric types.
 PrimitiveType promote(Type t1, Type t2)
          Binary promotion for numeric types.
 ClassType RuntimeException()
           
 ClassType Serializable()
           
 PrimitiveType Short()
           
 ClassType String()
           
 Type superType(ReferenceType type)
          Returns the immediate supertype of type, or null if type has no supertype.
 Resolver systemResolver()
          Returns the system resolver.
 ClassType Throwable()
           
 ParsedTopLevelClassType topLevelClassType(Job job)
           
 java.lang.String translateArray(Context c, ArrayType t)
           
 java.lang.String translateLocalClass(Context c, LocalClassType t)
           
 java.lang.String translateMemberClass(Context c, MemberClassType t)
           
 java.lang.String translatePackage(Context c, Package p)
           
 java.lang.String translatePrimitive(Context c, PrimitiveType t)
           
 java.lang.String translateTopLevelClass(Context c, TopLevelClassType t)
           
 Type typeForClass(java.lang.Class clazz)
          Returns a canonical type corresponding to the Java Class object class.
 java.util.Collection uncheckedExceptions()
          Returns a collection of the Throwable types that need not be declared in method and constructor signatures.
 UnknownQualifier unknownQualifier(Position pos)
          Get an unknown type qualifier.
 UnknownType unknownType(Position pos)
          Get an unknown type.
 PrimitiveType Void()
           
 java.lang.String wrapperTypeString(PrimitiveType t)
           
 

Method Detail

initialize

public void initialize(Compiler compiler)
                throws SemanticException
Initialize the type system with the compiler. This method must be called before any other type system method is called.

compiler

public Compiler compiler()
Return the compiler associated with this type system.

systemResolver

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

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.

initializerInstance

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

constructorInstance

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

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.

fieldInstance

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

localInstance

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

forClass

public ClassType forClass(java.lang.Class clazz)
                   throws SemanticException
Return a class type for the Class object. Only a Resolver should call this method.

placeHolder

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

placeHolder

public TypeObject placeHolder(TypeObject o)

unknownType

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

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) || isSame(child, ancestor)

descendsFrom

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

isAssignableSubtype

public boolean isAssignableSubtype(Type child,
                                   Type ancestor)
Returns true iff child and ancestor are non-primitive types, and a variable of type child may be legally assigned to a variable of type ancestor.

isCastValid

public boolean isCastValid(Type fromType,
                           Type toType)
Requires: all type arguments are canonical. 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)
Requires: all type arguments are canonical. Returns true iff an implicit cast from fromType to toType is valid; in other words, every member of fromType is member of toType.

isSame

public boolean isSame(Type type1,
                      Type type2)
Requires: all type arguments are canonical. Returns true iff type1 and type2 are the same type.

numericConversionValid

public boolean numericConversionValid(Type t,
                                      long value)
Returns true if value can be implicitly cast to Primitive type t.

leastCommonAncestor

public Type leastCommonAncestor(Type type1,
                                Type type2)
                         throws SemanticException
Requires: all type arguments are canonical. Returns the least common ancestor of Type1 and Type2

isCanonical

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

isAccessible

public boolean isAccessible(MemberInstance mi,
                            Context context)
Checks whether a method or field within target with access flags 'flags' can be accessed from Context context.

isEnclosed

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

isThrowable

public boolean isThrowable(Type type)
Requires: all type arguments are canonical. Returns true iff an object of 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.

promote

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

findField

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

findMethod

public MethodInstance findMethod(ReferenceType container,
                                 java.lang.String name,
                                 java.util.List argTypes,
                                 Context c)
                          throws SemanticException
Find a method. We need to pass the context because the method we find depends on whether the method is accessible from the context.

findConstructor

public ConstructorInstance findConstructor(ClassType container,
                                           java.util.List argTypes,
                                           Context c)
                                    throws SemanticException
Find a constructor. We need to pass the context because the method we find depends on whether the method is accessible from the context.

findMemberClass

public MemberClassType findMemberClass(ClassType container,
                                       java.lang.String name,
                                       Context c)
                                throws SemanticException
Find a member class. We need to pass the context because the method we find depends on whether the method is accessible from the context.

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.

hasSameArguments

public boolean hasSameArguments(ProcedureInstance m1,
                                ProcedureInstance m2)
Returns true iff has the same arguments as

Null

public NullType Null()

Void

public PrimitiveType Void()

Boolean

public PrimitiveType Boolean()

Char

public PrimitiveType Char()

Byte

public PrimitiveType Byte()

Short

public PrimitiveType Short()

Int

public PrimitiveType Int()

Long

public PrimitiveType Long()

Float

public PrimitiveType Float()

Double

public PrimitiveType Double()

Object

public ClassType Object()

String

public ClassType String()

Class

public ClassType Class()

Throwable

public ClassType Throwable()

Error

public ClassType Error()

Exception

public ClassType Exception()

RuntimeException

public ClassType RuntimeException()

Cloneable

public ClassType Cloneable()

Serializable

public ClassType Serializable()

NullPointerException

public ClassType NullPointerException()

ClassCastException

public ClassType ClassCastException()

OutOfBoundsException

public ClassType OutOfBoundsException()

ArrayStoreException

public ClassType ArrayStoreException()

ArithmeticException

public ClassType ArithmeticException()

arrayOf

public ArrayType arrayOf(Type type)
Returns a type identical to , but with more array dimensions. must be >= 0.

arrayOf

public ArrayType arrayOf(Position pos,
                         Type type)

arrayOf

public ArrayType arrayOf(Type type,
                         int dims)

arrayOf

public ArrayType arrayOf(Position pos,
                         Type type,
                         int dims)

typeForClass

public Type typeForClass(java.lang.Class clazz)
                  throws SemanticException
Returns a canonical type corresponding to the Java Class object class. Does not require that have a JavaClass theClass. Does not require that have a ClassType registered in this typeSystem. Does not register the type in this TypeSystem. this TypeSystem. For use only by ClassType implementations.

packageForName

public Package packageForName(java.lang.String name)

packageForName

public Package packageForName(Package prefix,
                              java.lang.String name)

createContext

public Context createContext(ImportTable it)

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.

anonClassType

public ParsedAnonClassType anonClassType(Job job)

topLevelClassType

public ParsedTopLevelClassType topLevelClassType(Job job)

memberClassType

public ParsedMemberClassType memberClassType(Job job)

localClassType

public ParsedLocalClassType localClassType(Job job)

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.

translatePackage

public java.lang.String translatePackage(Context c,
                                         Package p)

translatePrimitive

public java.lang.String translatePrimitive(Context c,
                                           PrimitiveType t)

translateArray

public java.lang.String translateArray(Context c,
                                       ArrayType t)

translateTopLevelClass

public java.lang.String translateTopLevelClass(Context c,
                                               TopLevelClassType t)

translateMemberClass

public java.lang.String translateMemberClass(Context c,
                                             MemberClassType t)

translateLocalClass

public java.lang.String translateLocalClass(Context c,
                                            LocalClassType t)

wrapperTypeString

public java.lang.String wrapperTypeString(PrimitiveType t)

primitiveForName

public PrimitiveType primitiveForName(java.lang.String name)
                               throws SemanticException

checkMethodFlags

public void checkMethodFlags(Flags f)
                      throws SemanticException

checkLocalFlags

public void checkLocalFlags(Flags f)
                     throws SemanticException

checkFieldFlags

public void checkFieldFlags(Flags f)
                     throws SemanticException

checkConstructorFlags

public void checkConstructorFlags(Flags f)
                           throws SemanticException

checkInitializerFlags

public void checkInitializerFlags(Flags f)
                           throws SemanticException

checkTopLevelClassFlags

public void checkTopLevelClassFlags(Flags f)
                             throws SemanticException

checkMemberClassFlags

public void checkMemberClassFlags(Flags f)
                           throws SemanticException

checkLocalClassFlags

public void checkLocalClassFlags(Flags f)
                          throws SemanticException

checkAccessFlags

public void checkAccessFlags(Flags f)
                      throws SemanticException

checkCycles

public void checkCycles(ReferenceType t)
                 throws SemanticException