package binaryen

  1. Overview
  2. Docs

Source file expression.ml

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
type t

external block : Module.t -> string -> t list -> Type.t -> t = "caml_binaryen_block"
let block ?(return_type=Type.auto) wasm_mod name exprs =
  block wasm_mod name exprs return_type
(** Module, block name, expression list. *)

external if_ : Module.t -> t -> t -> t -> t = "caml_binaryen_if"
(** Module, condition, true branch, false branch. False branch may be null. *)

external loop : Module.t -> string -> t -> t = "caml_binaryen_loop"
(** Module, loop name, body. *)

external break : Module.t -> string -> t -> t -> t = "caml_binaryen_break"
(** Module, block name, condition, result. Value and condition may be null. *)

external switch : Module.t -> string list -> string -> t -> t -> t
  = "caml_binaryen_switch"
(** Module, branch names, default branch name, condition, value. Value may be null. *)

external call : Module.t -> string -> t list -> Type.t -> t
  = "caml_binaryen_call"
(** Module, function name, params, return type. *)

external call_indirect : Module.t -> string -> t -> t list -> Type.t -> Type.t -> t
  = "caml_binaryen_call_indirect__bytecode" "caml_binaryen_call_indirect"
(** Module, table, function value, params, params type, return type. *)

external return_call : Module.t -> string -> t list -> Type.t -> t
  = "caml_binaryen_return_call"
(** Module, function name, params, return type. *)

external return_call_indirect : Module.t -> string -> t -> t list -> Type.t -> Type.t -> t
  = "caml_binaryen_return_call_indirect__bytecode" "caml_binaryen_return_call_indirect"
(** Module, table, function value, params, params type, return type. *)

external local_get : Module.t -> int -> Type.t -> t = "caml_binaryen_local_get"
(** Module, slot, type. *)

external local_set : Module.t -> int -> t -> t = "caml_binaryen_local_set"
(** Module, slot, value. *)

external local_tee : Module.t -> int -> t -> Type.t -> t
  = "caml_binaryen_local_tee"
(** Module, slot, value, type. *)

external global_get : Module.t -> string -> Type.t -> t
  = "caml_binaryen_global_get"
(** Module, name, type. *)

external global_set : Module.t -> string -> t -> t = "caml_binaryen_global_set"
(** Module, name, value. *)

external load : Module.t -> int -> bool -> int -> int -> Type.t -> t -> t
  = "caml_binaryen_load__bytecode" "caml_binaryen_load"
let load wasm_mod bytes ?(signed=false) offset align ty ptr =
  load wasm_mod bytes signed offset align ty ptr
(** Module, num_bytes, ?signed, offset, align, type, ptr. *)

external store : Module.t -> int -> int -> int -> t -> t -> Type.t -> t
  = "caml_binaryen_store__bytecode" "caml_binaryen_store"
(** Module, num_bytes, offset, align, ptr, value, type. *)

external const : Module.t -> Literal.t -> t = "caml_binaryen_const"

external unary : Module.t -> Op.t -> t -> t = "caml_binaryen_unary"

external binary : Module.t -> Op.t -> t -> t -> t = "caml_binaryen_binary"

external select : Module.t -> t -> t -> t -> Type.t -> t = "caml_binaryen_select"
let select wasm_mod cond tru fals =
  select wasm_mod cond tru fals Type.auto
(** Module, condition, true branch, false branch. *)

external drop : Module.t -> t -> t = "caml_binaryen_drop"

external return : Module.t -> t -> t = "caml_binaryen_return"

external memory_size : Module.t -> t = "caml_binaryen_memory_size"

external memory_grow : Module.t -> t -> t = "caml_binaryen_memory_grow"

external nop : Module.t -> t = "caml_binaryen_nop"

external unreachable : Module.t -> t = "caml_binaryen_unreachable"

external memory_copy : Module.t -> t -> t -> t -> t
  = "caml_binaryen_memory_copy"
(** Module, destination, source, size. *)

external memory_fill : Module.t -> t -> t -> t -> t
  = "caml_binaryen_memory_fill"
(** Module, destination, value, size. *)

external tuple_make : Module.t -> t list -> t = "caml_binaryen_tuple_make"
(** Module, items *)

external tuple_extract : Module.t -> t -> int -> t
  = "caml_binaryen_tuple_extract"
(** Module, tuple, index *)

external pop : Module.t -> Type.t -> t = "caml_binaryen_pop"
(** Module, type *)

external null : unit -> t = "caml_binaryen_null_expression"
(** A null reference. *)

external print : t -> unit = "caml_binaryen_expression_print"
(** Print an expression to the console. *)
OCaml

Innovation. Community. Security.