Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove some trailing whitespace in printed components #796

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
@@ -1,5 +1,5 @@
(component
(type (;0;)
(type (;0;)
(component
(type (;0;) (record (field "a" s8) (field "b" u8) (field "c" s16) (field "d" u16) (field "e" s32) (field "f" u32) (field "g" s64) (field "h" u64) (field "i" float32) (field "j" float64) (field "k" bool) (field "l" string)))
(export "record1" (type (eq 0)))
Expand Down Expand Up @@ -61,9 +61,9 @@
)
(import "a" (component (;0;) (type 0)))
(instance (;0;) (instantiate 0))
(type (;1;)
(type (;1;)
(component
(type (;0;)
(type (;0;)
(instance
(type (;0;) (func))
(export "a" (func (type 0)))
Expand Down Expand Up @@ -124,7 +124,7 @@
)
)
(import "a" (instance (type 0)))
(type (;1;)
(type (;1;)
(instance
(type (;0;) (func (param "x" string) (result string)))
(export "m" (func (type 0)))
Expand All @@ -143,7 +143,7 @@
)
)
(component (;2;)
(type (;0;)
(type (;0;)
(instance
(type (;0;) (func (param "x" string) (result string)))
(export "m" (func (type 0)))
Expand Down
6 changes: 3 additions & 3 deletions crates/wasm-compose/tests/compositions/complex/b.wat
Expand Up @@ -29,7 +29,7 @@
(type (func (param "x" 26)))
(type (result 13 (error string)))
(type (func (result 28)))
(type
(type
(instance
(alias outer 1 0 (type))
(export "a" (func (type 0)))
Expand Down Expand Up @@ -256,7 +256,7 @@
(core func (canon lower (func 11)))
(core func (canon lower (func 12)))
(core func (canon lower (func 13)))
(core instance
(core instance
(export "m" (func 0))
(export "n" (func 1))
(export "o" (func 2))
Expand Down Expand Up @@ -300,7 +300,7 @@
(core func (canon lower (func 18) (memory 0) (realloc 21) string-encoding=utf8))
(core func (canon lower (func 19) (memory 0) (realloc 21) string-encoding=utf8))
(core func (canon lower (func 20) (memory 0) (realloc 21) string-encoding=utf8))
(core instance
(core instance
(export "$imports" (table 0))
(export "0" (func 22))
(export "1" (func 23))
Expand Down
8 changes: 4 additions & 4 deletions crates/wasm-compose/tests/compositions/complex/composed.wat
Expand Up @@ -238,7 +238,7 @@
(type (;27;) (func (param "x" 26)))
(type (;28;) (result 13 (error string)))
(type (;29;) (func (result 28)))
(type (;30;)
(type (;30;)
(instance
(alias outer 1 0 (type (;0;)))
(export "a" (func (type 0)))
Expand Down Expand Up @@ -472,7 +472,7 @@
(core func (;18;) (canon lower (func 11)))
(core func (;19;) (canon lower (func 12)))
(core func (;20;) (canon lower (func 13)))
(core instance (;1;)
(core instance (;1;)
(export "m" (func 0))
(export "n" (func 1))
(export "o" (func 2))
Expand Down Expand Up @@ -516,7 +516,7 @@
(core func (;26;) (canon lower (func 18) (memory 0) (realloc 21) string-encoding=utf8))
(core func (;27;) (canon lower (func 19) (memory 0) (realloc 21) string-encoding=utf8))
(core func (;28;) (canon lower (func 20) (memory 0) (realloc 21) string-encoding=utf8))
(core instance (;3;)
(core instance (;3;)
(export "$imports" (table 0))
(export "0" (func 22))
(export "1" (func 23))
Expand Down Expand Up @@ -546,7 +546,7 @@
)
)
(component (;2;)
(type (;0;)
(type (;0;)
(instance
(type (;0;) (func (param "x" string) (result string)))
(export "m" (func (type 0)))
Expand Down
@@ -1,5 +1,5 @@
(component
(type (;0;)
(type (;0;)
(instance
(type (;0;) (func))
(export "b" (func (type 0)))
Expand All @@ -11,7 +11,7 @@
)
(import "a" (instance (;0;) (type 0)))
(component (;0;)
(type (;0;)
(type (;0;)
(instance
(type (;0;) (func (param "x" string)))
(export "a" (func (type 0)))
Expand All @@ -26,7 +26,7 @@
)
)
(component (;1;)
(type (;0;)
(type (;0;)
(instance
(type (;0;) (func))
(export "b" (func (type 0)))
Expand All @@ -35,7 +35,7 @@
)
)
(import "a" (instance (;0;) (type 0)))
(type (;1;)
(type (;1;)
(instance)
)
(import "b" (instance (;1;) (type 1)))
Expand Down
5 changes: 3 additions & 2 deletions crates/wasmprinter/src/lib.rs
Expand Up @@ -1660,12 +1660,13 @@ impl Printer {
let state = states.last_mut().unwrap();
self.print_name(&state.component.type_names, state.component.types)?;
}
self.result.push(' ');
match ty {
ComponentType::Defined(ty) => {
self.result.push(' ');
self.print_defined_type(states.last_mut().unwrap(), &ty)?;
}
ComponentType::Func(ty) => {
self.result.push(' ');
self.print_component_func_type(states.last_mut().unwrap(), &ty)?;
}
ComponentType::Component(decls) => {
Expand Down Expand Up @@ -1961,9 +1962,9 @@ impl Printer {
self.newline(offset);
self.start_group("core instance ");
self.print_name(&state.core.instance_names, state.core.instances)?;
self.result.push(' ');
match instance {
Instance::Instantiate { module_index, args } => {
self.result.push(' ');
self.start_group("instantiate ");
self.print_idx(&state.core.module_names, module_index)?;
for arg in args.iter() {
Expand Down