net.sf.transjvm
Class InstructionStream

java.lang.Object
  extended by net.sf.transjvm.InstructionStream

public class InstructionStream
extends java.lang.Object

Utility stream for writing instruction codes.

Author:
Mark Shannon

Constructor Summary
InstructionStream(ByteStream stream, ConstantPool pool, Frame frame)
           
 
Method Summary
 void _instanceof(TypeID id)
           
 void _new(TypeID id)
           
 void add(int incr)
           
 void addLocalVariableName(int start, int length, java.lang.String name, TypeID type, int index)
           
 int address()
           
 void anewarray(TypeID id)
           
 void athrow()
           
 void bconst(boolean value)
           
 void beginSub()
           
 void branchBackwards(int opcode, int address)
          Inserts a backwards branch.
 int branchForwards(int opcode)
          Inserts a forward branch
 void byteArg(int opcode, int arg)
           
 void checkcast(TypeID id)
           
 void close()
           
 void dconst(double value)
           
 void dup_x1()
           
 void dup_x2()
           
 void dup()
           
 void dup2_x1()
           
 void dup2_x2()
           
 void dup2()
           
 void endSub()
           
 void fconst(float f)
           
 void getfield(FieldID id)
           
 Attribute getLineNumberTable()
           
 Attribute getLocalVariableTable()
           
 void getstatic(FieldID id)
           
 void handleException(int start, int end, TypeID type, int target)
           
 void iconst(int value)
           
 void intArg(int opcode, int arg)
           
 void jumpBackwards(int address)
          Inserts a backwards jump.
 int jumpForwards()
          Inserts a forward jump.
 void lconst(long value)
           
 void line(int line)
          Marks start of new source code line, for debugging.
 int maxStack()
           
 void newarray(TypeID component)
           
 void patch(int address)
          Patches a forward jump or branch, to branch to the current address.
 void pop2()
           
 void putfield(FieldID id)
           
 void putstatic(FieldID id)
           
 void sconst(java.lang.String s)
           
 void shortArg(int opcode, int arg)
           
 void stackDepth(int depth)
          Ensures that the JVM will allocate stack space of no less than depth.
 void write(int value)
           
 void writeInt(int value)
           
 void writeRef(MemberID id)
           
 void writeShortAt(int address, int value)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InstructionStream

public InstructionStream(ByteStream stream,
                         ConstantPool pool,
                         Frame frame)
Method Detail

address

public int address()

writeInt

public void writeInt(int value)

write

public void write(int value)

getLineNumberTable

public Attribute getLineNumberTable()

close

public void close()

maxStack

public int maxStack()

stackDepth

public void stackDepth(int depth)
Ensures that the JVM will allocate stack space of no less than depth.


line

public void line(int line)
Marks start of new source code line, for debugging.


byteArg

public void byteArg(int opcode,
                    int arg)

shortArg

public void shortArg(int opcode,
                     int arg)

intArg

public void intArg(int opcode,
                   int arg)

anewarray

public void anewarray(TypeID id)
Throws:
java.lang.IllegalArgumentException - if id is a primitive type

athrow

public void athrow()

_new

public void _new(TypeID id)
Throws:
java.lang.IllegalArgumentException - if id is a primitive type

checkcast

public void checkcast(TypeID id)
Throws:
java.lang.IllegalArgumentException - if id is a primitive type

dup

public void dup()

dup2

public void dup2()

dup_x1

public void dup_x1()

dup2_x1

public void dup2_x1()

dup_x2

public void dup_x2()

dup2_x2

public void dup2_x2()

getfield

public void getfield(FieldID id)

getstatic

public void getstatic(FieldID id)

add

public void add(int incr)

_instanceof

public void _instanceof(TypeID id)
Throws:
java.lang.IllegalArgumentException - if id is a primitive type

writeRef

public void writeRef(MemberID id)

newarray

public void newarray(TypeID component)

lconst

public void lconst(long value)

dconst

public void dconst(double value)

fconst

public void fconst(float f)

sconst

public void sconst(java.lang.String s)

bconst

public void bconst(boolean value)

iconst

public void iconst(int value)

pop2

public void pop2()

putfield

public void putfield(FieldID id)

putstatic

public void putstatic(FieldID id)

jumpForwards

public int jumpForwards()
Inserts a forward jump. Equivalent to branchForwards(Opcodes.JVM_goto)

Returns:
Address to be passed to patch method.

branchForwards

public int branchForwards(int opcode)
Inserts a forward branch

Parameters:
opcode - Opcode for the branch.
Returns:
Address to be passed to patch method.

branchBackwards

public void branchBackwards(int opcode,
                            int address)
Inserts a backwards branch.

Parameters:
opcode - Opcode for the branch.
address - The target address.

jumpBackwards

public void jumpBackwards(int address)
Inserts a backwards jump. Equivalent to branchBackwards(Opcodes.JVM_goto)

Parameters:
address - The target address.

writeShortAt

public void writeShortAt(int address,
                         int value)

patch

public void patch(int address)
Patches a forward jump or branch, to branch to the current address.

Parameters:
address - the address returned by the coresponding forward jump or branch.

handleException

public void handleException(int start,
                            int end,
                            TypeID type,
                            int target)

beginSub

public void beginSub()

endSub

public void endSub()

getLocalVariableTable

public Attribute getLocalVariableTable()

addLocalVariableName

public void addLocalVariableName(int start,
                                 int length,
                                 java.lang.String name,
                                 TypeID type,
                                 int index)


Copyright 2004-5, Mark Shannon