@@ -135,9 +135,9 @@ let empty_context () =
135
135
deferred_locals = ref []
136
136
}
137
137
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 ()}
141
141
142
142
let defer_locals (c : context) f =
143
143
c.deferred_locals := (fun () -> ignore (f ())) :: !(c.deferred_locals)
@@ -208,19 +208,19 @@ let define_def_type (c : context) (dt : def_type) =
208
208
assert (c.types.space.count > Lib.List32.length c.types.ctx);
209
209
c.types.ctx <- c.types.ctx @ [dt]
210
210
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)
224
224
225
225
let find_type_index (c : context) dt loc =
226
226
let st = SubT (Final, [], dt) in
@@ -232,16 +232,16 @@ let find_type_index (c : context) dt loc =
232
232
with
233
233
| Some i -> Int32.of_int i @@ loc
234
234
| None ->
235
- let i = anon_type c (at loc) in
235
+ let i = anon_type c loc in
236
236
define_type c (RecT [st] @@ loc);
237
237
define_def_type c (DefT (RecT [st], 0l));
238
238
i @@ loc
239
239
240
- let inline_func_type (c : context) ft at =
240
+ let inline_func_type (c : context) ft loc =
241
241
let dt = DefFuncT ft in
242
- find_type_index c dt at
242
+ find_type_index c dt loc
243
243
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 =
245
245
if ft = FuncT ([], []) then
246
246
(* Deferring ensures that type lookup is only triggered when
247
247
symbolic identifiers are used, and not for desugared functions *)
@@ -426,9 +426,9 @@ field_type_list :
426
426
struct_field_list :
427
427
| /* empty */ { fun c x -> [] }
428
428
| LPAR FIELD field_type_list RPAR struct_field_list
429
- { let at3 = $loc($3) in
429
+ { let loc3 = $loc($3) in
430
430
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 }
432
432
| LPAR FIELD bind_var field_type RPAR struct_field_list
433
433
{ fun c x -> ignore (bind_field c x $3); $4 c :: $6 c x }
434
434
@@ -508,7 +508,7 @@ var_list :
508
508
| var var_list { fun c lookup -> $1 c lookup :: $2 c lookup }
509
509
510
510
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 }
512
512
| bind_var { fun c anon bind -> bind c $1 } /* Sugar */
513
513
514
514
bind_var :
@@ -519,13 +519,13 @@ labeling_opt :
519
519
{ let loc = $sloc in
520
520
fun c xs ->
521
521
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' }
523
523
| bind_var
524
524
{ let loc = $sloc in
525
525
fun c xs ->
526
526
List.iter
527
527
(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' }
529
529
530
530
labeling_end_opt :
531
531
| /* empty */ { [] }
@@ -897,9 +897,9 @@ resume_expr_handler :
897
897
898
898
if_block :
899
899
| type_use if_block_param_body
900
- { let at = $sloc in
900
+ { let loc = $sloc in
901
901
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 ),
903
903
snd ($2 c c') }
904
904
| if_block_param_body /* Sugar */
905
905
{ let at = $sloc in
@@ -1031,7 +1031,7 @@ func_fields_body :
1031
1031
{ let loc3 = $loc($3) in
1032
1032
(fun c -> let FuncT (ts1, ts2) = fst $5 c in
1033
1033
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) }
1035
1035
| LPAR PARAM bind_var val_type RPAR func_fields_body /* Sugar */
1036
1036
{ (fun c -> let FuncT (ts1, ts2) = fst $6 c in
1037
1037
FuncT ($4 c :: ts1, ts2)),
@@ -1047,11 +1047,11 @@ func_result_body :
1047
1047
func_body :
1048
1048
| instr_list
1049
1049
{ let loc = $sloc in
1050
- fun c -> ignore (anon_label c (at loc) );
1050
+ fun c -> ignore (anon_label c loc);
1051
1051
{ftype = -1l @@ loc; locals = []; body = $1 c} }
1052
1052
| LPAR LOCAL local_type_list RPAR func_body
1053
1053
{ 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
1055
1055
{f with locals = snd $3 c @ f.Ast.locals} }
1056
1056
| LPAR LOCAL bind_var local_type RPAR func_body /* Sugar */
1057
1057
{ fun c -> ignore (bind_local c $3); let f = $6 c in
@@ -1234,9 +1234,9 @@ global_fields :
1234
1234
1235
1235
tag :
1236
1236
| 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 }
1240
1240
1241
1241
tag_fields :
1242
1242
| tag_type
@@ -1305,7 +1305,7 @@ inline_export :
1305
1305
type_def :
1306
1306
| LPAR TYPE sub_type RPAR
1307
1307
{ 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 }
1309
1309
| LPAR TYPE bind_var sub_type RPAR /* Sugar */
1310
1310
{ fun c -> let x = bind_type c $3 in fun () -> $4 c x }
1311
1311
0 commit comments