module JCode:sig..end
High level Ocaml representation of JVM opcodes.
typejconst =[ `ANull
| `Byte of int
| `Class of JBasics.object_type
| `Double of float
| `Float of float
| `Int of int32
| `Long of int64
| `MethodHandle of JBasics.method_handle
| `MethodType of JBasics.method_descriptor
| `Short of int
| `String of JBasics.jstr ]
typejinterface_or_class =[ `Class | `Interface ]
type jopcode =
| |
OpLoad of |
|||
| |
OpStore of |
|||
| |
OpIInc of |
(* | index, increment | *) |
| |
OpPop |
|||
| |
OpPop2 |
|||
| |
OpDup |
|||
| |
OpDupX1 |
|||
| |
OpDupX2 |
|||
| |
OpDup2 |
|||
| |
OpDup2X1 |
|||
| |
OpDup2X2 |
|||
| |
OpSwap |
|||
| |
OpConst of |
|||
| |
OpAdd of |
|||
| |
OpSub of |
|||
| |
OpMult of |
|||
| |
OpDiv of |
|||
| |
OpRem of |
|||
| |
OpNeg of |
|||
| |
OpIShl |
|||
| |
OpLShl |
|||
| |
OpIShr |
|||
| |
OpLShr |
|||
| |
OpIUShr |
|||
| |
OpLUShr |
|||
| |
OpIAnd |
|||
| |
OpLAnd |
|||
| |
OpIOr |
|||
| |
OpLOr |
|||
| |
OpIXor |
|||
| |
OpLXor |
|||
| |
OpI2L |
|||
| |
OpI2F |
|||
| |
OpI2D |
|||
| |
OpL2I |
|||
| |
OpL2F |
|||
| |
OpL2D |
|||
| |
OpF2I |
|||
| |
OpF2L |
|||
| |
OpF2D |
|||
| |
OpD2I |
|||
| |
OpD2L |
|||
| |
OpD2F |
|||
| |
OpI2B |
|||
| |
OpI2C |
|||
| |
OpI2S |
|||
| |
OpCmp of |
|||
| |
OpIf of |
|||
| |
OpIfCmp of |
|||
| |
OpGoto of |
|||
| |
OpJsr of |
|||
| |
OpRet of |
|||
| |
OpTableSwitch of |
(* | (default,low,high,jump offsets) | *) |
| |
OpLookupSwitch of |
(* | (default, (match,offset) list) | *) |
| |
OpNew of |
|||
| |
OpNewArray of |
|||
| |
OpAMultiNewArray of |
(* | ClassInfo, dims | *) |
| |
OpCheckCast of |
|||
| |
OpInstanceOf of |
|||
| |
OpGetStatic of |
|||
| |
OpPutStatic of |
|||
| |
OpGetField of |
|||
| |
OpPutField of |
|||
| |
OpArrayLength |
|||
| |
OpArrayLoad of |
|||
| |
OpArrayStore of |
|||
| |
OpInvoke of |
|||
| |
OpReturn of |
|||
| |
OpThrow |
|||
| |
OpMonitorEnter |
|||
| |
OpMonitorExit |
|||
| |
OpNop |
|||
| |
OpBreakpoint |
|||
| |
OpInvalid |
(* | if | *) |
typejopcodes =jopcode array
type exception_handler = {
|
e_start : |
|
e_end : |
|
e_handler : |
|
e_catch_type : |
Exception handler.
High level representation of code.
type jcode = {
|
c_max_stack : |
|||
|
c_max_locals : |
|||
|
c_code : |
|||
|
c_exc_tbl : |
(* | The list is ordered in the same way as in the bytecode (See JVM Spec se8 §2.10). | *) |
|
c_line_number_table : |
(* | (start_pc, line_number) | *) |
|
c_local_variable_table : |
(* | (start_pc, length, name, type, index) | *) |
|
c_local_variable_type_table : |
(* | LocalVariableTable for generics, described in the JVM Spec se8, §4.7.14 | *) |
|
c_stack_map : |
|||
|
c_attributes : |
Code structure.
val empty : jcodeEmpty list of opcodes
val get_source_line_number : int -> jcode -> int optionget_source_line_number pp m returns the source line number corresponding
to the program point pp of the method code m. The line number give a
rough idea and may be wrong. It uses the attribute LineNumberTable
(cf. JVM Spec se8 §4.7.12).
val get_source_line_number' : int -> (int * int) list -> int optionget_source_line_number pp lnt returns the source line number corresponding
to the program point pp given the LineNumberTable attribute lnt. The
line number give a rough idea and may be wrong. It uses the attribute
LineNumberTable (cf. JVM Spec se8 §4.7.12).
val get_local_variable_info : int -> int -> jcode -> (string * JBasics.value_type) optionget_local_variable_info i pp m returns the name and signature of
the local variable i at program point pp in the method code
m (including the pp of the first assignement of i, it's not
the case in c_local_variable_table), if they are defined in the
local variable table (The bytecode needs to be compiled with the
-g option). Otherwise the value None is returned.
val replace_code : ?update_max_stack:bool ->
jcode -> int -> jopcode list -> jcodereplace_code code pp l replaces the opcode present at program
point pp in the code with the instructions contained in l.
For consistency, the program point pp must not refer to an
OpInvalid instruction, and the list of instructions l should
contain a correct number of OpInvalid after each core instruction
in order to fulfill a correct line numbering of the generated
bytecode.
val insert_code : ?update_max_stack:bool ->
jcode -> int -> jopcode list -> jcodeinsert_code code pp l insert the the instructions contained in
l at program point pp in the code. For consistency, the
program point pp must not refer to an OpInvalid instruction,
and the list of instructions l should contain a correct number of
OpInvalid after each core instruction in order to fulfill a
correct line numbering of the generated bytecode.
type lambda_info = {
|
functional_interface : |
|
captured_arguments : |
|
checkcast_arguments : |
|
lambda_handle : |
val build_lambda_info : JBasics.bootstrap_method -> JBasics.method_signature -> lambda_infobuild_lambda_info bm ms builds an information caracterizing the
construction of the lambda expression referenced by the opcode
OpInvoke (`Dynamic bm, ms).