Module Mlang.Bir_interpreter

Program values

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

Instrumentation of the interpreter

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

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

module type S = sig ... end

Signature of the modules produced by the functor

module FloatDefInterp : S

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 FloatMfInterp : S
module MPFRDefInterp : S
module MPFRMultInterp : S
module MPFRMfInterp : S
module BigIntMfInterp : S
module IntvDefInterp : S
module IntvMultInterp : S
module IntvMfInterp : S
module RatDefInterp : S
module RatMultInterp : S
module RatMfInterp : S

Generic interpretation API

val get_interp : Cli.value_sort -> Cli.round_ops -> (module S)
val evaluate_program : Bir_interface.bir_function -> Bir.program -> Mir.literal Mlang.Bir.VariableMap.t -> int -> Cli.value_sort -> Cli.round_ops -> unit -> unit

Main interpreter function

val evaluate_expr : Mir.program -> Bir.expression Pos.marked -> Cli.value_sort -> Cli.round_ops -> Mir.literal

Interprets only an expression