nz.net.juju.jaune
Class CodeSection

java.lang.Object
  |
  +--nz.net.juju.jaune.CodeSection

public class CodeSection
extends java.lang.Object

A CodeSection is the smallest emittable block, and can contain such things as all of the code for a method, a class header, a constant string definiton etc. Everything in the section must exist in the same area (data, bss, code). Includes support for tracking in-method labels. RETARGET: The area definitions need to be pulled out.


Field Summary
static java.lang.String BSS
          Section for all variable un-inited data, such as static fields.
static java.lang.String CLINIT
          Section for static initialiser data
static java.lang.String CODE
          Section for all code data, such as methods or classes
static java.lang.String CONST
          Section for all constant data, such as strings.
 
Constructor Summary
CodeSection(java.lang.String area)
           
 
Method Summary
 void add(java.lang.String op)
          Add a normal line
 void addDebug(java.lang.String msg)
          Add a debug line
 void addLabel(Label label)
          Add a explicit label
 void addLabel(java.lang.String label)
           
 java.lang.String getArea()
           
 Label getLabelForPC(int pc)
          Returns the Label that can be used to reference the given PC within the method.
 void markPC(int pc)
          Marks that the following lines related to the given PC.
 void markTarget(int abs)
          Mark the given PC as being referenced, so that when the section is emitted a label will be included at that PC.
 void print(java.io.PrintStream out, PeepholeOptimiser opt)
          Print this section to the given output, running the given peephole rules if supplied.
 void setLabel(java.lang.String label)
          Set the label to emmit at the start of this section.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CONST

public static final java.lang.String CONST
Section for all constant data, such as strings.

CLINIT

public static final java.lang.String CLINIT
Section for static initialiser data

CODE

public static final java.lang.String CODE
Section for all code data, such as methods or classes

BSS

public static final java.lang.String BSS
Section for all variable un-inited data, such as static fields.
Constructor Detail

CodeSection

public CodeSection(java.lang.String area)
Method Detail

getArea

public java.lang.String getArea()

markPC

public void markPC(int pc)
Marks that the following lines related to the given PC. This PC may later be referenced by markTarget().

markTarget

public void markTarget(int abs)
Mark the given PC as being referenced, so that when the section is emitted a label will be included at that PC.

getLabelForPC

public Label getLabelForPC(int pc)
Returns the Label that can be used to reference the given PC within the method. Used for jumps etc.

add

public void add(java.lang.String op)
Add a normal line

addDebug

public void addDebug(java.lang.String msg)
Add a debug line

addLabel

public void addLabel(Label label)
Add a explicit label

addLabel

public void addLabel(java.lang.String label)

setLabel

public void setLabel(java.lang.String label)
Set the label to emmit at the start of this section.

print

public void print(java.io.PrintStream out,
                  PeepholeOptimiser opt)
Print this section to the given output, running the given peephole rules if supplied.
Parameters:
rules - May be null.