From 92acc135dca86cdd4c934feafc965fb1dda1575b Mon Sep 17 00:00:00 2001 From: zapashcanon Date: Fri, 10 Nov 2023 20:24:07 +0100 Subject: [PATCH] use the default set of warnings --- interpreter/binary/decode.ml | 4 +- interpreter/binary/utf8.ml | 4 +- interpreter/dune | 5 -- interpreter/exec/eval.ml | 54 ++++++++-------- interpreter/exec/eval_num.ml | 2 +- interpreter/exec/ixx.ml | 4 +- interpreter/exec/v128.ml | 4 +- interpreter/host/env.ml | 4 +- interpreter/runtime/table.ml | 2 +- interpreter/script/import.ml | 2 +- interpreter/script/js.ml | 14 ++-- interpreter/script/run.ml | 6 +- interpreter/syntax/free.ml | 12 ++-- interpreter/syntax/values.ml | 4 +- interpreter/text/arrange.ml | 44 ++++++------- interpreter/text/parser.mly | 120 +++++++++++++++++------------------ interpreter/util/lib.ml | 4 +- interpreter/valid/valid.ml | 20 +++--- 18 files changed, 152 insertions(+), 157 deletions(-) diff --git a/interpreter/binary/decode.ml b/interpreter/binary/decode.ml index fa3a0ef9e5..7a205197b0 100644 --- a/interpreter/binary/decode.ml +++ b/interpreter/binary/decode.ml @@ -944,7 +944,7 @@ let code_section s = (* Element section *) -let passive s = +let passive _s = Passive let active s = @@ -957,7 +957,7 @@ let active_zero s = let offset = const s in Active {index; offset} -let declarative s = +let declarative _s = Declarative let elem_index s = diff --git a/interpreter/binary/utf8.ml b/interpreter/binary/utf8.ml index b922954882..4a2260b90c 100644 --- a/interpreter/binary/utf8.ml +++ b/interpreter/binary/utf8.ml @@ -8,7 +8,7 @@ let con n = 0x80 lor (n land 0x3f) let rec encode ns = Lib.String.implode (List.map Char.chr (encode' ns)) and encode' = function | [] -> [] - | n::ns when n < 0 -> + | n::_ns when n < 0 -> raise Utf8 | n::ns when n < 0x80 -> n :: encode' ns @@ -32,7 +32,7 @@ and decode' = function | [] -> [] | b1::bs when b1 < 0x80 -> code 0x0 b1 :: decode' bs - | b1::bs when b1 < 0xc0 -> + | b1::_bs when b1 < 0xc0 -> raise Utf8 | b1::b2::bs when b1 < 0xe0 -> code 0x80 ((b1 land 0x1f) lsl 6 + con b2) :: decode' bs diff --git a/interpreter/dune b/interpreter/dune index 9a853921db..62cf0a2233 100644 --- a/interpreter/dune +++ b/interpreter/dune @@ -46,11 +46,6 @@ (ocamlyacc (modules parser))) -(env - (_ - (flags - (-w +a-4-27-42-44-45-70 -warn-error +a-3)))) - (rule (alias runtest) (deps diff --git a/interpreter/exec/eval.ml b/interpreter/exec/eval.ml index 90221c4cdf..46cae63520 100644 --- a/interpreter/exec/eval.ml +++ b/interpreter/exec/eval.ml @@ -102,7 +102,7 @@ let func_ref inst x i at = | _ -> Crash.error at ("type mismatch for element " ^ Int32.to_string i) let func_type_of = function - | Func.AstFunc (t, inst, f) -> t + | Func.AstFunc (t, _inst, _f) -> t | Func.HostFunc (t, _) -> t let block_type inst bt = @@ -166,7 +166,7 @@ let rec step (c : config) : config = vs', [Label (n2, [], (args, List.map plain es')) @@ e.at] | Loop (bt, es'), vs -> - let FuncType (ts1, ts2) = block_type frame.inst bt in + let FuncType (ts1, _ts2) = block_type frame.inst bt in let n1 = Lib.List32.length ts1 in let args, vs' = take n1 vs e.at, drop n1 vs e.at in vs', [Label (n1, [e' @@ e.at], (args, List.map plain es')) @@ e.at] @@ -205,7 +205,7 @@ let rec step (c : config) : config = else vs, [Invoke func @@ e.at] - | Drop, v :: vs' -> + | Drop, _v :: vs' -> vs', [] | Select _, Num (I32 i) :: v2 :: v1 :: vs' -> @@ -362,7 +362,7 @@ let rec step (c : config) : config = vs', [] with exn -> vs', [Trapping (memory_error e.at exn) @@ e.at]); - | VecLoadLane ({offset; ty; pack; _}, j), Vec (V128 v) :: Num (I32 i) :: vs' -> + | VecLoadLane ({offset; pack; _}, j), Vec (V128 v) :: Num (I32 i) :: vs' -> let mem = memory frame.inst (0l @@ e.at) in let addr = I64_convert.extend_i32_u i in (try @@ -383,7 +383,7 @@ let rec step (c : config) : config = in Vec (V128 v) :: vs', [] with exn -> vs', [Trapping (memory_error e.at exn) @@ e.at]) - | VecStoreLane ({offset; ty; pack; _}, j), Vec (V128 v) :: Num (I32 i) :: vs' -> + | VecStoreLane ({offset; pack; _}, j), Vec (V128 v) :: Num (I32 i) :: vs' -> let mem = memory frame.inst (0l @@ e.at) in let addr = I64_convert.extend_i32_u i in (try @@ -594,48 +594,48 @@ let rec step (c : config) : config = | Refer r, vs -> Ref r :: vs, [] - | Trapping msg, vs -> + | Trapping _msg, _vs -> assert false - | Returning vs', vs -> + | Returning _vs', _vs -> Crash.error e.at "undefined frame" - | Breaking (k, vs'), vs -> + | Breaking (_k, _vs'), _vs -> Crash.error e.at "undefined label" - | Label (n, es0, (vs', [])), vs -> + | Label (_n, _es0, (vs', [])), vs -> vs' @ vs, [] - | Label (n, es0, (vs', {it = Trapping msg; at} :: es')), vs -> + | Label (_n, _es0, (_vs', {it = Trapping msg; at} :: _es')), vs -> vs, [Trapping msg @@ at] - | Label (n, es0, (vs', {it = Returning vs0; at} :: es')), vs -> + | Label (_n, _es0, (_vs', {it = Returning vs0; at} :: _es')), vs -> vs, [Returning vs0 @@ at] - | Label (n, es0, (vs', {it = Breaking (0l, vs0); at} :: es')), vs -> + | Label (n, es0, (_vs', {it = Breaking (0l, vs0); _ } :: _es')), vs -> take n vs0 e.at @ vs, List.map plain es0 - | Label (n, es0, (vs', {it = Breaking (k, vs0); at} :: es')), vs -> + | Label (_n, _es0, (_vs', {it = Breaking (k, vs0); at} :: _es')), vs -> vs, [Breaking (Int32.sub k 1l, vs0) @@ at] | Label (n, es0, code'), vs -> let c' = step {c with code = code'} in vs, [Label (n, es0, c'.code) @@ e.at] - | Frame (n, frame', (vs', [])), vs -> + | Frame (_n, _frame', (vs', [])), vs -> vs' @ vs, [] - | Frame (n, frame', (vs', {it = Trapping msg; at} :: es')), vs -> + | Frame (_n, _frame', (_vs', {it = Trapping msg; at} :: _es')), vs -> vs, [Trapping msg @@ at] - | Frame (n, frame', (vs', {it = Returning vs0; at} :: es')), vs -> + | Frame (n, _frame', (_vs', {it = Returning vs0; _} :: _es')), vs -> take n vs0 e.at @ vs, [] | Frame (n, frame', code'), vs -> let c' = step {frame = frame'; code = code'; budget = c.budget - 1} in vs, [Frame (n, c'.frame, c'.code) @@ e.at] - | Invoke func, vs when c.budget = 0 -> + | Invoke _func, _vs when c.budget = 0 -> Exhaustion.error e.at "call stack exhausted" | Invoke func, vs -> @@ -643,13 +643,13 @@ let rec step (c : config) : config = let n1, n2 = Lib.List32.length ins, Lib.List32.length out in let args, vs' = take n1 vs e.at, drop n1 vs e.at in (match func with - | Func.AstFunc (t, inst', f) -> + | Func.AstFunc (_t, inst', f) -> let locals' = List.rev args @ List.map default_value f.it.locals in let frame' = {inst = !inst'; locals = List.map ref locals'} in let instr' = [Label (n2, [], ([], List.map plain f.it.body)) @@ f.at] in vs', [Frame (n2, frame', ([], instr')) @@ e.at] - | Func.HostFunc (t, f) -> + | Func.HostFunc (_t, f) -> try List.rev (f (List.rev args)) @ vs', [] with Crash (_, msg) -> Crash.error e.at msg ) @@ -661,10 +661,10 @@ let rec eval (c : config) : value stack = | vs, [] -> vs - | vs, {it = Trapping msg; at} :: _ -> + | _vs, {it = Trapping msg; at} :: _ -> Trap.error at msg - | vs, es -> + | _vs, _es -> eval (step c) @@ -672,7 +672,7 @@ let rec eval (c : config) : value stack = let invoke (func : func_inst) (vs : value list) : value list = let at = match func with Func.AstFunc (_, _, f) -> f.at | _ -> no_region in - let FuncType (ins, out) = Func.type_of func in + let FuncType (ins, _out) = Func.type_of func in if List.length vs <> List.length ins then Crash.error at "wrong number of arguments"; if not (List.for_all2 (fun v -> (=) (type_of_value v)) vs ins) then @@ -685,7 +685,7 @@ let eval_const (inst : module_inst) (const : const) : value = let c = config inst [] (List.map plain const.it) in match eval c with | [v] -> v - | vs -> Crash.error const.at "wrong number of results on stack" + | _vs -> Crash.error const.at "wrong number of results on stack" (* Modules *) @@ -693,12 +693,12 @@ let eval_const (inst : module_inst) (const : const) : value = let create_func (inst : module_inst) (f : func) : func_inst = Func.alloc (type_ inst f.it.ftype) (ref inst) f -let create_table (inst : module_inst) (tab : table) : table_inst = +let create_table (_inst : module_inst) (tab : table) : table_inst = let {ttype} = tab.it in let TableType (_lim, t) = ttype in Table.alloc ttype (NullRef t) -let create_memory (inst : module_inst) (mem : memory) : memory_inst = +let create_memory (_inst : module_inst) (mem : memory) : memory_inst = let {mtype} = mem.it in Memory.alloc mtype @@ -718,10 +718,10 @@ let create_export (inst : module_inst) (ex : export) : export_inst = in (name, ext) let create_elem (inst : module_inst) (seg : elem_segment) : elem_inst = - let {etype; einit; _} = seg.it in + let { einit; _} = seg.it in Elem.alloc (List.map (fun c -> as_ref (eval_const inst c)) einit) -let create_data (inst : module_inst) (seg : data_segment) : data_inst = +let create_data (_inst : module_inst) (seg : data_segment) : data_inst = let {dinit; _} = seg.it in Data.alloc dinit diff --git a/interpreter/exec/eval_num.ml b/interpreter/exec/eval_num.ml index 40dd1be07c..3b00ce8bf4 100644 --- a/interpreter/exec/eval_num.ml +++ b/interpreter/exec/eval_num.ml @@ -89,7 +89,7 @@ struct | CopySign -> FXX.copysign in fun v1 v2 -> to_num (f (of_num 1 v1) (of_num 2 v2)) - let testop op = assert false + let testop _op = assert false let relop op = let f = match op with diff --git a/interpreter/exec/ixx.ml b/interpreter/exec/ixx.ml index 0a13d22b6e..ac83a3c45d 100644 --- a/interpreter/exec/ixx.ml +++ b/interpreter/exec/ixx.ml @@ -175,7 +175,7 @@ struct (* result is floored (which is the same as truncating for unsigned values) *) let div_u x y = - let q, r = divrem_u x y in q + let q, _r = divrem_u x y in q (* result has the sign of the dividend *) let rem_s x y = @@ -185,7 +185,7 @@ struct Rep.rem x y let rem_u x y = - let q, r = divrem_u x y in r + let _q, r = divrem_u x y in r let avgr_u x y = let open Int64 in diff --git a/interpreter/exec/v128.ml b/interpreter/exec/v128.ml index 873035ad35..638c094a4d 100644 --- a/interpreter/exec/v128.ml +++ b/interpreter/exec/v128.ml @@ -109,7 +109,7 @@ struct let reduceop f a s = List.fold_left (fun a b -> f a (b <> IXX.zero)) a (to_lanes s) let cmp f x y = if f x y then IXX.of_int_s (-1) else IXX.zero - let splat x = of_lanes (List.init num_lanes (fun i -> x)) + let splat x = of_lanes (List.init num_lanes (fun _i -> x)) let extract_lane_s i s = List.nth (to_lanes s) i let extract_lane_u i s = IXX.as_unsigned (extract_lane_s i s) let replace_lane i v x = unopi (fun j y -> if j = i then x else y) v @@ -212,7 +212,7 @@ struct let all_ones = FXX.of_float (Int64.float_of_bits (Int64.minus_one)) let cmp f x y = if f x y then all_ones else FXX.zero - let splat x = of_lanes (List.init num_lanes (fun i -> x)) + let splat x = of_lanes (List.init num_lanes (fun _i -> x)) let extract_lane i s = List.nth (to_lanes s) i let replace_lane i v x = unopi (fun j y -> if j = i then x else y) v diff --git a/interpreter/host/env.ml b/interpreter/host/env.ml index 58239d10bc..85ea591f88 100644 --- a/interpreter/host/env.ml +++ b/interpreter/host/env.ml @@ -18,12 +18,12 @@ let type_error v t = let empty = function | [] -> () - | vs -> error "type error, too many arguments" + | _vs -> error "type error, too many arguments" let single = function | [] -> error "type error, missing arguments" | [v] -> v - | vs -> error "type error, too many arguments" + | _vs -> error "type error, too many arguments" let int = function | Num (I32 i) -> Int32.to_int i diff --git a/interpreter/runtime/table.ml b/interpreter/runtime/table.ml index e7fc317e8d..df95d8527f 100644 --- a/interpreter/runtime/table.ml +++ b/interpreter/runtime/table.ml @@ -51,7 +51,7 @@ let load tab i = Lib.Array32.get tab.content i let store tab i r = - let TableType (lim, t) = tab.ty in + let TableType (_lim, t) = tab.ty in if type_of_ref r <> t then raise Type; if i < 0l || i >= Lib.Array32.length tab.content then raise Bounds; Lib.Array32.set tab.content i r diff --git a/interpreter/script/import.ml b/interpreter/script/import.ml index c9e65eafcd..96954e084a 100644 --- a/interpreter/script/import.ml +++ b/interpreter/script/import.ml @@ -10,7 +10,7 @@ let registry = ref Registry.empty let register name lookup = registry := Registry.add name lookup !registry let lookup (m : module_) (im : import) : Instance.extern = - let {module_name; item_name; idesc} = im.it in + let {module_name; item_name; _} = im.it in let t = import_type m im in try Registry.find module_name !registry item_name t with Not_found -> Unknown.error im.at diff --git a/interpreter/script/js.ml b/interpreter/script/js.ml index 2eb849a6c1..d139948574 100644 --- a/interpreter/script/js.ml +++ b/interpreter/script/js.ml @@ -217,7 +217,7 @@ let bind (mods : modules) x_opt m = let lookup (mods : modules) x_opt name at = let exports = try Map.find (of_var_opt mods x_opt) mods.env with Not_found -> - raise (Eval.Crash (at, + raise (Eval.Crash (at, if x_opt = None then "no module defined within script" else "unknown module " ^ of_var_opt mods x_opt ^ " within script")) in try NameMap.find name exports with Not_found -> @@ -275,10 +275,10 @@ let invoke ft vs at = let get t at = [], GlobalImport t @@ at, [GlobalGet (subject_idx @@ at) @@ at] -let run ts at = +let run _ts _at = [], [] -let assert_return ress ts at = +let assert_return ress _ts at = let test res = let nan_bitmask_of = function | CanonicalNan -> abs_mask_of (* must only differ from the canonical NaN in its sign bit *) @@ -354,7 +354,7 @@ let assert_return ress ts at = VecTest (V128 (V128.I8x16 V128Op.AllTrue)) @@ at; Test (I32 I32Op.Eqz) @@ at; BrIf (0l @@ at) @@ at ] - | RefResult (RefPat {it = Values.NullRef t; _}) -> + | RefResult (RefPat {it = Values.NullRef _t; _}) -> [ RefIsNull @@ at; Test (Values.I32 I32Op.Eqz) @@ at; BrIf (0l @@ at) @@ at ] @@ -425,8 +425,8 @@ let is_js_num_type = function let is_js_value_type = function | NumType t -> is_js_num_type t - | VecType t -> false - | RefType t -> true + | VecType _t -> false + | RefType _t -> true let is_js_global_type = function | GlobalType (t, mut) -> is_js_value_type t && mut = Immutable @@ -508,7 +508,7 @@ let of_num_pat = function | Values.F32 n | Values.F64 n -> of_nan n let of_vec_pat = function - | VecPat (Values.V128 (shape, pats)) -> + | VecPat (Values.V128 (_shape, pats)) -> Printf.sprintf "v128(\"%s\")" (String.concat " " (List.map of_num_pat pats)) let of_ref_pat = function diff --git a/interpreter/script/run.ml b/interpreter/script/run.ml index e0019d84a0..33d28e572e 100644 --- a/interpreter/script/run.ml +++ b/interpreter/script/run.ml @@ -155,7 +155,7 @@ let input_binary_file file run = success with exn -> close_in ic; raise exn -let input_js_file file run = +let input_js_file file _run = raise (Sys_error (file ^ ": unrecognized input file type")) let input_file file run = @@ -268,7 +268,7 @@ let string_of_num_pat (p : num_pat) = let string_of_vec_pat (p : vec_pat) = match p with - | VecPat (Values.V128 (shape, ns)) -> + | VecPat (Values.V128 (_shape, ns)) -> String.concat " " (List.map string_of_num_pat ns) let string_of_ref_pat (p : ref_pat) = @@ -347,7 +347,7 @@ let run_action act : Values.value list = let inst = lookup_instance x_opt act.at in (match Instance.export inst name with | Some (Instance.ExternFunc f) -> - let Types.FuncType (ins, out) = Func.type_of f in + let Types.FuncType (ins, _out) = Func.type_of f in if List.length vs <> List.length ins then Script.error act.at "wrong number of arguments"; List.iter2 (fun v t -> diff --git a/interpreter/syntax/free.ml b/interpreter/syntax/free.ml index 8e1a37a458..bc3b962183 100644 --- a/interpreter/syntax/free.ml +++ b/interpreter/syntax/free.ml @@ -103,8 +103,8 @@ let const (c : const) = block c.it let global (g : global) = const g.it.ginit let func (f : func) = {(block f.it.body) with locals = Set.empty} -let table (t : table) = empty -let memory (m : memory) = empty +let table (_t : table) = empty +let memory (_m : memory) = empty let segment_mode f (m : segment_mode) = match m.it with @@ -117,7 +117,7 @@ let elem (s : elem_segment) = let data (s : data_segment) = segment_mode memories s.it.dmode -let type_ (t : type_) = empty +let type_ (_t : type_) = empty let export_desc (d : export_desc) = match d.it with @@ -129,9 +129,9 @@ let export_desc (d : export_desc) = let import_desc (d : import_desc) = match d.it with | FuncImport x -> types (var x) - | TableImport tt -> empty - | MemoryImport mt -> empty - | GlobalImport gt -> empty + | TableImport _tt -> empty + | MemoryImport _mt -> empty + | GlobalImport _gt -> empty let export (e : export) = export_desc e.it.edesc let import (i : import) = import_desc i.it.idesc diff --git a/interpreter/syntax/values.ml b/interpreter/syntax/values.ml index eefe37d5d0..e7fa5d1b90 100644 --- a/interpreter/syntax/values.ml +++ b/interpreter/syntax/values.ml @@ -81,7 +81,7 @@ module V128Vec = struct type t = V128.t let to_vec i = V128 i - let of_vec n = function V128 z -> z + let of_vec _n = function V128 z -> z end @@ -169,7 +169,7 @@ let string_of_vec = function let hex_string_of_vec = function | V128 v -> V128.to_hex_string v -let string_of_ref' = ref (function NullRef t -> "null" | _ -> "ref") +let string_of_ref' = ref (function NullRef _t -> "null" | _ -> "ref") let string_of_ref r = !string_of_ref' r let string_of_value = function diff --git a/interpreter/text/arrange.ml b/interpreter/text/arrange.ml index dc56743eb6..ad85e14132 100644 --- a/interpreter/text/arrange.ml +++ b/interpreter/text/arrange.ml @@ -102,10 +102,10 @@ module IntOp = struct open Ast.IntOp - let testop xx = function + let testop _xx = function | Eqz -> "eqz" - let relop xx = function + let relop _xx = function | Eq -> "eq" | Ne -> "ne" | LtS -> "lt_s" @@ -117,13 +117,13 @@ struct | GeS -> "ge_s" | GeU -> "ge_u" - let unop xx = function + let unop _xx = function | Clz -> "clz" | Ctz -> "ctz" | Popcnt -> "popcnt" | ExtendS sz -> "extend" ^ pack_size sz ^ "_s" - let binop xx = function + let binop _xx = function | Add -> "add" | Sub -> "sub" | Mul -> "mul" @@ -159,9 +159,9 @@ module FloatOp = struct open Ast.FloatOp - let testop xx = function (_ : testop) -> . + let testop _xx = function (_ : testop) -> . - let relop xx = function + let relop _xx = function | Eq -> "eq" | Ne -> "ne" | Lt -> "lt" @@ -169,7 +169,7 @@ struct | Le -> "le" | Ge -> "ge" - let unop xx = function + let unop _xx = function | Neg -> "neg" | Abs -> "abs" | Ceil -> "ceil" @@ -178,7 +178,7 @@ struct | Nearest -> "nearest" | Sqrt -> "sqrt" - let binop xx = function + let binop _xx = function | Add -> "add" | Sub -> "sub" | Mul -> "mul" @@ -213,17 +213,17 @@ struct | "32x4" -> "64x2" | _ -> assert false - let voidop xxxx = function (_ : void) -> . + let voidop _xxxx = function (_ : void) -> . - let itestop xxxx (op : itestop) = match op with + let itestop _xxxx (op : itestop) = match op with | AllTrue -> "all_true" - let iunop xxxx (op : iunop) = match op with + let iunop _xxxx (op : iunop) = match op with | Neg -> "neg" | Abs -> "abs" | Popcnt -> "popcnt" - let funop xxxx (op : funop) = match op with + let funop _xxxx (op : funop) = match op with | Neg -> "neg" | Abs -> "abs" | Sqrt -> "sqrt" @@ -256,7 +256,7 @@ struct | Shuffle is -> "shuffle " ^ String.concat " " (List.map nat is) | Swizzle -> "swizzle" - let fbinop xxxx (op : fbinop) = match op with + let fbinop _xxxx (op : fbinop) = match op with | Add -> "add" | Sub -> "sub" | Mul -> "mul" @@ -266,7 +266,7 @@ struct | Pmin -> "pmin" | Pmax -> "pmax" - let irelop xxxx (op : irelop) = match op with + let irelop _xxxx (op : irelop) = match op with | Eq -> "eq" | Ne -> "ne" | LtS -> "lt_s" @@ -278,7 +278,7 @@ struct | GeS -> "ge_s" | GeU -> "ge_u" - let frelop xxxx (op : frelop) = match op with + let frelop _xxxx (op : frelop) = match op with | Eq -> "eq" | Ne -> "ne" | Lt -> "lt" @@ -306,12 +306,12 @@ struct | ConvertUI32x4 -> "convert_" ^ (if xxxx = "32x4" then "" else "low_") ^ "i32x4_u" - let ishiftop xxxx (op : ishiftop) = match op with + let ishiftop _xxxx (op : ishiftop) = match op with | Shl -> "shl" | ShrS -> "shr_s" | ShrU -> "shr_u" - let ibitmaskop xxxx (op : ibitmaskop) = match op with + let ibitmaskop _xxxx (op : ibitmaskop) = match op with | Bitmask -> "bitmask" let vtestop (op : vtestop) = match op with @@ -329,16 +329,16 @@ struct let vternop (op : vternop) = match op with | Bitselect -> "bitselect" - let splatop xxxx (op : nsplatop) = match op with + let splatop _xxxx (op : nsplatop) = match op with | Splat -> "splat" - let pextractop xxxx (op : extension nextractop) = match op with + let pextractop _xxxx (op : extension nextractop) = match op with | Extract (i, ext) -> "extract_lane" ^ extension ext ^ " " ^ nat i - let extractop xxxx (op : unit nextractop) = match op with + let extractop _xxxx (op : unit nextractop) = match op with | Extract (i, ()) -> "extract_lane " ^ nat i - let replaceop xxxx (op : nreplaceop) = match op with + let replaceop _xxxx (op : nreplaceop) = match op with | Replace i -> "replace_lane " ^ nat i let lane_oper (pop, iop, fop) op = @@ -507,7 +507,7 @@ let rec instr e = let const head c = match c.it with | [e] -> instr e - | es -> Node (head, list instr c.it) + | _es -> Node (head, list instr c.it) (* Functions *) diff --git a/interpreter/text/parser.mly b/interpreter/text/parser.mly index e29be3ae3b..5f522c02be 100644 --- a/interpreter/text/parser.mly +++ b/interpreter/text/parser.mly @@ -322,16 +322,16 @@ num_list: | num num_list { $1 :: $2 } var : - | NAT { let at = at () in fun c lookup -> nat32 $1 at @@ at } + | NAT { let at = at () in fun _c _lookup -> nat32 $1 at @@ at } | VAR { let at = at () in fun c lookup -> lookup c ($1 @@ at) @@ at } var_list : - | /* empty */ { fun c lookup -> [] } + | /* empty */ { fun _c _lookup -> [] } | var var_list { fun c lookup -> $1 c lookup :: $2 c lookup } bind_var_opt : - | /* empty */ { fun c anon bind -> anon c } - | bind_var { fun c anon bind -> bind c $1 } /* Sugar */ + | /* empty */ { fun c anon _bind -> anon c } + | bind_var { fun c _anon bind -> bind c $1 } /* Sugar */ bind_var : | VAR { $1 @@ at () } @@ -367,7 +367,7 @@ align_opt : /* Instructions & Expressions */ instr_list : - | /* empty */ { fun c -> [] } + | /* empty */ { fun _c -> [] } | instr1 instr_list { fun c -> $1 c @ $2 c } | select_instr_instr_list { $1 } | call_instr_instr_list { $1 } @@ -378,15 +378,15 @@ instr1 : | expr { $1 } /* Sugar */ plain_instr : - | UNREACHABLE { fun c -> unreachable } - | NOP { fun c -> nop } - | DROP { fun c -> drop } + | UNREACHABLE { fun _c -> unreachable } + | NOP { fun _c -> nop } + | DROP { fun _c -> drop } | BR var { fun c -> br ($2 c label) } | BR_IF var { fun c -> br_if ($2 c label) } | BR_TABLE var var_list { fun c -> let xs, x = Lib.List.split_last ($2 c label :: $3 c label) in br_table xs x } - | RETURN { fun c -> return } + | RETURN { fun _c -> return } | CALL var { fun c -> call ($2 c func) } | LOCAL_GET var { fun c -> local_get ($2 c local) } | LOCAL_SET var { fun c -> local_set ($2 c local) } @@ -400,50 +400,50 @@ plain_instr : | TABLE_FILL var { fun c -> table_fill ($2 c table) } | TABLE_COPY var var { fun c -> table_copy ($2 c table) ($3 c table) } | TABLE_INIT var var { fun c -> table_init ($2 c table) ($3 c elem) } - | TABLE_GET { let at = at () in fun c -> table_get (0l @@ at) } /* Sugar */ - | TABLE_SET { let at = at () in fun c -> table_set (0l @@ at) } /* Sugar */ - | TABLE_SIZE { let at = at () in fun c -> table_size (0l @@ at) } /* Sugar */ - | TABLE_GROW { let at = at () in fun c -> table_grow (0l @@ at) } /* Sugar */ - | TABLE_FILL { let at = at () in fun c -> table_fill (0l @@ at) } /* Sugar */ + | TABLE_GET { let at = at () in fun _c -> table_get (0l @@ at) } /* Sugar */ + | TABLE_SET { let at = at () in fun _c -> table_set (0l @@ at) } /* Sugar */ + | TABLE_SIZE { let at = at () in fun _c -> table_size (0l @@ at) } /* Sugar */ + | TABLE_GROW { let at = at () in fun _c -> table_grow (0l @@ at) } /* Sugar */ + | TABLE_FILL { let at = at () in fun _c -> table_fill (0l @@ at) } /* Sugar */ | TABLE_COPY /* Sugar */ - { let at = at () in fun c -> table_copy (0l @@ at) (0l @@ at) } + { let at = at () in fun _c -> table_copy (0l @@ at) (0l @@ at) } | TABLE_INIT var /* Sugar */ { let at = at () in fun c -> table_init (0l @@ at) ($2 c elem) } | ELEM_DROP var { fun c -> elem_drop ($2 c elem) } - | LOAD offset_opt align_opt { fun c -> $1 $3 $2 } - | STORE offset_opt align_opt { fun c -> $1 $3 $2 } - | VEC_LOAD offset_opt align_opt { fun c -> $1 $3 $2 } - | VEC_STORE offset_opt align_opt { fun c -> $1 $3 $2 } + | LOAD offset_opt align_opt { fun _c -> $1 $3 $2 } + | STORE offset_opt align_opt { fun _c -> $1 $3 $2 } + | VEC_LOAD offset_opt align_opt { fun _c -> $1 $3 $2 } + | VEC_STORE offset_opt align_opt { fun _c -> $1 $3 $2 } | VEC_LOAD_LANE offset_opt align_opt NAT - { let at = at () in fun c -> $1 $3 $2 (vec_lane_index $4 at) } + { let at = at () in fun _c -> $1 $3 $2 (vec_lane_index $4 at) } | VEC_STORE_LANE offset_opt align_opt NAT - { let at = at () in fun c -> $1 $3 $2 (vec_lane_index $4 at) } - | MEMORY_SIZE { fun c -> memory_size } - | MEMORY_GROW { fun c -> memory_grow } - | MEMORY_FILL { fun c -> memory_fill } - | MEMORY_COPY { fun c -> memory_copy } + { let at = at () in fun _c -> $1 $3 $2 (vec_lane_index $4 at) } + | MEMORY_SIZE { fun _c -> memory_size } + | MEMORY_GROW { fun _c -> memory_grow } + | MEMORY_FILL { fun _c -> memory_fill } + | MEMORY_COPY { fun _c -> memory_copy } | MEMORY_INIT var { fun c -> memory_init ($2 c data) } | DATA_DROP var { fun c -> data_drop ($2 c data) } - | REF_NULL ref_kind { fun c -> ref_null $2 } - | REF_IS_NULL { fun c -> ref_is_null } + | REF_NULL ref_kind { fun _c -> ref_null $2 } + | REF_IS_NULL { fun _c -> ref_is_null } | REF_FUNC var { fun c -> ref_func ($2 c func) } - | CONST num { fun c -> fst (num $1 $2) } - | TEST { fun c -> $1 } - | COMPARE { fun c -> $1 } - | UNARY { fun c -> $1 } - | BINARY { fun c -> $1 } - | CONVERT { fun c -> $1 } - | VEC_CONST VEC_SHAPE num_list { let at = at () in fun c -> fst (vec $1 $2 $3 at) } - | VEC_UNARY { fun c -> $1 } - | VEC_BINARY { fun c -> $1 } - | VEC_TERNARY { fun c -> $1 } - | VEC_TEST { fun c -> $1 } - | VEC_SHIFT { fun c -> $1 } - | VEC_BITMASK { fun c -> $1 } - | VEC_SHUFFLE num_list { let at = at () in fun c -> i8x16_shuffle (shuffle_lit $2 at) } - | VEC_SPLAT { fun c -> $1 } - | VEC_EXTRACT NAT { let at = at () in fun c -> $1 (vec_lane_index $2 at) } - | VEC_REPLACE NAT { let at = at () in fun c -> $1 (vec_lane_index $2 at) } + | CONST num { fun _c -> fst (num $1 $2) } + | TEST { fun _c -> $1 } + | COMPARE { fun _c -> $1 } + | UNARY { fun _c -> $1 } + | BINARY { fun _c -> $1 } + | CONVERT { fun _c -> $1 } + | VEC_CONST VEC_SHAPE num_list { let at = at () in fun _c -> fst (vec $1 $2 $3 at) } + | VEC_UNARY { fun _c -> $1 } + | VEC_BINARY { fun _c -> $1 } + | VEC_TERNARY { fun _c -> $1 } + | VEC_TEST { fun _c -> $1 } + | VEC_SHIFT { fun _c -> $1 } + | VEC_BITMASK { fun _c -> $1 } + | VEC_SHUFFLE num_list { let at = at () in fun _c -> i8x16_shuffle (shuffle_lit $2 at) } + | VEC_SPLAT { fun _c -> $1 } + | VEC_EXTRACT NAT { let at = at () in fun _c -> $1 (vec_lane_index $2 at) } + | VEC_REPLACE NAT { let at = at () in fun _c -> $1 (vec_lane_index $2 at) } select_instr_instr_list : @@ -619,12 +619,12 @@ if_ : { fun c c' -> let es = $1 c in let es0, es1, es2 = $2 c c' in es @ es0, es1, es2 } | LPAR THEN instr_list RPAR LPAR ELSE instr_list RPAR /* Sugar */ - { fun c c' -> [], $3 c', $7 c' } + { fun _c c' -> [], $3 c', $7 c' } | LPAR THEN instr_list RPAR /* Sugar */ - { fun c c' -> [], $3 c', [] } + { fun _c c' -> [], $3 c', [] } expr_list : - | /* empty */ { fun c -> [] } + | /* empty */ { fun _c -> [] } | expr expr_list { fun c -> $1 c @ $2 c } const_expr : @@ -640,23 +640,23 @@ func : func_fields : | type_use func_fields_body - { fun c x at -> + { fun c _x at -> let c' = enter_func c in let y = inline_type_explicit c' ($1 c' type_) (fst $2) at in [{(snd $2 c') with ftype = y} @@ at], [], [] } | func_fields_body /* Sugar */ - { fun c x at -> + { fun c _x at -> let c' = enter_func c in let y = inline_type c' (fst $1) at in [{(snd $1 c') with ftype = y} @@ at], [], [] } | inline_import type_use func_fields_import /* Sugar */ - { fun c x at -> + { fun c _x at -> let y = inline_type_explicit c ($2 c type_) $3 at in [], [{ module_name = fst $1; item_name = snd $1; idesc = FuncImport y @@ at } @@ at ], [] } | inline_import func_fields_import /* Sugar */ - { fun c x at -> + { fun c _x at -> let y = inline_type c $2 at in [], [{ module_name = fst $1; item_name = snd $1; @@ -726,7 +726,7 @@ elem_expr : | expr { let at = at () in fun c -> $1 c @@ at } /* Sugar */ elem_expr_list : - | /* empty */ { fun c -> [] } + | /* empty */ { fun _c -> [] } | elem_expr elem_expr_list { fun c -> $1 c :: $2 c } elem_var_list : @@ -779,9 +779,9 @@ table : table_fields : | table_type - { fun c x at -> [{ttype = $1} @@ at], [], [], [] } + { fun _c _x at -> [{ttype = $1} @@ at], [], [], [] } | inline_import table_type /* Sugar */ - { fun c x at -> + { fun _c _x at -> [], [], [{ module_name = fst $1; item_name = snd $1; idesc = TableImport $2 @@ at } @@ at], [] } @@ -831,9 +831,9 @@ memory : memory_fields : | memory_type - { fun c x at -> [{mtype = $1} @@ at], [], [], [] } + { fun _c _x at -> [{mtype = $1} @@ at], [], [], [] } | inline_import memory_type /* Sugar */ - { fun c x at -> + { fun _c _x at -> [], [], [{ module_name = fst $1; item_name = snd $1; idesc = MemoryImport $2 @@ at } @@ at], [] } @@ -841,7 +841,7 @@ memory_fields : { fun c x at -> let mems, data, ims, exs = $2 c x at in mems, data, ims, $1 (MemoryExport x) c :: exs } | LPAR DATA string_list RPAR /* Sugar */ - { fun c x at -> + { fun _c x at -> let offset = [i32_const (0l @@ at) @@ at] @@ at in let size = Int32.(div (add (of_int (String.length $3)) 65535l) 65536l) in [{mtype = MemoryType {min = size; max = Some size}} @@ at], @@ -856,9 +856,9 @@ global : global_fields : | global_type const_expr - { fun c x at -> [{gtype = $1; ginit = $2 c} @@ at], [], [] } + { fun c _x at -> [{gtype = $1; ginit = $2 c} @@ at], [], [] } | inline_import global_type /* Sugar */ - { fun c x at -> + { fun _c _x at -> [], [{ module_name = fst $1; item_name = snd $1; idesc = GlobalImport $2 @@ at } @@ at], [] } @@ -909,7 +909,7 @@ export : inline_export : | LPAR EXPORT name RPAR - { let at = at () in fun d c -> {name = $3; edesc = d @@ at} @@ at } + { let at = at () in fun d _c -> {name = $3; edesc = d @@ at} @@ at } /* Modules */ diff --git a/interpreter/util/lib.ml b/interpreter/util/lib.ml index 90c4e4fe0f..b5c702ea63 100644 --- a/interpreter/util/lib.ml +++ b/interpreter/util/lib.ml @@ -93,8 +93,8 @@ struct and index_where' p xs i = match xs with | [] -> None - | x::xs' when p x -> Some i - | x::xs' -> index_where' p xs' (i+1) + | x::_xs' when p x -> Some i + | _x::xs' -> index_where' p xs' (i+1) let index_of x = index_where ((=) x) diff --git a/interpreter/valid/valid.ml b/interpreter/valid/valid.ml index cfe7f310f2..54a84e268f 100644 --- a/interpreter/valid/valid.ml +++ b/interpreter/valid/valid.ml @@ -104,7 +104,7 @@ let push (ell1, ts1) (ell2, ts2) = (if ell1 = Ellipses || ell2 = Ellipses then Ellipses else NoEllipses), ts2 @ ts1 -let peek i (ell, ts) = +let peek i (_ell, ts) = try List.nth (List.rev ts) i with Failure _ -> None @@ -288,7 +288,7 @@ let rec check_instr (c : context) (e : instr) (s : infer_result_type) : op_type ts1 --> ts2 | CallIndirect (x, y) -> - let TableType (lim, t) = table c x in + let TableType (_lim, t) = table c x in let FuncType (ts1, ts2) = type_ c y in require (t = FuncRefType) x.at ("type mismatch: instruction requires table of functions" ^ @@ -546,13 +546,13 @@ let check_limits {min; max} range at msg = require (I32.le_u min max) at "size minimum must not be greater than maximum" -let check_num_type (t : num_type) at = +let check_num_type (_t : num_type) _at = () -let check_vec_type (t : vec_type) at = +let check_vec_type (_t : vec_type) _at = () -let check_ref_type (t : ref_type) at = +let check_ref_type (_t : ref_type) _at = () let check_value_type (t : value_type) at = @@ -577,7 +577,7 @@ let check_memory_type (mt : memory_type) at = "memory size must be at most 65536 pages (4GiB)" let check_global_type (gt : global_type) at = - let GlobalType (t, mut) = gt in + let GlobalType (t, _mut) = gt in check_value_type t at @@ -623,11 +623,11 @@ let check_const (c : context) (const : const) (t : value_type) = (* Tables, Memories, & Globals *) -let check_table (c : context) (tab : table) = +let check_table (_c : context) (tab : table) = let {ttype} = tab.it in check_table_type ttype tab.at -let check_memory (c : context) (mem : memory) = +let check_memory (_c : context) (mem : memory) = let {mtype} = mem.it in check_memory_type mtype mem.at @@ -656,12 +656,12 @@ let check_data_mode (c : context) (mode : segment_mode) = | Declarative -> assert false let check_data (c : context) (seg : data_segment) = - let {dinit; dmode} = seg.it in + let {dmode; _} = seg.it in check_data_mode c dmode let check_global (c : context) (glob : global) = let {gtype; ginit} = glob.it in - let GlobalType (t, mut) = gtype in + let GlobalType (t, _mut) = gtype in check_const c ginit t