Commit 7a7815f
authored
* Refactor how operand immediates are printed
Delegate the space-before-immediate to printing the immediate itself
rather than forcing a space between each immediate. Avoids the need to
`pop()` or otherwise test if space is already present in situations
where immediates are omitted.
* Add a test exercising labels
* Update how operators are printed in `wasmprinter`
Previously operators were printed to a temporary buffer and then
depending on what happened it would conditionally go into the actual
module or instead be discarded (e.g. the last `end`). This commit
refactors to instead avoid a temporary buffer entirely and
unconditionally emit instructions to the real output. This is done by
restructuring the printing slightly by having "before_op" and "after_op"
hooks while printing which are used to manage nesting/newlines instead
of the outer loop in the main printer. This is combined with a few other
minor things such as a `is_end_then_eof` method which is used to avoid
printing the final `end`.
One minor test update happened here with a `delegate` instruction from
the legacy exception-handling proposal which I think is a bugfix given
my read of the older proposal.
* Review comments
1 parent 9340ed2 commit 7a7815f
File tree
8 files changed
+205
-196
lines changed- crates
- wasmparser/src
- readers/core
- wasmprinter/src
- tests
- cli
- local
- snapshots/local
- labels.wast
8 files changed
+205
-196
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1712 | 1712 | | |
1713 | 1713 | | |
1714 | 1714 | | |
| 1715 | + | |
| 1716 | + | |
| 1717 | + | |
| 1718 | + | |
| 1719 | + | |
| 1720 | + | |
1715 | 1721 | | |
1716 | 1722 | | |
1717 | 1723 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
209 | 209 | | |
210 | 210 | | |
211 | 211 | | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
212 | 218 | | |
213 | 219 | | |
214 | 220 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1281 | 1281 | | |
1282 | 1282 | | |
1283 | 1283 | | |
1284 | | - | |
1285 | | - | |
1286 | | - | |
| 1284 | + | |
| 1285 | + | |
| 1286 | + | |
1287 | 1287 | | |
1288 | 1288 | | |
1289 | 1289 | | |
| |||
1299 | 1299 | | |
1300 | 1300 | | |
1301 | 1301 | | |
1302 | | - | |
1303 | | - | |
1304 | | - | |
1305 | | - | |
1306 | | - | |
1307 | | - | |
1308 | | - | |
1309 | | - | |
1310 | | - | |
1311 | | - | |
1312 | | - | |
1313 | | - | |
1314 | | - | |
1315 | | - | |
1316 | | - | |
1317 | | - | |
1318 | | - | |
1319 | | - | |
1320 | | - | |
1321 | | - | |
1322 | | - | |
1323 | | - | |
1324 | | - | |
1325 | | - | |
1326 | | - | |
1327 | | - | |
1328 | | - | |
1329 | | - | |
1330 | | - | |
1331 | | - | |
1332 | | - | |
1333 | | - | |
1334 | | - | |
1335 | | - | |
1336 | | - | |
1337 | | - | |
1338 | | - | |
1339 | | - | |
1340 | | - | |
1341 | | - | |
1342 | | - | |
1343 | | - | |
| 1302 | + | |
| 1303 | + | |
1344 | 1304 | | |
1345 | 1305 | | |
1346 | 1306 | | |
| |||
1596 | 1556 | | |
1597 | 1557 | | |
1598 | 1558 | | |
1599 | | - | |
1600 | 1559 | | |
1601 | | - | |
1602 | | - | |
1603 | | - | |
1604 | | - | |
1605 | | - | |
1606 | | - | |
1607 | | - | |
1608 | | - | |
1609 | 1560 | | |
1610 | | - | |
1611 | | - | |
1612 | | - | |
1613 | | - | |
1614 | | - | |
1615 | | - | |
1616 | | - | |
1617 | | - | |
1618 | | - | |
1619 | | - | |
1620 | | - | |
1621 | | - | |
1622 | | - | |
1623 | | - | |
| 1561 | + | |
| 1562 | + | |
1624 | 1563 | | |
1625 | 1564 | | |
1626 | | - | |
1627 | | - | |
1628 | | - | |
1629 | | - | |
1630 | | - | |
1631 | | - | |
1632 | | - | |
| 1565 | + | |
| 1566 | + | |
1633 | 1567 | | |
1634 | 1568 | | |
1635 | 1569 | | |
| |||
1639 | 1573 | | |
1640 | 1574 | | |
1641 | 1575 | | |
1642 | | - | |
1643 | | - | |
1644 | | - | |
| 1576 | + | |
| 1577 | + | |
| 1578 | + | |
1645 | 1579 | | |
1646 | 1580 | | |
1647 | 1581 | | |
1648 | 1582 | | |
1649 | 1583 | | |
1650 | | - | |
1651 | | - | |
1652 | | - | |
1653 | | - | |
1654 | | - | |
1655 | | - | |
1656 | | - | |
| 1584 | + | |
1657 | 1585 | | |
1658 | | - | |
1659 | 1586 | | |
1660 | 1587 | | |
1661 | 1588 | | |
| |||
0 commit comments