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