Skip to content
This repository
tag: v737
Fetching contributors…

Cannot retrieve contributors at this time

file 99 lines (79 sloc) 2.818 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
(*
Copyright © 2011 MLstate

This file is part of OPA.

OPA is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License, version 3, as published by
the Free Software Foundation.

OPA is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
more details.

You should have received a copy of the GNU Affero General Public License
along with OPA. If not, see <http://www.gnu.org/licenses/>.
*)
(**
Runtime library for qmlClosure in caml

Meant for QmlClosure, for backends (to allow the bsl to
manipulate directly the closure through the server lib)
and for the closure bsl
*)

module AnyArray : sig
  type t = Obj.t array
  val create : int -> t
  val set : t -> int -> 'a -> unit
  val get : t -> int -> 'a
  val length : t -> int
  val append_sub : t -> int -> t -> t
  val sub : t -> int -> t
  val sub2 : t -> int -> int -> t
  val append : t -> t -> t
end

(**/**)
type t_extra
#<Ifstatic:CPS_WITH_ML_CLOSURE .*>
type t
#<Else>
(* this type is exposed for manipulation ONLY by the code generated by QmlClosure *)
type t = {
  arity : int;
  mutable identifier : Obj.t option;
  args: AnyArray.t;
  mutable func: Obj.t;
  extra : t_extra;
}
#<End>
(**/**)

(** {6 Debug} *)

val check : 'a -> bool
val assert_ : 'a -> t
val show : 'a -> string

(** {6 Allocation} *)

val create : 'ml_closure -> int -> 'record -> t
val create_no_ident : 'ml_closure -> int -> t
val create_no_ident1 : 'ml_closure -> t
val create_no_ident2 : 'ml_closure -> t
val create_no_function : int -> 'record -> t
val create_anyarray : 'ml_closure -> int -> 'record -> t
val define_function : t -> 'ml_closure -> unit

(** {6 Application} *)

(** full application of a closure *)
val args_apply : t -> AnyArray.t -> 'result
val args_apply1 : t -> 'arg1 -> 'result
val args_apply2 : t -> 'arg1 -> 'arg2 -> 'result

(** partial application of a closure *)
val env_apply : t -> AnyArray.t -> t
val env_apply1 : t -> 'arg1 -> t
val env_apply2 : t -> 'arg1 -> 'arg2 -> t

(** partial application of a closure with type information about pushed args *)
val env_apply_with_ty : t -> AnyArray.t -> AnyArray.t -> t
val env_apply1_with_ty : t -> 'arg1 -> 'ty_arg1 -> t
val env_apply2_with_ty : t -> 'arg1 -> 'arg2 -> 'ty_arg1 -> 'ty_arg1 -> t


(** {6 Interface for serialization} *)

val is_empty : 'closure -> bool
val get_identifier : 'closure -> 'ident option
val set_identifier : t -> 'ident -> unit
val get_args : t -> AnyArray.t
val get_tyargs : t -> AnyArray.t

(** {6 Interface for bsl projections} *)

val import : 'ml_closure -> int -> t
val export : t -> 'ml_closure
Something went wrong with that request. Please try again.