codeBits.mli 1.45 KB
Newer Older
1 2 3 4 5
(* This module provides a number of tiny functions that help produce
   [IL] code. *)

open IL

6 7 8 9 10
(* A list subject to a condition. *)

val listif: bool -> 'a list -> 'a list
val elementif: bool -> 'a -> 'a list

11 12 13
(* Standard types. *)

val tunit: typ
14
val tbool: typ
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
val tint: typ
val tstring: typ
val texn: typ
val tposition: typ
val tlexbuf: typ
val tobj : typ

(* Building a type variable. *)

val tvar: string -> typ

(* Building a type scheme. *)

val scheme: string list -> typ -> typescheme
val type2scheme: typ -> typescheme

(* Projecting out of a [PVar] pattern. *)

val pat2var: pattern -> string

(* Building a [let] construct, with on-the-fly simplification. *)

val blet: (pattern * expr) list * expr -> expr
val mlet: pattern list -> expr list -> expr -> expr

(* [bottom] is an expression that has every type. Its semantics is
   irrelevant. *)

val bottom: expr

(* Boolean constants. *)

val etrue: expr
val efalse: expr
val eboolconst: bool -> expr

POTTIER Francois's avatar
POTTIER Francois committed
51 52 53 54
(* Integer constants as patterns. *)

val pint: int -> pattern

55 56 57 58 59 60 61 62 63 64
(* These help build function types. *)

val arrow: typ -> typ -> typ
val arrowif: bool -> typ -> typ -> typ
val marrow: typ list -> typ -> typ

(* These functions are used to generate names in menhir's namespace. *)
val prefix: string -> string
val dataprefix: string -> string
val tvprefix: string -> string
65

66 67 68
(* Converting an interface to a structure. Only exception and type definitions
   go through. *)
val interface_to_structure: interface -> structure
69