@@ -25,7 +25,7 @@ use crate::primitives::{
2525 ResizableLimits , ResizableLimits64 , Result , SIMDLaneIndex , SectionCode , TableType , Type ,
2626 TypeOrFuncType , V128 ,
2727} ;
28- use crate :: { ExportType , Import , ImportSectionEntryType , InstanceType , ModuleType } ;
28+ use crate :: { EventType , ExportType , Import , ImportSectionEntryType , InstanceType , ModuleType } ;
2929
3030const MAX_WASM_BR_TABLE_SIZE : usize = MAX_WASM_FUNCTION_SIZE ;
3131
@@ -186,6 +186,7 @@ impl<'a> BinaryReader<'a> {
186186 -0x05 => Ok ( Type :: V128 ) ,
187187 -0x10 => Ok ( Type :: FuncRef ) ,
188188 -0x11 => Ok ( Type :: ExternRef ) ,
189+ -0x18 => Ok ( Type :: ExnRef ) ,
189190 -0x20 => Ok ( Type :: Func ) ,
190191 -0x40 => Ok ( Type :: EmptyBlockType ) ,
191192 _ => Err ( BinaryReaderError :: new (
@@ -202,6 +203,7 @@ impl<'a> BinaryReader<'a> {
202203 1 => Ok ( ExternalKind :: Table ) ,
203204 2 => Ok ( ExternalKind :: Memory ) ,
204205 3 => Ok ( ExternalKind :: Global ) ,
206+ 4 => Ok ( ExternalKind :: Event ) ,
205207 5 => Ok ( ExternalKind :: Module ) ,
206208 6 => Ok ( ExternalKind :: Instance ) ,
207209 7 => Ok ( ExternalKind :: Type ) ,
@@ -300,6 +302,7 @@ impl<'a> BinaryReader<'a> {
300302 ExternalKind :: Function => ImportSectionEntryType :: Function ( self . read_var_u32 ( ) ?) ,
301303 ExternalKind :: Table => ImportSectionEntryType :: Table ( self . read_table_type ( ) ?) ,
302304 ExternalKind :: Memory => ImportSectionEntryType :: Memory ( self . read_memory_type ( ) ?) ,
305+ ExternalKind :: Event => ImportSectionEntryType :: Event ( self . read_event_type ( ) ?) ,
303306 ExternalKind :: Global => ImportSectionEntryType :: Global ( self . read_global_type ( ) ?) ,
304307 ExternalKind :: Module => ImportSectionEntryType :: Module ( self . read_var_u32 ( ) ?) ,
305308 ExternalKind :: Instance => ImportSectionEntryType :: Instance ( self . read_var_u32 ( ) ?) ,
@@ -368,6 +371,18 @@ impl<'a> BinaryReader<'a> {
368371 }
369372 }
370373
374+ pub ( crate ) fn read_event_type ( & mut self ) -> Result < EventType > {
375+ let attribute = self . read_var_u32 ( ) ?;
376+ if attribute != 0 {
377+ return Err ( BinaryReaderError :: new (
378+ "invalid event attributes" ,
379+ self . original_position ( ) - 1 ,
380+ ) ) ;
381+ }
382+ let type_index = self . read_var_u32 ( ) ?;
383+ Ok ( EventType { type_index } )
384+ }
385+
371386 pub ( crate ) fn read_global_type ( & mut self ) -> Result < GlobalType > {
372387 Ok ( GlobalType {
373388 content_type : self . read_type ( ) ?,
@@ -434,6 +449,7 @@ impl<'a> BinaryReader<'a> {
434449 10 => Ok ( SectionCode :: Code ) ,
435450 11 => Ok ( SectionCode :: Data ) ,
436451 12 => Ok ( SectionCode :: DataCount ) ,
452+ 13 => Ok ( SectionCode :: Event ) ,
437453 100 => Ok ( SectionCode :: Module ) ,
438454 101 => Ok ( SectionCode :: Instance ) ,
439455 102 => Ok ( SectionCode :: Alias ) ,
@@ -1082,6 +1098,18 @@ impl<'a> BinaryReader<'a> {
10821098 ty : self . read_blocktype ( ) ?,
10831099 } ,
10841100 0x05 => Operator :: Else ,
1101+ 0x06 => Operator :: Try {
1102+ ty : self . read_blocktype ( ) ?,
1103+ } ,
1104+ 0x07 => Operator :: Catch ,
1105+ 0x08 => Operator :: Throw {
1106+ index : self . read_var_u32 ( ) ?,
1107+ } ,
1108+ 0x09 => Operator :: Rethrow ,
1109+ 0x0a => Operator :: BrOnExn {
1110+ relative_depth : self . read_var_u32 ( ) ?,
1111+ index : self . read_var_u32 ( ) ?,
1112+ } ,
10851113 0x0b => Operator :: End ,
10861114 0x0c => Operator :: Br {
10871115 relative_depth : self . read_var_u32 ( ) ?,
0 commit comments