Module Extlib


module Extlib: sig .. end
Useful operations.

This module does not depend of any of frama-c module.
Consult the Plugin Development Guide for additional details.


val nop : 'a -> unit
Do nothing.
val adapt_filename : string -> string
Ensure that the given filename has the extension "cmo" in bytecode and "cmxs" in native
val max_cpt : int -> int -> int
val number_to_color : int -> int

Function builders


exception NotYetImplemented of string
Consult the Plugin Development Guide for additional details.
val not_yet_implemented : string -> 'a
Raises NotYetImplemented with the given string.
val mk_fun : string -> ('a -> 'b) Pervasives.ref
Deprecated.since Beryllium-20090601-beta1+dev
build a reference to an unitialized function (which raises NotYetImplemented if it is called).

Function combinators


val ($) : ('a -> 'b) -> ('c -> 'a) -> 'c -> 'b
Composition.
val swap : ('a -> 'b -> 'c) -> 'b -> 'a -> 'c
Swap arguments.

Lists


val as_singleton : 'a list -> 'a
returns the unique element of a singleton list.
Raises Invalid_argument on a non singleton list.
val filter_out : ('a -> bool) -> 'a list -> 'a list
Filter out elements that pass the test
val filter_map : ('a -> bool) -> ('a -> 'b) -> 'a list -> 'b list
Combines filter and map.
val product_fold : ('a -> 'b -> 'c -> 'a) -> 'a -> 'b list -> 'c list -> 'a
product f acc l1 l2 is similar to fold_left f acc l12 with l12 the list of all pairs of an elt of l1 and an elt of l2
val product : ('a -> 'b -> 'c) -> 'a list -> 'b list -> 'c list
product f l1 l2 applies f to all the pairs of an elt of l1 and an element of l2.
val find_index : ('a -> bool) -> 'a list -> int
returns the index (starting at 0) of the first element verifying the condition
Raises Not_found if no element in the list matches the condition
val list_compare : ('a -> 'a -> int) -> 'a list -> 'a list -> int
Generic list comparison function, where the elements are compared with the specified function
Since Boron-20100401

Options


val may : ('a -> unit) -> 'a option -> unit
val may_map : ('a -> 'b) -> ?dft:'b -> 'a option -> 'b
may_map f ?dft x applies f to the value of x if exists. Otherwise returns the default value dft. Assume that either x or dft is defined.
val opt_map : ('a -> 'b) -> 'a option -> 'b option
val opt_filter : ('a -> bool) -> 'a option -> 'a option
val the : 'a option -> 'a
Raises Invalid_argument if the value is none.
Consult the Plugin Development Guide for additional details.
val find_or_none : ('a -> 'b) -> 'a -> 'b option
val opt_equal : ('a -> 'a -> bool) -> 'a option -> 'a option -> bool
val opt_compare : ('a -> 'a -> int) -> 'a option -> 'a option -> int
Since Boron-20100401

Strings


val string_prefix : ?strict:bool -> string -> string -> bool
string_prefix ~strict p s returns true if and only if p is a prefix of the string s. If strict is true, the prefix must be strict (that is, s must moreover be strictly longer than p. strict is false by default.
Since Boron-20100401

Performance


val getperfcount : unit -> int
val getperfcount1024 : unit -> int
val time : ?msg:string -> ('a -> 'b) -> 'a -> 'b
val time1024 : ?msg:string -> ('a -> 'b) -> 'a -> 'b
val address_of_value : 'a -> int

Exception catcher


val try_finally : finally:(unit -> unit) -> ('a -> 'b) -> 'a -> 'b

System commands
val cleanup_at_exit : string -> unit
cleanup_at_exit file indicates that file must be removed when the program exits (except if exit is caused by a signal). If file does not exist, nothing happens.
val temp_file_cleanup_at_exit : string -> string -> string
Similar to Filename.temp_file except that the temporary file will be deleted at the end of the execution (see above).
val safe_remove : string -> unit
Tries to delete a file and never fails.