Skip to content

Commit

Permalink
Tweak printing page sizes in text format (#1769)
Browse files Browse the repository at this point in the history
Put a space before `(pagesize ...)` and additionally use
`start_group`/`end_group` so it gets colors automatically applied.
  • Loading branch information
alexcrichton committed Sep 9, 2024
1 parent 668cb31 commit ebfd6a0
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 9 deletions.
6 changes: 5 additions & 1 deletion crates/wasmprinter/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1159,7 +1159,11 @@ impl Printer<'_, '_> {
let p = 1_u64
.checked_shl(p)
.ok_or_else(|| anyhow!("left shift overflow").context("invalid page size"))?;
write!(self.result, "(pagesize {p:#x})")?;

self.result.write_str(" ")?;
self.start_group("pagesize ")?;
write!(self.result, "{p:#x}")?;
self.end_group()?;
}
Ok(())
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(module
(memory (;0;) 1(pagesize 0x1))
(memory (;0;) 1 (pagesize 0x1))
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(module
(memory (;0;) 1(pagesize 0x10000))
(memory (;0;) 1 (pagesize 0x10000))
)
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@
local.get 0
memory.grow
)
(memory (;0;) 0(pagesize 0x10000))
(memory (;0;) 0 (pagesize 0x10000))
(export "grow" (func 0))
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(module
(memory (;0;) 1 2(pagesize 0x1))
(memory (;0;) 1 2 (pagesize 0x1))
)
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
local.get 0
i32.load8_u
)
(memory $small (;0;) 10(pagesize 0x1))
(memory $large (;1;) 1(pagesize 0x10000))
(memory $small (;0;) 10 (pagesize 0x1))
(memory $large (;1;) 1 (pagesize 0x10000))
(export "copy-small-to-large" (func 0))
(export "copy-large-to-small" (func 1))
(export "load8-small" (func 2))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
(module
(memory (;0;) 1 2(pagesize 0x10000))
(memory (;0;) 1 2 (pagesize 0x10000))
)
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
local.get 1
i32.store
)
(memory (;0;) 0(pagesize 0x1))
(memory (;0;) 0 (pagesize 0x1))
(export "size" (func 0))
(export "grow" (func 1))
(export "load" (func 2))
Expand Down

0 comments on commit ebfd6a0

Please sign in to comment.