Module Lambda

type compile_time_constant =
  1. | Big_endian
  2. | Word_size
  3. | Int_size
  4. | Max_wosize
  5. | Ostype_unix
  6. | Ostype_win32
  7. | Ostype_cygwin
  8. | Backend_type
type immediate_or_pointer =
  1. | Immediate
  2. | Pointer
type initialization_or_assignment =
  1. | Assignment
  2. | Heap_initialization
  3. | Root_initialization
type is_safe =
  1. | Safe
  2. | Unsafe
type primitive =
  1. | Pbytes_to_string
  2. | Pbytes_of_string
  3. | Pignore
  4. | Pgetglobal of Ident.t
  5. | Psetglobal of Ident.t
  6. | Pmakeblock of int * Asttypes.mutable_flag * block_shape
  7. | Pfield of int
  8. | Pfield_computed
  9. | Psetfield of int * immediate_or_pointer * initialization_or_assignment
  10. | Psetfield_computed of immediate_or_pointer * initialization_or_assignment
  11. | Pfloatfield of int
  12. | Psetfloatfield of int * initialization_or_assignment
  13. | Pduprecord of Types.record_representation * int
  14. | Pccall of Primitive.description
  15. | Praise of raise_kind
  16. | Psequand
  17. | Psequor
  18. | Pnot
  19. | Pnegint
  20. | Paddint
  21. | Psubint
  22. | Pmulint
  23. | Pdivint of is_safe
  24. | Pmodint of is_safe
  25. | Pandint
  26. | Porint
  27. | Pxorint
  28. | Plslint
  29. | Plsrint
  30. | Pasrint
  31. | Pintcomp of integer_comparison
  32. | Pcompare_ints
  33. | Pcompare_floats
  34. | Pcompare_bints of boxed_integer
  35. | Poffsetint of int
  36. | Poffsetref of int
  37. | Pintoffloat
  38. | Pfloatofint
  39. | Pnegfloat
  40. | Pabsfloat
  41. | Paddfloat
  42. | Psubfloat
  43. | Pmulfloat
  44. | Pdivfloat
  45. | Pfloatcomp of float_comparison
  46. | Pstringlength
  47. | Pstringrefu
  48. | Pstringrefs
  49. | Pbyteslength
  50. | Pbytesrefu
  51. | Pbytessetu
  52. | Pbytesrefs
  53. | Pbytessets
  54. | Pmakearray of array_kind * Asttypes.mutable_flag
  55. | Pduparray of array_kind * Asttypes.mutable_flag
    (*

    For Pduparray, the argument must be an immutable array. The arguments of Pduparray give the kind and mutability of the array being *produced* by the duplication.

    *)
  56. | Parraylength of array_kind
  57. | Parrayrefu of array_kind
  58. | Parraysetu of array_kind
  59. | Parrayrefs of array_kind
  60. | Parraysets of array_kind
  61. | Pisint
  62. | Pisout
  63. | Pbintofint of boxed_integer
  64. | Pintofbint of boxed_integer
  65. | Pcvtbint of boxed_integer * boxed_integer
  66. | Pnegbint of boxed_integer
  67. | Paddbint of boxed_integer
  68. | Psubbint of boxed_integer
  69. | Pmulbint of boxed_integer
  70. | Pdivbint of {
    1. size : boxed_integer;
    2. is_safe : is_safe;
    }
  71. | Pmodbint of {
    1. size : boxed_integer;
    2. is_safe : is_safe;
    }
  72. | Pandbint of boxed_integer
  73. | Porbint of boxed_integer
  74. | Pxorbint of boxed_integer
  75. | Plslbint of boxed_integer
  76. | Plsrbint of boxed_integer
  77. | Pasrbint of boxed_integer
  78. | Pbintcomp of boxed_integer * integer_comparison
  79. | Pbigarrayref of bool * int * bigarray_kind * bigarray_layout
  80. | Pbigarrayset of bool * int * bigarray_kind * bigarray_layout
  81. | Pbigarraydim of int
  82. | Pstring_load_16 of bool
  83. | Pstring_load_32 of bool
  84. | Pstring_load_64 of bool
  85. | Pbytes_load_16 of bool
  86. | Pbytes_load_32 of bool
  87. | Pbytes_load_64 of bool
  88. | Pbytes_set_16 of bool
  89. | Pbytes_set_32 of bool
  90. | Pbytes_set_64 of bool
  91. | Pbigstring_load_16 of bool
  92. | Pbigstring_load_32 of bool
  93. | Pbigstring_load_64 of bool
  94. | Pbigstring_set_16 of bool
  95. | Pbigstring_set_32 of bool
  96. | Pbigstring_set_64 of bool
  97. | Pctconst of compile_time_constant
  98. | Pbswap16
  99. | Pbbswap of boxed_integer
  100. | Pint_as_pointer
  101. | Popaque
and integer_comparison =
  1. | Ceq
  2. | Cne
  3. | Clt
  4. | Cgt
  5. | Cle
  6. | Cge
and float_comparison =
  1. | CFeq
  2. | CFneq
  3. | CFlt
  4. | CFnlt
  5. | CFgt
  6. | CFngt
  7. | CFle
  8. | CFnle
  9. | CFge
  10. | CFnge
and array_kind =
  1. | Pgenarray
  2. | Paddrarray
  3. | Pintarray
  4. | Pfloatarray
and value_kind =
  1. | Pgenval
  2. | Pfloatval
  3. | Pboxedintval of boxed_integer
  4. | Pintval
and block_shape = value_kind list option
and boxed_integer = Primitive.boxed_integer =
  1. | Pnativeint
  2. | Pint32
  3. | Pint64
and bigarray_kind =
  1. | Pbigarray_unknown
  2. | Pbigarray_float32
  3. | Pbigarray_float64
  4. | Pbigarray_sint8
  5. | Pbigarray_uint8
  6. | Pbigarray_sint16
  7. | Pbigarray_uint16
  8. | Pbigarray_int32
  9. | Pbigarray_int64
  10. | Pbigarray_caml_int
  11. | Pbigarray_native_int
  12. | Pbigarray_complex32
  13. | Pbigarray_complex64
and bigarray_layout =
  1. | Pbigarray_unknown_layout
  2. | Pbigarray_c_layout
  3. | Pbigarray_fortran_layout
and raise_kind =
  1. | Raise_regular
  2. | Raise_reraise
  3. | Raise_notrace
val equal_primitive : primitive -> primitive -> bool
val equal_value_kind : value_kind -> value_kind -> bool
val equal_boxed_integer : boxed_integer -> boxed_integer -> bool
type structured_constant =
  1. | Const_base of Asttypes.constant
  2. | Const_block of int * structured_constant list
  3. | Const_float_array of string list
  4. | Const_immstring of string
type tailcall_attribute =
  1. | Tailcall_expectation of bool
  2. | Default_tailcall
type inline_attribute =
  1. | Always_inline
  2. | Never_inline
  3. | Hint_inline
  4. | Unroll of int
  5. | Default_inline
val equal_inline_attribute : inline_attribute -> inline_attribute -> bool
type specialise_attribute =
  1. | Always_specialise
  2. | Never_specialise
  3. | Default_specialise
val equal_specialise_attribute : specialise_attribute -> specialise_attribute -> bool
type local_attribute =
  1. | Always_local
  2. | Never_local
  3. | Default_local
type poll_attribute =
  1. | Error_poll
  2. | Default_poll
type function_kind =
  1. | Curried
  2. | Tupled
type let_kind =
  1. | Strict
  2. | Alias
  3. | StrictOpt
type meth_kind =
  1. | Self
  2. | Public
  3. | Cached
val equal_meth_kind : meth_kind -> meth_kind -> bool
type shared_code = (int * int) list
type function_attribute = {
  1. inline : inline_attribute;
  2. specialise : specialise_attribute;
  3. local : local_attribute;
  4. poll : poll_attribute;
  5. is_a_functor : bool;
  6. stub : bool;
  7. tmc_candidate : bool;
}
type scoped_location = Debuginfo.Scoped_location.t
type lambda =
  1. | Lvar of Ident.t
  2. | Lmutvar of Ident.t
  3. | Lconst of structured_constant
  4. | Lapply of lambda_apply
  5. | Lfunction of lfunction
  6. | Llet of let_kind * value_kind * Ident.t * lambda * lambda
  7. | Lmutlet of value_kind * Ident.t * lambda * lambda
  8. | Lletrec of (Ident.t * lambda) list * lambda
  9. | Lprim of primitive * lambda list * scoped_location
  10. | Lswitch of lambda * lambda_switch * scoped_location
  11. | Lstringswitch of lambda * (string * lambda) list * lambda option * scoped_location
  12. | Lstaticraise of int * lambda list
  13. | Lstaticcatch of lambda * int * (Ident.t * value_kind) list * lambda
  14. | Ltrywith of lambda * Ident.t * lambda
  15. | Lifthenelse of lambda * lambda * lambda
  16. | Lsequence of lambda * lambda
  17. | Lwhile of lambda * lambda
  18. | Lfor of Ident.t * lambda * lambda * Asttypes.direction_flag * lambda
  19. | Lassign of Ident.t * lambda
  20. | Lsend of meth_kind * lambda * lambda * lambda list * scoped_location
  21. | Levent of lambda * lambda_event
  22. | Lifused of Ident.t * lambda
and lfunction = private {
  1. kind : function_kind;
  2. params : (Ident.t * value_kind) list;
  3. return : value_kind;
  4. body : lambda;
  5. attr : function_attribute;
  6. loc : scoped_location;
}
and lambda_apply = {
  1. ap_func : lambda;
  2. ap_args : lambda list;
  3. ap_loc : scoped_location;
  4. ap_tailcall : tailcall_attribute;
  5. ap_inlined : inline_attribute;
  6. ap_specialised : specialise_attribute;
}
and lambda_switch = {
  1. sw_numconsts : int;
  2. sw_consts : (int * lambda) list;
  3. sw_numblocks : int;
  4. sw_blocks : (int * lambda) list;
  5. sw_failaction : lambda option;
}
and lambda_event = {
  1. lev_loc : scoped_location;
  2. lev_kind : lambda_event_kind;
  3. lev_repr : int ref option;
  4. lev_env : Env.t;
}
and lambda_event_kind =
  1. | Lev_before
  2. | Lev_after of Types.type_expr
  3. | Lev_function
  4. | Lev_pseudo
  5. | Lev_module_definition of Ident.t
type program = {
  1. module_ident : Ident.t;
  2. main_module_block_size : int;
  3. required_globals : Ident.Set.t;
  4. code : lambda;
}
val make_key : lambda -> lambda option
val const_unit : structured_constant
val const_int : int -> structured_constant
val lambda_unit : lambda
val name_lambda : let_kind -> lambda -> (Ident.t -> lambda) -> lambda
val name_lambda_list : lambda list -> (lambda list -> lambda) -> lambda
val lfunction : kind:function_kind -> params:(Ident.t * value_kind) list -> return:value_kind -> body:lambda -> attr:function_attribute -> loc:scoped_location -> lambda
val iter_head_constructor : (lambda -> unit) -> lambda -> unit

iter_head_constructor f lam apply f to only the first level of sub expressions of lam. It does not recursively traverse the expression.

val shallow_iter : tail:(lambda -> unit) -> non_tail:(lambda -> unit) -> lambda -> unit

Same as iter_head_constructor, but use a different callback for sub-terms which are in tail position or not.

val transl_prim : string -> string -> lambda

Translate a value from a persistent module. For instance:

transl_internal_value "CamlinternalLazy" "force"
val free_variables : lambda -> Ident.Set.t
val transl_module_path : scoped_location -> Env.t -> Path.t -> lambda
val transl_value_path : scoped_location -> Env.t -> Path.t -> lambda
val transl_extension_path : scoped_location -> Env.t -> Path.t -> lambda
val transl_class_path : scoped_location -> Env.t -> Path.t -> lambda
val make_sequence : ('a -> lambda) -> 'a list -> lambda
val subst : (Ident.t -> Types.value_description -> Env.t -> Env.t) -> ?freshen_bound_variables:bool -> lambda Ident.Map.t -> lambda -> lambda

subst update_env ?freshen_bound_variables s lt applies a substitution s to the lambda-term lt.

Assumes that the image of the substitution is out of reach of the bound variables of the lambda-term (no capture).

update_env is used to refresh the environment contained in debug events.

freshen_bound_variables, which defaults to false, freshens the bound variables within lt.

val rename : Ident.t Ident.Map.t -> lambda -> lambda

A version of subst specialized for the case where we're just renaming idents.

val duplicate : lambda -> lambda

Duplicate a term, freshening all locally-bound identifiers.

val map : (lambda -> lambda) -> lambda -> lambda

Bottom-up rewriting, applying the function on each node from the leaves to the root.

val shallow_map : (lambda -> lambda) -> lambda -> lambda

Rewrite each immediate sub-term with the function.

val bind : let_kind -> Ident.t -> lambda -> lambda -> lambda
val bind_with_value_kind : let_kind -> (Ident.t * value_kind) -> lambda -> lambda -> lambda
val negate_integer_comparison : integer_comparison -> integer_comparison
val swap_integer_comparison : integer_comparison -> integer_comparison
val negate_float_comparison : float_comparison -> float_comparison
val swap_float_comparison : float_comparison -> float_comparison
val default_function_attribute : function_attribute
val default_stub_attribute : function_attribute
val function_is_curried : lfunction -> bool
val find_exact_application : function_kind -> arity:int -> lambda list -> lambda list option
val max_arity : unit -> int

Maximal number of parameters for a function, or in other words, maximal length of the params list of a lfunction record. This is unlimited (max_int) for bytecode, but limited (currently to 126) for native code.

val next_raise_count : unit -> int
val staticfail : lambda
val is_guarded : lambda -> bool
val patch_guarded : lambda -> lambda -> lambda
val raise_kind : raise_kind -> string
val merge_inline_attributes : inline_attribute -> inline_attribute -> inline_attribute option
val reset : unit -> unit