|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgnu.jel.ClassFile
public class ClassFile
This class represents a classfile image in JEL.
Constructor Summary | |
---|---|
ClassFile(int modifiers,
String name,
Class superClass,
Class[] interfaces,
LocalField[] fields)
Starts creation of a new class file. |
Method Summary | |
---|---|
ClassFile |
clone()
Makes a clone of this object. |
void |
code(long op)
code up to 8 operations. |
void |
codeB(long op)
|
void |
codeLDC(Object o,
int primitiveID)
generates code for code loading constant of primitive type or string. |
void |
codeM(Member m)
|
byte[] |
getImage()
Finishes class and returns the resulting bytecode. |
int |
getIndex(Object item,
int typeid)
Used to determine an old CP index or to create a new one for an item. |
void |
newMethod(LocalMethod m,
Class[] vars)
Starts a new method of this class. |
void |
noteStk(int s,
int a)
Notes removal of typeID s and subsequent addition of typeID a to Java stack. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public ClassFile(int modifiers, String name, Class superClass, Class[] interfaces, LocalField[] fields)
Sizes of fAccess, fNames and fTypes arrays must be the same.
modifiers
- sum of one or more of PUBLIC, FINAL,
INTERFACE, ABSTRACT
constants of java.lang.reflect.Modifiername
- is the name of new class (must be in Java historical form,
i.e. with dots replaced by slashes '/')superClass
- is the superclass of this classinterfaces
- array of interfaces this class implementsfields
- fields this class will haveMethod Detail |
---|
public ClassFile clone()
This is used in JEL to avoid step-by step creation of service
methods of gnu.jel.CompiledExpression (
public void newMethod(LocalMethod m, Class[] vars)
m
- method descriptor.vars
- types of local variables by number.public byte[] getImage()
public void noteStk(int s, int a)
If either is negative the corresponding operation (addition/removal) is skipped. This method is needed to allow ClassFile to compute the maximum stack occupation for the generated code. It is responsibility of the user (of this class) to call noteStk() each time the stack is changed from within the code.
s
- typeid to be put on stack (-1 if none).a
- typeid to be taken off Java stack (-1 if none).public final void codeB(long op)
public final void codeM(Member m)
public final void code(long op)
Additionally to Java bytecodes this method accepts (and interprets) some more commands. See the implementation.
op
- operations to code (least significant bytes coded first).public final void codeLDC(Object o, int primitiveID)
o
- reflection object or String containing the constantprimitiveID
- type ID to save lookups.public int getIndex(Object item, int typeid)
item
- an item to create or get an index fortypeid
- identifies type of argument to avoid linear searches
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |