|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.j2s.Java2Scribble
public class Java2Scribble
This class maintains the global (inter-class) information used while converting Java byte codes to Scribble.
$Id: Java2Scribble.java,v 1.29 2007-10-04 19:58:13 burrill Exp $
Copyright 2008 by the
Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Field Summary | |
---|---|
static int |
ARRAYTYPE
|
static IntegerType |
byteType
The Scale representation for the Java byte type. |
static PointerType |
cCharpType
The Scale representation for a pointer to the Java char type. |
static PointerType |
charpType
The Scale representation for a pointer to the Java char type. |
static CharacterType |
charType
The Scale representation for the Java char type. |
static int |
CLASSTYPE
|
ProcedureDecl |
createStringProc
A procedure that constructs a String from an array of shorts. |
static FloatType |
doubleType
The Scale representation for the Java double type. |
ProcedureDecl |
findIntMethodProc
A procedure that finds the address of an interface method. |
FloatLiteral |
float0
The literal for 0.0. |
FloatLiteral |
float1
The literal for 1.0. |
FloatLiteral |
float2
The literal for 2.0. |
static FloatType |
floatType
The Scale representation for the Java float type. |
VariableDecl |
globalExceptionVariable
The global exception variable. |
ProcedureDecl |
instanceOfProc
A procedure that checks if a is an instance of b |
IntLiteral |
int0
The literal for 0. |
IntLiteral |
int1
The literal for 1. |
IntLiteral |
int2
The literal for 2. |
IntLiteral |
int3
The literal for 3. |
IntLiteral |
int4
The literal for 4. |
IntLiteral |
int5
The literal for 5. |
static int |
INTERFACETYPE
|
IntLiteral |
intm1
The literal for -1. |
static PointerType |
intpType
The Scale representation for a pointer to the Java int type. |
static IntegerType |
intType
The Scale representation for the Java int type. |
static IntegerType |
longType
The Scale representation for the Java long type. |
ProcedureDecl |
lookupExceptionProc
A procedure that maps an exception to an index into the methods exception table. |
ProcedureDecl |
makeExceptionProc
A procedure that creates an exception. |
IntLiteral |
nil
The literal for null. |
static IntegerType |
shortType
The Scale representation for the Java short type. |
Type |
stringpType
Of type pointer to the String class. |
static Type[] |
typeMap
Map from Java type specifier (int) to the Scale type. |
static PointerType |
voidp
The Scale representation for the unspecified pointer type. |
Constructor Summary | |
---|---|
Java2Scribble()
|
Method Summary | |
---|---|
void |
addTopGlobal(Declaration d)
Specify that the Declaration is a top level declaration so that it is processed by Clef2C later. |
static void |
cleanup()
Clean up for profiling statistics. |
void |
convertClass(ClassStuff cs,
CallGraph cg)
|
ProcedureType |
createMethodType(Type ct,
java.lang.String descriptor,
boolean isStatic)
Return a Clef ProcedureType for the method. |
void |
defineFunctions()
Create the Declarations for various runtime procedures needed. |
void |
defineStructures()
Each class has a virtual function transfer vector (vtable) associated with it. |
FieldDecl |
findField(ClassStuff cs,
java.lang.String fname)
Return the named FieldDecl in the structure. |
java.lang.String |
genMethodName(java.lang.String className,
java.lang.String mName,
java.lang.String descriptor)
Return the fully qualified name of a method. |
Accessibility |
getAccess(int accessFlags)
Convert from Java method access specifier to Scale access specifier. |
FieldDecl |
getArrayField(java.lang.String fname)
Return the named FieldDecl in the array structure. |
Type |
getArrayHeaderType()
Return the generic array structure type. |
Type |
getArrayType(int type)
Return the array type for the specified Java type. |
ClassStuff |
getClass(java.lang.String cname)
Return the class information for the specified class. |
VariableDecl |
getClassDecl(ClassStuff ecs)
Return the variable defining the class' CLASSENTRY. |
VariableDecl |
getClassDecl(java.lang.String name)
Return the variable defining the class' CLASSENTRY. |
java.util.Enumeration<ClassStuff> |
getClasses()
Return an enumeration of all the classes. |
Vector<Type> |
getClefTypes(java.lang.String descriptor)
Return a vector of AST Type s
corresponding the the types specified in the descriptor. |
Declaration |
getGlobal(java.lang.String name)
Return the top level Declaration for the specified name. |
VariableDecl |
getGlobalVar(ClassStuff cs,
java.lang.String fname)
Return the VariableDecl for the static field of a Java class. |
Literal |
getIntLiteral(int value)
Return return a Clef Literal with the specified value. |
java.lang.Object |
getLiteral(ClassFile cf,
int index)
Return the Clef Literal for the specified constant value. |
ProcedureDecl |
getProcedureDecl(Type ct,
java.lang.String name,
java.lang.String descriptor,
boolean isStatic)
Create a Clef ProcedureDecl for the specified method. |
java.util.Enumeration<Declaration> |
getTopDecls()
Return the special top level Declarations. |
int |
getTypeSpecifier(Type type)
Return the Java type specifier for the Scale type. |
VariableDecl |
getVTableDecl(ClassStuff cs)
Return the virtual table VariableDecl for the class. |
FieldDecl |
getVTableField(java.lang.String fname)
Return the named FieldDecl in the virtual table structure. |
VariableDecl |
makeExceptionTable(ClassFile cf,
java.lang.String methodName,
ExceptionEntry[] entries)
Create the run time exception table for a class' method. |
VariableDecl |
makeStringInit(java.lang.String s)
This method creates the Clef representation of a Java String as an array of shorts. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int CLASSTYPE
public static final int INTERFACETYPE
public static final int ARRAYTYPE
public static final IntegerType byteType
public static final IntegerType shortType
public static final IntegerType intType
public static final IntegerType longType
public static final FloatType floatType
public static final FloatType doubleType
public static final CharacterType charType
public static final PointerType charpType
public static final PointerType cCharpType
public static final PointerType intpType
public static final PointerType voidp
public static final Type[] typeMap
public ProcedureDecl createStringProc
public Type stringpType
public ProcedureDecl findIntMethodProc
public ProcedureDecl makeExceptionProc
public ProcedureDecl lookupExceptionProc
public ProcedureDecl instanceOfProc
public VariableDecl globalExceptionVariable
public final IntLiteral intm1
public final IntLiteral int0
public final IntLiteral int1
public final IntLiteral int2
public final IntLiteral int3
public final IntLiteral int4
public final IntLiteral int5
public final FloatLiteral float0
public final FloatLiteral float1
public final FloatLiteral float2
public final IntLiteral nil
Constructor Detail |
---|
public Java2Scribble()
Method Detail |
---|
public void convertClass(ClassStuff cs, CallGraph cg)
public int getTypeSpecifier(Type type)
public java.util.Enumeration<ClassStuff> getClasses()
ClassStuff
public Declaration getGlobal(java.lang.String name)
public ClassStuff getClass(java.lang.String cname)
cname
- is the name of the classpublic Accessibility getAccess(int accessFlags)
public VariableDecl getGlobalVar(ClassStuff cs, java.lang.String fname)
cs
- specifies the class with the static fieldfname
- is the name of the fieldpublic void addTopGlobal(Declaration d)
public java.util.Enumeration<Declaration> getTopDecls()
public void defineStructures()
The structure of the vtable is as follows:
struct VTABLE { const CLASS *class; // The class structure for this class int interfaceCount; // The number of interfaces implemented by this class INTERFACEENTRY *interfaces; // A list of the interfaces implemented by this class void *methods[0] // The addresses of the virtual methods - there is at least one. };Each INTERFACEENTRY records a different interface:struct INTERFACEENTRY { int hash; // A hash of the interface name const CLASS *class; // The class structure for this interface void *((methods *)[0]); // A pointer to a table of method addresses } ;The CLASS structure is defined asstruct CLASS { const unsigned short *name; const struct CLASS *super; byte kind; };Note - all the addresses that occur in the array pointed to by the methods field are also in the VTABLE instance for the class.
public void defineFunctions()
public VariableDecl getClassDecl(java.lang.String name)
name
- is the name of the classpublic VariableDecl getClassDecl(ClassStuff ecs)
ecs
- is the ClassStuff for the classpublic Type getArrayType(int type)
type
- is the Java typeCodeAttribute
public Vector<Type> getClefTypes(java.lang.String descriptor)
Type
s
corresponding the the types specified in the descriptor.
Type
public java.lang.String genMethodName(java.lang.String className, java.lang.String mName, java.lang.String descriptor)
className
- is the name of the method's classmName
- is the name of the methoddescriptor
- is the Java method descriptorpublic VariableDecl makeStringInit(java.lang.String s)
public VariableDecl makeExceptionTable(ClassFile cf, java.lang.String methodName, ExceptionEntry[] entries)
cf
- is the ClassFile for the classmethodName
- is the name of the methodentries
- is the table of exception handlerspublic java.lang.Object getLiteral(ClassFile cf, int index)
cf
- is the class file containing the constantindex
- is the index of the constant in the constant poolpublic Literal getIntLiteral(int value)
public ProcedureType createMethodType(Type ct, java.lang.String descriptor, boolean isStatic)
ct
- is the type of the 'this' parameterdescriptor
- is the Java method descriptorpublic ProcedureDecl getProcedureDecl(Type ct, java.lang.String name, java.lang.String descriptor, boolean isStatic)
ct
- is the type of the 'this' parametername
- is the name of the methoddescriptor
- is the Java method descriptor
public FieldDecl findField(ClassStuff cs, java.lang.String fname)
cs
- specifies the classfname
- specifies the name of the fieldpublic FieldDecl getArrayField(java.lang.String fname)
public FieldDecl getVTableField(java.lang.String fname)
public VariableDecl getVTableDecl(ClassStuff cs)
public Type getArrayHeaderType()
public static void cleanup()
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |