Skip to content

Commit

Permalink
Slight simplifications to text format (WebAssembly#84)
Browse files Browse the repository at this point in the history
* Remove passive segment func ref shorthand

* Drop passive keyword
  • Loading branch information
rossberg authored and binji committed May 13, 2019
1 parent 4c97261 commit 6eb26a3
Show file tree
Hide file tree
Showing 7 changed files with 307 additions and 237 deletions.
2 changes: 1 addition & 1 deletion interpreter/text/arrange.ml
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ let segment head active passive seg =
match seg.it with
| Active {index; offset; init} ->
Node (head, atom var index :: Node ("offset", const offset) :: active init)
| Passive {etype; data} -> Node (head ^ " passive", passive etype data)
| Passive {etype; data} -> Node (head, passive etype data)

let active_elem el =
match el.it with
Expand Down
1 change: 0 additions & 1 deletion interpreter/text/lexer.mll
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@ rule token = parse
| "memory" { MEMORY }
| "elem" { ELEM }
| "data" { DATA }
| "passive" { PASSIVE }
| "offset" { OFFSET }
| "import" { IMPORT }
| "export" { EXPORT }
Expand Down
11 changes: 5 additions & 6 deletions interpreter/text/parser.mly
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ let inline_type_explicit (c : context) x ft at =
%token CONST UNARY BINARY TEST COMPARE CONVERT
%token REF_NULL REF_FUNC
%token FUNC START TYPE PARAM RESULT LOCAL GLOBAL
%token TABLE ELEM MEMORY DATA PASSIVE OFFSET IMPORT EXPORT TABLE
%token TABLE ELEM MEMORY DATA OFFSET IMPORT EXPORT TABLE
%token MODULE BIN QUOTE
%token SCRIPT REGISTER INVOKE GET
%token ASSERT_MALFORMED ASSERT_INVALID ASSERT_SOFT_INVALID ASSERT_UNLINKABLE
Expand Down Expand Up @@ -573,7 +573,6 @@ offset :
elemref :
| LPAR REF_NULL RPAR { let at = at () in fun c -> ref_null @@ at }
| LPAR REF_FUNC var RPAR { let at = at () in fun c -> ref_func ($3 c func) @@ at }
| var { let at = at () in fun c -> ref_func ($1 c func) @@ at }
passive_elemref_list :
| /* empty */ { fun c -> [] }
Expand All @@ -585,10 +584,10 @@ active_elemref_list :
fun c lookup -> List.map f ($1 c lookup) }
elem :
| LPAR ELEM bind_var_opt PASSIVE elem_type passive_elemref_list RPAR
| LPAR ELEM bind_var_opt elem_type passive_elemref_list RPAR
{ let at = at () in
fun c -> ignore ($3 c anon_elem bind_elem);
fun () -> Passive {etype = $5; data = $6 c} @@ at }
fun () -> Passive {etype = $4; data = $5 c} @@ at }
| LPAR ELEM bind_var var offset active_elemref_list RPAR
{ let at = at () in
fun c -> ignore (bind_elem c $3);
Expand Down Expand Up @@ -631,10 +630,10 @@ table_fields :
[], [] }
data :
| LPAR DATA bind_var_opt PASSIVE string_list RPAR
| LPAR DATA bind_var_opt string_list RPAR
{ let at = at () in
fun c -> ignore ($3 c anon_data bind_data);
fun () -> Passive {etype = (); data = $5} @@ at }
fun () -> Passive {etype = (); data = $4} @@ at }
| LPAR DATA bind_var var offset string_list RPAR
{ let at = at () in
fun c -> ignore (bind_data c $3);
Expand Down
14 changes: 7 additions & 7 deletions test/core/bulk.wast
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
;; Passive segment syntax
;; segment syntax
(module
(memory 1)
(data passive "foo"))
(data "foo"))

(module
(table 3 funcref)
(elem passive funcref (ref.func 0) (ref.null) (ref.func 1))
(elem funcref (ref.func 0) (ref.null) (ref.func 1))
(func)
(func))

Expand Down Expand Up @@ -120,7 +120,7 @@
;; memory.init
(module
(memory 1)
(data passive "\aa\bb\cc\dd")
(data "\aa\bb\cc\dd")

(func (export "init") (param i32 i32 i32)
(memory.init 0
Expand Down Expand Up @@ -159,7 +159,7 @@
;; data.drop
(module
(memory 1)
(data $p passive "")
(data $p "")
(data $a 0 (i32.const 0) "")

(func (export "drop_passive") (data.drop $p))
Expand All @@ -182,7 +182,7 @@
;; table.init
(module
(table 3 funcref)
(elem passive funcref
(elem funcref
(ref.func $zero) (ref.func $one) (ref.func $zero) (ref.func $one))

(func $zero (result i32) (i32.const 0))
Expand Down Expand Up @@ -227,7 +227,7 @@
(module
(table 1 funcref)
(func $f)
(elem $p passive funcref (ref.func $f))
(elem $p funcref (ref.func $f))
(elem $a 0 (i32.const 0) $f)

(func (export "drop_passive") (elem.drop $p))
Expand Down
Loading

0 comments on commit 6eb26a3

Please sign in to comment.