module Annotation: sig
.. end
Annotations in both low- and high-level forms.
It also provides conversion functions between levels as well as i/o
functions for low-level.
type
location = Utils.u1 list
Location, that is list of indexes used to disambiguate an annotation target.
type
intervals = (Utils.u2 * Utils.u2 * Utils.u2) list
Intervals, that is (start, length, index) triple where:
- start is the begin of the interval in the code;
- length is the size of the interval;
- index is the position of the local variable.
type
target =
type
primitive_type = [ `Boolean | `Byte | `Char | `Double | `Float | `Int | `Long | `Short ]
Represents the primitives types that can be used inside an annotation.
type
info_element_value =
type
info = {
}
Represents an annotation as defined in the class file format
specification.
type
extended_info = {
}
Represents an extended annotation as defined in the class file
format specification.
Exception
type
error =
| |
Invalid_tag of Utils.UChar.t |
| |
Inconsistent_primitive_value |
| |
Invalid_string_value of Utils.u2 |
| |
Invalid_enum_value of Utils.u2 * Utils.u2 |
| |
Invalid_class_value of Utils.u2 |
| |
Invalid_annotation_type_value of Utils.u2 |
| |
Invalid_element_name of Utils.u2 |
| |
Invalid_list_length of int |
| |
Invalid_target of int |
exception Exception of error
val string_of_error : error -> string
I/O functions
val read_target : InputStream.t -> target
read_target st
reads an element target from st
.
Raises Exception
if st
does not contain a valid element target.
Raises InputStream.Exception
if an i/o error occurs.
val write_target : OutputStream.t -> target -> unit
write_target st e
writes element target e
onto st
.
Raises Exception
if e
is not a valid element target.
Raises OutputStream.Exception
if an i/o error occurs.
val read_info_element_value : InputStream.t -> info_element_value
read_info_element_value st
reads an element value from st
.
Raises Exception
if st
does not contain a valid element value.
Raises InputStream.Exception
if an i/o error occurs.
val write_info_element_value : OutputStream.t -> info_element_value -> unit
write_info_element_value st e
writes element value e
onto st
.
Raises Exception
if e
is not a valid element value.
Raises OutputStream.Exception
if an i/o error occurs.
val read_info : InputStream.t -> info
read_info st
reads an annotation from st
.
Raises Exception
if st
does not contain a valid annotation.
Raises InputStream.Exception
if an i/o error occurs.
val write_info : OutputStream.t -> info -> unit
write_info st a
writes annotation a
onto st
.
Raises Exception
if a
is not a valid annotation.
Raises OutputStream.Exception
if an i/o error occurs.
val read_extended_info : InputStream.t -> extended_info
read_extended_info st
reads an extended annotation from st
.
Raises Exception
if st
does not contain a valid extended
annotation.
Raises InputStream.Exception
if an i/o error occurs.
val write_extended_info : OutputStream.t -> extended_info -> unit
write_extended_info st a
writes extended annotation a
onto st
.
Raises Exception
if a
is not a valid extended annotation.
Raises OutputStream.Exception
if an i/o error occurs.
type
element_value =
| |
Boolean_value of bool |
| |
Byte_value of int |
| |
Char_value of Utils.UChar.t |
| |
Double_value of float |
| |
Float_value of float |
| |
Int_value of int32 |
| |
Long_value of int64 |
| |
Short_value of int |
| |
String_value of Utils.UTF8.t |
| |
Enum_value of Name.for_class * Name.for_field |
| |
Class_value of Name.for_class |
| |
Annotation_value of t |
| |
Array_value of element_value list |
type
t = Name.for_class * (Utils.UTF8.t * element_value) list
Represents an annotation in high-level form.
type
extended = Name.for_class * (Utils.UTF8.t * element_value) list *
target
Represents an extended annotation in high-level form.
val equal_element_value : element_value -> element_value -> bool
Equality over element values.
val compare_element_value : element_value -> element_value -> int
Comparison over element values.
val hash_element_value : element_value -> int
Hash function over element values.
val equal : t -> t -> bool
Equality over annotations.
val compare : t -> t -> int
Comparison over annotations.
val hash : t -> int
Hash function over annotations.
val equal_extended : extended -> extended -> bool
Equality over extended annotations.
val compare_extended : extended -> extended -> int
Comparison over extended annotations.
val hash_extended : extended -> int
Hash function over extended annotations.
Conversion functions
val decode_element_value : ConstantPool.t -> info_element_value -> element_value
Converts from a low-level into a high-level form according to
passed pool.
Raises Exception
if an error occurs during conversion.
val decode : ConstantPool.t -> info -> t
Converts from a low-level into a high-level form according to
passed pool.
Raises Exception
if an error occurs during conversion.
val decode_extended : ConstantPool.t -> extended_info -> extended
Converts from a low-level into a high-level form according to
passed pool.
Raises Exception
if an error occurs during conversion.
val encode_element_value : ConstantPool.extendable ->
element_value -> info_element_value
Converts from a high-level into a low-level form, using passed
extendable pool.
Raises Exception
if an error occurs during conversion.
val encode : ConstantPool.extendable -> t -> info
Converts from a high-level into a low-level form, using passed
extendable pool.
Raises Exception
if an error occurs during conversion.
val encode_extended : ConstantPool.extendable -> extended -> extended_info
Converts from a high-level into a low-level form, using passed
extendable pool.
Raises Exception
if an error occurs during conversion.