Skip to content

Commit d534658

Browse files
committed
Merge with WebAssembly/function-references
2 parents 4663060 + c3fb2ad commit d534658

File tree

1 file changed

+34
-34
lines changed

1 file changed

+34
-34
lines changed

interpreter/text/parser.mly

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,9 @@ let empty_context () =
135135
deferred_locals = ref []
136136
}
137137

138-
let enter_block (c : context) at = {c with labels = scoped "label" 1l c.labels at}
139-
let enter_let (c : context) at = {c with locals = empty (); deferred_locals = ref []}
140-
let enter_func (c : context) at = {(enter_let c at) with labels = empty ()}
138+
let enter_block (c : context) loc = {c with labels = scoped "label" 1l c.labels (at loc)}
139+
let enter_let (c : context) loc = {c with locals = empty (); deferred_locals = ref []}
140+
let enter_func (c : context) loc = {(enter_let c at) with labels = empty ()}
141141

142142
let defer_locals (c : context) f =
143143
c.deferred_locals := (fun () -> ignore (f ())) :: !(c.deferred_locals)
@@ -208,19 +208,19 @@ let define_def_type (c : context) (dt : def_type) =
208208
assert (c.types.space.count > Lib.List32.length c.types.ctx);
209209
c.types.ctx <- c.types.ctx @ [dt]
210210

211-
let anon_type (c : context) at = new_fields c; bind "type" c.types.space 1l at
212-
let anon_func (c : context) at = bind "function" c.funcs 1l at
213-
let anon_locals (c : context) n at =
214-
defer_locals c (fun () -> bind "local" c.locals n at)
215-
let anon_global (c : context) at = bind "global" c.globals 1l at
216-
let anon_table (c : context) at = bind "table" c.tables 1l at
217-
let anon_memory (c : context) at = bind "memory" c.memories 1l at
218-
let anon_tag (c : context) at = bind "tag" c.tags 1l at
219-
let anon_elem (c : context) at = bind "elem segment" c.elems 1l at
220-
let anon_data (c : context) at = bind "data segment" c.datas 1l at
221-
let anon_label (c : context) at = bind "label" c.labels 1l at
222-
let anon_fields (c : context) x n at =
223-
bind "field" (Lib.List32.nth c.types.fields x) n at
211+
let anon_type (c : context) loc = bind "type" c.types.space 1l (at loc)
212+
let anon_func (c : context) loc = bind "function" c.funcs 1l (at loc)
213+
let anon_locals (c : context) n loc =
214+
defer_locals c (fun () -> bind "local" c.locals n (at loc))
215+
let anon_global (c : context) loc = bind "global" c.globals 1l (at loc)
216+
let anon_table (c : context) loc = bind "table" c.tables 1l (at loc)
217+
let anon_memory (c : context) loc = bind "memory" c.memories 1l (at loc)
218+
let anon_tag (c : context) loc = bind "tag" c.tags 1l (at loc)
219+
let anon_elem (c : context) loc = bind "elem segment" c.elems 1l (at loc)
220+
let anon_data (c : context) loc = bind "data segment" c.datas 1l (at loc)
221+
let anon_label (c : context) loc = bind "label" c.labels 1l (at loc)
222+
let anon_fields (c : context) x n loc =
223+
bind "field" (Lib.List32.nth c.types.fields x) n (at loc)
224224

225225
let find_type_index (c : context) dt loc =
226226
let st = SubT (Final, [], dt) in
@@ -232,16 +232,16 @@ let find_type_index (c : context) dt loc =
232232
with
233233
| Some i -> Int32.of_int i @@ loc
234234
| None ->
235-
let i = anon_type c (at loc) in
235+
let i = anon_type c loc in
236236
define_type c (RecT [st] @@ loc);
237237
define_def_type c (DefT (RecT [st], 0l));
238238
i @@ loc
239239

240-
let inline_func_type (c : context) ft at =
240+
let inline_func_type (c : context) ft loc =
241241
let dt = DefFuncT ft in
242-
find_type_index c dt at
242+
find_type_index c dt loc
243243

244-
let inline_func_type_explicit (c : context) x ft (loc : (Lexing.position * Lexing.position)) =
244+
let inline_func_type_explicit (c : context) x ft loc =
245245
if ft = FuncT ([], []) then
246246
(* Deferring ensures that type lookup is only triggered when
247247
symbolic identifiers are used, and not for desugared functions *)
@@ -426,9 +426,9 @@ field_type_list :
426426
struct_field_list :
427427
| /* empty */ { fun c x -> [] }
428428
| LPAR FIELD field_type_list RPAR struct_field_list
429-
{ let at3 = $loc($3) in
429+
{ let loc3 = $loc($3) in
430430
fun c x -> let fts = $3 c in
431-
ignore (anon_fields c x (Lib.List32.length fts) (at at3)); fts @ $5 c x }
431+
ignore (anon_fields c x (Lib.List32.length fts) loc3); fts @ $5 c x }
432432
| LPAR FIELD bind_var field_type RPAR struct_field_list
433433
{ fun c x -> ignore (bind_field c x $3); $4 c :: $6 c x }
434434

@@ -508,7 +508,7 @@ var_list :
508508
| var var_list { fun c lookup -> $1 c lookup :: $2 c lookup }
509509

510510
bind_var_opt :
511-
| /* empty */ { let loc = $sloc in fun c anon bind -> anon c (at loc) }
511+
| /* empty */ { let at = $sloc in fun c anon bind -> anon c at }
512512
| bind_var { fun c anon bind -> bind c $1 } /* Sugar */
513513

514514
bind_var :
@@ -519,13 +519,13 @@ labeling_opt :
519519
{ let loc = $sloc in
520520
fun c xs ->
521521
List.iter (fun x -> error x.at "mismatching label") xs;
522-
let c' = enter_block c (at loc) in ignore (anon_label c' (at loc)); c' }
522+
let c' = enter_block c loc in ignore (anon_label c' loc); c' }
523523
| bind_var
524524
{ let loc = $sloc in
525525
fun c xs ->
526526
List.iter
527527
(fun x -> if x.it <> $1.it then error x.at "mismatching label") xs;
528-
let c' = enter_block c (at loc) in ignore (bind_label c' $1); c' }
528+
let c' = enter_block c loc in ignore (bind_label c' $1); c' }
529529

530530
labeling_end_opt :
531531
| /* empty */ { [] }
@@ -897,9 +897,9 @@ resume_expr_handler :
897897

898898
if_block :
899899
| type_use if_block_param_body
900-
{ let at = $sloc in
900+
{ let loc = $sloc in
901901
fun c c' ->
902-
VarBlockType (inline_func_type_explicit c ($1 c) (fst ($2 c c')) at),
902+
VarBlockType (inline_func_type_explicit c ($1 c) (fst ($2 c c')) loc),
903903
snd ($2 c c') }
904904
| if_block_param_body /* Sugar */
905905
{ let at = $sloc in
@@ -1031,7 +1031,7 @@ func_fields_body :
10311031
{ let loc3 = $loc($3) in
10321032
(fun c -> let FuncT (ts1, ts2) = fst $5 c in
10331033
FuncT (snd $3 c @ ts1, ts2)),
1034-
(fun c -> anon_locals c (fst $3) (at loc3); snd $5 c) }
1034+
(fun c -> anon_locals c (fst $3) loc3; snd $5 c) }
10351035
| LPAR PARAM bind_var val_type RPAR func_fields_body /* Sugar */
10361036
{ (fun c -> let FuncT (ts1, ts2) = fst $6 c in
10371037
FuncT ($4 c :: ts1, ts2)),
@@ -1047,11 +1047,11 @@ func_result_body :
10471047
func_body :
10481048
| instr_list
10491049
{ let loc = $sloc in
1050-
fun c -> ignore (anon_label c (at loc));
1050+
fun c -> ignore (anon_label c loc);
10511051
{ftype = -1l @@ loc; locals = []; body = $1 c} }
10521052
| LPAR LOCAL local_type_list RPAR func_body
10531053
{ let loc3 = $loc($3) in
1054-
fun c -> anon_locals c (fst $3) (at loc3); let f = $5 c in
1054+
fun c -> anon_locals c (fst $3) loc3; let f = $5 c in
10551055
{f with locals = snd $3 c @ f.Ast.locals} }
10561056
| LPAR LOCAL bind_var local_type RPAR func_body /* Sugar */
10571057
{ fun c -> ignore (bind_local c $3); let f = $6 c in
@@ -1234,9 +1234,9 @@ global_fields :
12341234

12351235
tag :
12361236
| LPAR TAG bind_var_opt tag_fields RPAR
1237-
{ let at = $sloc in
1238-
fun c -> let x = $3 c anon_tag bind_tag @@ at in
1239-
fun () -> $4 c x at }
1237+
{ let loc = $sloc in
1238+
fun c -> let x = $3 c anon_tag bind_tag @@ loc in
1239+
fun () -> $4 c x loc }
12401240

12411241
tag_fields :
12421242
| tag_type
@@ -1305,7 +1305,7 @@ inline_export :
13051305
type_def :
13061306
| LPAR TYPE sub_type RPAR
13071307
{ let loc = $sloc in
1308-
fun c -> let x = anon_type c (at loc) in fun () -> $3 c x }
1308+
fun c -> let x = anon_type c loc in fun () -> $3 c x }
13091309
| LPAR TYPE bind_var sub_type RPAR /* Sugar */
13101310
{ fun c -> let x = bind_type c $3 in fun () -> $4 c x }
13111311

0 commit comments

Comments
 (0)