diff --git a/manifest/main.ml b/manifest/main.ml index e68fe43879aef55ad439991798a34cde8e66dcb9..c9b46ae90a9ffc40181c011c016bad6478b34be3 100644 --- a/manifest/main.ml +++ b/manifest/main.ml @@ -1152,6 +1152,7 @@ let octez_webassembly_interpreter = ~synopsis:"WebAssembly reference interpreter with tweaks for Tezos" ~dune:Dune.[[S "include_subdirs"; S "unqualified"]] ~deps:[octez_lwt_result_stdlib; zarith; lazy_containers |> open_] + ~preprocess:[pps ppx_deriving_show] let _octez_webassembly_repl = private_exe diff --git a/opam/tezos-webassembly-interpreter.opam b/opam/tezos-webassembly-interpreter.opam index dab8fbe57fe8202f26d9f630ef73b4be345c0548..35e7d63d52ec6f8636bad9ca421c6bbbe2989d8b 100644 --- a/opam/tezos-webassembly-interpreter.opam +++ b/opam/tezos-webassembly-interpreter.opam @@ -9,6 +9,7 @@ dev-repo: "git+https://gitlab.com/tezos/tezos.git" license: "Apache-2.0" depends: [ "dune" { >= "3.0" } + "ppx_deriving" "tezos-lwt-result-stdlib" "zarith" { >= "1.12" & < "1.13" } "lazy-containers" diff --git a/src/lib_scoru_wasm/test/ast_printer.ml b/src/lib_scoru_wasm/test/ast_printer.ml index 44fa6a3778c18df1d74234fea51fa2ec885921a0..aed91327a2f16dddda42088e68c044d4f1df5aef 100644 --- a/src/lib_scoru_wasm/test/ast_printer.ml +++ b/src/lib_scoru_wasm/test/ast_printer.ml @@ -26,59 +26,17 @@ open Lazy_containers open Tezos_webassembly_interpreter -let pp_pos out {Source.file; line; column} = - Format.fprintf - out - "@[{file = %S;@; line = %d;@; column = %d}@]" - (String.escaped file) - line - column - -let pp_region out {Source.left; right} = - Format.fprintf - out - "@[{left = %a;@; right = %a}@]" - pp_pos - left - pp_pos - right - -let pp_phrase pp_it out Source.{it; at} = - Format.fprintf out "@[{it = %a;@; at = %a}@]" pp_it it pp_region at - let pp_int32 out n = Format.fprintf out "%ld" n let pp_int64 out n = Format.fprintf out "%Ld" n -let pp_var = pp_phrase pp_int32 +let pp_f32 _out _f32 = + Stdlib.failwith "32bit floating point values are not supported" -let pp_num_type out num = - Format.fprintf - out - "%s" - (match num with - | Types.I32Type -> "I32Type" - | I64Type -> "I64Type" - | F32Type -> "F32Type" - | F64Type -> "F64Type") - -let pp_ref_type out ref = - Format.fprintf - out - "%s" - (match ref with - | Types.FuncRefType -> "FuncRefType" - | ExternRefType -> "ExternRefType") - -let pp_vec_type out = function - | Types.V128Type -> Format.pp_print_string out "V128Type" +let pp_f64 _out _f64 = + Stdlib.failwith "64bit floating point values are not supported" -let pp_value_type out vt = - let open Types in - match vt with - | NumType nt -> Format.fprintf out "NumType%a" pp_num_type nt - | VecType vt -> Format.fprintf out "VecType %a" pp_vec_type vt - | RefType rt -> Format.fprintf out "RefType %a" pp_ref_type rt +let pp_var = Source.pp_phrase pp_int32 let pp_list pp out x = Format.fprintf @@ -87,13 +45,7 @@ let pp_list pp out x = (Format.pp_print_list ~pp_sep:(fun out () -> Format.fprintf out ";@;") pp) x -let pp_value_type_list = pp_list pp_value_type - -let pp_block_label out (Ast.Block_label l) = - Format.fprintf out "Block_label @[(%ld)@]" l - -let pp_data_label out (Ast.Data_label l) = - Format.fprintf out "Data_label @[(%ld)@]" l +let pp_value_type_list = pp_list Types.pp_value_type let pp_opt pp out = function | Some x -> Format.fprintf out "Some @[(%a)@]" pp x @@ -103,10 +55,6 @@ let pp_unit out () = Format.pp_print_string out "()" let pp_pair pp1 pp2 out (x, y) = Format.fprintf out "(%a, %a)" pp1 x pp2 y -let pp_block_type out = function - | Ast.VarBlockType v -> pp_var out v - | Ast.ValBlockType v -> pp_opt pp_value_type out v - let pp_memop pp_ty pp_pack out {Ast.ty; align; pack; offset} = Format.fprintf out @@ -119,145 +67,7 @@ let pp_memop pp_ty pp_pack out {Ast.ty; align; pack; offset} = pp_int32 offset -let pp_pack_size out ps = - Format.fprintf - out - "%s" - (match ps with - | Types.Pack8 -> "Pack8" - | Pack16 -> "Pack16" - | Pack32 -> "Pack32" - | Pack64 -> "Pack64") - -let pp_extension out ex = - Format.fprintf out "%s" (match ex with Types.SX -> "SX" | ZX -> "ZX") - -let pp_load_op = - pp_memop pp_num_type (pp_opt (pp_pair pp_pack_size pp_extension)) - -let pp_store_op = pp_memop pp_num_type (pp_opt pp_pack_size) - -let pp_pack_shape out p = - Format.fprintf - out - "%s" - (match p with - | Types.Pack8x8 -> "Pack8x8" - | Pack16x4 -> "Pack16x4" - | Pack32x2 -> "Pack32x2") - -let pp_vec_extension out = function - | Types.ExtLane (ps, e) -> (pp_pair pp_pack_shape pp_extension) out (ps, e) - | ExtSplat -> Format.pp_print_string out "ExtSplat" - | ExtZero -> Format.pp_print_string out "ExZero" - -let pp_vec_load_op = - pp_memop pp_vec_type (pp_opt @@ pp_pair pp_pack_size pp_vec_extension) - -let pp_vec_store_op = pp_memop pp_vec_type pp_unit - -let pp_vec_laneop = - pp_pair (pp_memop pp_vec_type pp_pack_size) Format.pp_print_int - -let pp_value_op pp_int32 pp_int64 out = function - | Values.I32 x -> pp_int32 out x - | I64 x -> pp_int64 out x - | _ -> Stdlib.failwith "Floating point values are not supported" - -let pp_num = pp_phrase (pp_value_op pp_int32 pp_int64) - -let pp_laneop pp_i8x16 pp_i16x8 pp_i32x4 pp_i64x2 out = function - | V128.I8x16 x -> pp_i8x16 x out - | V128.I16x8 x -> pp_i16x8 x out - | V128.I32x4 x -> pp_i32x4 x out - | V128.I64x2 x -> pp_i64x2 x out - | _ -> Stdlib.failwith "Floating point ops are not supported" - -let pp_int_relop out op = - Format.pp_print_string - out - (match op with - | Ast.IntOp.Eq -> "Eq" - | Ne -> "Ne" - | LtS -> "LtS" - | LtU -> "LtU" - | LeS -> "LeS" - | LeU -> "LeU" - | GtS -> "GtS" - | GtU -> "GtU" - | GeS -> "GeS" - | GeU -> "GeU") - -let float_relop_gen out op = - Format.pp_print_string - out - (match op with - | Ast.FloatOp.Eq -> "Eq" - | Ne -> "Ne" - | Lt -> "Lt" - | Le -> "Le" - | Gt -> "Gt" - | Ge -> "Ge") - -let pp_relop = pp_value_op pp_int_relop pp_int_relop - -let pp_int_unop out op = - match op with - | Ast.IntOp.Clz -> Format.pp_print_string out "Clz" - | Ctz -> Format.pp_print_string out "Ctz" - | Popcnt -> Format.pp_print_string out "Popcnt" - | ExtendS ps -> Format.fprintf out "Extend %a" pp_pack_size ps - -let pp_int_binop out op = - Format.pp_print_string - out - (match op with - | Ast.IntOp.Add -> "Add" - | Sub -> "Sub" - | Mul -> "Mul" - | DivS -> "DivS" - | DivU -> "DivU" - | RemS -> "RemS" - | RemU -> "RemU" - | And -> "And" - | Or -> "Or" - | Xor -> "Xor" - | Shl -> "Shl" - | ShrS -> "ShrS" - | ShrU -> "ShrU" - | Rotl -> "Rotl" - | Rotr -> "Rotr") - -let pp_int_cvtop out op = - Format.pp_print_string - out - (match op with - | Ast.IntOp.ExtendSI32 -> "ExtendSI32" - | ExtendUI32 -> "ExtendUI32" - | WrapI64 -> "WrapI64" - | TruncSF32 -> "TruncSF32" - | TruncUF32 -> "TruncUF32" - | TruncSF64 -> "TruncSF64" - | TruncUF64 -> "TruncUF64" - | TruncSatSF32 -> "TruncSatSF32" - | TruncSatUF32 -> "TruncSatUF32" - | TruncSatSF64 -> "TruncSatSF64" - | TruncSatUF64 -> "TruncSatUF64" - | ReinterpretFloat -> "ReinterpretFloat") - -let pp_cvtop = pp_value_op pp_int_cvtop pp_int_cvtop - -let pp_unop = pp_value_op pp_int_unop pp_int_unop - -let pp_binop = pp_value_op pp_int_binop pp_int_binop - -let pp_vec = - let pp out = function - | Values.V128 bits -> - let hash = Hashtbl.hash bits in - Format.fprintf out "V128 (#%d)" hash - in - pp_phrase pp +let pp_num = Source.pp_phrase (Values.pp_op pp_int32 pp_int64 pp_f32 pp_f64) (* Generate instructions. The following are missing: @@ -326,13 +136,13 @@ let pp_instr' out instr = Format.fprintf out "BrTable(%a, %a)" (pp_list pp_var) vs pp_var v | CallIndirect (v1, v2) -> Format.fprintf out "CallIndirect(%a, %a)" pp_var v1 pp_var v2 - | Load o -> Format.fprintf out "Load(%a)" pp_load_op o - | Store o -> Format.fprintf out "Store(%a)" pp_store_op o - | VecLoad o -> Format.fprintf out "VecLoad(%a)" pp_vec_load_op o - | VecStore o -> Format.fprintf out "VecSore(%a)" pp_vec_store_op o + | Load o -> Format.fprintf out "Load(%a)" pp_loadop o + | Store o -> Format.fprintf out "Store(%a)" pp_storeop o + | VecLoad o -> Format.fprintf out "VecLoad(%a)" pp_vec_loadop o + | VecStore o -> Format.fprintf out "VecSore(%a)" pp_vec_storeop o | VecLoadLane o -> Format.fprintf out "VecLoadLane(%a)" pp_vec_laneop o | VecStoreLane o -> Format.fprintf out "VecSoreLane(%a)" pp_vec_laneop o - | RefNull rt -> Format.fprintf out "RefNull (%a)" pp_ref_type rt + | RefNull rt -> Format.fprintf out "RefNull (%a)" Types.pp_ref_type rt | Const c -> Format.fprintf out "Const(%a)" pp_num c | Compare c -> Format.fprintf out "Compare(%a)" pp_relop c | Unary c -> Format.fprintf out "Unary (%a)" pp_unop c @@ -341,7 +151,7 @@ let pp_instr' out instr = | VecConst c -> Format.fprintf out "VecConst (%a)" pp_vec c | _ -> Stdlib.failwith "Unsupported instruction" -let pp_instr = pp_phrase pp_instr' +let pp_instr = Source.pp_phrase pp_instr' let pp_vector pp out v = (* Force evaluation of the vector. *) @@ -353,22 +163,22 @@ let pp_vector_z pp out v = let _ = Lwt_main.run @@ Lazy_vector.ZVector.to_list v in Lazy_vector.ZVector.pp pp out v -let pp_resul_type = pp_vector pp_value_type +let pp_resul_type = pp_vector Types.pp_value_type let pp_func_type out = function | Types.FuncType (pt, rt) -> Format.fprintf out "FuncType (%a, %a)" pp_resul_type pt pp_resul_type rt let pp_func = - pp_phrase @@ fun out {Ast.ftype; locals; body} -> + Source.pp_phrase @@ fun out {Ast.ftype; locals; body} -> Format.fprintf out "@[{ftype = %a;@; locals = %a;@; body = %a}@]" pp_var ftype - (pp_vector pp_value_type) + (pp_vector Types.pp_value_type) locals - pp_block_label + Ast.pp_block_label body let pp_func out func = @@ -384,30 +194,11 @@ let pp_func out func = | Func.HostFunc (ft, n) -> Format.fprintf out "HostFunc @[(%a,@; %s)@]" pp_func_type ft n -let pp_ref_type out = function - | Types.FuncRefType -> Format.fprintf out "FuncRefType" - | Types.ExternRefType -> Format.fprintf out "ExternRefType" - -let pp_limit pp out {Types.min; Types.max} = - Format.fprintf out "{min = %a; max = %a}" pp min (pp_opt pp) max - -let pp_table_type out (Types.TableType (limit, ref_type)) = - Format.fprintf - out - "Types.TableType (%a, %a)" - (pp_limit pp_int32) - limit - pp_ref_type - ref_type - let pp_ref out = function - | Values.NullRef rt -> Format.fprintf out "NullRef (%a)" pp_ref_type rt + | Values.NullRef rt -> Format.fprintf out "NullRef (%a)" Types.pp_ref_type rt | Values.ExternRef n -> Format.fprintf out "ExternRef(%a)" pp_int32 n | _ -> Stdlib.failwith "Unsupported value ref" -let pp_memory_type out (Types.MemoryType limit) = - Format.fprintf out "MemoryType %a" (pp_limit pp_int32) limit - let pp_chunk_byte_vector out chunks = let bs = Lwt_main.run @@ Chunked_byte_vector.to_string chunks in (* We just show the hash of the chunk in order to avoid too much noise. *) @@ -420,25 +211,12 @@ let pp_table out t = Format.fprintf out "@[{ty = %a;@; content = (%a)}@]" - pp_table_type + Types.pp_table_type ty (pp_vector pp_ref) c -let pp_mutable out = function - | Types.Immutable -> Format.pp_print_string out "Immutable" - | Types.Mutable -> Format.pp_print_string out "Mutable" - -let pp_global_type out (Types.GlobalType (vt, mt)) = - Format.fprintf - out - "GlobalType @[(%a, %a)@]" - pp_value_type - vt - pp_mutable - mt - -let pp_value_num = pp_value_op pp_int32 pp_int64 +let pp_value_num = Values.pp_op pp_int32 pp_int64 pp_f32 pp_f64 let pp_value out = function | Values.Num n -> Format.fprintf out "Num %a" pp_value_num n @@ -453,7 +231,7 @@ let pp_memory out memory = Format.fprintf out "@[{ty = %a;@; content = %a}@]" - pp_memory_type + Types.pp_memory_type ty pp_chunk_byte_vector content @@ -464,7 +242,7 @@ let pp_global out global = Format.fprintf out "@[{ty = %a;@; content = %a}@]" - pp_global_type + Types.pp_global_type ty pp_value content @@ -494,7 +272,7 @@ let pp_allocations out allocations = pp_datas_table allocations.Ast.datas -let pp_data_inst out ref = pp_data_label out !ref +let pp_data_inst out ref = Ast.pp_data_label out !ref let pp_module out { @@ -556,7 +334,7 @@ let rec pp_admin_instr' out instr = Format.fprintf out "From_block @[(%a,@; %li)@]" - pp_block_label + Ast.pp_block_label block index | Plain instr -> Format.fprintf out "Plain @[%a@]" pp_instr' instr @@ -602,27 +380,12 @@ let rec pp_admin_instr' out instr = and pp_admin_instr out instr = pp_admin_instr' out instr.Source.it -let pp_input_message out message = - let open Input_buffer in - Format.fprintf - out - "@[{rtype = %li;@;\ - raw_level = %li;@;\ - message_counter = %s;@;\ - payload = %a;@;\ - }@]" - message.rtype - message.raw_level - (Z.to_string message.message_counter) - Hex.pp - (Hex.of_bytes message.payload) - let pp_input_buffer out input = let open Input_buffer in Format.fprintf out "@[{content = %a;@;num_elements = %s;@;}@]" - (pp_vector_z pp_input_message) + (pp_vector_z Input_buffer.pp_message) (Lazy_vector.Mutable.ZVector.snapshot input.content) (Z.to_string input.num_elements) diff --git a/src/lib_webassembly/dune b/src/lib_webassembly/dune index 918b7aa412533ad524a08775759534777ec0bf76..7e822e15bcd9f947c6905c4a995196d4960a2e8b 100644 --- a/src/lib_webassembly/dune +++ b/src/lib_webassembly/dune @@ -9,6 +9,7 @@ tezos-lwt-result-stdlib zarith lazy-containers) + (preprocess (pps ppx_deriving.show)) (flags (:standard) -open Lazy_containers)) diff --git a/src/lib_webassembly/exec/v128.ml b/src/lib_webassembly/exec/v128.ml index 6cd736ebd83e6f8339cb9648a646b1df82c6334f..6e6c75d7dfce2d903a82be5fff3d1e9f44f71d13 100644 --- a/src/lib_webassembly/exec/v128.ml +++ b/src/lib_webassembly/exec/v128.ml @@ -707,6 +707,8 @@ let of_strings shape ss = ss) ; to_string b +let pp fmt v128 = Format.pp_print_string fmt v128 + let string_of_shape = function | I8x16 _ -> "i8x16" | I16x8 _ -> "i16x8" diff --git a/src/lib_webassembly/exec/v128.mli b/src/lib_webassembly/exec/v128.mli index 0dbdcf46dc16bb41b2ecfcd10ed932d8dcaad148..9dae83098de28bbba6d712c4530454341f22b069 100644 --- a/src/lib_webassembly/exec/v128.mli +++ b/src/lib_webassembly/exec/v128.mli @@ -38,6 +38,8 @@ val to_hex_string : t -> string val of_strings : shape -> string list -> t +val pp : Format.formatter -> t -> unit + (* Shape-based operations *) module type IntShape = sig diff --git a/src/lib_webassembly/runtime/input_buffer.ml b/src/lib_webassembly/runtime/input_buffer.ml index 3acb67621f765d31b7abcc55b5b4acd23afd98d7..39ca0715afa752776cb4d1d4e5bee293e65b094d 100644 --- a/src/lib_webassembly/runtime/input_buffer.ml +++ b/src/lib_webassembly/runtime/input_buffer.ml @@ -1,9 +1,10 @@ type message = { rtype : int32; raw_level : int32; - message_counter : Z.t; + message_counter : Z.t; [@printer Z.pp_print] payload : bytes; } +[@@deriving show] exception Bounds diff --git a/src/lib_webassembly/runtime/input_buffer.mli b/src/lib_webassembly/runtime/input_buffer.mli index 8d734257fd00e79f109758352893f217a5b32660..fa17ddefe4db1c4ae036a05464d9cba177d9b6a4 100644 --- a/src/lib_webassembly/runtime/input_buffer.mli +++ b/src/lib_webassembly/runtime/input_buffer.mli @@ -7,6 +7,7 @@ type message = { message_counter : Z.t; payload : bytes; } +[@@deriving show] (** An element of type t will have a content which is a lazy_vector of messages and a pointer to the number of elements to be able to dequeue. At this point diff --git a/src/lib_webassembly/syntax/ast.ml b/src/lib_webassembly/syntax/ast.ml index fb16ca18a6ccffab73f7a351e9991b82cb378d47..880cbd286841a5c3638bcce0076d740c7482112d 100644 --- a/src/lib_webassembly/syntax/ast.ml +++ b/src/lib_webassembly/syntax/ast.ml @@ -25,7 +25,7 @@ type void = Lib.void (* Operators *) module IntOp = struct - type unop = Clz | Ctz | Popcnt | ExtendS of pack_size + type unop = Clz | Ctz | Popcnt | ExtendS of pack_size [@@deriving show] type binop = | Add @@ -43,10 +43,12 @@ module IntOp = struct | ShrU | Rotl | Rotr + [@@deriving show] type testop = Eqz type relop = Eq | Ne | LtS | LtU | GtS | GtU | LeS | LeU | GeS | GeU + [@@deriving show] type cvtop = | ExtendSI32 @@ -61,16 +63,18 @@ module IntOp = struct | TruncSatSF64 | TruncSatUF64 | ReinterpretFloat + [@@deriving show] end module FloatOp = struct type unop = Neg | Abs | Ceil | Floor | Trunc | Nearest | Sqrt + [@@deriving show] - type binop = Add | Sub | Mul | Div | Min | Max | CopySign + type binop = Add | Sub | Mul | Div | Min | Max | CopySign [@@deriving show] type testop = | - type relop = Eq | Ne | Lt | Gt | Le | Ge + type relop = Eq | Ne | Lt | Gt | Le | Ge [@@deriving show] type cvtop = | ConvertSI32 @@ -80,6 +84,7 @@ module FloatOp = struct | PromoteF32 | DemoteF64 | ReinterpretInt + [@@deriving show] end module I32Op = IntOp @@ -201,12 +206,16 @@ end type testop = (I32Op.testop, I64Op.testop, F32Op.testop, F64Op.testop) Values.op type unop = (I32Op.unop, I64Op.unop, F32Op.unop, F64Op.unop) Values.op +[@@deriving show] type binop = (I32Op.binop, I64Op.binop, F32Op.binop, F64Op.binop) Values.op +[@@deriving show] type relop = (I32Op.relop, I64Op.relop, F32Op.relop, F64Op.relop) Values.op +[@@deriving show] type cvtop = (I32Op.cvtop, I64Op.cvtop, F32Op.cvtop, F64Op.cvtop) Values.op +[@@deriving show] type vec_testop = V128Op.testop Values.vecop @@ -237,32 +246,35 @@ type vec_extractop = V128Op.extractop Values.vecop type vec_replaceop = V128Op.replaceop Values.vecop type ('t, 'p) memop = {ty : 't; align : int; offset : int32; pack : 'p} +[@@deriving show] -type loadop = (num_type, (pack_size * extension) option) memop +type loadop = (num_type, (pack_size * extension) option) memop [@@deriving show] -type storeop = (num_type, pack_size option) memop +type storeop = (num_type, pack_size option) memop [@@deriving show] type vec_loadop = (vec_type, (pack_size * vec_extension) option) memop +[@@deriving show] -type vec_storeop = (vec_type, unit) memop +type vec_storeop = (vec_type, unit) memop [@@deriving show] -type vec_laneop = (vec_type, pack_size) memop * int +type vec_laneop = (vec_type, pack_size) memop * int [@@deriving show] (* Expressions *) -type var = int32 Source.phrase +type var = int32 Source.phrase [@@deriving show] type num = Values.num Source.phrase -type vec = Values.vec Source.phrase +type vec = Values.vec Source.phrase [@@deriving show] type name = int Vector.t type name_list = int list type block_type = VarBlockType of var | ValBlockType of value_type option +[@@deriving show] -type block_label = Block_label of int32 +type block_label = Block_label of int32 [@@deriving show] type nonrec instr' = | Unreachable (* trap unconditionally *) @@ -367,7 +379,7 @@ and elem_segment' = { emode : segment_mode; } -type data_label = Data_label of int32 +type data_label = Data_label of int32 [@@deriving show] type data_segment = data_segment' Source.phrase diff --git a/src/lib_webassembly/syntax/types.ml b/src/lib_webassembly/syntax/types.ml index d7a499fc0c596a7b771058829367718a635b4d67..58d9c36a839d9ec246c78f6da5e4627685bc9221 100644 --- a/src/lib_webassembly/syntax/types.ml +++ b/src/lib_webassembly/syntax/types.ml @@ -1,29 +1,30 @@ (* Types *) -type num_type = I32Type | I64Type | F32Type | F64Type +type num_type = I32Type | I64Type | F32Type | F64Type [@@deriving show] -type vec_type = V128Type +type vec_type = V128Type [@@deriving show] -type ref_type = FuncRefType | ExternRefType +type ref_type = FuncRefType | ExternRefType [@@deriving show] type value_type = | NumType of num_type | VecType of vec_type | RefType of ref_type +[@@deriving show] type result_type = value_type Lazy_vector.Int32Vector.t type func_type = FuncType of result_type * result_type -type 'a limits = {min : 'a; max : 'a option} +type 'a limits = {min : 'a; max : 'a option} [@@deriving show] -type mutability = Immutable | Mutable +type mutability = Immutable | Mutable [@@deriving show] -type table_type = TableType of Int32.t limits * ref_type +type table_type = TableType of Int32.t limits * ref_type [@@deriving show] -type memory_type = MemoryType of Int32.t limits +type memory_type = MemoryType of Int32.t limits [@@deriving show] -type global_type = GlobalType of value_type * mutability +type global_type = GlobalType of value_type * mutability [@@deriving show] type extern_type = | ExternFuncType of func_type @@ -32,13 +33,14 @@ type extern_type = | ExternGlobalType of global_type (* Reference-interpreter-todo: these types should move somewhere else *) -type pack_size = Pack8 | Pack16 | Pack32 | Pack64 +type pack_size = Pack8 | Pack16 | Pack32 | Pack64 [@@deriving show] -type extension = SX | ZX +type extension = SX | ZX [@@deriving show] -type pack_shape = Pack8x8 | Pack16x4 | Pack32x2 +type pack_shape = Pack8x8 | Pack16x4 | Pack32x2 [@@deriving show] type vec_extension = ExtLane of pack_shape * extension | ExtSplat | ExtZero +[@@deriving show] (* Attributes *) diff --git a/src/lib_webassembly/syntax/values.ml b/src/lib_webassembly/syntax/values.ml index fe6c110bcbeddf15c063e07d42df511ac1cdabf7..9efe5faa13e8798bbc3f82b5e63660a687c0633b 100644 --- a/src/lib_webassembly/syntax/values.ml +++ b/src/lib_webassembly/syntax/values.ml @@ -7,12 +7,13 @@ type ('i32, 'i64, 'f32, 'f64) op = | I64 of 'i64 | F32 of 'f32 | F64 of 'f64 +[@@deriving show] -type 'v128 vecop = V128 of 'v128 +type 'v128 vecop = V128 of 'v128 [@@deriving show] type num = (I32.t, I64.t, F32.t, F64.t) op -type vec = V128.t vecop +type vec = V128.t vecop [@@deriving show] type ref_ = .. diff --git a/src/lib_webassembly/util/source.ml b/src/lib_webassembly/util/source.ml index fe5ad2021371e6865c311605c9f4888ba4d924b7..d514b5f4bcbca0ddc313818c12a82acffafd37ba 100644 --- a/src/lib_webassembly/util/source.ml +++ b/src/lib_webassembly/util/source.ml @@ -1,8 +1,8 @@ -type pos = {file : string; line : int; column : int} +type pos = {file : string; line : int; column : int} [@@deriving show] -type region = {left : pos; right : pos} +type region = {left : pos; right : pos} [@@deriving show] -type 'a phrase = {at : region; it : 'a} +type 'a phrase = {at : region; it : 'a} [@@deriving show] let ( @@ ) x region = {it = x; at = region} diff --git a/src/lib_webassembly/util/source.mli b/src/lib_webassembly/util/source.mli index dab908a490a398998dd38490512f372daf976c21..480e59c2bf60687f00e3fa0781bd849e01fee881 100644 --- a/src/lib_webassembly/util/source.mli +++ b/src/lib_webassembly/util/source.mli @@ -1,8 +1,8 @@ -type pos = {file : string; line : int; column : int} +type pos = {file : string; line : int; column : int} [@@deriving show] -type region = {left : pos; right : pos} +type region = {left : pos; right : pos} [@@deriving show] -type 'a phrase = {at : region; it : 'a} +type 'a phrase = {at : region; it : 'a} [@@deriving show] val no_pos : pos