Skip to content

Commit

Permalink
implement the extended const-proposal
Browse files Browse the repository at this point in the history
  • Loading branch information
Laplace-Demon authored and zapashcanon committed Jun 7, 2024
1 parent 9c4ac2b commit 4d24a89
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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] ||
Expand Down
4 changes: 2 additions & 2 deletions src/text_to_binary/rewrite.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
3 changes: 3 additions & 0 deletions test/script/extended_const.t
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4d24a89

Please sign in to comment.