@@ -1329,10 +1329,12 @@ impl Printer<'_, '_> {
13291329 branch_hints = rest;
13301330 op_printer. printer . newline ( * hint_offset) ?;
13311331 let desc = if hint. taken { "\" \\ 01\" " } else { "\" \\ 00\" " } ;
1332+ op_printer. printer . result . start_comment ( ) ?;
13321333 write ! (
13331334 op_printer. printer. result,
13341335 "(@metadata.code.branch_hint {desc})" ,
13351336 ) ?;
1337+ op_printer. printer . result . reset_color ( ) ?;
13361338 }
13371339 }
13381340
@@ -1525,9 +1527,10 @@ impl Printer<'_, '_> {
15251527 } => {
15261528 let table_index = table_index. unwrap_or ( 0 ) ;
15271529 if table_index != 0 {
1528- self . result . write_str ( " (table " ) ?;
1530+ self . result . write_str ( " " ) ?;
1531+ self . start_group ( "table " ) ?;
15291532 self . print_idx ( & state. core . table_names , table_index) ?;
1530- self . result . write_str ( ")" ) ?;
1533+ self . end_group ( ) ?;
15311534 }
15321535 self . result . write_str ( " " ) ?;
15331536 self . print_const_expr_sugar ( state, offset_expr, "offset" ) ?;
@@ -1574,9 +1577,10 @@ impl Printer<'_, '_> {
15741577 offset_expr,
15751578 } => {
15761579 if * memory_index != 0 {
1577- self . result . write_str ( "( memory ") ?;
1580+ self . start_group ( " memory ") ?;
15781581 self . print_idx ( & state. core . memory_names , * memory_index) ?;
1579- self . result . write_str ( ") " ) ?;
1582+ self . end_group ( ) ?;
1583+ self . result . write_str ( " " ) ?;
15801584 }
15811585 self . print_const_expr_sugar ( state, offset_expr, "offset" ) ?;
15821586 self . result . write_str ( " " ) ?;
@@ -1634,19 +1638,19 @@ impl Printer<'_, '_> {
16341638
16351639 fn print_primitive_val_type ( & mut self , ty : & PrimitiveValType ) -> Result < ( ) > {
16361640 match ty {
1637- PrimitiveValType :: Bool => self . result . write_str ( "bool" ) ?,
1638- PrimitiveValType :: S8 => self . result . write_str ( "s8" ) ?,
1639- PrimitiveValType :: U8 => self . result . write_str ( "u8" ) ?,
1640- PrimitiveValType :: S16 => self . result . write_str ( "s16" ) ?,
1641- PrimitiveValType :: U16 => self . result . write_str ( "u16" ) ?,
1642- PrimitiveValType :: S32 => self . result . write_str ( "s32" ) ?,
1643- PrimitiveValType :: U32 => self . result . write_str ( "u32" ) ?,
1644- PrimitiveValType :: S64 => self . result . write_str ( "s64" ) ?,
1645- PrimitiveValType :: U64 => self . result . write_str ( "u64" ) ?,
1646- PrimitiveValType :: F32 => self . result . write_str ( "f32" ) ?,
1647- PrimitiveValType :: F64 => self . result . write_str ( "f64" ) ?,
1648- PrimitiveValType :: Char => self . result . write_str ( "char" ) ?,
1649- PrimitiveValType :: String => self . result . write_str ( "string" ) ?,
1641+ PrimitiveValType :: Bool => self . print_type_keyword ( "bool" ) ?,
1642+ PrimitiveValType :: S8 => self . print_type_keyword ( "s8" ) ?,
1643+ PrimitiveValType :: U8 => self . print_type_keyword ( "u8" ) ?,
1644+ PrimitiveValType :: S16 => self . print_type_keyword ( "s16" ) ?,
1645+ PrimitiveValType :: U16 => self . print_type_keyword ( "u16" ) ?,
1646+ PrimitiveValType :: S32 => self . print_type_keyword ( "s32" ) ?,
1647+ PrimitiveValType :: U32 => self . print_type_keyword ( "u32" ) ?,
1648+ PrimitiveValType :: S64 => self . print_type_keyword ( "s64" ) ?,
1649+ PrimitiveValType :: U64 => self . print_type_keyword ( "u64" ) ?,
1650+ PrimitiveValType :: F32 => self . print_type_keyword ( "f32" ) ?,
1651+ PrimitiveValType :: F64 => self . print_type_keyword ( "f64" ) ?,
1652+ PrimitiveValType :: Char => self . print_type_keyword ( "char" ) ?,
1653+ PrimitiveValType :: String => self . print_type_keyword ( "string" ) ?,
16501654 }
16511655 Ok ( ( ) )
16521656 }
@@ -1985,14 +1989,17 @@ impl Printer<'_, '_> {
19851989 }
19861990 ComponentType :: Resource { rep, dtor } => {
19871991 self . result . write_str ( " " ) ?;
1988- self . start_group ( "resource" ) ?;
1989- self . result . write_str ( " ( rep ") ?;
1992+ self . start_group ( "resource " ) ?;
1993+ self . start_group ( " rep ") ?;
19901994 self . print_valtype ( states. last ( ) . unwrap ( ) , rep) ?;
1991- self . result . write_str ( ")" ) ?;
1995+ self . end_group ( ) ?;
19921996 if let Some ( dtor) = dtor {
1993- self . result . write_str ( " (dtor (func " ) ?;
1997+ self . result . write_str ( " " ) ?;
1998+ self . start_group ( "dtor " ) ?;
1999+ self . start_group ( "func " ) ?;
19942000 self . print_idx ( & states. last ( ) . unwrap ( ) . core . func_names , dtor) ?;
1995- self . result . write_str ( "))" ) ?;
2001+ self . end_group ( ) ?;
2002+ self . end_group ( ) ?;
19962003 }
19972004 self . end_group ( ) ?;
19982005 }
@@ -2087,23 +2094,25 @@ impl Printer<'_, '_> {
20872094 self . end_group ( ) ?;
20882095 }
20892096 ComponentTypeRef :: Type ( bounds) => {
2090- self . result . write_str ( "( type ") ?;
2097+ self . start_group ( " type ") ?;
20912098 if index {
20922099 self . print_name ( & state. component . type_names , state. component . types ) ?;
20932100 self . result . write_str ( " " ) ?;
20942101 state. component . types += 1 ;
20952102 }
20962103 match bounds {
20972104 TypeBounds :: Eq ( idx) => {
2098- self . result . write_str ( "( eq ") ?;
2105+ self . start_group ( " eq ") ?;
20992106 self . print_idx ( & state. component . type_names , * idx) ?;
2100- self . result . write_str ( ")" ) ?;
2107+ self . end_group ( ) ?;
21012108 }
21022109 TypeBounds :: SubResource => {
2103- self . result . write_str ( "(sub resource)" ) ?;
2110+ self . start_group ( "sub " ) ?;
2111+ self . print_type_keyword ( "resource" ) ?;
2112+ self . end_group ( ) ?;
21042113 }
21052114 } ;
2106- self . result . write_str ( ")" ) ?;
2115+ self . end_group ( ) ?;
21072116 }
21082117 ComponentTypeRef :: Instance ( idx) => {
21092118 self . start_group ( "instance " ) ?;
0 commit comments