Class OptiAsmBackEnd

java.lang.Object
  |
  +--OptiAsmBackEnd

class OptiAsmBackEnd
extends java.lang.Object
implements BackEnd, JVM


Field Summary
(package private)  java.util.Hashtable allNatives
          Hashtable of natives found on the path.
(package private)  java.io.PrintWriter asmout
          the output stream for the asm file.
(package private)  java.lang.String asmoutFilename
          the filename of the asm file.
(package private) static int depCounter
          counter for producing unique hash keys.
(package private)  java.lang.String projectname
          the project name
 
Constructor Summary
(package private) OptiAsmBackEnd(java.lang.String projectname, java.lang.String baseDirectory)
          construct an OptiAsmBackEnd from project name and directory.
 
Method Summary
(package private)  java.lang.String commentFilter(java.lang.String s)
          get an abbreviated, one-line version of a string without any dangerous characters, suitable for comments.
(package private)  void copyStream(java.io.InputStream stream, java.lang.String name)
          copy the contents of an open stream to the assembly output stream.
 void generate()
          generate the code.
(package private)  void generateClassTable()
          write the class table to the asm file.
(package private)  void generateClassTableEntry(Klass cl)
          write one class table entry to the asm file.
(package private)  void generateClinitCode()
          write the code that calls the <clinit> methods.
(package private)  void generateConstantStrings()
          write the constant strings.
(package private)  void generateHeader()
          write the (more or less constant) header part of the asm file.
(package private)  void generateLeadout()
          write the leadout code.
(package private)  void generateMethod(MethodInfo method)
          write a single method.
(package private)  void generateMultianewarray(Klass cls, int dimensions, int offsetToLength, java.lang.String labelPrefix)
          generate code for a 'multianewarray' instruction.
(package private)  void generatePilotMain()
          write PalmOS PilotMain code.
(package private)  void generateResources()
          write the resources section.
(package private)  void generateStackAdjust(int delta)
          generate a stack-adjust instruction as a replacement for unneeded bytecodes.
(package private)  void generateStatic()
          write the section for the static fields.
(package private)  void generateSubroutines()
          write the needed subroutines.
(package private)  void generateVtable(Klass cl)
          write the vtable and the classname for this class
(package private)  void generateVtableAll()
          write classname and (if needed) vtable for all classes.
 void insertNatives(Klass cls)
          insert native methods into a class.
(package private)  void loadAllNatives()
          load all native methods.
(package private)  int localToOffset(int local, int argLimit)
          translate a JVM local-var index to a frame-pointer (a6) offset.
(package private)  void report()
           
 java.lang.String toString()
          the full name of this class.
 void updateAll()
          update the 'needed' state of all elements that the back-end's implementation depends upon.
 
Methods inherited from class java.lang.Object
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

asmout

java.io.PrintWriter asmout
the output stream for the asm file.

asmoutFilename

java.lang.String asmoutFilename
the filename of the asm file.

projectname

java.lang.String projectname
the project name

depCounter

static int depCounter
counter for producing unique hash keys.

allNatives

java.util.Hashtable allNatives
Hashtable of natives found on the path.
Constructor Detail

OptiAsmBackEnd

OptiAsmBackEnd(java.lang.String projectname,
               java.lang.String baseDirectory)
construct an OptiAsmBackEnd from project name and directory.
Method Detail

insertNatives

public void insertNatives(Klass cls)
insert native methods into a class. If a java version (from the class file) exists, it is replaced by the native method.
Specified by:
insertNatives in interface BackEnd

updateAll

public void updateAll()
update the 'needed' state of all elements that the back-end's implementation depends upon.
Specified by:
updateAll in interface BackEnd

loadAllNatives

void loadAllNatives()
load all native methods.

copyStream

void copyStream(java.io.InputStream stream,
                java.lang.String name)
copy the contents of an open stream to the assembly output stream.

generate

public void generate()
generate the code.
Specified by:
generate in interface BackEnd

generateHeader

void generateHeader()
write the (more or less constant) header part of the asm file.

generateClassTableEntry

void generateClassTableEntry(Klass cl)
write one class table entry to the asm file.

generateClassTable

void generateClassTable()
write the class table to the asm file.

generateVtable

void generateVtable(Klass cl)
write the vtable and the classname for this class

generateVtableAll

void generateVtableAll()
write classname and (if needed) vtable for all classes.

generateStatic

void generateStatic()
write the section for the static fields.

generateConstantStrings

void generateConstantStrings()
write the constant strings.

generatePilotMain

void generatePilotMain()
write PalmOS PilotMain code.

generateMethod

void generateMethod(MethodInfo method)
write a single method.

generateMultianewarray

void generateMultianewarray(Klass cls,
                            int dimensions,
                            int offsetToLength,
                            java.lang.String labelPrefix)
generate code for a 'multianewarray' instruction. The code leaves the array in register a0.
Parameters:
cls - the array class to be instantiated
dimensions - the number of dimensions
offsetToLength - the stack-relative offset where we find the length for this dimension
labelPrefix - prefix to be used for branch labels within this 'multianewarray' code block

generateStackAdjust

void generateStackAdjust(int delta)
generate a stack-adjust instruction as a replacement for unneeded bytecodes.
Parameters:
delta - the stack growth to be simulated (in 4-byte int-units)

generateClinitCode

void generateClinitCode()
write the code that calls the <clinit> methods.

generateSubroutines

void generateSubroutines()
write the needed subroutines. This is controlled mainly by the JVM opcodes used in the program.

generateLeadout

void generateLeadout()
write the leadout code. This is the DataSize label.

generateResources

void generateResources()
write the resources section.

commentFilter

java.lang.String commentFilter(java.lang.String s)
get an abbreviated, one-line version of a string without any dangerous characters, suitable for comments.

localToOffset

int localToOffset(int local,
                  int argLimit)
translate a JVM local-var index to a frame-pointer (a6) offset.
Parameters:
local - the index of the local var (from the bytecode).
argLimit - the first local-index not belonging to an argument.

toString

public java.lang.String toString()
the full name of this class.
Overrides:
toString in class java.lang.Object

report

void report()