@@ -1329,10 +1329,12 @@ impl Printer<'_, '_> {
1329
1329
branch_hints = rest;
1330
1330
op_printer. printer . newline ( * hint_offset) ?;
1331
1331
let desc = if hint. taken { "\" \\ 01\" " } else { "\" \\ 00\" " } ;
1332
+ op_printer. printer . result . start_comment ( ) ?;
1332
1333
write ! (
1333
1334
op_printer. printer. result,
1334
1335
"(@metadata.code.branch_hint {desc})" ,
1335
1336
) ?;
1337
+ op_printer. printer . result . reset_color ( ) ?;
1336
1338
}
1337
1339
}
1338
1340
@@ -1525,9 +1527,10 @@ impl Printer<'_, '_> {
1525
1527
} => {
1526
1528
let table_index = table_index. unwrap_or ( 0 ) ;
1527
1529
if table_index != 0 {
1528
- self . result . write_str ( " (table " ) ?;
1530
+ self . result . write_str ( " " ) ?;
1531
+ self . start_group ( "table " ) ?;
1529
1532
self . print_idx ( & state. core . table_names , table_index) ?;
1530
- self . result . write_str ( ")" ) ?;
1533
+ self . end_group ( ) ?;
1531
1534
}
1532
1535
self . result . write_str ( " " ) ?;
1533
1536
self . print_const_expr_sugar ( state, offset_expr, "offset" ) ?;
@@ -1574,9 +1577,10 @@ impl Printer<'_, '_> {
1574
1577
offset_expr,
1575
1578
} => {
1576
1579
if * memory_index != 0 {
1577
- self . result . write_str ( "( memory ") ?;
1580
+ self . start_group ( " memory ") ?;
1578
1581
self . print_idx ( & state. core . memory_names , * memory_index) ?;
1579
- self . result . write_str ( ") " ) ?;
1582
+ self . end_group ( ) ?;
1583
+ self . result . write_str ( " " ) ?;
1580
1584
}
1581
1585
self . print_const_expr_sugar ( state, offset_expr, "offset" ) ?;
1582
1586
self . result . write_str ( " " ) ?;
@@ -1634,19 +1638,19 @@ impl Printer<'_, '_> {
1634
1638
1635
1639
fn print_primitive_val_type ( & mut self , ty : & PrimitiveValType ) -> Result < ( ) > {
1636
1640
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" ) ?,
1650
1654
}
1651
1655
Ok ( ( ) )
1652
1656
}
@@ -1985,14 +1989,17 @@ impl Printer<'_, '_> {
1985
1989
}
1986
1990
ComponentType :: Resource { rep, dtor } => {
1987
1991
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 ") ?;
1990
1994
self . print_valtype ( states. last ( ) . unwrap ( ) , rep) ?;
1991
- self . result . write_str ( ")" ) ?;
1995
+ self . end_group ( ) ?;
1992
1996
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 " ) ?;
1994
2000
self . print_idx ( & states. last ( ) . unwrap ( ) . core . func_names , dtor) ?;
1995
- self . result . write_str ( "))" ) ?;
2001
+ self . end_group ( ) ?;
2002
+ self . end_group ( ) ?;
1996
2003
}
1997
2004
self . end_group ( ) ?;
1998
2005
}
@@ -2087,23 +2094,25 @@ impl Printer<'_, '_> {
2087
2094
self . end_group ( ) ?;
2088
2095
}
2089
2096
ComponentTypeRef :: Type ( bounds) => {
2090
- self . result . write_str ( "( type ") ?;
2097
+ self . start_group ( " type ") ?;
2091
2098
if index {
2092
2099
self . print_name ( & state. component . type_names , state. component . types ) ?;
2093
2100
self . result . write_str ( " " ) ?;
2094
2101
state. component . types += 1 ;
2095
2102
}
2096
2103
match bounds {
2097
2104
TypeBounds :: Eq ( idx) => {
2098
- self . result . write_str ( "( eq ") ?;
2105
+ self . start_group ( " eq ") ?;
2099
2106
self . print_idx ( & state. component . type_names , * idx) ?;
2100
- self . result . write_str ( ")" ) ?;
2107
+ self . end_group ( ) ?;
2101
2108
}
2102
2109
TypeBounds :: SubResource => {
2103
- self . result . write_str ( "(sub resource)" ) ?;
2110
+ self . start_group ( "sub " ) ?;
2111
+ self . print_type_keyword ( "resource" ) ?;
2112
+ self . end_group ( ) ?;
2104
2113
}
2105
2114
} ;
2106
- self . result . write_str ( ")" ) ?;
2115
+ self . end_group ( ) ?;
2107
2116
}
2108
2117
ComponentTypeRef :: Instance ( idx) => {
2109
2118
self . start_group ( "instance " ) ?;
0 commit comments