Skip to content

Commit 1a7305e

Browse files
authored
Merge pull request #127 from ocaml-wasm/renamings
Remove wa_ filename prefix
2 parents d7bf42c + 34bfa2a commit 1a7305e

34 files changed

+197
-190
lines changed

.git-blame-ignore-revs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,8 @@
44
7de742a776fcdad4b098695617b9e7afab822c82
55
# Biome
66
5a78e2466221c91fc3607be5b6549797551de4d1
7+
# Wasm_of_ocaml: renamed files
8+
02b848f0dae1924326aceb5e2b689eb4870b9e0c
9+
f51c956d4294c55b45a05fa6520cb5cdc9e2ade3
10+
40f4d4e4034d8fd21e28d74e5ff127dcd3fec37d
11+
a1d6554ea9d055f817edea5d32e485d836001cb3

compiler/bin-wasm_of_ocaml/compile.ml

Lines changed: 36 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@ let update_sourcemap ~sourcemap_root ~sourcemap_don't_inline_content sourcemap_f
4343
else
4444
Some
4545
(List.map source_map.sources ~f:(fun file ->
46-
if String.equal file Wa_source_map.blackbox_filename
46+
if String.equal file Wasm_source_map.blackbox_filename
4747
then
48-
Some (Source_map.Source_content.create Wa_source_map.blackbox_contents)
48+
Some (Source_map.Source_content.create Wasm_source_map.blackbox_contents)
4949
else if Sys.file_exists file && not (Sys.is_directory file)
5050
then Some (Source_map.Source_content.create (Fs.read_file file))
5151
else None))
@@ -56,8 +56,8 @@ let update_sourcemap ~sourcemap_root ~sourcemap_don't_inline_content sourcemap_f
5656
; sourceroot =
5757
(if Option.is_some sourcemap_root then sourcemap_root else source_map.sourceroot)
5858
; ignore_list =
59-
(if List.mem Wa_source_map.blackbox_filename ~set:source_map.sources
60-
then [ Wa_source_map.blackbox_filename ]
59+
(if List.mem Wasm_source_map.blackbox_filename ~set:source_map.sources
60+
then [ Wasm_source_map.blackbox_filename ]
6161
else [])
6262
}
6363
in
@@ -100,7 +100,7 @@ let link_and_optimize
100100
then Some (Filename.temp_file "wasm-merged" ".wasm.map")
101101
else None)
102102
@@ fun opt_temp_sourcemap ->
103-
Wa_binaryen.link
103+
Binaryen.link
104104
~runtime_files:(runtime_file :: runtime_wasm_files)
105105
~input_files:wat_files
106106
~opt_output_sourcemap:opt_temp_sourcemap
@@ -112,14 +112,14 @@ let link_and_optimize
112112
(if enable_source_maps then Some (Filename.temp_file "wasm-dce" ".wasm.map") else None)
113113
@@ fun opt_temp_sourcemap' ->
114114
let primitives =
115-
Wa_binaryen.dead_code_elimination
115+
Binaryen.dead_code_elimination
116116
~dependencies:Wa_runtime.dependencies
117117
~opt_input_sourcemap:opt_temp_sourcemap
118118
~opt_output_sourcemap:opt_temp_sourcemap'
119119
~input_file:temp_file
120120
~output_file:temp_file'
121121
in
122-
Wa_binaryen.optimize
122+
Binaryen.optimize
123123
~profile
124124
~opt_input_sourcemap:opt_temp_sourcemap'
125125
~opt_output_sourcemap:opt_sourcemap
@@ -136,12 +136,12 @@ let link_runtime ~profile runtime_wasm_files output_file =
136136
Fs.write_file ~name:runtime_file ~contents:Wa_runtime.wasm_runtime;
137137
Fs.with_intermediate_file (Filename.temp_file "wasm-merged" ".wasm")
138138
@@ fun temp_file ->
139-
Wa_binaryen.link
139+
Binaryen.link
140140
~opt_output_sourcemap:None
141141
~runtime_files:(runtime_file :: runtime_wasm_files)
142142
~input_files:[]
143143
~output_file:temp_file;
144-
Wa_binaryen.optimize
144+
Binaryen.optimize
145145
~profile
146146
~opt_input_sourcemap:None
147147
~opt_output_sourcemap:None
@@ -160,10 +160,10 @@ let generate_prelude ~out_file =
160160
let Driver.{ program; variable_uses; in_cps; deadcode_sentinal; _ } =
161161
Driver.optimize ~profile code
162162
in
163-
let context = Wa_generate.start () in
163+
let context = Generate.start () in
164164
let debug = Parse_bytecode.Debug.create ~include_cmis:false false in
165165
let _ =
166-
Wa_generate.f
166+
Generate.f
167167
~context
168168
~unit_name:(Some "prelude")
169169
~live_vars:variable_uses
@@ -172,7 +172,7 @@ let generate_prelude ~out_file =
172172
~debug
173173
program
174174
in
175-
Wa_generate.output ch ~context;
175+
Generate.output ch ~context;
176176
uinfo.provides
177177

178178
let build_prelude z =
@@ -181,7 +181,7 @@ let build_prelude z =
181181
Fs.with_intermediate_file (Filename.temp_file "prelude_file" ".wasm")
182182
@@ fun tmp_prelude_file ->
183183
let predefined_exceptions = generate_prelude ~out_file:prelude_file in
184-
Wa_binaryen.optimize
184+
Binaryen.optimize
185185
~profile:(Driver.profile 1)
186186
~input_file:prelude_file
187187
~output_file:tmp_prelude_file
@@ -214,7 +214,7 @@ let build_js_runtime ~primitives ?runtime_arguments () =
214214
| Javascript.Expression_statement e, N -> e
215215
| _ -> assert false
216216
in
217-
let prelude = Wa_link.output_js always_required_js in
217+
let prelude = Link.output_js always_required_js in
218218
let init_fun =
219219
match Parse_js.parse (Parse_js.Lexer.of_string Wa_runtime.js_runtime) with
220220
| [ (Expression_statement f, _) ] -> f
@@ -230,7 +230,7 @@ let build_js_runtime ~primitives ?runtime_arguments () =
230230
in
231231
[ Javascript.Expression_statement js, Javascript.N ]
232232
in
233-
Wa_link.output_js js
233+
Link.output_js js
234234
in
235235
prelude ^ launcher
236236

@@ -241,13 +241,13 @@ let add_source_map sourcemap_don't_inline_content z opt_source_map_file =
241241
if not sourcemap_don't_inline_content
242242
then
243243
let sm = Source_map.of_file file in
244-
Wa_source_map.iter_sources sm (fun i j file ->
244+
Wasm_source_map.iter_sources sm (fun i j file ->
245245
if Sys.file_exists file && not (Sys.is_directory file)
246246
then
247247
let sm = Fs.read_file file in
248248
Zip.add_entry
249249
z
250-
~name:(Wa_link.source_name i j file)
250+
~name:(Link.source_name i j file)
251251
~contents:(Yojson.Basic.to_string (`String sm))))
252252
opt_source_map_file
253253

@@ -266,7 +266,7 @@ let run
266266
} =
267267
Config.set_target `Wasm;
268268
Jsoo_cmdline.Arg.eval common;
269-
Wa_generate.init ();
269+
Generate.init ();
270270
let output_file = fst output_file in
271271
if debug_mem () then Debug.start_profiling output_file;
272272
List.iter params ~f:(fun (s, v) -> Config.Param.set s v);
@@ -322,10 +322,10 @@ let run
322322
let Driver.{ program; variable_uses; in_cps; deadcode_sentinal; _ } =
323323
Driver.optimize ~profile code
324324
in
325-
let context = Wa_generate.start () in
325+
let context = Generate.start () in
326326
let debug = one.debug in
327327
let toplevel_name, generated_js =
328-
Wa_generate.f
328+
Generate.f
329329
~context
330330
~unit_name
331331
~live_vars:variable_uses
@@ -334,8 +334,8 @@ let run
334334
~debug
335335
program
336336
in
337-
if standalone then Wa_generate.add_start_function ~context toplevel_name;
338-
Wa_generate.output ch ~context;
337+
if standalone then Generate.add_start_function ~context toplevel_name;
338+
Generate.output ch ~context;
339339
if times () then Format.eprintf "compilation: %a@." Timer.print t;
340340
generated_js
341341
in
@@ -348,8 +348,8 @@ let run
348348
link_runtime ~profile runtime_wasm_files tmp_wasm_file;
349349
let primitives =
350350
tmp_wasm_file
351-
|> (fun file -> Wa_link.Wasm_binary.read_imports ~file)
352-
|> List.filter_map ~f:(fun { Wa_link.Wasm_binary.module_; name; _ } ->
351+
|> (fun file -> Link.Wasm_binary.read_imports ~file)
352+
|> List.filter_map ~f:(fun { Link.Wasm_binary.module_; name; _ } ->
353353
if String.equal module_ "js" then Some name else None)
354354
|> StringSet.of_list
355355
in
@@ -358,7 +358,7 @@ let run
358358
Zip.add_file z ~name:"runtime.wasm" ~file:tmp_wasm_file;
359359
Zip.add_entry z ~name:"runtime.js" ~contents:js_runtime;
360360
let predefined_exceptions = build_prelude z in
361-
Wa_link.add_info
361+
Link.add_info
362362
z
363363
~predefined_exceptions
364364
~build_info:(Build_info.create `Runtime)
@@ -399,13 +399,13 @@ let run
399399
let strings, fragments =
400400
output_gen wat_file (output code ~unit_name:(Some unit_name))
401401
in
402-
Wa_binaryen.optimize
402+
Binaryen.optimize
403403
~profile
404404
~opt_input_sourcemap:None
405405
~opt_output_sourcemap:opt_tmp_map_file
406406
~input_file:wat_file
407407
~output_file:tmp_wasm_file;
408-
{ Wa_link.unit_name; unit_info; strings; fragments }
408+
{ Link.unit_name; unit_info; strings; fragments }
409409
in
410410
cont unit_data unit_name tmp_wasm_file opt_tmp_map_file
411411
in
@@ -425,7 +425,7 @@ let run
425425
Fs.gen_file (Filename.chop_extension output_file ^ ".wat")
426426
@@ fun wat_file ->
427427
let dir = Filename.chop_extension output_file ^ ".assets" in
428-
Wa_link.gen_dir dir
428+
Link.gen_dir dir
429429
@@ fun tmp_dir ->
430430
Sys.mkdir tmp_dir 0o777;
431431
let opt_sourcemap =
@@ -455,21 +455,21 @@ let run
455455
if enable_source_maps
456456
then (
457457
Sys.rename (Filename.concat tmp_dir "code.wasm.map") (tmp_wasm_file' ^ ".map");
458-
Wa_link.Wasm_binary.append_source_map_section
458+
Link.Wasm_binary.append_source_map_section
459459
~file:tmp_wasm_file'
460460
~url:(wasm_name ^ ".wasm.map"));
461461
let js_runtime =
462462
let missing_primitives =
463-
let l = Wa_link.Wasm_binary.read_imports ~file:tmp_wasm_file' in
463+
let l = Link.Wasm_binary.read_imports ~file:tmp_wasm_file' in
464464
List.filter_map
465-
~f:(fun { Wa_link.Wasm_binary.module_; name; _ } ->
465+
~f:(fun { Link.Wasm_binary.module_; name; _ } ->
466466
if String.equal module_ "env" then Some name else None)
467467
l
468468
in
469469
build_js_runtime
470470
~primitives
471471
~runtime_arguments:
472-
(Wa_link.build_runtime_arguments
472+
(Link.build_runtime_arguments
473473
~missing_primitives
474474
~wasm_dir:dir
475475
~link_spec:[ wasm_name, None ]
@@ -492,7 +492,7 @@ let run
492492
unit_data)
493493
in
494494
let unit_data = [ compile_cmo' z cmo ] in
495-
Wa_link.add_info z ~build_info:(Build_info.create `Cmo) ~unit_data ();
495+
Link.add_info z ~build_info:(Build_info.create `Cmo) ~unit_data ();
496496
Zip.close_out z
497497
| `Cma cma ->
498498
Fs.gen_file output_file
@@ -515,10 +515,10 @@ let run
515515
else None)
516516
@@ fun opt_output_sourcemap_file ->
517517
let l = List.rev l in
518-
Wa_wasm_link.f
518+
Wasm_link.f
519519
(List.map
520520
~f:(fun (_, _, file, opt_source_map) ->
521-
{ Wa_wasm_link.module_name = "OCaml"
521+
{ Wasm_link.module_name = "OCaml"
522522
; file
523523
; code = None
524524
; opt_source_map = Option.map ~f:(fun f -> `File f) opt_source_map
@@ -531,7 +531,7 @@ let run
531531
List.map ~f:(fun (unit_data, _, _, _) -> unit_data) l)
532532
[]
533533
in
534-
Wa_link.add_info z ~build_info:(Build_info.create `Cma) ~unit_data ();
534+
Link.add_info z ~build_info:(Build_info.create `Cma) ~unit_data ();
535535
Zip.close_out z);
536536
close_ic ());
537537
Debug.stop_profiling ()

compiler/bin-wasm_of_ocaml/link.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ let options =
8181
let f { common; output_file; files; linkall; enable_source_maps; mklib } =
8282
Js_of_ocaml_compiler.Config.set_target `Wasm;
8383
Jsoo_cmdline.Arg.eval common;
84-
Wa_link.link ~output_file ~linkall ~mklib ~enable_source_maps ~files
84+
Link.link ~output_file ~linkall ~mklib ~enable_source_maps ~files
8585

8686
let info =
8787
Info.make
File renamed without changes.
File renamed without changes.

compiler/lib-wasm/wa_code_generation.ml renamed to compiler/lib-wasm/code_generation.ml

Lines changed: 9 additions & 9 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;
@@ -292,7 +292,7 @@ let event loc : unit t =
292292
| Event _ :: instrs | instrs -> { st with instrs = Event loc :: instrs } )
293293

294294
let hidden_location =
295-
{ Parse_info.src = Some Wa_source_map.blackbox_filename
295+
{ Parse_info.src = Some Wasm_source_map.blackbox_filename
296296
; name = None
297297
; col = 0
298298
; line = 1
@@ -645,7 +645,7 @@ let function_body ~context ~param_names ~body =
645645
| Local (i, x, typ) -> local_types.(i) <- x, typ
646646
| Expr _ -> ())
647647
st.vars;
648-
let body = Wa_tail_call.f body in
648+
let body = Tail_call.f body in
649649
let param_count = List.length param_names in
650650
let locals =
651651
local_types

0 commit comments

Comments
 (0)