js.tinyvm
Class ClassRecord

java.lang.Object
  extended by js.tinyvm.ClassRecord
All Implemented Interfaces:
WritableData
Direct Known Subclasses:
PrimitiveClassRecord

public class ClassRecord
extends java.lang.Object
implements WritableData

Abstraction for a class record (see vmsrc/language.h).


Constructor Summary
ClassRecord()
           
 
Method Summary
 void addInterfaces(ClassRecord pUserClass)
           
 void addInterfaceUser(ClassRecord pRec)
           
 void addUsedMethod(java.lang.String aRef)
           
 int computeClassSize()
           
static java.lang.String cpEntryId(org.apache.bcel.classfile.Constant aEntry)
           
 void dump(IByteWriter aOut)
          Dump.
 boolean equals(java.lang.Object aObj)
           
 void findHiddenMethods()
           
 int getAllocationSize()
           
static java.lang.String getArrayClassName(java.lang.String aName)
           
 int getArrayDimension()
           
 ClassRecord getArrayElementClass()
           
 java.lang.String getCanonicalName()
           
static ClassRecord getClassRecord(java.lang.String className, ClassPath aCP, Binary aBinary)
           
 int getClassSize()
           
 int getInstanceFieldOffset(java.lang.String aName)
           
 int getLength()
          Returns the length of the record, in bytes.
 java.lang.String getName()
           
 ClassRecord getParent()
           
 PrimitiveClassRecord getPrimitiveClass()
          Return the wrapped class if this class is a wrapper
 java.lang.String getSimpleName()
           
 java.lang.String getSourceFilename()
           
 int getStaticFieldIndex(java.lang.String aName)
           
 int getStaticFieldOffset(java.lang.String aName)
           
 StaticFieldRecord getStaticFieldRecord(java.lang.String aName)
           
 StaticValue getStaticValue(java.lang.String aName)
           
 int hashCode()
           
 boolean hasMethod(Signature aSignature, boolean aStatic)
          (Call only after record has been processed).
 boolean hasParent()
           
 boolean hasReference()
           
 boolean hasStaticInitializer()
           
 void initFlags()
           
 void initParent()
           
 boolean instanceUsed()
           
 boolean isArray()
           
 boolean isInterface()
           
 boolean isPrimitive()
           
 boolean isWrapper()
          Determine if this class is a wrapper
 void markInstanceUsed()
           
 void markMethod(MethodRecord pRec, boolean directCall)
           
 void markMethods()
           
 void markUsed()
           
 java.lang.String signature()
           
 void storeCode(RecordTable<CodeSequence> aCodeSequences, boolean aPostProcess)
           
 void storeConstants(RecordTable<ConstantRecord> aConstantTable, RecordTable<ConstantValue> aConstantValues)
           
 void storeFields(RecordTable<RecordTable<InstanceFieldRecord>> aInstanceFieldTables, RecordTable<StaticFieldRecord> aStaticFields, RecordTable<StaticValue> aStaticState)
           
 void storeInterfaceMap(RecordTable<InterfaceMap> maps)
          Create and store the inetrface map for this interface class.
 void storeMethods(RecordTable<RecordTable<MethodRecord>> aMethodTables, RecordTable<RecordTable<ExceptionRecord>> aExceptionTables, HashVector<Signature> aSignatures, boolean aAll)
           
 void storeOptimizedFields(RecordTable<RecordTable<InstanceFieldRecord>> aInstanceFieldTables)
           
 void storeOptimizedImplementingClasses(RecordTable<ClassRecord> aClassRecords)
          Add the classes which implement this interface into the the set of class records.
 void storeOptimizedMethods(RecordTable<RecordTable<MethodRecord>> aMethodTables, RecordTable<RecordTable<ExceptionRecord>> aExceptionTables, HashVector<Signature> aSignatures)
           
 void storeOptimizedStaticFields(RecordTable<StaticFieldRecord> aStaticFields, RecordTable<StaticValue> aStaticState, int align)
           
 void storeReferredClasses(java.util.HashMap<java.lang.String,ClassRecord> aClasses, RecordTable<ClassRecord> aClassRecords, ClassPath aClassPath, java.util.ArrayList<java.lang.String> aInterfaceMethods)
           
 java.lang.String toString()
           
 void useAllMethods()
           
 boolean used()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ClassRecord

public ClassRecord()
Method Detail

useAllMethods

public void useAllMethods()

getName

public java.lang.String getName()

getCanonicalName

public java.lang.String getCanonicalName()

getSimpleName

public java.lang.String getSimpleName()

getSourceFilename

public java.lang.String getSourceFilename()

getLength

public int getLength()
Description copied from interface: WritableData
Returns the length of the record, in bytes.

Specified by:
getLength in interface WritableData

dump

public void dump(IByteWriter aOut)
          throws TinyVMException
Description copied from interface: WritableData
Dump.

Specified by:
dump in interface WritableData
Parameters:
aOut - writer to write binary to
Throws:
TinyVMException

isArray

public boolean isArray()

isInterface

public boolean isInterface()

isPrimitive

public boolean isPrimitive()

hasStaticInitializer

public boolean hasStaticInitializer()

hasMethod

public boolean hasMethod(Signature aSignature,
                         boolean aStatic)
(Call only after record has been processed).

Parameters:
aSignature -
aStatic -
Returns:

initFlags

public void initFlags()

getAllocationSize

public int getAllocationSize()
                      throws TinyVMException
Returns:
Number of bytes required for object allocation.
Throws:
TinyVMException

getClassSize

public int getClassSize()
                 throws TinyVMException
Returns:
Number of bytes occupied by instance fields.
Throws:
TinyVMException

computeClassSize

public int computeClassSize()
                     throws TinyVMException
Returns:
The size of the class in bytes, including any VM space. This is the exact size required for memory allocation.
Throws:
TinyVMException

hasReference

public boolean hasReference()
                     throws TinyVMException
Throws:
TinyVMException

hasParent

public boolean hasParent()

getParent

public ClassRecord getParent()

initParent

public void initParent()
                throws TinyVMException
Throws:
TinyVMException

getArrayClassName

public static java.lang.String getArrayClassName(java.lang.String aName)

storeReferredClasses

public void storeReferredClasses(java.util.HashMap<java.lang.String,ClassRecord> aClasses,
                                 RecordTable<ClassRecord> aClassRecords,
                                 ClassPath aClassPath,
                                 java.util.ArrayList<java.lang.String> aInterfaceMethods)
                          throws TinyVMException
Throws:
TinyVMException

addUsedMethod

public void addUsedMethod(java.lang.String aRef)

cpEntryId

public static java.lang.String cpEntryId(org.apache.bcel.classfile.Constant aEntry)

getInstanceFieldOffset

public int getInstanceFieldOffset(java.lang.String aName)
                           throws TinyVMException
Throws:
TinyVMException

getStaticFieldOffset

public int getStaticFieldOffset(java.lang.String aName)
                         throws TinyVMException
Parameters:
aName -
Returns:
Offset relative to the start of the static state block.
Throws:
TinyVMException

getStaticValue

public StaticValue getStaticValue(java.lang.String aName)
                           throws TinyVMException
Parameters:
aName - the name of the static field.
Returns:
The StaticValue for the given name
Throws:
TinyVMException

getStaticFieldIndex

public int getStaticFieldIndex(java.lang.String aName)

getStaticFieldRecord

public StaticFieldRecord getStaticFieldRecord(java.lang.String aName)

storeConstants

public void storeConstants(RecordTable<ConstantRecord> aConstantTable,
                           RecordTable<ConstantValue> aConstantValues)
                    throws TinyVMException
Throws:
TinyVMException

storeMethods

public void storeMethods(RecordTable<RecordTable<MethodRecord>> aMethodTables,
                         RecordTable<RecordTable<ExceptionRecord>> aExceptionTables,
                         HashVector<Signature> aSignatures,
                         boolean aAll)
                  throws TinyVMException
Throws:
TinyVMException

storeOptimizedMethods

public void storeOptimizedMethods(RecordTable<RecordTable<MethodRecord>> aMethodTables,
                                  RecordTable<RecordTable<ExceptionRecord>> aExceptionTables,
                                  HashVector<Signature> aSignatures)
                           throws TinyVMException
Throws:
TinyVMException

storeOptimizedStaticFields

public void storeOptimizedStaticFields(RecordTable<StaticFieldRecord> aStaticFields,
                                       RecordTable<StaticValue> aStaticState,
                                       int align)
                                throws TinyVMException
Throws:
TinyVMException

storeOptimizedFields

public void storeOptimizedFields(RecordTable<RecordTable<InstanceFieldRecord>> aInstanceFieldTables)
                          throws TinyVMException
Throws:
TinyVMException

storeFields

public void storeFields(RecordTable<RecordTable<InstanceFieldRecord>> aInstanceFieldTables,
                        RecordTable<StaticFieldRecord> aStaticFields,
                        RecordTable<StaticValue> aStaticState)
                 throws TinyVMException
Throws:
TinyVMException

storeCode

public void storeCode(RecordTable<CodeSequence> aCodeSequences,
                      boolean aPostProcess)
               throws TinyVMException
Throws:
TinyVMException

markMethods

public void markMethods()
                 throws TinyVMException
Throws:
TinyVMException

markMethod

public void markMethod(MethodRecord pRec,
                       boolean directCall)
                throws TinyVMException
Throws:
TinyVMException

getClassRecord

public static ClassRecord getClassRecord(java.lang.String className,
                                         ClassPath aCP,
                                         Binary aBinary)
                                  throws TinyVMException
Throws:
TinyVMException

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

equals

public boolean equals(java.lang.Object aObj)
Overrides:
equals in class java.lang.Object

addInterfaces

public void addInterfaces(ClassRecord pUserClass)

addInterfaceUser

public void addInterfaceUser(ClassRecord pRec)

findHiddenMethods

public void findHiddenMethods()
                       throws TinyVMException
Throws:
TinyVMException

markUsed

public void markUsed()

markInstanceUsed

public void markInstanceUsed()

used

public boolean used()

instanceUsed

public boolean instanceUsed()

getArrayDimension

public int getArrayDimension()

getArrayElementClass

public ClassRecord getArrayElementClass()

signature

public java.lang.String signature()

isWrapper

public boolean isWrapper()
Determine if this class is a wrapper

Returns:
true if the class is a wrapper, otherwise false

getPrimitiveClass

public PrimitiveClassRecord getPrimitiveClass()
Return the wrapped class if this class is a wrapper

Returns:
the primitive class or null if this class is not a wrapper

storeOptimizedImplementingClasses

public void storeOptimizedImplementingClasses(RecordTable<ClassRecord> aClassRecords)
Add the classes which implement this interface into the the set of class records.

Parameters:
aClassRecords - Set of records

storeInterfaceMap

public void storeInterfaceMap(RecordTable<InterfaceMap> maps)
                       throws TinyVMException
Create and store the inetrface map for this interface class. The interface map provides a mechanism for quickly testing if a particular class implements this interface (or a super interface).

Parameters:
maps - the set of ineterface maps.
Throws:
TinyVMException