File: code_generation.mli

package info (click to toggle)
js-of-ocaml 6.2.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 37,932 kB
  • sloc: ml: 135,957; javascript: 58,364; ansic: 437; makefile: 422; sh: 12; perl: 4
file content (207 lines) | stat: -rw-r--r-- 6,106 bytes parent folder | download
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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
(* Wasm_of_ocaml compiler
 * http://www.ocsigen.org/js_of_ocaml/
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation, with linking exception;
 * either version 2.1 of the License, or (at your option) any later version.
 *
 * This program 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
 *)

open Stdlib

type constant_global

type context =
  { constants : Wasm_ast.expression Code.Var.Hashtbl.t
  ; mutable data_segments : string Code.Var.Map.t
  ; mutable constant_globals : constant_global Code.Var.Map.t
  ; mutable other_fields : Wasm_ast.module_field list
  ; mutable imports : (Code.Var.t * Wasm_ast.import_desc) StringMap.t StringMap.t
  ; type_names : Code.Var.t String.Hashtbl.t
  ; types : Wasm_ast.type_field Code.Var.Hashtbl.t
  ; mutable closure_envs : Code.Var.t Code.Var.Map.t
        (** GC: mapping of recursive functions to their shared environment *)
  ; closure_types : (Wasm_ast.value_type option list, int) Hashtbl.t
  ; mutable apply_funs : Code.Var.t Stdlib.IntMap.t
  ; mutable cps_apply_funs : Code.Var.t Stdlib.IntMap.t
  ; mutable curry_funs : Code.Var.t Stdlib.IntMap.t
  ; mutable cps_curry_funs : Code.Var.t Stdlib.IntMap.t
  ; mutable dummy_funs : Code.Var.t Stdlib.IntMap.t
  ; mutable cps_dummy_funs : Code.Var.t Stdlib.IntMap.t
  ; mutable init_code : Wasm_ast.instruction list
  ; mutable fragments : Javascript.expression StringMap.t
  ; mutable globalized_variables : Code.Var.Set.t
  ; value_type : Wasm_ast.value_type
  ; mutable unit_name : string option
  }

val make_context : value_type:Wasm_ast.value_type -> context

type 'a t

type expression = Wasm_ast.expression t

val ( let* ) : 'a t -> ('a -> 'b t) -> 'b t

val return : 'a -> 'a t

val instr : Wasm_ast.instruction -> unit t

val seq : unit t -> expression -> expression

val expression_list : ('a -> 'b t) -> 'a list -> 'b list t

module Arith : sig
  val const : int32 -> expression

  val to_int31 : expression -> expression

  val of_int31 : expression -> expression

  val ( + ) : expression -> expression -> expression

  val ( - ) : expression -> expression -> expression

  val ( * ) : expression -> expression -> expression

  val ( / ) : expression -> expression -> expression

  val ( mod ) : expression -> expression -> expression

  val ( lsl ) : expression -> expression -> expression

  val ( lsr ) : expression -> expression -> expression

  val ( asr ) : expression -> expression -> expression

  val ( land ) : expression -> expression -> expression

  val ( lor ) : expression -> expression -> expression

  val ( lxor ) : expression -> expression -> expression

  val ( < ) : expression -> expression -> expression

  val ( <= ) : expression -> expression -> expression

  val ( = ) : expression -> expression -> expression

  val ( <> ) : expression -> expression -> expression

  val ult : expression -> expression -> expression

  val uge : expression -> expression -> expression

  val eqz : expression -> expression
end

val cast : ?nullable:bool -> Wasm_ast.heap_type -> expression -> expression

val load : Wasm_ast.var -> expression

val tee : ?typ:Wasm_ast.value_type -> Wasm_ast.var -> expression -> expression

val store :
  ?always:bool -> ?typ:Wasm_ast.value_type -> Wasm_ast.var -> expression -> unit t

val assign : Wasm_ast.var -> expression -> unit t

val drop : expression -> unit t

val push : expression -> unit t

val loop : Wasm_ast.func_type -> unit t -> unit t

val block : Wasm_ast.func_type -> unit t -> unit t

val block_expr : Wasm_ast.func_type -> unit t -> expression

val if_ : Wasm_ast.func_type -> expression -> unit t -> unit t -> unit t

val try_expr :
     Wasm_ast.func_type
  -> unit t
  -> (Code.Var.t * int * Wasm_ast.value_type) list
  -> expression

val add_var : ?typ:Wasm_ast.value_type -> Wasm_ast.var -> Wasm_ast.var t

val define_var : Wasm_ast.var -> expression -> unit t

val is_small_constant : Wasm_ast.expression -> bool t

val event : Parse_info.t -> unit t

val no_event : unit t

val hidden_location : Parse_info.t

type type_def =
  { supertype : Wasm_ast.var option
  ; final : bool
  ; typ : Wasm_ast.str_type
  }

val register_type : string -> (unit -> type_def t) -> Wasm_ast.var t

val heap_type_sub : Wasm_ast.heap_type -> Wasm_ast.heap_type -> bool t

val register_import :
  ?import_module:string -> name:string -> Wasm_ast.import_desc -> Wasm_ast.var t

val register_global :
     Wasm_ast.var
  -> ?exported_name:string
  -> ?constant:bool
  -> Wasm_ast.global_type
  -> Wasm_ast.expression
  -> unit t

val get_global : Code.Var.t -> Wasm_ast.expression option t

val register_data_segment : Code.Var.t -> string -> unit t

val register_init_code : unit t -> unit t

val init_code : context -> unit t

val register_fragment : string -> (unit -> Javascript.expression) -> unit t

val get_context : context t

val set_closure_env : Code.Var.t -> Code.Var.t -> unit t

val get_closure_env : Code.Var.t -> Code.Var.t t

val is_closure : Code.Var.t -> bool t

val unit_name : string option t

val need_apply_fun : cps:bool -> arity:int -> Code.Var.t t

val need_curry_fun : cps:bool -> arity:int -> Code.Var.t t

val need_dummy_fun : cps:bool -> arity:int -> Code.Var.t t

val function_body :
     context:context
  -> param_names:Code.Var.t list
  -> body:unit t
  -> (Wasm_ast.var * Wasm_ast.value_type) list * Wasm_ast.instruction list

val variable_type : Code.Var.t -> Wasm_ast.value_type option t

val array_placeholder : Code.Var.t -> expression

val default_value :
     Wasm_ast.value_type
  -> (Wasm_ast.expression * Wasm_ast.value_type * Wasm_ast.ref_type option) t