Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Intepreter and test updates from @rossberg #99

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions interpreter/binary/decode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -281,19 +281,19 @@ let limits uN s =
let flags = byte s in
require (flags land 0xfa = 0) s (pos s - 1) "malformed limits flags";
let has_max = (flags land 1 = 1) in
let is64 = (flags land 4 = 4) in
let at = if flags land 4 = 4 then I64AT else I32AT in
let min = uN s in
let max = opt uN has_max s in
{min; max}, is64
at, {min; max}

let table_type s =
let t = ref_type s in
let lim, is64 = limits u64 s in
TableT (lim, (if is64 then I64AddrType else I32AddrType), t)
let at, lim = limits u64 s in
TableT (at, lim, t)

let memory_type s =
let lim, is64 = limits u64 s in
MemoryT (lim, if is64 then I64AddrType else I32AddrType)
let at, lim = limits u64 s in
MemoryT (at, lim)

let global_type s =
let t = val_type s in
Expand Down
10 changes: 5 additions & 5 deletions interpreter/binary/encode.ml
Original file line number Diff line number Diff line change
Expand Up @@ -194,15 +194,15 @@ struct
| RecT [st] -> sub_type st
| RecT sts -> s7 (-0x32); vec sub_type sts

let limits vu {min; max} at =
let flags = flag (max <> None) 0 + flag (at = I64AddrType) 2 in
byte flags; vu min; opt vu max
let limits at {min; max} =
let flags = flag (max <> None) 0 + flag (at = I64AT) 2 in
byte flags; u64 min; opt u64 max

let table_type = function
| TableT (lim, at, t) -> ref_type t; limits u64 lim at
| TableT (at, lim, t) -> ref_type t; limits at lim

let memory_type = function
| MemoryT (lim, at) -> limits u64 lim at
| MemoryT (at, lim) -> limits at lim

let global_type = function
| GlobalT (mut, t) -> val_type t; mutability mut
Expand Down
Loading
Loading