module ConstantPool: sig
.. end
Constant pool definition as well as i/o functions.
Types
type
element =
Type for constant pool entry.
val equal_element : element -> element -> bool
Equality over pool elements.
val compare_element : element -> element -> int
Comparison over pool elements.
val hash_element : element -> int
Hash function over pool elements.
val dummy_element : element
Element used for 0-index entry as well as for unused long or double
entries.
type
tag =
| |
CONSTANT_Class |
| |
CONSTANT_Fieldref |
| |
CONSTANT_Methodref |
| |
CONSTANT_InterfaceMethodref |
| |
CONSTANT_String |
| |
CONSTANT_Integer |
| |
CONSTANT_Float |
| |
CONSTANT_Long |
| |
CONSTANT_Double |
| |
CONSTANT_NameAndType |
| |
CONSTANT_Utf8 |
| |
CONSTANT_MethodHandle |
| |
CONSTANT_MethodType |
| |
CONSTANT_InvokeDynamic |
| |
CONSTANT_ModuleId |
Type for tag identifying element kind.
type
t
Type for constant pools.
val equal : t -> t -> bool
Equality over pools.
val compare : t -> t -> int
Comparison over pools.
val hash : t -> int
Hash function over pools.
Exception
type
error =
exception Exception of error
val string_of_error : error -> string
I/O functions
val read_element : InputStream.t -> element
val read : InputStream.t -> Utils.u2 -> t
val write_element : OutputStream.t -> element -> unit
val write : OutputStream.t -> t -> unit
Check functions
val size : t -> Utils.u2
Returns the size of the passed pool.
val get_entry : t -> Utils.u2 -> element
get_entry pool index
returns the entry at index
in pool
if
index
is valid, raising Exception
otherwise.
Raises Exception
if an attempt is made to get a dummy element.
val check : t -> unit
Checks the passed pool for consistency.
Raises Exception
if pool is not consistent.
val check_entry_for_kind : t -> Utils.u2 -> tag -> bool
check_entry_for_kind pool index tag
tests whether the entry at
index
is of the kind designated by tag
.
val version_bounds : element -> Version.bounds
Returns the version bounds for the passed pool element.
val check_version : Version.t -> t -> unit
check_version v pool
checks that pool
conforms to version v
,
raising Version.Exception
if not.
Extendable pools
type
extendable
Type for extendable constant pools (used for conversion from class
definitions to class files. The add_xyz
functions below provide
maximum sharing of constant pool elements.
val make_extendable : unit -> extendable
Builds an empty extendable pool.
val make_extendable_from_pool : t -> extendable
Builds an extendable pool from a classic one.
Raises Exception
if the passed pool is too large.
val make_extendable_from_array : element array -> extendable
Builds an extendable pool from an array of elements.
Raises Exception
if the passed array is too large.
val get_extendable_entry : extendable -> Utils.u2 -> element
get_extendable_entry pool index
returns the entry at index
in
pool
if index
is valid, raising Exception
otherwise.
Raises Exception
if an attempt is made to get a dummy element.
val add_class : extendable -> Name.for_class -> Utils.u2
add_class pool class_name
augments pool
with class whose name is
class_name
. Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_array_class : extendable -> Descriptor.array_type -> Utils.u2
add_array_class pool array_type
augments pool
with array type
whose descriptor is array_type
. Returns index of existing or
created entry.
Raises Exception
if the passed pool is too large.
val add_field : extendable ->
Name.for_class -> Name.for_field -> Descriptor.for_field -> Utils.u2
add_field pool class_name field_name field_type
augments pool
with field field_name
of type field_type
in class class_name
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_method : extendable ->
Name.for_class -> Name.for_method -> Descriptor.for_method -> Utils.u2
add_method pool class_name method_name method_type
augments pool
with method method_name
of type method_type
in class class_name
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_interface_method : extendable ->
Name.for_class -> Name.for_method -> Descriptor.for_method -> Utils.u2
add_interface_method pool interface_name method_name method_type
augments
pool
with interface method method_name
of type method_type
in
interface interface_name
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_array_method : extendable ->
Descriptor.array_type -> Name.for_method -> Descriptor.for_method -> Utils.u2
add_array_method pool array_type method_name method_type
augments
pool
with array method method_name
of type method_type
in array
type array_type
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_string : extendable -> Utils.UTF8.t -> Utils.u2
add_string pool s
augments pool
with string s
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_integer : extendable -> int32 -> Utils.u2
add_integer pool i
augments pool
with integer i
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_float : extendable -> float -> Utils.u2
add_float pool f
augments pool
with float f
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_long : extendable -> int64 -> Utils.u2
add_long pool l
augments pool
with long l
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_double : extendable -> float -> Utils.u2
add_double pool d
augments pool
with double d
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_name_and_type : extendable -> Utils.UTF8.t -> Utils.UTF8.t -> Utils.u2
add_name_and_type pool n t
augments pool
with mane n
and type
t
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_utf8 : extendable -> Utils.UTF8.t -> Utils.u2
add_utf8 pool s
augments pool
with constant s
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_method_handle : extendable -> Reference.t -> Utils.u2
add_method_handle pool reference
augments pool
with an handle to
reference
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_method_type : extendable -> Descriptor.for_method -> Utils.u2
add_method_type pool method_type
augments pool
with method type
method_type
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_invoke_dynamic : extendable ->
Utils.u2 -> Name.for_method -> Descriptor.for_method -> Utils.u2
add_invoke_dynamic pool index method_name method_type
augments
pool
with invoke dynamic with index
into BootstrapMethods
attributes, method method_name
of type method_type
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val add_moduleid : extendable -> Utils.UTF8.t -> Utils.UTF8.t -> Utils.u2
add_moduleid pool n v
augments pool
with name n
and version
v
.
Returns index of existing or created entry.
Raises Exception
if the passed pool is too large.
val to_pool : extendable -> t
Converts an extendable pool into a pool.