js.tinyvm
Class CodeUtilities

java.lang.Object
  extended by js.tinyvm.CodeUtilities
All Implemented Interfaces:
OpCodeConstants, OpCodeInfo

public class CodeUtilities
extends java.lang.Object
implements OpCodeConstants, OpCodeInfo


Field Summary
 
Fields inherited from interface js.tinyvm.OpCodeConstants
OP_AALOAD, OP_AASTORE, OP_ACONST_NULL, OP_ALOAD, OP_ALOAD_0, OP_ALOAD_1, OP_ALOAD_2, OP_ALOAD_3, OP_ANEWARRAY, OP_ARETURN, OP_ARRAYLENGTH, OP_ASTORE, OP_ASTORE_0, OP_ASTORE_1, OP_ASTORE_2, OP_ASTORE_3, OP_ATHROW, OP_BALOAD, OP_BASTORE, OP_BIPUSH, OP_BREAKPOINT, OP_CALOAD, OP_CASTORE, OP_CHECKCAST, OP_D2F, OP_D2I, OP_D2L, OP_DADD, OP_DALOAD, OP_DASTORE, OP_DCMPG, OP_DCMPL, OP_DCONST_0, OP_DCONST_1, OP_DDIV, OP_DLOAD, OP_DLOAD_0, OP_DLOAD_1, OP_DLOAD_2, OP_DLOAD_3, OP_DMUL, OP_DNEG, OP_DREM, OP_DRETURN, OP_DSTORE, OP_DSTORE_0, OP_DSTORE_1, OP_DSTORE_2, OP_DSTORE_3, OP_DSUB, OP_DUP, OP_DUP_X1, OP_DUP_X2, OP_DUP2, OP_DUP2_X1, OP_DUP2_X2, OP_F2D, OP_F2I, OP_F2L, OP_FADD, OP_FALOAD, OP_FASTORE, OP_FCMPG, OP_FCMPL, OP_FCONST_0, OP_FCONST_1, OP_FCONST_2, OP_FDIV, OP_FLOAD, OP_FLOAD_0, OP_FLOAD_1, OP_FLOAD_2, OP_FLOAD_3, OP_FMUL, OP_FNEG, OP_FREM, OP_FRETURN, OP_FSTORE, OP_FSTORE_0, OP_FSTORE_1, OP_FSTORE_2, OP_FSTORE_3, OP_FSUB, OP_GETFIELD, OP_GETSTATIC, OP_GOTO, OP_GOTO_W, OP_I2B, OP_I2C, OP_I2D, OP_I2F, OP_I2L, OP_I2S, OP_IADD, OP_IALOAD, OP_IAND, OP_IASTORE, OP_ICONST_0, OP_ICONST_1, OP_ICONST_2, OP_ICONST_3, OP_ICONST_4, OP_ICONST_5, OP_ICONST_M1, OP_IDIV, OP_IF_ACMPEQ, OP_IF_ACMPNE, OP_IF_ICMPEQ, OP_IF_ICMPGE, OP_IF_ICMPGT, OP_IF_ICMPLE, OP_IF_ICMPLT, OP_IF_ICMPNE, OP_IFEQ, OP_IFGE, OP_IFGT, OP_IFLE, OP_IFLT, OP_IFNE, OP_IFNONNULL, OP_IFNULL, OP_IINC, OP_ILOAD, OP_ILOAD_0, OP_ILOAD_1, OP_ILOAD_2, OP_ILOAD_3, OP_IMUL, OP_INEG, OP_INSTANCEOF, OP_INVOKEINTERFACE, OP_INVOKESPECIAL, OP_INVOKESTATIC, OP_INVOKEVIRTUAL, OP_IOR, OP_IREM, OP_IRETURN, OP_ISHL, OP_ISHR, OP_ISTORE, OP_ISTORE_0, OP_ISTORE_1, OP_ISTORE_2, OP_ISTORE_3, OP_ISUB, OP_IUSHR, OP_IXOR, OP_JSR, OP_JSR_W, OP_L2D, OP_L2F, OP_L2I, OP_LADD, OP_LALOAD, OP_LAND, OP_LASTORE, OP_LCMP, OP_LCONST_0, OP_LCONST_1, OP_LDC, OP_LDC_W, OP_LDC2_W, OP_LDIV, OP_LLOAD, OP_LLOAD_0, OP_LLOAD_1, OP_LLOAD_2, OP_LLOAD_3, OP_LMUL, OP_LNEG, OP_LOOKUPSWITCH, OP_LOR, OP_LREM, OP_LRETURN, OP_LSHL, OP_LSHR, OP_LSTORE, OP_LSTORE_0, OP_LSTORE_1, OP_LSTORE_2, OP_LSTORE_3, OP_LSUB, OP_LUSHR, OP_LXOR, OP_MONITORENTER, OP_MONITOREXIT, OP_MULTIANEWARRAY, OP_NEW, OP_NEWARRAY, OP_NOP, OP_POP, OP_POP2, OP_PUTFIELD, OP_PUTSTATIC, OP_RET, OP_RETURN, OP_SALOAD, OP_SASTORE, OP_SIPUSH, OP_SWAP, OP_TABLESWITCH, OP_WIDE, OP_XXXUNUSEDXXX
 
Fields inherited from interface js.tinyvm.OpCodeInfo
OP_GETFIELD_1, OP_GETSTATIC_1, OP_GETSTATIC_2, OP_GETSTATIC_3, OP_GETSTATIC_4, OP_LDC_1, OP_LDC_2, OP_LDC_3, OP_LDC_4, OP_PUTFIELD_1, OP_PUTSTATIC_1, OP_PUTSTATIC_2, OP_PUTSTATIC_3, OP_PUTSTATIC_4, OPCODE_ARGS, OPCODE_NAME
 
Constructor Summary
CodeUtilities(java.lang.String aMethodName, org.apache.bcel.classfile.JavaClass aCF, Binary aBinary)
           
 
Method Summary
 void exitOnBadOpCode(int aOpCode)
           
static java.lang.String fullMethod(org.apache.bcel.classfile.JavaClass aCF, java.lang.String aMethodName)
           
 int genConstantLoad(int aPoolIndex)
          Process a constant load operation.
 int genStaticAccess(int aPoolIndex, int optInst, int normInst)
          Generate and instruction to access a static field.
 void markArray(int aPoolIndex)
          Mark an array as being used.
 void markClass(int aPoolIndex)
          Mark the class as being used.
 void markPrimitiveArray(byte type)
          Mark a primitive array as being used.
 int processArray(int aPoolIndex)
          Process and array index.
 void processCalls(byte[] aCode, org.apache.bcel.classfile.JavaClass aClassFile, Binary aBinary)
           
 int processClassIndex(int aPoolIndex)
          Process a class index.
 byte[] processCode(byte[] aCode)
           
 int processConstantIndex(int aPoolIndex)
          Process a constant index.
 int processMultiArray(int aPoolIndex)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CodeUtilities

public CodeUtilities(java.lang.String aMethodName,
                     org.apache.bcel.classfile.JavaClass aCF,
                     Binary aBinary)
Method Detail

exitOnBadOpCode

public void exitOnBadOpCode(int aOpCode)
                     throws TinyVMException
Throws:
TinyVMException

fullMethod

public static java.lang.String fullMethod(org.apache.bcel.classfile.JavaClass aCF,
                                          java.lang.String aMethodName)

processConstantIndex

public int processConstantIndex(int aPoolIndex)
                         throws TinyVMException
Process a constant index. Given a reference to the constant pool, return the corresponding index into the leJOS constant table.

Parameters:
aPoolIndex - the constant pool index
Returns:
The constant table index
Throws:
TinyVMException

processClassIndex

public int processClassIndex(int aPoolIndex)
                      throws TinyVMException
Process a class index. Given a constant pool index for a class object, return the corresponding index into the leJOS class table.

Parameters:
aPoolIndex - the constant pool index
Returns:
the class table index
Throws:
TinyVMException

processArray

public int processArray(int aPoolIndex)
                 throws TinyVMException
Process and array index. Given an index into the constant pool for an array class, return the corresponding index into the leJOS class table.

Parameters:
aPoolIndex - the constant index for the array
Returns:
the class table index.
Throws:
TinyVMException

processMultiArray

public int processMultiArray(int aPoolIndex)
                      throws TinyVMException
Throws:
TinyVMException

markClass

public void markClass(int aPoolIndex)
               throws TinyVMException
Mark the class as being used.

Parameters:
aPoolIndex -
Throws:
TinyVMException

markArray

public void markArray(int aPoolIndex)
               throws TinyVMException
Mark an array as being used.

Parameters:
aPoolIndex - The constant pool index for the array.
Throws:
TinyVMException

markPrimitiveArray

public void markPrimitiveArray(byte type)
                        throws TinyVMException
Mark a primitive array as being used.

Parameters:
type - The primitive type of the array.
Throws:
TinyVMException

genConstantLoad

public int genConstantLoad(int aPoolIndex)
                    throws TinyVMException
Process a constant load operation. Given a reference to the constant pool, return the corresponding instruction and index required to load it.

Parameters:
aPoolIndex - the constant pool index
Returns:
The constant load instruction.
Throws:
TinyVMException

genStaticAccess

public int genStaticAccess(int aPoolIndex,
                           int optInst,
                           int normInst)
                    throws TinyVMException
Generate and instruction to access a static field.

Parameters:
aPoolIndex - The field to access
optInst - The optimized version of the instruction
normInst - The normal version of the instruction.
Returns:
Throws:
TinyVMException

processCode

public byte[] processCode(byte[] aCode)
                   throws TinyVMException
Throws:
TinyVMException

processCalls

public void processCalls(byte[] aCode,
                         org.apache.bcel.classfile.JavaClass aClassFile,
                         Binary aBinary)
                  throws TinyVMException
Throws:
TinyVMException