gnu.jel
Class ClassFile

java.lang.Object
  |
  +--gnu.jel.ClassFile
All Implemented Interfaces:
java.lang.Cloneable

public class ClassFile
extends java.lang.Object
implements java.lang.Cloneable

This class represents a classfile image in JEL.


Field Summary
protected  int currJump
           
protected  LocalMethod currMethod
           
protected  boolean invert_next_jump
           
static java.lang.Class[] specialClasses
           
static Member[] specialMethods
           
protected  gnu.jel.PatchableByteArrayOutputStream textData
           
protected  TypesStack typesStk
           
 
Constructor Summary
ClassFile(int modifiers, java.lang.String name, java.lang.Class superClass, java.lang.Class[] interfaces, LocalField[] fields)
          Starts creation of a new class file.
 
Method Summary
 void branch_end()
          Finishes generation of code for conditional.
 void branch_false()
          Starts generation of code when condition is "true".
 void branch_true()
          Starts generation of code when condition is "true".
 java.lang.Object clone()
          Makes a clone of this object.
 void code(long op)
           
 void codeB(long op)
           
 void codeI(int ind)
           
 void codeLDC(java.lang.Object o, int primitiveID)
           
protected  void ensure_jump()
           
protected  void ensure_value()
           
 byte[] getImage()
           
 int getIndex(java.lang.Object item, int typeid)
          Used to determine an old CP index or to create a new one for an item.
static java.lang.String getSignature(java.lang.Class cls)
          Computes the signature of the given class.
static java.lang.String getSignature(Member m)
          Computes signature of the given member.
protected  void labels_block()
           
protected  void labels_unblock_not()
           
protected  void labels_unblock()
           
protected  void logical_end(boolean and)
           
protected  void logical_param(boolean and)
           
static void main(java.lang.String[] args)
          Performs unitary test of the code generator.
 void newMethod(LocalMethod m, java.lang.Class[] vars)
          Starts a new method of this class.
static void test(Tester t)
          Performs unitary test of the code generator.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

textData

protected gnu.jel.PatchableByteArrayOutputStream textData

currMethod

protected LocalMethod currMethod

typesStk

protected TypesStack typesStk

currJump

protected int currJump

invert_next_jump

protected boolean invert_next_jump

specialClasses

public static final java.lang.Class[] specialClasses

specialMethods

public static final Member[] specialMethods
Constructor Detail

ClassFile

public ClassFile(int modifiers,
                 java.lang.String name,
                 java.lang.Class superClass,
                 java.lang.Class[] interfaces,
                 LocalField[] fields)
Starts creation of a new class file.

Sizes of fAccess, fNames and fTypes arrays must be the same.

Parameters:
modifiers - sum of one or more of PUBLIC, FINAL, INTERFACE, ABSTRACT constants of java.lang.reflect.Modifier
name - is the name of new class (can be null to denote that the unique name should be automatically generated and belong to gnu.jel.generated package)
superClass - is the superclass of this class
interfaces - array of interfaces this class implements
fAccess - array of modifiers for each field, each modifier can be a sum of one or more of PUBLIC, PRIVATE, PROTECTED, STATIC, FINAL, VOLATILE, TRANSIENT constants defined in java.lang.reflect.Modifier
fNames - array of names of all fields.
fTypes - array of Classes representing types of all fields.
Method Detail

clone

public java.lang.Object clone()
Makes a clone of this object.
Overrides:
clone in class java.lang.Object
Returns:
a clone of this object

newMethod

public void newMethod(LocalMethod m,
                      java.lang.Class[] vars)
Starts a new method of this class.
Parameters:
m - method descriptor.
vars - types of local variables..

getImage

public byte[] getImage()

labels_block

protected void labels_block()

labels_unblock

protected void labels_unblock()

labels_unblock_not

protected void labels_unblock_not()

ensure_jump

protected final void ensure_jump()

ensure_value

protected final void ensure_value()

branch_true

public void branch_true()
Starts generation of code when condition is "true".

branch_false

public void branch_false()
Starts generation of code when condition is "true".

branch_end

public void branch_end()
Finishes generation of code for conditional.
See Also:
branch_true()

logical_param

protected void logical_param(boolean and)

logical_end

protected void logical_end(boolean and)

codeB

public final void codeB(long op)

code

public final void code(long op)

codeLDC

public final void codeLDC(java.lang.Object o,
                          int primitiveID)

codeI

public final void codeI(int ind)

getIndex

public int getIndex(java.lang.Object item,
                    int typeid)
Used to determine an old CP index or to create a new one for an item.
Parameters:
item - an item to create or get an index for
typeid - identifies type of argument to avoid linear searches
Returns:
index for an item (negative if it has to be written)

getSignature

public static java.lang.String getSignature(Member m)
Computes signature of the given member.
Parameters:
m - the member to compute the sugnature of.
Returns:
the signature.

getSignature

public static java.lang.String getSignature(java.lang.Class cls)
Computes the signature of the given class.

The signature of the class (Field descriptor) is the string and it's format is described in the paragraph 4.3.2 of the Java VM specification (ISBN 0-201-63451-1).

The same can be done using java.lang.Class.getName() by converting it's result into the "historical form".

This utility method can be used outside of the JEL package it does not involve any JEL specific assumptions and should follow JVM Specification precisely.

Parameters:
cls - is the class to compute the signature of. Can be primitive or array type.
Returns:
the class signature.

main

public static void main(java.lang.String[] args)
Performs unitary test of the code generator.
Parameters:
args - ignored.

test

public static void test(Tester t)
Performs unitary test of the code generator.

Used if all package is being tested and not just codegen.

Parameters:
t - Tester to report test results.