Skip to content
This repository was archived by the owner on Nov 3, 2021. It is now read-only.

Commit 6eb26a3

Browse files
rossbergbinji
authored andcommitted
Slight simplifications to text format (#84)
* Remove passive segment func ref shorthand * Drop passive keyword
1 parent 4c97261 commit 6eb26a3

File tree

7 files changed

+307
-237
lines changed

7 files changed

+307
-237
lines changed

interpreter/text/arrange.ml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ let segment head active passive seg =
300300
match seg.it with
301301
| Active {index; offset; init} ->
302302
Node (head, atom var index :: Node ("offset", const offset) :: active init)
303-
| Passive {etype; data} -> Node (head ^ " passive", passive etype data)
303+
| Passive {etype; data} -> Node (head, passive etype data)
304304

305305
let active_elem el =
306306
match el.it with

interpreter/text/lexer.mll

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,6 @@ rule token = parse
339339
| "memory" { MEMORY }
340340
| "elem" { ELEM }
341341
| "data" { DATA }
342-
| "passive" { PASSIVE }
343342
| "offset" { OFFSET }
344343
| "import" { IMPORT }
345344
| "export" { EXPORT }

interpreter/text/parser.mly

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ let inline_type_explicit (c : context) x ft at =
167167
%token CONST UNARY BINARY TEST COMPARE CONVERT
168168
%token REF_NULL REF_FUNC
169169
%token FUNC START TYPE PARAM RESULT LOCAL GLOBAL
170-
%token TABLE ELEM MEMORY DATA PASSIVE OFFSET IMPORT EXPORT TABLE
170+
%token TABLE ELEM MEMORY DATA OFFSET IMPORT EXPORT TABLE
171171
%token MODULE BIN QUOTE
172172
%token SCRIPT REGISTER INVOKE GET
173173
%token ASSERT_MALFORMED ASSERT_INVALID ASSERT_SOFT_INVALID ASSERT_UNLINKABLE
@@ -573,7 +573,6 @@ offset :
573573
elemref :
574574
| LPAR REF_NULL RPAR { let at = at () in fun c -> ref_null @@ at }
575575
| LPAR REF_FUNC var RPAR { let at = at () in fun c -> ref_func ($3 c func) @@ at }
576-
| var { let at = at () in fun c -> ref_func ($1 c func) @@ at }
577576
578577
passive_elemref_list :
579578
| /* empty */ { fun c -> [] }
@@ -585,10 +584,10 @@ active_elemref_list :
585584
fun c lookup -> List.map f ($1 c lookup) }
586585
587586
elem :
588-
| LPAR ELEM bind_var_opt PASSIVE elem_type passive_elemref_list RPAR
587+
| LPAR ELEM bind_var_opt elem_type passive_elemref_list RPAR
589588
{ let at = at () in
590589
fun c -> ignore ($3 c anon_elem bind_elem);
591-
fun () -> Passive {etype = $5; data = $6 c} @@ at }
590+
fun () -> Passive {etype = $4; data = $5 c} @@ at }
592591
| LPAR ELEM bind_var var offset active_elemref_list RPAR
593592
{ let at = at () in
594593
fun c -> ignore (bind_elem c $3);
@@ -631,10 +630,10 @@ table_fields :
631630
[], [] }
632631
633632
data :
634-
| LPAR DATA bind_var_opt PASSIVE string_list RPAR
633+
| LPAR DATA bind_var_opt string_list RPAR
635634
{ let at = at () in
636635
fun c -> ignore ($3 c anon_data bind_data);
637-
fun () -> Passive {etype = (); data = $5} @@ at }
636+
fun () -> Passive {etype = (); data = $4} @@ at }
638637
| LPAR DATA bind_var var offset string_list RPAR
639638
{ let at = at () in
640639
fun c -> ignore (bind_data c $3);

test/core/bulk.wast

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
;; Passive segment syntax
1+
;; segment syntax
22
(module
33
(memory 1)
4-
(data passive "foo"))
4+
(data "foo"))
55

66
(module
77
(table 3 funcref)
8-
(elem passive funcref (ref.func 0) (ref.null) (ref.func 1))
8+
(elem funcref (ref.func 0) (ref.null) (ref.func 1))
99
(func)
1010
(func))
1111

@@ -120,7 +120,7 @@
120120
;; memory.init
121121
(module
122122
(memory 1)
123-
(data passive "\aa\bb\cc\dd")
123+
(data "\aa\bb\cc\dd")
124124

125125
(func (export "init") (param i32 i32 i32)
126126
(memory.init 0
@@ -159,7 +159,7 @@
159159
;; data.drop
160160
(module
161161
(memory 1)
162-
(data $p passive "")
162+
(data $p "")
163163
(data $a 0 (i32.const 0) "")
164164

165165
(func (export "drop_passive") (data.drop $p))
@@ -182,7 +182,7 @@
182182
;; table.init
183183
(module
184184
(table 3 funcref)
185-
(elem passive funcref
185+
(elem funcref
186186
(ref.func $zero) (ref.func $one) (ref.func $zero) (ref.func $one))
187187

188188
(func $zero (result i32) (i32.const 0))
@@ -227,7 +227,7 @@
227227
(module
228228
(table 1 funcref)
229229
(func $f)
230-
(elem $p passive funcref (ref.func $f))
230+
(elem $p funcref (ref.func $f))
231231
(elem $a 0 (i32.const 0) $f)
232232

233233
(func (export "drop_passive") (elem.drop $p))

0 commit comments

Comments
 (0)