module Instruction:sig
..end
Instructions are high-level code elements,
low-level elements being provided by ByteCode
module.
typeshort_offset =
Utils.s2
typelong_offset =
Utils.s4
type
t =
| |
AALOAD |
(* | load reference from array. | *) |
| |
AASTORE |
(* | store into reference array. | *) |
| |
ACONST_NULL |
(* | push null. | *) |
| |
ALOAD of |
(* | load reference from local variable. | *) |
| |
ALOAD_0 |
(* | load reference from local variable. | *) |
| |
ALOAD_1 |
(* | load reference from local variable. | *) |
| |
ALOAD_2 |
(* | load reference from local variable. | *) |
| |
ALOAD_3 |
(* | load reference from local variable. | *) |
| |
ANEWARRAY of |
(* | create new array of references. | *) |
| |
ARETURN |
(* | return reference from method. | *) |
| |
ARRAYLENGTH |
(* | get length of array. | *) |
| |
ASTORE of |
(* | store reference into local variable. | *) |
| |
ASTORE_0 |
(* | store reference into local variable. | *) |
| |
ASTORE_1 |
(* | store reference into local variable. | *) |
| |
ASTORE_2 |
(* | store reference into local variable. | *) |
| |
ASTORE_3 |
(* | store reference into local variable. | *) |
| |
ATHROW |
(* | throw exception or error. | *) |
| |
BALOAD |
(* | load byte or boolean from array. | *) |
| |
BASTORE |
(* | store into byte or boolean array. | *) |
| |
BIPUSH of |
(* | push byte. | *) |
| |
CALOAD |
(* | load char from array. | *) |
| |
CASTORE |
(* | store into char array. | *) |
| |
CHECKCAST of |
(* | check whether object is of given type. | *) |
| |
D2F |
(* | convert double to float. | *) |
| |
D2I |
(* | convert double to int. | *) |
| |
D2L |
(* | convert double to long. | *) |
| |
DADD |
(* | add double. | *) |
| |
DALOAD |
(* | load double from array. | *) |
| |
DASTORE |
(* | store into double array. | *) |
| |
DCMPG |
(* | compare double. | *) |
| |
DCMPL |
(* | compare double. | *) |
| |
DCONST_0 |
(* | push double. | *) |
| |
DCONST_1 |
(* | push double. | *) |
| |
DDIV |
(* | divide double. | *) |
| |
DLOAD of |
(* | load double from local variable. | *) |
| |
DLOAD_0 |
(* | load double from local variable. | *) |
| |
DLOAD_1 |
(* | load double from local variable. | *) |
| |
DLOAD_2 |
(* | load double from local variable. | *) |
| |
DLOAD_3 |
(* | load double from local variable. | *) |
| |
DMUL |
(* | multiply double. | *) |
| |
DNEG |
(* | negate double. | *) |
| |
DREM |
(* | remainder double. | *) |
| |
DRETURN |
(* | return double from method. | *) |
| |
DSTORE of |
(* | store double into local variable. | *) |
| |
DSTORE_0 |
(* | store double into local variable. | *) |
| |
DSTORE_1 |
(* | store double into local variable. | *) |
| |
DSTORE_2 |
(* | store double into local variable. | *) |
| |
DSTORE_3 |
(* | store double into local variable. | *) |
| |
DSUB |
(* | subtract double. | *) |
| |
DUP |
(* | duplicate the top operand stack value. | *) |
| |
DUP2 |
(* | duplicate the top one or two operand stack values. | *) |
| |
DUP2_X1 |
(* | duplicate the top one or two operand stack values and insert two or three values down. | *) |
| |
DUP2_X2 |
(* | duplicate the top one or two operand stack values and insert two, three, or four values down. | *) |
| |
DUP_X1 |
(* | duplicate the top operand stack value and insert two values down. | *) |
| |
DUP_X2 |
(* | duplicate the top operand stack value and insert two or threee values down. | *) |
| |
F2D |
(* | convert float to double. | *) |
| |
F2I |
(* | convert float to int. | *) |
| |
F2L |
(* | convert float to long. | *) |
| |
FADD |
(* | add float. | *) |
| |
FALOAD |
(* | load float from array. | *) |
| |
FASTORE |
(* | store into float array. | *) |
| |
FCMPG |
(* | compare float. | *) |
| |
FCMPL |
(* | compare float. | *) |
| |
FCONST_0 |
(* | push float. | *) |
| |
FCONST_1 |
(* | push float. | *) |
| |
FCONST_2 |
(* | push float. | *) |
| |
FDIV |
(* | divide float. | *) |
| |
FLOAD of |
(* | load float from local variable. | *) |
| |
FLOAD_0 |
(* | load float from local variable. | *) |
| |
FLOAD_1 |
(* | load float from local variable. | *) |
| |
FLOAD_2 |
(* | load float from local variable. | *) |
| |
FLOAD_3 |
(* | load float from local variable. | *) |
| |
FMUL |
(* | multiply float. | *) |
| |
FNEG |
(* | negate float. | *) |
| |
FREM |
(* | remainder float. | *) |
| |
FRETURN |
(* | return float from method. | *) |
| |
FSTORE of |
(* | store float into local variable. | *) |
| |
FSTORE_0 |
(* | store float into local variable. | *) |
| |
FSTORE_1 |
(* | store float into local variable. | *) |
| |
FSTORE_2 |
(* | store float into local variable. | *) |
| |
FSTORE_3 |
(* | store float into local variable. | *) |
| |
FSUB |
(* | subtract float. | *) |
| |
GETFIELD of |
(* | fetch field from object. | *) |
| |
GETSTATIC of |
(* | get static field from class. | *) |
| |
GOTO of |
(* | branch always. | *) |
| |
GOTO_W of |
(* | branch always. | *) |
| |
I2B |
(* | convert int to byte. | *) |
| |
I2C |
(* | convert int to char. | *) |
| |
I2D |
(* | convert int to double. | *) |
| |
I2F |
(* | convert int to float. | *) |
| |
I2L |
(* | convert int to long. | *) |
| |
I2S |
(* | convert int to short. | *) |
| |
IADD |
(* | add int. | *) |
| |
IALOAD |
(* | load int from array. | *) |
| |
IAND |
(* | boolean AND int. | *) |
| |
IASTORE |
(* | store into int array. | *) |
| |
ICONST_0 |
(* | push int constant. | *) |
| |
ICONST_1 |
(* | push int constant. | *) |
| |
ICONST_2 |
(* | push int constant. | *) |
| |
ICONST_3 |
(* | push int constant. | *) |
| |
ICONST_4 |
(* | push int constant. | *) |
| |
ICONST_5 |
(* | push int constant. | *) |
| |
ICONST_M1 |
(* | push int constant. | *) |
| |
IDIV |
(* | divide int. | *) |
| |
IF_ACMPEQ of |
(* | branch if reference comparison succeeds. | *) |
| |
IF_ACMPNE of |
(* | branch if reference comparison succeeds. | *) |
| |
IF_ICMPEQ of |
(* | branch if int comparison succeeds. | *) |
| |
IF_ICMPGE of |
(* | branch if int comparison succeeds. | *) |
| |
IF_ICMPGT of |
(* | branch if int comparison succeeds. | *) |
| |
IF_ICMPLE of |
(* | branch if int comparison succeeds. | *) |
| |
IF_ICMPLT of |
(* | branch if int comparison succeeds. | *) |
| |
IF_ICMPNE of |
(* | branch if int comparison succeeds. | *) |
| |
IFEQ of |
(* | branch if int comparison with zero succeeds. | *) |
| |
IFGE of |
(* | branch if int comparison with zero succeeds. | *) |
| |
IFGT of |
(* | branch if int comparison with zero succeeds. | *) |
| |
IFLE of |
(* | branch if int comparison with zero succeeds. | *) |
| |
IFLT of |
(* | branch if int comparison with zero succeeds. | *) |
| |
IFNE of |
(* | branch if int comparison with zero succeeds. | *) |
| |
IFNONNULL of |
(* | branch if reference not null. | *) |
| |
IFNULL of |
(* | branch if reference not null. | *) |
| |
IINC of |
(* | increment local variable by constant. | *) |
| |
ILOAD of |
(* | load int from local variable. | *) |
| |
ILOAD_0 |
(* | load int from local variable. | *) |
| |
ILOAD_1 |
(* | load int from local variable. | *) |
| |
ILOAD_2 |
(* | load int from local variable. | *) |
| |
ILOAD_3 |
(* | load int from local variable. | *) |
| |
IMUL |
(* | multiply int. | *) |
| |
INEG |
(* | negate int. | *) |
| |
INSTANCEOF of |
(* | determine if object is of given type. | *) |
| |
INVOKEDYNAMIC of |
(* | invoke instance method; resolve and dispatch based on class. | *) |
| |
INVOKEINTERFACE of |
(* | invoke interface method. | *) |
| |
INVOKESPECIAL of |
(* | invoke instance method; special handling for superclass, private, and instance initialization method invocations. | *) |
| |
INVOKESTATIC of |
(* | invoke a class (static) method. | *) |
| |
INVOKEVIRTUAL of |
(* | invoke instance method; dispatch based on class. | *) |
| |
IOR |
(* | boolean OR int. | *) |
| |
IREM |
(* | remainder int. | *) |
| |
IRETURN |
(* | return int from method. | *) |
| |
ISHL |
(* | shift left int. | *) |
| |
ISHR |
(* | arithmetic shift right int. | *) |
| |
ISTORE of |
(* | store int into local variable. | *) |
| |
ISTORE_0 |
(* | store int into local variable. | *) |
| |
ISTORE_1 |
(* | store int into local variable. | *) |
| |
ISTORE_2 |
(* | store int into local variable. | *) |
| |
ISTORE_3 |
(* | store int into local variable. | *) |
| |
ISUB |
(* | subtract int. | *) |
| |
IUSHR |
(* | logical shift right int. | *) |
| |
IXOR |
(* | boolean XOR int. | *) |
| |
JSR of |
(* | jump subroutine. | *) |
| |
JSR_W of |
(* | jump subroutine (wide index). | *) |
| |
L2D |
(* | convert long to double. | *) |
| |
L2F |
(* | convert long to float. | *) |
| |
L2I |
(* | convert long to int. | *) |
| |
LADD |
(* | add long. | *) |
| |
LALOAD |
(* | load long from array. | *) |
| |
LAND |
(* | boolean AND long. | *) |
| |
LASTORE |
(* | store into long array. | *) |
| |
LCMP |
(* | compare long. | *) |
| |
LCONST_0 |
(* | push long constant. | *) |
| |
LCONST_1 |
(* | push long constant. | *) |
| |
LDC of |
(* | push item from runtime constant pool. | *) |
| |
LDC2_W of |
(* | push long or double from runtime constant pool (wide index). | *) |
| |
LDC_W of |
(* | push item from runtime constant pool (wide index). | *) |
| |
LDIV |
(* | divide long. | *) |
| |
LLOAD of |
(* | load long from local variable. | *) |
| |
LLOAD_0 |
(* | load long from local variable. | *) |
| |
LLOAD_1 |
(* | load long from local variable. | *) |
| |
LLOAD_2 |
(* | load long from local variable. | *) |
| |
LLOAD_3 |
(* | load long from local variable. | *) |
| |
LMUL |
(* | multiply long. | *) |
| |
LNEG |
(* | negate long. | *) |
| |
LOOKUPSWITCH of |
(* | access jump table by key match and jump. | *) |
| |
LOR |
(* | boolean OR long. | *) |
| |
LREM |
(* | remainder long. | *) |
| |
LRETURN |
(* | return long from method. | *) |
| |
LSHL |
(* | shift left long. | *) |
| |
LSHR |
(* | arithmetic shift right long. | *) |
| |
LSTORE of |
(* | store long into local variable. | *) |
| |
LSTORE_0 |
(* | store long into local variable. | *) |
| |
LSTORE_1 |
(* | store long into local variable. | *) |
| |
LSTORE_2 |
(* | store long into local variable. | *) |
| |
LSTORE_3 |
(* | store long into local variable. | *) |
| |
LSUB |
(* | subtract long. | *) |
| |
LUSHR |
(* | logical shift right long. | *) |
| |
LXOR |
(* | boolean XOR long. | *) |
| |
MONITORENTER |
(* | enter monitor for object. | *) |
| |
MONITOREXIT |
(* | exit monitor for object. | *) |
| |
MULTIANEWARRAY of |
(* | create new multidimensional array. | *) |
| |
NEW of |
(* | create new object. | *) |
| |
NEWARRAY of |
(* | create new arrayhandler. | *) |
| |
NOP |
(* | do nothing. | *) |
| |
POP |
(* | pop the top operand stack value. | *) |
| |
POP2 |
(* | pop the top one or two operand stack values. | *) |
| |
PUTFIELD of |
(* | set field in object. | *) |
| |
PUTSTATIC of |
(* | set static field in class. | *) |
| |
RET of |
(* | return from subroutine. | *) |
| |
RETURN |
(* | return void from method. | *) |
| |
SALOAD |
(* | load short from array. | *) |
| |
SASTORE |
(* | store into short array. | *) |
| |
SIPUSH of |
(* | push short. | *) |
| |
SWAP |
(* | swap the top two operand stack values. | *) |
| |
TABLESWITCH of |
(* | access jump table by index and jump. | *) |
| |
WIDE_ALOAD of |
(* | load reference from local variable. | *) |
| |
WIDE_ASTORE of |
(* | store reference into local variable. | *) |
| |
WIDE_DLOAD of |
(* | load double from local variable. | *) |
| |
WIDE_DSTORE of |
(* | store double into local variable. | *) |
| |
WIDE_FLOAD of |
(* | load float from local variable. | *) |
| |
WIDE_FSTORE of |
(* | store float into local variable. | *) |
| |
WIDE_IINC of |
(* | increment local variable by constant. | *) |
| |
WIDE_ILOAD of |
(* | load int from local variable. | *) |
| |
WIDE_ISTORE of |
(* | store int into local variable. | *) |
| |
WIDE_LLOAD of |
(* | load long from local variable. | *) |
| |
WIDE_LSTORE of |
(* | store long into local variable. | *) |
| |
WIDE_RET of |
(* | return from subroutine. | *) |
val equal : t -> t -> bool
val compare : t -> t -> int
val hash : t -> int
type
error =
| |
Invalid_pool_element |
| |
Invalid_field |
| |
Invalid_dynamic_method |
| |
Invalid_interface_method |
| |
Invalid_method |
| |
Invalid_parameter |
| |
Invalid_primitive_type |
| |
Invalid_switch_cases |
| |
Invalid_pool_index |
| |
Invalid_pool_entry |
| |
Invalid_primitive_array_type |
| |
Invalid_index |
| |
Invalid_array_element |
| |
Invalid_class_name |
| |
Invalid_unsigned_byte |
| |
Invalid_byte |
| |
Invalid_unsigned_short |
| |
Invalid_signed_short |
| |
Invalid_signed_long |
| |
Invalid_short_offset |
| |
Invalid_long_offset |
| |
Invalid_number_of_arguments |
| |
Unknown_instruction |
| |
Invalid_method_handle |
| |
Too_many_bootstrap_specifiers |
exception Exception of error
val string_of_error : error -> string
val decode : Bootstrap.methods -> ConstantPool.t -> ByteCode.instruction -> t
decode bsm cpool i
decodes instruction i
using constant pool cpool
,
and bootstrap information bsm
.
Raise Exception
if an instruction parameter is invalid.
Raise ConstantPool.Exception
if a constant pool index is invalid.
Raise Exception
if constant pool is invalid.val encode : Bootstrap.methods ->
ConstantPool.extendable -> t -> ByteCode.instruction
encode bsm cpool i
encodes instruction i
using constant pool cpool
,
and bootstrap information bsm
.
Raise ConstantPool.Exception
if constant pool is too large.
Raise Exception
if an instruction parameter is invalid.type
parameter =
| |
Int_constant of |
(* | Constant parameter: integer value. | *) |
| |
Offset of |
(* | Constant parameter: offset value. | *) |
| |
Float_constant of |
(* | Constant parameter: float value. | *) |
| |
String_constant of |
(* | Constant parameter: string value. | *) |
| |
Class_name of |
(* | Reference to a class. | *) |
| |
Array_type of |
(* | Reference to an array type. | *) |
| |
Primitive_type of |
(* | Reference to a primitive type. | *) |
| |
Field of |
(* | Reference to a field (either static or instance one). | *) |
| |
Dynamic_method of |
(* | Reference to a dynamic method: method name and descriptor but no receiver. | *) |
| |
Method of |
(* | Reference to a method (either static or instance one). | *) |
| |
Array_method of |
(* | Reference to an array method: name and descriptor with an array type as receiver. | *) |
| |
Method_type_constant of |
(* | Constant method type (parameters and return type). | *) |
| |
Method_handle_constant of |
(* | Constant method handle (reference to field of method). | *) |
type
parameters_tail =
| |
No_tail |
(* | No additional parameter. | *) |
| |
Match_offset_pairs of |
(* | List of match/offset pairs (used for lookup switches). | *) |
| |
Long_offsets of |
(* | List of offsets (used for table switches). | *) |
val compile : int ->
bool ->
string ->
parameter list ->
parameters_tail -> int * t
compile ofs wide mnemo params param_tail
compiles instruction whose
mnemonic is mnemo
, params
and param_tail
being parameters while
wide
indicates whether the wide version of the instruction should
be compiled. ofs
is the compilation offset; the returned couple
consists of instruction size and compiled instruction.
Raises Exception
if instruction does not exist or is passed invalid
parameters.val decompile : int ->
t ->
int * bool * string * parameter list *
parameters_tail
decompile ofs i
decompiles instruction i
at offset ofs
.
Returns (sz, wide, mnemo, p, t)
where: sz
is instruction size,
wide
indicates whether the instruction is a wide one,
mnemo
is instruction mnemonic, and p
and t
are parameters.val size_of : int -> t -> int
size_of ofs i
returns the size of instruction i
at offset ofs
.val size_of_list : int -> t list -> int
size_of_list ofs l
returns the size of instruction list l
at
offset ofs
.val version_bounds : t -> Version.bounds