@@ -102,7 +102,7 @@ let func_ref inst x i at =
102
102
| _ -> Crash. error at (" type mismatch for element " ^ Int32. to_string i)
103
103
104
104
let func_type_of = function
105
- | Func. AstFunc (t , inst , f ) -> t
105
+ | Func. AstFunc (t , _inst , _f ) -> t
106
106
| Func. HostFunc (t , _ ) -> t
107
107
108
108
let block_type inst bt =
@@ -166,7 +166,7 @@ let rec step (c : config) : config =
166
166
vs', [Label (n2, [] , (args, List. map plain es')) @@ e.at]
167
167
168
168
| Loop (bt , es' ), vs ->
169
- let FuncType (ts1, ts2 ) = block_type frame.inst bt in
169
+ let FuncType (ts1, _ts2 ) = block_type frame.inst bt in
170
170
let n1 = Lib.List32. length ts1 in
171
171
let args, vs' = take n1 vs e.at, drop n1 vs e.at in
172
172
vs', [Label (n1, [e' @@ e.at], (args, List. map plain es')) @@ e.at]
@@ -205,7 +205,7 @@ let rec step (c : config) : config =
205
205
else
206
206
vs, [Invoke func @@ e.at]
207
207
208
- | Drop , v :: vs' ->
208
+ | Drop , _v :: vs' ->
209
209
vs', []
210
210
211
211
| Select _ , Num (I32 i ) :: v2 :: v1 :: vs' ->
@@ -361,7 +361,7 @@ let rec step (c : config) : config =
361
361
vs', []
362
362
with exn -> vs', [Trapping (memory_error e.at exn ) @@ e.at]);
363
363
364
- | VecLoadLane ({offset; ty; pack; _} , j ), Vec (V128 v ) :: Num (I32 i ) :: vs' ->
364
+ | VecLoadLane ({offset; ty = _ ; pack; _} , j ), Vec (V128 v ) :: Num (I32 i ) :: vs' ->
365
365
let mem = memory frame.inst (0l @@ e.at) in
366
366
let addr = I64_convert. extend_i32_u i in
367
367
(try
@@ -382,7 +382,7 @@ let rec step (c : config) : config =
382
382
in Vec (V128 v) :: vs', []
383
383
with exn -> vs', [Trapping (memory_error e.at exn ) @@ e.at])
384
384
385
- | VecStoreLane ({offset; ty; pack; _} , j ), Vec (V128 v ) :: Num (I32 i ) :: vs' ->
385
+ | VecStoreLane ({offset; ty = _ ; pack; _} , j ), Vec (V128 v ) :: Num (I32 i ) :: vs' ->
386
386
let mem = memory frame.inst (0l @@ e.at) in
387
387
let addr = I64_convert. extend_i32_u i in
388
388
(try
@@ -592,62 +592,62 @@ let rec step (c : config) : config =
592
592
| Refer r , vs ->
593
593
Ref r :: vs, []
594
594
595
- | Trapping msg , vs ->
595
+ | Trapping _msg , _vs ->
596
596
assert false
597
597
598
- | Returning vs ' , vs ->
598
+ | Returning _vs ' , _vs ->
599
599
Crash. error e.at " undefined frame"
600
600
601
- | Breaking (k , vs ' ), vs ->
601
+ | Breaking (_k , _vs ' ), _vs ->
602
602
Crash. error e.at " undefined label"
603
603
604
- | Label (n , es0 , (vs' , [] )), vs ->
604
+ | Label (_n , _es0 , (vs' , [] )), vs ->
605
605
vs' @ vs, []
606
606
607
- | Label (n , es0 , (vs ' , {it = Trapping msg ; at} :: es ' )), vs ->
607
+ | Label (_n , _es0 , (_vs ' , {it = Trapping msg ; at} :: _es ' )), vs ->
608
608
vs, [Trapping msg @@ at]
609
609
610
- | Label (n , es0 , (vs ' , {it = Returning vs0 ; at} :: es ' )), vs ->
610
+ | Label (_n , _es0 , (_vs ' , {it = Returning vs0 ; at} :: _es ' )), vs ->
611
611
vs, [Returning vs0 @@ at]
612
612
613
- | Label (n , es0 , (vs ' , {it = Breaking (0l , vs0 ); at} :: es ' )), vs ->
613
+ | Label (n , es0 , (_vs ' , {it = Breaking (0l , vs0 ); at = _ } :: _es ' )), vs ->
614
614
take n vs0 e.at @ vs, List. map plain es0
615
615
616
- | Label (n , es0 , (vs ' , {it = Breaking (k , vs0 ); at} :: es ' )), vs ->
616
+ | Label (_n , _es0 , (_vs ' , {it = Breaking (k , vs0 ); at} :: _es ' )), vs ->
617
617
vs, [Breaking (Int32. sub k 1l , vs0) @@ at]
618
618
619
619
| Label (n , es0 , code' ), vs ->
620
620
let c' = step {c with code = code'} in
621
621
vs, [Label (n, es0, c'.code) @@ e.at]
622
622
623
- | Frame (n , frame ' , (vs' , [] )), vs ->
623
+ | Frame (_n , _frame ' , (vs' , [] )), vs ->
624
624
vs' @ vs, []
625
625
626
- | Frame (n , frame ' , (vs ' , {it = Trapping msg ; at} :: es ' )), vs ->
626
+ | Frame (_n , _frame ' , (_vs ' , {it = Trapping msg ; at} :: _es ' )), vs ->
627
627
vs, [Trapping msg @@ at]
628
628
629
- | Frame (n , frame ' , (vs ' , {it = Returning vs0 ; at} :: es ' )), vs ->
629
+ | Frame (n , _frame ' , (_vs ' , {it = Returning vs0 ; at = _ } :: _es ' )), vs ->
630
630
take n vs0 e.at @ vs, []
631
631
632
632
| Frame (n , frame' , code' ), vs ->
633
633
let c' = step {frame = frame'; code = code'; budget = c.budget - 1 } in
634
634
vs, [Frame (n, c'.frame, c'.code) @@ e.at]
635
635
636
- | Invoke func , vs when c.budget = 0 ->
636
+ | Invoke _func , _vs when c.budget = 0 ->
637
637
Exhaustion. error e.at " call stack exhausted"
638
638
639
639
| Invoke func , vs ->
640
640
let FuncType (ins, out) = func_type_of func in
641
641
let n1, n2 = Lib.List32. length ins, Lib.List32. length out in
642
642
let args, vs' = take n1 vs e.at, drop n1 vs e.at in
643
643
(match func with
644
- | Func. AstFunc (t , inst' , f ) ->
644
+ | Func. AstFunc (_t , inst' , f ) ->
645
645
let locals' = List. rev args @ List. map default_value f.it.locals in
646
646
let frame' = {inst = ! inst'; locals = List. map ref locals'} in
647
647
let instr' = [Label (n2, [] , ([] , List. map plain f.it.body)) @@ f.at] in
648
648
vs', [Frame (n2, frame', ([] , instr')) @@ e.at]
649
649
650
- | Func. HostFunc (t , f ) ->
650
+ | Func. HostFunc (_t , f ) ->
651
651
try List. rev (f (List. rev args)) @ vs', []
652
652
with Crash (_ , msg ) -> Crash. error e.at msg
653
653
)
@@ -659,18 +659,18 @@ let rec eval (c : config) : value stack =
659
659
| vs , [] ->
660
660
vs
661
661
662
- | vs , {it = Trapping msg ; at} :: _ ->
662
+ | _vs , {it = Trapping msg ; at} :: _ ->
663
663
Trap. error at msg
664
664
665
- | vs , es ->
665
+ | _vs , _es ->
666
666
eval (step c)
667
667
668
668
669
669
(* Functions & Constants *)
670
670
671
671
let invoke (func : func_inst ) (vs : value list ) : value list =
672
672
let at = match func with Func. AstFunc (_ , _ , f ) -> f.at | _ -> no_region in
673
- let FuncType (ins, out ) = Func. type_of func in
673
+ let FuncType (ins, _out ) = Func. type_of func in
674
674
if List. length vs <> List. length ins then
675
675
Crash. error at " wrong number of arguments" ;
676
676
if not (List. for_all2 (fun v -> (= ) (type_of_value v)) vs ins) then
@@ -683,20 +683,20 @@ let eval_const (inst : module_inst) (const : const) : value =
683
683
let c = config inst [] (List. map plain const.it) in
684
684
match eval c with
685
685
| [v] -> v
686
- | vs -> Crash. error const.at " wrong number of results on stack"
686
+ | _vs -> Crash. error const.at " wrong number of results on stack"
687
687
688
688
689
689
(* Modules *)
690
690
691
691
let create_func (inst : module_inst ) (f : func ) : func_inst =
692
692
Func. alloc (type_ inst f.it.ftype) (ref inst) f
693
693
694
- let create_table (inst : module_inst ) (tab : table ) : table_inst =
694
+ let create_table (_inst : module_inst ) (tab : table ) : table_inst =
695
695
let {ttype} = tab.it in
696
696
let TableType (_lim, t) = ttype in
697
697
Table. alloc ttype (NullRef t)
698
698
699
- let create_memory (inst : module_inst ) (mem : memory ) : memory_inst =
699
+ let create_memory (_inst : module_inst ) (mem : memory ) : memory_inst =
700
700
let {mtype} = mem.it in
701
701
Memory. alloc mtype
702
702
@@ -716,10 +716,10 @@ let create_export (inst : module_inst) (ex : export) : export_inst =
716
716
in (name, ext)
717
717
718
718
let create_elem (inst : module_inst ) (seg : elem_segment ) : elem_inst =
719
- let {etype; einit; _} = seg.it in
719
+ let {etype = _ ; einit; _} = seg.it in
720
720
Elem. alloc (List. map (fun c -> as_ref (eval_const inst c)) einit)
721
721
722
- let create_data (inst : module_inst ) (seg : data_segment ) : data_inst =
722
+ let create_data (_inst : module_inst ) (seg : data_segment ) : data_inst =
723
723
let {dinit; _} = seg.it in
724
724
Data. alloc dinit
725
725
0 commit comments