jbet
Class Snippit
java.lang.Object
jbet.Snippit
public class Snippit
- extends java.lang.Object
This class encapsulates a list of instructions, including
exception ranges. All branches are stored as pointers so
non-length preserveing transformations can be made with ease.
A lot of the functionality in this class is only meant to be called
by MethodInfo, specificly, the functions involveing reading and
writeing to a file. They really aren't usefull on their own.
Things that specify ranges in the classfile are of the form [a, b)
that is highly inconvienient because there is nothing for b to
point to if it is off the end of the snippit; therefore Snippit
stores ranges as [a, b] internaly and translates to the half-open
form when reading and writing.
all of the insert instructions destroy their arguements. This is
because copying a snippit is a rather expensive operation.
- Since:
- JDK 1.1.8
Method Summary |
void |
addLinesAsPCs(jbet.ConstantPool cp)
|
void |
append(Snippit snippit)
|
void |
assemble(Lexer lexer,
Instruction place,
int state,
MethodInfo mi)
This assembles a snippit, and possibly some options for a methodinfo
Lexer is the input stream, place is where to put the assembled
instructions and state is INS_AT, INS_OVER, INS_AFTER, or INS_BEFORE. |
void |
assemble(java.lang.String str)
|
void |
comment(java.lang.String s)
|
static Snippit.Instructions |
cString(java.lang.String s)
|
void |
disassemble(LineWriter out,
java.lang.String prefix)
|
boolean |
empty()
|
ExceptionRec |
exAt(int i)
|
Instruction |
first()
|
void |
grabRecs(Snippit snippit)
|
void |
insertAfter(Instruction instr,
Instruction newinst)
|
void |
insertAfter(Instruction instr,
Snippit snippit)
|
void |
insertAt(Instruction instr,
Snippit snippit)
|
void |
insertBefore(Instruction instr,
Snippit snippit)
|
void |
insertOver(Instruction instr,
Snippit snippit)
|
InstrEnum |
instrs()
|
Instruction |
last()
|
jbet.LineNumRec |
lnAt(int i)
|
jbet.LocalVarRec |
lvAt(int i)
|
int |
maxcodesize()
|
void |
moveDown(Type top,
Type[] ts)
|
int |
numEx()
|
Instruction |
pop_norec()
|
Instruction |
pop()
|
void |
prepend(Snippit snippit)
|
void |
printCode(LineWriter out,
boolean lines)
|
void |
printCode(LineWriter out,
boolean lines,
boolean counts)
|
Snippit |
println(Snippit.Instructions[] strings)
|
Snippit |
println(Snippit.Instructions a,
Snippit.Instructions b)
|
Snippit |
println(java.lang.String s)
|
Snippit |
println(Type t)
|
void |
push(Instruction instr)
|
void |
redirect(Instruction from,
Instruction to)
|
void |
remove(Instruction instr)
|
Snippit |
setDupX(Type t,
int x)
append useful instruction sequences |
Snippit |
setPopX(Type t,
int x)
|
Instruction |
shift_norec()
|
Instruction |
shift()
|
Snippit |
splitAt(Instruction last)
|
void |
unshift(Instruction instr)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
JbetLogFacility
public static java.lang.String JbetLogFacility
exVector
public java.util.Vector exVector
lvVector
public java.util.Vector lvVector
lnVector
public java.util.Vector lnVector
Snippit
public Snippit(Snippit s)
Snippit
public Snippit()
instrs
public InstrEnum instrs()
addLinesAsPCs
public void addLinesAsPCs(jbet.ConstantPool cp)
exAt
public ExceptionRec exAt(int i)
numEx
public int numEx()
lnAt
public jbet.LineNumRec lnAt(int i)
lvAt
public jbet.LocalVarRec lvAt(int i)
first
public Instruction first()
last
public Instruction last()
empty
public boolean empty()
insertAt
public void insertAt(Instruction instr,
Snippit snippit)
insertOver
public void insertOver(Instruction instr,
Snippit snippit)
insertAfter
public void insertAfter(Instruction instr,
Instruction newinst)
grabRecs
public void grabRecs(Snippit snippit)
insertAfter
public void insertAfter(Instruction instr,
Snippit snippit)
insertBefore
public void insertBefore(Instruction instr,
Snippit snippit)
redirect
public void redirect(Instruction from,
Instruction to)
append
public void append(Snippit snippit)
prepend
public void prepend(Snippit snippit)
push
public void push(Instruction instr)
unshift
public void unshift(Instruction instr)
remove
public void remove(Instruction instr)
splitAt
public Snippit splitAt(Instruction last)
pop
public Instruction pop()
throws java.lang.ArrayIndexOutOfBoundsException
- Throws:
java.lang.ArrayIndexOutOfBoundsException
pop_norec
public Instruction pop_norec()
throws java.lang.ArrayIndexOutOfBoundsException
- Throws:
java.lang.ArrayIndexOutOfBoundsException
shift
public Instruction shift()
throws java.lang.ArrayIndexOutOfBoundsException
- Throws:
java.lang.ArrayIndexOutOfBoundsException
shift_norec
public Instruction shift_norec()
throws java.lang.ArrayIndexOutOfBoundsException
- Throws:
java.lang.ArrayIndexOutOfBoundsException
comment
public void comment(java.lang.String s)
setDupX
public Snippit setDupX(Type t,
int x)
- append useful instruction sequences
- Parameters:
t
- type of operandsx
- number to dup or pop
- Returns:
- this
setPopX
public Snippit setPopX(Type t,
int x)
println
public Snippit println(java.lang.String s)
println
public Snippit println(Type t)
cString
public static Snippit.Instructions cString(java.lang.String s)
println
public Snippit println(Snippit.Instructions[] strings)
println
public Snippit println(Snippit.Instructions a,
Snippit.Instructions b)
moveDown
public void moveDown(Type top,
Type[] ts)
printCode
public void printCode(LineWriter out,
boolean lines)
printCode
public void printCode(LineWriter out,
boolean lines,
boolean counts)
maxcodesize
public int maxcodesize()
disassemble
public void disassemble(LineWriter out,
java.lang.String prefix)
assemble
public void assemble(java.lang.String str)
throws ClassFileException
- Throws:
ClassFileException
assemble
public void assemble(Lexer lexer,
Instruction place,
int state,
MethodInfo mi)
throws ClassFileException
- This assembles a snippit, and possibly some options for a methodinfo
Lexer is the input stream, place is where to put the assembled
instructions and state is INS_AT, INS_OVER, INS_AFTER, or INS_BEFORE.
if place is null it will just append them, and if mi is null then
it will not accept any MethodInfo options
I know it's kind of wrong to have this thing take a methodinfo and
modify it, but hey, it's easy that way.
- Throws:
ClassFileException