Skip to content
This repository was archived by the owner on Apr 25, 2025. It is now read-only.

Commit 9fda8b6

Browse files
authored
Merge pull request #170 from takikawa/spec-tests-event-to-tag
Rename events to tags in spec interpreter and core tests
2 parents 6d71748 + 2a8cc8d commit 9fda8b6

25 files changed

+207
-207
lines changed

interpreter/binary/decode.ml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ let global_type s =
192192
let mut = mutability s in
193193
GlobalType (t, mut)
194194

195-
let event_type s =
195+
let tag_type s =
196196
zero s; at var s
197197

198198

@@ -564,7 +564,7 @@ let id s =
564564
| 10 -> `CodeSection
565565
| 11 -> `DataSection
566566
| 12 -> `DataCountSection
567-
| 13 -> `EventSection
567+
| 13 -> `TagSection
568568
| _ -> error s (pos s) "malformed section id"
569569
) bo
570570

@@ -593,7 +593,7 @@ let import_desc s =
593593
| 0x01 -> TableImport (table_type s)
594594
| 0x02 -> MemoryImport (memory_type s)
595595
| 0x03 -> GlobalImport (global_type s)
596-
| 0x04 -> EventImport (event_type s)
596+
| 0x04 -> TagImport (tag_type s)
597597
| _ -> error s (pos s - 1) "malformed import kind"
598598

599599
let import s =
@@ -631,14 +631,14 @@ let memory s =
631631
let memory_section s =
632632
section `MemorySection (vec (at memory)) [] s
633633

634-
(* Event section *)
634+
(* Tag section *)
635635

636-
let event s =
637-
let etype = event_type s in
638-
{etype}
636+
let tag s =
637+
let tgtype = tag_type s in
638+
{tgtype}
639639

640-
let event_section s =
641-
section `EventSection (vec (at event)) [] s
640+
let tag_section s =
641+
section `TagSection (vec (at tag)) [] s
642642

643643
(* Global section *)
644644

@@ -659,7 +659,7 @@ let export_desc s =
659659
| 0x01 -> TableExport (at var s)
660660
| 0x02 -> MemoryExport (at var s)
661661
| 0x03 -> GlobalExport (at var s)
662-
| 0x04 -> EventExport (at var s)
662+
| 0x04 -> TagExport (at var s)
663663
| _ -> error s (pos s - 1) "malformed export kind"
664664

665665
let export s =
@@ -835,7 +835,7 @@ let module_ s =
835835
iterate custom_section s;
836836
let memories = memory_section s in
837837
iterate custom_section s;
838-
let events = event_section s in
838+
let tags = tag_section s in
839839
iterate custom_section s;
840840
let globals = global_section s in
841841
iterate custom_section s;
@@ -862,7 +862,7 @@ let module_ s =
862862
let funcs =
863863
List.map2 Source.(fun t f -> {f.it with ftype = t} @@ f.at)
864864
func_types func_bodies
865-
in {types; tables; memories; events; globals; funcs; imports; exports; elems;
865+
in {types; tables; memories; tags; globals; funcs; imports; exports; elems;
866866
datas; start}
867867

868868

interpreter/binary/encode.ml

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ let encode m =
121121
let memory_type = function
122122
| MemoryType lim -> limits vu32 lim
123123

124-
let event_type x = vu32 0x00l; var x
124+
let tag_type x = vu32 0x00l; var x
125125

126126
let mutability = function
127127
| Immutable -> u8 0
@@ -443,7 +443,7 @@ let encode m =
443443
| TableImport t -> u8 0x01; table_type t
444444
| MemoryImport t -> u8 0x02; memory_type t
445445
| GlobalImport t -> u8 0x03; global_type t
446-
| EventImport t -> u8 0x04; event_type t
446+
| TagImport t -> u8 0x04; tag_type t
447447

448448
let import im =
449449
let {module_name; item_name; idesc} = im.it in
@@ -474,11 +474,11 @@ let encode m =
474474
let memory_section mems =
475475
section 5 (vec memory) mems (mems <> [])
476476

477-
(* Event section *)
478-
let event (e : event) = u8 0x00; var e.it.etype
477+
(* Tag section *)
478+
let tag (t : tag) = u8 0x00; var t.it.tgtype
479479

480-
let event_section es =
481-
section 13 (vec event) es (es <> [])
480+
let tag_section ts =
481+
section 13 (vec tag) ts (ts <> [])
482482

483483
(* Global section *)
484484
let global g =
@@ -495,7 +495,7 @@ let encode m =
495495
| TableExport x -> u8 1; var x
496496
| MemoryExport x -> u8 2; var x
497497
| GlobalExport x -> u8 3; var x
498-
| EventExport x -> u8 4; var x
498+
| TagExport x -> u8 4; var x
499499

500500
let export ex =
501501
let {name = n; edesc} = ex.it in
@@ -604,7 +604,7 @@ let encode m =
604604
func_section m.it.funcs;
605605
table_section m.it.tables;
606606
memory_section m.it.memories;
607-
event_section m.it.events;
607+
tag_section m.it.tags;
608608
global_section m.it.globals;
609609
export_section m.it.exports;
610610
start_section m.it.start;

interpreter/exec/eval.ml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ let type_ (inst : module_inst) x = lookup "type" inst.types x
8585
let func (inst : module_inst) x = lookup "function" inst.funcs x
8686
let table (inst : module_inst) x = lookup "table" inst.tables x
8787
let memory (inst : module_inst) x = lookup "memory" inst.memories x
88-
let event (inst : module_inst) x = lookup "event" inst.events x
88+
let tag (inst : module_inst) x = lookup "tag" inst.tags x
8989
let global (inst : module_inst) x = lookup "global" inst.globals x
9090
let elem (inst : module_inst) x = lookup "element segment" inst.elems x
9191
let data (inst : module_inst) x = lookup "data segment" inst.datas x
@@ -581,8 +581,8 @@ let create_memory (inst : module_inst) (mem : memory) : memory_inst =
581581
let {mtype} = mem.it in
582582
Memory.alloc mtype
583583

584-
let create_event (inst : module_inst) (e : event) : event_inst =
585-
Event.alloc (type_ inst e.it.etype)
584+
let create_tag (inst : module_inst) (t : tag) : tag_inst =
585+
Tag.alloc (type_ inst t.it.tgtype)
586586

587587
let create_global (inst : module_inst) (glob : global) : global_inst =
588588
let {gtype; ginit} = glob.it in
@@ -597,7 +597,7 @@ let create_export (inst : module_inst) (ex : export) : export_inst =
597597
| TableExport x -> ExternTable (table inst x)
598598
| MemoryExport x -> ExternMemory (memory inst x)
599599
| GlobalExport x -> ExternGlobal (global inst x)
600-
| EventExport x -> ExternEvent (event inst x)
600+
| TagExport x -> ExternTag (tag inst x)
601601
in (name, ext)
602602

603603
let create_elem (inst : module_inst) (seg : elem_segment) : elem_inst =
@@ -617,7 +617,7 @@ let add_import (m : module_) (ext : extern) (im : import) (inst : module_inst)
617617
| ExternFunc func -> {inst with funcs = func :: inst.funcs}
618618
| ExternTable tab -> {inst with tables = tab :: inst.tables}
619619
| ExternMemory mem -> {inst with memories = mem :: inst.memories}
620-
| ExternEvent event -> {inst with events = event :: inst.events}
620+
| ExternTag tag -> {inst with tags = tag :: inst.tags}
621621
| ExternGlobal glob -> {inst with globals = glob :: inst.globals}
622622

623623
let init_func (inst : module_inst) (func : func_inst) =
@@ -660,7 +660,7 @@ let run_start start =
660660

661661
let init (m : module_) (exts : extern list) : module_inst =
662662
let
663-
{ imports; tables; memories; events; globals; funcs; types;
663+
{ imports; tables; memories; tags; globals; funcs; types;
664664
exports; elems; datas; start
665665
} = m.it
666666
in
@@ -676,7 +676,7 @@ let init (m : module_) (exts : extern list) : module_inst =
676676
{ inst1 with
677677
tables = inst1.tables @ List.map (create_table inst1) tables;
678678
memories = inst1.memories @ List.map (create_memory inst1) memories;
679-
events = inst1.events @ List.map (create_event inst1) events;
679+
tags = inst1.tags @ List.map (create_tag inst1) tags;
680680
globals = inst1.globals @ List.map (create_global inst1) globals;
681681
}
682682
in

interpreter/runtime/event.ml

Lines changed: 0 additions & 10 deletions
This file was deleted.

interpreter/runtime/event.mli

Lines changed: 0 additions & 7 deletions
This file was deleted.

interpreter/runtime/instance.ml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type module_inst =
66
funcs : func_inst list;
77
tables : table_inst list;
88
memories : memory_inst list;
9-
events : event_inst list;
9+
tags : tag_inst list;
1010
globals : global_inst list;
1111
exports : export_inst list;
1212
elems : elem_inst list;
@@ -16,7 +16,7 @@ type module_inst =
1616
and func_inst = module_inst ref Func.t
1717
and table_inst = Table.t
1818
and memory_inst = Memory.t
19-
and event_inst = Event.t
19+
and tag_inst = Tag.t
2020
and global_inst = Global.t
2121
and export_inst = Ast.name * extern
2222
and elem_inst = Values.ref_ list ref
@@ -26,7 +26,7 @@ and extern =
2626
| ExternFunc of func_inst
2727
| ExternTable of table_inst
2828
| ExternMemory of memory_inst
29-
| ExternEvent of event_inst
29+
| ExternTag of tag_inst
3030
| ExternGlobal of global_inst
3131

3232

@@ -50,15 +50,15 @@ let () =
5050
(* Auxiliary functions *)
5151

5252
let empty_module_inst =
53-
{ types = []; funcs = []; tables = []; memories = []; events = [];
53+
{ types = []; funcs = []; tables = []; memories = []; tags = [];
5454
globals = []; exports = []; elems = []; datas = [] }
5555

5656
let extern_type_of = function
5757
| ExternFunc func -> ExternFuncType (Func.type_of func)
5858
| ExternTable tab -> ExternTableType (Table.type_of tab)
5959
| ExternMemory mem -> ExternMemoryType (Memory.type_of mem)
6060
| ExternGlobal glob -> ExternGlobalType (Global.type_of glob)
61-
| ExternEvent event -> ExternEventType (Event.type_of event)
61+
| ExternTag tag -> ExternTagType (Tag.type_of tag)
6262

6363
let export inst name =
6464
try Some (List.assoc name inst.exports) with Not_found -> None

interpreter/runtime/tag.ml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
open Types
2+
3+
type tag = {ty : func_type}
4+
type t = tag
5+
6+
let alloc ty =
7+
{ty}
8+
9+
let type_of tg =
10+
tg.ty

interpreter/runtime/tag.mli

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
open Types
2+
3+
type tag = {ty : func_type}
4+
type t = tag
5+
6+
val alloc : func_type -> tag
7+
val type_of : tag -> func_type

interpreter/script/run.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ let print_import m im =
215215
| ExternFuncType t -> "func", string_of_func_type t
216216
| ExternTableType t -> "table", string_of_table_type t
217217
| ExternMemoryType t -> "memory", string_of_memory_type t
218-
| ExternEventType t -> "event", string_of_func_type t
218+
| ExternTagType t -> "tag", string_of_func_type t
219219
| ExternGlobalType t -> "global", string_of_global_type t
220220
in
221221
Printf.printf " import %s \"%s\" \"%s\" : %s\n"
@@ -229,7 +229,7 @@ let print_export m ex =
229229
| ExternFuncType t -> "func", string_of_func_type t
230230
| ExternTableType t -> "table", string_of_table_type t
231231
| ExternMemoryType t -> "memory", string_of_memory_type t
232-
| ExternEventType t -> "event", string_of_func_type t
232+
| ExternTagType t -> "tag", string_of_func_type t
233233
| ExternGlobalType t -> "global", string_of_global_type t
234234
in
235235
Printf.printf " export %s \"%s\" : %s\n"

interpreter/syntax/ast.ml

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,10 @@ and memory' =
157157
mtype : memory_type;
158158
}
159159

160-
type event = event' Source.phrase
161-
and event' =
160+
type tag = tag' Source.phrase
161+
and tag' =
162162
{
163-
etype : var;
163+
tgtype : var;
164164
}
165165

166166

@@ -196,7 +196,7 @@ and export_desc' =
196196
| TableExport of var
197197
| MemoryExport of var
198198
| GlobalExport of var
199-
| EventExport of var
199+
| TagExport of var
200200

201201
type export = export' Source.phrase
202202
and export' =
@@ -211,7 +211,7 @@ and import_desc' =
211211
| TableImport of table_type
212212
| MemoryImport of memory_type
213213
| GlobalImport of global_type
214-
| EventImport of var
214+
| TagImport of var
215215

216216
type import = import' Source.phrase
217217
and import' =
@@ -228,7 +228,7 @@ and module_' =
228228
globals : global list;
229229
tables : table list;
230230
memories : memory list;
231-
events : event list;
231+
tags : tag list;
232232
funcs : func list;
233233
start : var option;
234234
elems : elem_segment list;
@@ -246,7 +246,7 @@ let empty_module =
246246
globals = [];
247247
tables = [];
248248
memories = [];
249-
events = [];
249+
tags = [];
250250
funcs = [];
251251
start = None;
252252
elems = [];
@@ -266,7 +266,7 @@ let import_type (m : module_) (im : import) : extern_type =
266266
| FuncImport x -> ExternFuncType (func_type_for m x)
267267
| TableImport t -> ExternTableType t
268268
| MemoryImport t -> ExternMemoryType t
269-
| EventImport x -> ExternEventType (func_type_for m x)
269+
| TagImport x -> ExternTagType (func_type_for m x)
270270
| GlobalImport t -> ExternGlobalType t
271271

272272
let export_type (m : module_) (ex : export) : extern_type =
@@ -287,10 +287,10 @@ let export_type (m : module_) (ex : export) : extern_type =
287287
| GlobalExport x ->
288288
let gts = globals its @ List.map (fun g -> g.it.gtype) m.it.globals in
289289
ExternGlobalType (nth gts x.it)
290-
| EventExport x ->
291-
let ets =
292-
events its @ List.map (fun (e : event) -> func_type_for m e.it.etype) m.it.events
293-
in ExternEventType (nth ets x.it)
290+
| TagExport x ->
291+
let tts =
292+
tags its @ List.map (fun t -> func_type_for m t.it.tgtype) m.it.tags
293+
in ExternTagType (nth tts x.it)
294294

295295
let string_of_name n =
296296
let b = Buffer.create 16 in

0 commit comments

Comments
 (0)