Skip to content

Commit a1d6554

Browse files
committed
Renamed Wa_ast into Wasm_ast
1 parent d7bf42c commit a1d6554

16 files changed

+90
-86
lines changed

compiler/lib-wasm/wa_code_generation.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
open! Stdlib
2020
open Code
21-
module W = Wa_ast
21+
module W = Wasm_ast
2222

2323
(*
2424
LLVM type checker does not work well. It does not handle 'br', and
@@ -41,9 +41,9 @@ type context =
4141
; mutable data_segments : string Var.Map.t
4242
; mutable constant_globals : constant_global Var.Map.t
4343
; mutable other_fields : W.module_field list
44-
; mutable imports : (Var.t * Wa_ast.import_desc) StringMap.t StringMap.t
44+
; mutable imports : (Var.t * Wasm_ast.import_desc) StringMap.t StringMap.t
4545
; type_names : (string, Var.t) Hashtbl.t
46-
; types : (Var.t, Wa_ast.type_field) Hashtbl.t
46+
; types : (Var.t, Wasm_ast.type_field) Hashtbl.t
4747
; mutable closure_envs : Var.t Var.Map.t
4848
(** GC: mapping of recursive functions to their shared environment *)
4949
; mutable apply_funs : Var.t IntMap.t
@@ -100,7 +100,7 @@ and state =
100100

101101
and 'a t = state -> 'a * state
102102

103-
type expression = Wa_ast.expression t
103+
type expression = Wasm_ast.expression t
104104

105105
let ( let* ) (type a b) (e : a t) (f : a -> b t) : b t =
106106
fun st ->
@@ -130,9 +130,9 @@ let register_constant x e st =
130130
(), st
131131

132132
type type_def =
133-
{ supertype : Wa_ast.var option
133+
{ supertype : Wasm_ast.var option
134134
; final : bool
135-
; typ : Wa_ast.str_type
135+
; typ : Wasm_ast.str_type
136136
}
137137

138138
let register_type nm gen_typ st =
@@ -141,7 +141,7 @@ let register_type nm gen_typ st =
141141
( (try Hashtbl.find context.type_names nm
142142
with Not_found ->
143143
let name = Var.fresh_n nm in
144-
let type_field = { Wa_ast.name; typ; supertype; final } in
144+
let type_field = { Wasm_ast.name; typ; supertype; final } in
145145
context.other_fields <- Type [ type_field ] :: context.other_fields;
146146
Hashtbl.add context.type_names nm name;
147147
Hashtbl.add context.types name type_field;

compiler/lib-wasm/wa_code_generation.mli

Lines changed: 38 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,13 @@ open Stdlib
2121
type constant_global
2222

2323
type context =
24-
{ constants : (Code.Var.t, Wa_ast.expression) Hashtbl.t
24+
{ constants : (Code.Var.t, Wasm_ast.expression) Hashtbl.t
2525
; mutable data_segments : string Code.Var.Map.t
2626
; mutable constant_globals : constant_global Code.Var.Map.t
27-
; mutable other_fields : Wa_ast.module_field list
28-
; mutable imports : (Code.Var.t * Wa_ast.import_desc) StringMap.t StringMap.t
27+
; mutable other_fields : Wasm_ast.module_field list
28+
; mutable imports : (Code.Var.t * Wasm_ast.import_desc) StringMap.t StringMap.t
2929
; type_names : (string, Code.Var.t) Hashtbl.t
30-
; types : (Code.Var.t, Wa_ast.type_field) Hashtbl.t
30+
; types : (Code.Var.t, Wasm_ast.type_field) Hashtbl.t
3131
; mutable closure_envs : Code.Var.t Code.Var.Map.t
3232
(** GC: mapping of recursive functions to their shared environment *)
3333
; mutable apply_funs : Code.Var.t Stdlib.IntMap.t
@@ -36,31 +36,31 @@ type context =
3636
; mutable cps_curry_funs : Code.Var.t Stdlib.IntMap.t
3737
; mutable dummy_funs : Code.Var.t Stdlib.IntMap.t
3838
; mutable cps_dummy_funs : Code.Var.t Stdlib.IntMap.t
39-
; mutable init_code : Wa_ast.instruction list
39+
; mutable init_code : Wasm_ast.instruction list
4040
; mutable string_count : int
4141
; mutable strings : string list
4242
; mutable string_index : int StringMap.t
4343
; mutable fragments : Javascript.expression StringMap.t
4444
; mutable globalized_variables : Code.Var.Set.t
45-
; value_type : Wa_ast.value_type
45+
; value_type : Wasm_ast.value_type
4646
; mutable unit_name : string option
4747
}
4848

49-
val make_context : value_type:Wa_ast.value_type -> context
49+
val make_context : value_type:Wasm_ast.value_type -> context
5050

5151
type 'a t
5252

53-
type expression = Wa_ast.expression t
53+
type expression = Wasm_ast.expression t
5454

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

5757
val return : 'a -> 'a t
5858

59-
val instr : Wa_ast.instruction -> unit t
59+
val instr : Wasm_ast.instruction -> unit t
6060

6161
val seq : unit t -> expression -> expression
6262

63-
val expression_list : ('a -> expression) -> 'a list -> Wa_ast.expression list t
63+
val expression_list : ('a -> expression) -> 'a list -> Wasm_ast.expression list t
6464

6565
module Arith : sig
6666
val const : int32 -> expression
@@ -106,38 +106,42 @@ module Arith : sig
106106
val eqz : expression -> expression
107107
end
108108

109-
val cast : ?nullable:bool -> Wa_ast.heap_type -> expression -> expression
109+
val cast : ?nullable:bool -> Wasm_ast.heap_type -> expression -> expression
110110

111-
val load : Wa_ast.var -> expression
111+
val load : Wasm_ast.var -> expression
112112

113-
val tee : ?typ:Wa_ast.value_type -> Wa_ast.var -> expression -> expression
113+
val tee : ?typ:Wasm_ast.value_type -> Wasm_ast.var -> expression -> expression
114114

115-
val store : ?always:bool -> ?typ:Wa_ast.value_type -> Wa_ast.var -> expression -> unit t
115+
val store :
116+
?always:bool -> ?typ:Wasm_ast.value_type -> Wasm_ast.var -> expression -> unit t
116117

117-
val assign : Wa_ast.var -> expression -> unit t
118+
val assign : Wasm_ast.var -> expression -> unit t
118119

119120
val drop : expression -> unit t
120121

121122
val push : expression -> unit t
122123

123-
val loop : Wa_ast.func_type -> unit t -> unit t
124+
val loop : Wasm_ast.func_type -> unit t -> unit t
124125

125-
val block : Wa_ast.func_type -> unit t -> unit t
126+
val block : Wasm_ast.func_type -> unit t -> unit t
126127

127-
val block_expr : Wa_ast.func_type -> unit t -> expression
128+
val block_expr : Wasm_ast.func_type -> unit t -> expression
128129

129-
val if_ : Wa_ast.func_type -> expression -> unit t -> unit t -> unit t
130+
val if_ : Wasm_ast.func_type -> expression -> unit t -> unit t -> unit t
130131

131132
val try_expr :
132-
Wa_ast.func_type -> unit t -> (Code.Var.t * int * Wa_ast.value_type) list -> expression
133+
Wasm_ast.func_type
134+
-> unit t
135+
-> (Code.Var.t * int * Wasm_ast.value_type) list
136+
-> expression
133137

134-
val add_var : ?typ:Wa_ast.value_type -> Wa_ast.var -> Wa_ast.var t
138+
val add_var : ?typ:Wasm_ast.value_type -> Wasm_ast.var -> Wasm_ast.var t
135139

136-
val define_var : Wa_ast.var -> expression -> unit t
140+
val define_var : Wasm_ast.var -> expression -> unit t
137141

138-
val is_small_constant : Wa_ast.expression -> bool t
142+
val is_small_constant : Wasm_ast.expression -> bool t
139143

140-
val get_i31_value : Wa_ast.var -> Wa_ast.var option t
144+
val get_i31_value : Wasm_ast.var -> Wasm_ast.var option t
141145

142146
val event : Parse_info.t -> unit t
143147

@@ -146,27 +150,27 @@ val no_event : unit t
146150
val hidden_location : Parse_info.t
147151

148152
type type_def =
149-
{ supertype : Wa_ast.var option
153+
{ supertype : Wasm_ast.var option
150154
; final : bool
151-
; typ : Wa_ast.str_type
155+
; typ : Wasm_ast.str_type
152156
}
153157

154-
val register_type : string -> (unit -> type_def t) -> Wa_ast.var t
158+
val register_type : string -> (unit -> type_def t) -> Wasm_ast.var t
155159

156-
val heap_type_sub : Wa_ast.heap_type -> Wa_ast.heap_type -> bool t
160+
val heap_type_sub : Wasm_ast.heap_type -> Wasm_ast.heap_type -> bool t
157161

158162
val register_import :
159-
?import_module:string -> name:string -> Wa_ast.import_desc -> Wa_ast.var t
163+
?import_module:string -> name:string -> Wasm_ast.import_desc -> Wasm_ast.var t
160164

161165
val register_global :
162-
Wa_ast.var
166+
Wasm_ast.var
163167
-> ?exported_name:string
164168
-> ?constant:bool
165-
-> Wa_ast.global_type
166-
-> Wa_ast.expression
169+
-> Wasm_ast.global_type
170+
-> Wasm_ast.expression
167171
-> unit t
168172

169-
val get_global : Code.Var.t -> Wa_ast.expression option t
173+
val get_global : Code.Var.t -> Wasm_ast.expression option t
170174

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

@@ -198,4 +202,4 @@ val function_body :
198202
context:context
199203
-> param_names:Code.Var.t list
200204
-> body:unit t
201-
-> (Wa_ast.var * Wa_ast.value_type) list * Wa_ast.instruction list
205+
-> (Wasm_ast.var * Wasm_ast.value_type) list * Wasm_ast.instruction list

compiler/lib-wasm/wa_curry.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
open! Stdlib
2020
open Code
21-
module W = Wa_ast
21+
module W = Wasm_ast
2222
open Wa_code_generation
2323

2424
module Make (Target : Wa_target_sig.S) = struct

compiler/lib-wasm/wa_gc_target.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
*)
1818

1919
open! Stdlib
20-
module W = Wa_ast
20+
module W = Wasm_ast
2121
open Wa_code_generation
2222

23-
type expression = Wa_ast.expression Wa_code_generation.t
23+
type expression = Wasm_ast.expression Wa_code_generation.t
2424

2525
let include_closure_arity = false
2626

compiler/lib-wasm/wa_generate.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818

1919
open! Stdlib
2020
open Code
21-
module W = Wa_ast
21+
module W = Wasm_ast
2222
open Wa_code_generation
2323

2424
module Generate (Target : Wa_target_sig.S) = struct

compiler/lib-wasm/wa_generate.mli

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,9 @@ val f :
2828
-> in_cps:Effects.in_cps
2929
-> deadcode_sentinal:Code.Var.t
3030
-> debug:Parse_bytecode.Debug.t
31-
-> Wa_ast.var * (string list * (string * Javascript.expression) list)
31+
-> Wasm_ast.var * (string list * (string * Javascript.expression) list)
3232

33-
val add_start_function : context:Wa_code_generation.context -> Wa_ast.var -> unit
33+
val add_start_function : context:Wa_code_generation.context -> Wasm_ast.var -> unit
3434

3535
val add_init_function : context:Wa_code_generation.context -> to_link:string list -> unit
3636

compiler/lib-wasm/wa_initialize_locals.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ let check_initialized ctx i =
3333

3434
let rec scan_expression ctx e =
3535
match e with
36-
| Wa_ast.Const _ | GlobalGet _ | Pop _ | RefFunc _ | RefNull _ -> ()
36+
| Wasm_ast.Const _ | GlobalGet _ | Pop _ | RefFunc _ | RefNull _ -> ()
3737
| UnOp (_, e')
3838
| I32WrapI64 e'
3939
| I64ExtendI32 (_, e')
@@ -74,7 +74,7 @@ and scan_expressions ctx l = List.iter ~f:(fun e -> scan_expression ctx e) l
7474

7575
and scan_instruction ctx i =
7676
match i with
77-
| Wa_ast.Drop e
77+
| Wasm_ast.Drop e
7878
| GlobalSet (_, e)
7979
| Br (_, Some e)
8080
| Br_if (_, e)
@@ -114,12 +114,12 @@ let f ~param_names ~locals instrs =
114114
List.iter ~f:(fun x -> mark_initialized ctx x) param_names;
115115
List.iter
116116
~f:(fun (var, typ) ->
117-
match (typ : Wa_ast.value_type) with
117+
match (typ : Wasm_ast.value_type) with
118118
| I32 | I64 | F32 | F64 | Ref { nullable = true; _ } -> mark_initialized ctx var
119119
| Ref { nullable = false; _ } -> ())
120120
locals;
121121
scan_instructions ctx instrs;
122122
List.map
123-
~f:(fun i -> Wa_ast.LocalSet (i, RefI31 (Const (I32 0l))))
123+
~f:(fun i -> Wasm_ast.LocalSet (i, RefI31 (Const (I32 0l))))
124124
(Code.Var.Set.elements !(ctx.uninitialized))
125125
@ instrs

compiler/lib-wasm/wa_initialize_locals.mli

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
*)
1818

1919
val f :
20-
param_names:Wa_ast.var list
21-
-> locals:(Wa_ast.var * Wa_ast.value_type) list
22-
-> Wa_ast.instruction list
23-
-> Wa_ast.instruction list
20+
param_names:Wasm_ast.var list
21+
-> locals:(Wasm_ast.var * Wasm_ast.value_type) list
22+
-> Wasm_ast.instruction list
23+
-> Wasm_ast.instruction list

compiler/lib-wasm/wa_tail_call.ml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,21 +20,21 @@ open! Stdlib
2020

2121
let get_return ~tail i =
2222
match i with
23-
| Wa_ast.Return (Some (LocalGet y)) -> Some y
23+
| Wasm_ast.Return (Some (LocalGet y)) -> Some y
2424
| Push (LocalGet y) when tail -> Some y
2525
| _ -> None
2626

2727
let rewrite_tail_call ~y i =
2828
match i with
29-
| Wa_ast.LocalSet (x, Call (symb, l)) when Code.Var.equal x y ->
30-
Some (Wa_ast.Return_call (symb, l))
29+
| Wasm_ast.LocalSet (x, Call (symb, l)) when Code.Var.equal x y ->
30+
Some (Wasm_ast.Return_call (symb, l))
3131
| LocalSet (x, Call_ref (ty, e, l)) when Code.Var.equal x y ->
3232
Some (Return_call_ref (ty, e, l))
3333
| _ -> None
3434

3535
let rec instruction ~tail i =
3636
match i with
37-
| Wa_ast.Loop (ty, l) -> Wa_ast.Loop (ty, instructions ~tail l)
37+
| Wasm_ast.Loop (ty, l) -> Wasm_ast.Loop (ty, instructions ~tail l)
3838
| Block (ty, l) -> Block (ty, instructions ~tail l)
3939
| If (ty, e, l1, l2) -> If (ty, e, instructions ~tail l1, instructions ~tail l2)
4040
| Return (Some (Call (symb, l))) -> Return_call (symb, l)

compiler/lib-wasm/wa_tail_call.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@
1616
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
1717
*)
1818

19-
val f : Wa_ast.instruction list -> Wa_ast.instruction list
19+
val f : Wasm_ast.instruction list -> Wasm_ast.instruction list

0 commit comments

Comments
 (0)