Memgraph.ReprRepresentation of ocaml values
This module aims at given a way to inspect the memory layout of ocaml values by providing some type to represent memory layouts, and some functions to convert arbitrary ocaml values into their explicit memory representation.
Contents of the closure info field, stored for each closure in a set of closures.
Represent OCaml blocks.
To have a high-level representation of a block's fields, we distinguish three cases:
and _ cell = | Int : int -> [< `Inline | `Direct ] cellIntegers
*)| Pointer : addr -> [< `Inline | `Direct ] cellPointers to some block
*)| External : Stdlib.Nativeint.t -> [< `Inline ] cellOut of heap pointer
*)| String : string -> [< `Block ] cellString
*)| Double : float -> [< `Block | `Inline ] cellA float
*)| Infix : [ `Inline ] cellAn infix header (used in closures)
*)| Closinfo : closinfo -> [< `Inline ] cellClosure info field
*)The actual type of memory cells containing concrete values. There are actually three type of cells:
`Direct cells are values that can be found in ocaml variables`Inline cells are values that can be found in a block's field array`Block cells are "big" values that take a whole blockObviously, some constructors can build more than one type of cells.
type pblock = private {block : block;The block being pointed at
*)offset : int;The offset in the block (used in mutually rec closures)
*)}This represents what is pointed at by a pointer. This is useful considering that an ocaml value can point at a closure within a set of closures, and thus point in the middle of an ocaml value (since there is an infix header, the value being pointed to is also an ocaml value, but things are easier to represent this way).
Apply the given function to a block, and all the blocks it points to (recursively). Each block is visited exactly once (the order is left unspecified though).
val repr : 'a -> [ `Direct ] cellGet the representation of a direct ocaml value.
A type containing a function to create cells.
val context : (context -> 'a) -> 'aAllow to use the same context for creating values, i.e. all values created with context.mk will correctly identify shared values between translated values.