Module Mlang.Bir_interpreter

Interpretation of BIR programs

Program values

type var_literal =
| SimpleVar of Mir.literal
| TableVar of int * Mir.literal array

Instrumentation of the interpreter

The BIR interpreter can be instrumented to record which program locations have been executed.

type code_location_segment =
| InsideBlock of int
| ConditionalBranch of bool
| InsideRule of Bir.rov_id
| InsideFunction of Bir.function_name
| InsideIterate of Bir.variable

Representation of each program location segment

val format_code_location_segment : Stdlib.Format.formatter -> code_location_segment -> unit
type code_location = code_location_segment list

A program location is simply the path inside the program

val format_code_location : Stdlib.Format.formatter -> code_location -> unit
val assign_hook : ( Bir.variable -> ( unit -> var_literal ) -> code_location -> unit ) Stdlib.ref

The instrumentation of the interpreter is done through this reference. The function that you assign to this reference will be called each time a variable assignment is executed

val exit_on_rte : bool Stdlib.ref

If set to true, the interpreter exits the whole process in case of runtime error

val repl_debug : bool Stdlib.ref

If set to true, prints the REPL debugger in case of runtime error

The interpreter functor

The intepreter is parametrized by the kind of floating-point values used for the execution

module type S = sig ... end

Signature of the modules produced by the functor

The different interpreters, which combine a representation of numbers and rounding operations. The first part of the name corresponds to the representation of numbers, and is one of the following:

module BigIntMfInterp : S

Generic interpretation API

val get_interp : Cli.value_sort -> Cli.round_ops -> (module S)
val evaluate_program : Bir.program -> Mir.literal Bir.VariableMap.t -> Cli.value_sort -> Cli.round_ops -> float option StrMap.t * StrSet.t

Main interpreter function

Interprets only an expression