jasm.lang
Class JvmTypes

java.lang.Object
  extended by jasm.lang.JvmTypes

public class JvmTypes
extends java.lang.Object


Field Summary
static JvmType.Clazz JAVA_IO_SERIALIZABLE
           
static JvmType.Clazz JAVA_LANG_ARITHMETICEXCEPTION
           
static JvmType.Clazz JAVA_LANG_BOOLEAN
           
static JvmType.Clazz JAVA_LANG_BYTE
           
static JvmType.Clazz JAVA_LANG_CHARACTER
           
static JvmType.Clazz JAVA_LANG_CLASS
           
static JvmType.Clazz JAVA_LANG_CLONEABLE
           
static JvmType.Clazz JAVA_LANG_DOUBLE
           
static JvmType.Clazz JAVA_LANG_ENUM
           
static JvmType.Clazz JAVA_LANG_FLOAT
           
static JvmType.Clazz JAVA_LANG_INTEGER
           
static JvmType.Clazz JAVA_LANG_LONG
           
static JvmType.Clazz JAVA_LANG_NULLPOINTEREXCEPTION
           
static JvmType.Clazz JAVA_LANG_OBJECT
           
static JvmType.Clazz JAVA_LANG_RUNTIMEEXCEPTION
           
static JvmType.Clazz JAVA_LANG_SHORT
           
static JvmType.Clazz JAVA_LANG_STRING
           
static JvmType.Clazz JAVA_LANG_THROWABLE
           
static JvmType.Clazz JAVA_LANG_VIRTUALMACHINEERROR
           
static JvmType.Clazz JAVA_UTIL_ITERATOR
           
static JvmType.Bool T_BOOL
           
static JvmType.Byte T_BYTE
           
static JvmType.Char T_CHAR
           
static JvmType.Double T_DOUBLE
           
static JvmType.Float T_FLOAT
           
static JvmType.Int T_INT
           
static JvmType.Long T_LONG
           
static JvmType.Null T_NULL
           
static JvmType.Short T_SHORT
           
static JvmType.Void T_VOID
          The following are provided for performance reasons, particularly to help reduce the memory footprint during compilation.
 
Constructor Summary
JvmTypes()
           
 
Method Summary
static int arrayDepth(JvmType t)
          Return the depth of array nesting.
static JvmType.Clazz boxedType(JvmType.Primitive p)
          Given a primitive type, determine the equivalent boxed type.
static boolean isBoxedType(JvmType t)
          Determine whether or not the given type is a wrapper for a primitive type.
static boolean isBoxedTypeOf(JvmType t, java.lang.String wrapper)
          Determine whether or not the given type is a wrapper for a primitive type.
static boolean isClass(java.lang.String pkg, java.lang.String clazz, JvmType t)
           
static boolean isGeneric(JvmType t)
           
static boolean isGenericArray(JvmType t)
           
static boolean isJavaLangObject(JvmType t)
          Check wither a given type is a reference to java.lang.Object or not.
static boolean isJavaLangString(JvmType t)
          Check wither a given type is a reference to java.lang.String or not.
static JvmType.Clazz parentType(JvmType.Clazz t)
          Return type representing the enclosing class for the given type, or null if the given type is already outermost.
static JvmType.Clazz stripGenerics(JvmType.Clazz ct)
           
static JvmType.Function stripGenerics(JvmType.Function ft)
           
static JvmType.Intersection stripGenerics(JvmType.Intersection wt)
           
static JvmType stripGenerics(JvmType.Variable vt)
           
static JvmType stripGenerics(JvmType.Wildcard wt)
           
static JvmType stripGenerics(JvmType t)
          The purpose of this method is to strip the generic information from a type.
static JvmType.Function substitute(JvmType.Function type, java.util.Map<java.lang.String,JvmType.Reference> binding)
          This method accepts a binding from type variables to concrete types, and then substitutes each such variable occuring in the target (function) type with its corresponding instantation.
static JvmType.Reference substitute(JvmType.Reference type, java.util.Map<java.lang.String,JvmType.Reference> binding)
          This method accepts a binding from type variables to concrete types, and then substitutes each such variable occuring in the target type with its corresponding instantation.
static JvmType.Primitive unboxedType(JvmType.Clazz p)
          Given a primitive wrapper class (i.e.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

T_VOID

public static final JvmType.Void T_VOID
The following are provided for performance reasons, particularly to help reduce the memory footprint during compilation.


T_NULL

public static final JvmType.Null T_NULL

T_BOOL

public static final JvmType.Bool T_BOOL

T_BYTE

public static final JvmType.Byte T_BYTE

T_CHAR

public static final JvmType.Char T_CHAR

T_SHORT

public static final JvmType.Short T_SHORT

T_INT

public static final JvmType.Int T_INT

T_LONG

public static final JvmType.Long T_LONG

T_FLOAT

public static final JvmType.Float T_FLOAT

T_DOUBLE

public static final JvmType.Double T_DOUBLE

JAVA_LANG_OBJECT

public static final JvmType.Clazz JAVA_LANG_OBJECT

JAVA_LANG_CLASS

public static final JvmType.Clazz JAVA_LANG_CLASS

JAVA_LANG_CLONEABLE

public static final JvmType.Clazz JAVA_LANG_CLONEABLE

JAVA_LANG_STRING

public static final JvmType.Clazz JAVA_LANG_STRING

JAVA_LANG_ENUM

public static final JvmType.Clazz JAVA_LANG_ENUM

JAVA_LANG_BOOLEAN

public static final JvmType.Clazz JAVA_LANG_BOOLEAN

JAVA_LANG_CHARACTER

public static final JvmType.Clazz JAVA_LANG_CHARACTER

JAVA_LANG_BYTE

public static final JvmType.Clazz JAVA_LANG_BYTE

JAVA_LANG_SHORT

public static final JvmType.Clazz JAVA_LANG_SHORT

JAVA_LANG_INTEGER

public static final JvmType.Clazz JAVA_LANG_INTEGER

JAVA_LANG_LONG

public static final JvmType.Clazz JAVA_LANG_LONG

JAVA_LANG_FLOAT

public static final JvmType.Clazz JAVA_LANG_FLOAT

JAVA_LANG_DOUBLE

public static final JvmType.Clazz JAVA_LANG_DOUBLE

JAVA_IO_SERIALIZABLE

public static final JvmType.Clazz JAVA_IO_SERIALIZABLE

JAVA_UTIL_ITERATOR

public static final JvmType.Clazz JAVA_UTIL_ITERATOR

JAVA_LANG_THROWABLE

public static final JvmType.Clazz JAVA_LANG_THROWABLE

JAVA_LANG_RUNTIMEEXCEPTION

public static final JvmType.Clazz JAVA_LANG_RUNTIMEEXCEPTION

JAVA_LANG_VIRTUALMACHINEERROR

public static final JvmType.Clazz JAVA_LANG_VIRTUALMACHINEERROR

JAVA_LANG_NULLPOINTEREXCEPTION

public static final JvmType.Clazz JAVA_LANG_NULLPOINTEREXCEPTION

JAVA_LANG_ARITHMETICEXCEPTION

public static final JvmType.Clazz JAVA_LANG_ARITHMETICEXCEPTION
Constructor Detail

JvmTypes

public JvmTypes()
Method Detail

boxedType

public static JvmType.Clazz boxedType(JvmType.Primitive p)
Given a primitive type, determine the equivalent boxed type. For example, the primitive type int yields the type java.lang.Integer.

Parameters:
p -
Returns:

unboxedType

public static JvmType.Primitive unboxedType(JvmType.Clazz p)
Given a primitive wrapper class (i.e. a boxed type), return the unboxed equivalent. For example, java.lang.Integer yields Type.Int, whilst java.lang.Boolean yields Type.Bool.

Parameters:
p -
Returns:

isBoxedType

public static boolean isBoxedType(JvmType t)
Determine whether or not the given type is a wrapper for a primitive type. E.g. java.lang.Integer is a wrapper for int.

Parameters:
t -
Returns:

isBoxedTypeOf

public static boolean isBoxedTypeOf(JvmType t,
                                    java.lang.String wrapper)
Determine whether or not the given type is a wrapper for a primitive type. E.g. java.lang.Integer is a wrapper for int.

Parameters:
t - --- type to test
wrapper - --- specific wrapper class to look for (i.e. Integer, Boolean, Character).
Returns:

substitute

public static JvmType.Reference substitute(JvmType.Reference type,
                                           java.util.Map<java.lang.String,JvmType.Reference> binding)
This method accepts a binding from type variables to concrete types, and then substitutes each such variable occuring in the target type with its corresponding instantation. For example, suppose we have this binding:
  K -> String
  V -> Integer
 
Then, substituting against HashMap yields HashMap.

Parameters:
type -
binding -
Returns:

substitute

public static JvmType.Function substitute(JvmType.Function type,
                                          java.util.Map<java.lang.String,JvmType.Reference> binding)
This method accepts a binding from type variables to concrete types, and then substitutes each such variable occuring in the target (function) type with its corresponding instantation. For example, suppose we have this binding:
  K -> String
  V -> Integer
 
Then, substituting against v f(K) yields Integer f(String).

Parameters:
type -
binding -
Returns:

isJavaLangObject

public static boolean isJavaLangObject(JvmType t)
Check wither a given type is a reference to java.lang.Object or not.

Parameters:
t -
Returns:

isJavaLangString

public static boolean isJavaLangString(JvmType t)
Check wither a given type is a reference to java.lang.String or not.

Parameters:
t -
Returns:

isClass

public static boolean isClass(java.lang.String pkg,
                              java.lang.String clazz,
                              JvmType t)

isGeneric

public static boolean isGeneric(JvmType t)

isGenericArray

public static boolean isGenericArray(JvmType t)

arrayDepth

public static int arrayDepth(JvmType t)
Return the depth of array nesting. E.g. "int" has 0 depth, "int[]" has depth 1, "int[][]" has depth 2, etc.

Parameters:
t -
Returns:

parentType

public static JvmType.Clazz parentType(JvmType.Clazz t)
Return type representing the enclosing class for the given type, or null if the given type is already outermost. For example, given pkg.Test$inner return pkg.Test.

Parameters:
t -
Returns:

stripGenerics

public static JvmType stripGenerics(JvmType t)
The purpose of this method is to strip the generic information from a type.

Parameters:
t -
Returns:

stripGenerics

public static JvmType.Clazz stripGenerics(JvmType.Clazz ct)

stripGenerics

public static JvmType.Function stripGenerics(JvmType.Function ft)

stripGenerics

public static JvmType stripGenerics(JvmType.Variable vt)

stripGenerics

public static JvmType stripGenerics(JvmType.Wildcard wt)

stripGenerics

public static JvmType.Intersection stripGenerics(JvmType.Intersection wt)


Copyright © 2013 David J. Pearce. All Rights Reserved.