diff --git a/CHANGES.md b/CHANGES.md index dfedfdd0d..9c5e996a8 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,6 @@ ## unreleased +- support the extended const proposal - `owi opt` and `owi sym` can run on `.wasm` files directly - remove dependency on `wabt` - better API for `Parse`, `Compile` and `Simplified` (renamed to `Binary`), added a `Binary_to_text` module diff --git a/README.md b/README.md index 731f8d3bb..35461755a 100644 --- a/README.md +++ b/README.md @@ -67,8 +67,8 @@ We only list proposals that reached phase 3 at least. | ------------------------------------------------ | -------- | | [Tail call] | ✔️ | | [Typed Function References] | ✔️ | +| [Extended Constant Expressions] | ✔️ | | [Garbage collection] | Ongoing | -| [Extended Constant Expressions] | ❌ | | [Multiple memories] | ❌ | | [Custom Annotation Syntax in the Text Format] | ❌ | | [Memory64] | ❌ | diff --git a/src/text_to_binary/rewrite.ml b/src/text_to_binary/rewrite.ml index 4808ff092..65960d4ea 100644 --- a/src/text_to_binary/rewrite.ml +++ b/src/text_to_binary/rewrite.ml @@ -351,7 +351,7 @@ let rewrite_const_expr (modul : Assigned.t) (expr : text expr) : match mut with | Const -> ok @@ Global_get (Raw idx) | Var -> Error `Constant_expression_required - end + end | Ref_null v -> let+ v = Binary_types.convert_heap_type None v in Ref_null v @@ -364,7 +364,7 @@ let rewrite_const_expr (modul : Assigned.t) (expr : text expr) : | Array_new_default t -> let+ t = find "unknown type" modul.typ (Some t) in Array_new_default t - | (I32_const _ | I64_const _ | F32_const _ | F64_const _ | Ref_i31) as i -> + | (I32_const _ | I64_const _ | F32_const _ | F64_const _ | Ref_i31) | I_binop (_, (Add | Sub | Mul)) as i -> Ok i | _i -> Error `Constant_expression_required in diff --git a/test/script/extended_const.t b/test/script/extended_const.t new file mode 100644 index 000000000..16f94a6c5 --- /dev/null +++ b/test/script/extended_const.t @@ -0,0 +1,3 @@ + $ owi script --no-exhaustion reference/proposals/extended-const/data.wast + $ owi script --no-exhaustion reference/proposals/extended-const/elem.wast + $ owi script --no-exhaustion reference/proposals/extended-const/global.wast