jon.recoil.org

Module Flambda2_terms.Switch_expr

Representation of conditional control flow: the Switch expression.

Scrutinees of Switches are of kind Naked_immediate. There are no default cases. Switches always have at least two cases.

type t
include Expr_std.S with type t := t
val print : Format.formatter -> t -> unit
include Flambda2_nominal.Contains_names.S with type t := t

Compute the free names of a term. Such computation covers all kinds of bindable names (variables, continuations, ...)

val apply_renaming : t -> Flambda2_nominal.Renaming.t -> t

Apply a renaming throughout a term.

include Flambda2_nominal.Contains_ids.S with type t := t
val ids_for_export : t -> Flambda2_nominal.Ids_for_export.t

Gather all table identifiers to export them.

val if_then_else : machine_width:Target_system.Machine_width.t -> condition_dbg:Debuginfo.t -> scrutinee:Flambda2_term_basics.Simple.t -> if_true:Apply_cont_expr.t -> if_false:Apply_cont_expr.t -> t

Create a Switch corresponding to a traditional if-then-else.

val scrutinee : t -> Flambda2_term_basics.Simple.t

The scrutinee of the switch.

val condition_dbg : t -> Debuginfo.t

The debuginfo to be used for the condition.

val iter : t -> f:(Flambda2_numbers.Target_ocaml_int.t -> Apply_cont_expr.t -> unit) -> unit

Call the given function f on each (discriminant, action) pair in the switch.

What the switch will do for each possible value of the discriminant.

val num_arms : t -> int

How many cases the switch has. (Note that this is not the number of destinations reached by the switch, which may be a smaller number.)