@@ -135,6 +135,9 @@ let sized f s =
135
135
136
136
open Types
137
137
138
+ let zero s = expect 0x00 s " zero byte expected"
139
+ let var s = vu32 s
140
+
138
141
let num_type s =
139
142
match vs7 s with
140
143
| - 0x01 -> I32Type
@@ -189,17 +192,17 @@ let global_type s =
189
192
let mut = mutability s in
190
193
GlobalType (t, mut)
191
194
195
+ let event_type s =
196
+ zero s; at var s
197
+
192
198
193
199
(* Decode instructions *)
194
200
195
201
open Ast
196
202
open Operators
197
203
198
- let var s = vu32 s
199
-
200
204
let op s = u8 s
201
205
let end_ s = expect 0x0b s " END opcode expected"
202
- let zero s = expect 0x00 s " zero byte expected"
203
206
204
207
let memop s =
205
208
let align = vu32 s in
@@ -527,6 +530,7 @@ let id s =
527
530
| 10 -> `CodeSection
528
531
| 11 -> `DataSection
529
532
| 12 -> `DataCountSection
533
+ | 13 -> `EventSection
530
534
| _ -> error s (pos s) " malformed section id"
531
535
) bo
532
536
@@ -555,6 +559,7 @@ let import_desc s =
555
559
| 0x01 -> TableImport (table_type s)
556
560
| 0x02 -> MemoryImport (memory_type s)
557
561
| 0x03 -> GlobalImport (global_type s)
562
+ | 0x04 -> EventImport (event_type s)
558
563
| _ -> error s (pos s - 1 ) " malformed import kind"
559
564
560
565
let import s =
@@ -592,6 +597,14 @@ let memory s =
592
597
let memory_section s =
593
598
section `MemorySection (vec (at memory)) [] s
594
599
600
+ (* Event section *)
601
+
602
+ let event s =
603
+ let etype = event_type s in
604
+ {etype}
605
+
606
+ let event_section s =
607
+ section `EventSection (vec (at event)) [] s
595
608
596
609
(* Global section *)
597
610
@@ -612,6 +625,7 @@ let export_desc s =
612
625
| 0x01 -> TableExport (at var s)
613
626
| 0x02 -> MemoryExport (at var s)
614
627
| 0x03 -> GlobalExport (at var s)
628
+ | 0x04 -> EventExport (at var s)
615
629
| _ -> error s (pos s - 1 ) " malformed export kind"
616
630
617
631
let export s =
@@ -787,6 +801,8 @@ let module_ s =
787
801
iterate custom_section s;
788
802
let memories = memory_section s in
789
803
iterate custom_section s;
804
+ let events = event_section s in
805
+ iterate custom_section s;
790
806
let globals = global_section s in
791
807
iterate custom_section s;
792
808
let exports = export_section s in
@@ -812,7 +828,8 @@ let module_ s =
812
828
let funcs =
813
829
List. map2 Source. (fun t f -> {f.it with ftype = t} @@ f.at)
814
830
func_types func_bodies
815
- in {types; tables; memories; globals; funcs; imports; exports; elems; datas; start}
831
+ in {types; tables; memories; events; globals; funcs; imports; exports; elems;
832
+ datas; start}
816
833
817
834
818
835
let decode name bs = at module_ (stream name bs)
0 commit comments