Module Value.Tag

Variants of values.

type 'a t = 'a tag

register ~name ~uuid (module T) creates a new variant constructor that accepts values of type T.t. Module T should implement Binable.S and Sexpable.S interfaces, provide compare and pretty-printing pp functions. This functions will be used to print, compare and serialize values.

The returned value of type T.t tag is a special key that can be used with create and get functions to pack and unpack values of type T.t into value.

Registration of a value tag, automatically adds a property slot to the Theory.program class. Then property name is package:name where package defaults to uuid.

No matter of the package name the uuid parameter is used as a typeid and to serialize and de-serialize values.

Note, this function delegates most of it work to register_slot.

  • since 2.2.0 adds [public], [desc], and [package] parameter
  • since 2.2.0 changed the defined slot name to [package:name]
val register : ?public:bool -> ?desc:string -> ?package:string -> name:string -> uuid:string -> (module S with type t = 'a) -> 'a tag

register ~name ~uuid (module T) creates a new variant constructor that accepts values of type T.t. Module T should implement Binable.S and Sexpable.S interfaces, provide compare and pretty-printing pp functions. This functions will be used to print, compare and serialize values.

The returned value of type T.t tag is a special key that can be used with create and get functions to pack and unpack values of type T.t into value.

Registration of a value tag, automatically adds a property slot to the Theory.program class. Then property name is package:name where package defaults to uuid.

No matter of the package name the uuid parameter is used as a typeid and to serialize and de-serialize values.

Note, this function delegates most of it work to register_slot.

  • since 2.2.0 adds [public], [desc], and [package] parameter
  • since 2.2.0 changed the defined slot name to [package:name]
val register_slot : ?uuid:string -> (Bap_core_theory.Theory.program, 'a option) Bap_core_theory.KB.slot -> (module S with type t = 'a) -> 'a tag

register_slot s f registers a KB property as a value.

An existing property of the Theory.program class can be also represented as BAP value and attached directly to program attributes, memory locations, or stored in the project dictionary.

slot tag returns a slot associated with the tag.

val name : 'a t -> string

name cons returns a name of a constructor.

val same : 'a t -> 'b t -> bool

same x y is true if tags x and y have the same type.

val same_witness : 'a t -> 'b t -> ('a, 'b) Core_kernel.Type_equal.t option

same_witness x y returns a value witnessing that value tags x and y has the same type.

val same_witness_exn : 'a t -> 'b t -> ('a, 'b) Core_kernel.Type_equal.t

same_witness_exn x y is the same as same_witness but raises exception if not (same x y).

val typeid : 'a t -> typeid

typeid t returns a type identifier of a type tag t.