Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion crates/wit-component/src/encoding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1685,8 +1685,8 @@ impl<'a> ComponentEncoder<'a> {
let mut state = EncodingState::default();
let mut types = TypeEncoder::default();
let mut imports = ImportEncoder::default();
types.encode_instance_imports(self.imports, &required_imports, &mut imports)?;
types.encode_func_types(exports.clone(), false)?;
types.encode_instance_imports(self.imports, &required_imports, &mut imports)?;
types.finish(&mut state.component);

if self.types_only {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
(component
(type (;0;) u8)
(type (;1;) (record (field "x" 0)))
(type (;2;) (func (param "b" 1)))
(type (;3;)
(instance
(alias outer 1 2 (type (;0;)))
(export "a" (func (type 0)))
)
)
(export "foo" (type 0))
(export "bar" (type 1))
(import "foo" (instance (;0;) (type 3)))
(core module (;0;)
(type (;0;) (func (param i32)))
(type (;1;) (func (param i32 i32 i32 i32) (result i32)))
(import "foo" "a" (func (;0;) (type 0)))
(func (;1;) (type 1) (param i32 i32 i32 i32) (result i32)
unreachable
)
(func (;2;) (type 0) (param i32)
unreachable
)
(memory (;0;) 1)
(export "memory" (memory 0))
(export "canonical_abi_realloc" (func 1))
(export "a" (func 2))
)
(alias export 0 "a" (func (;0;)))
(core func (;0;) (canon lower (func 0)))
(core instance (;0;)
(export "a" (func 0))
)
(core instance (;1;) (instantiate 0
(with "foo" (instance 0))
)
)
(core alias export 1 "memory" (memory (;0;)))
(core alias export 1 "canonical_abi_realloc" (func (;1;)))
(core alias export 1 "a" (func (;2;)))
(func (;1;) (type 2) (canon lift (core func 2)))
(export "a" (func 1))
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type foo = u8

record bar {
x: foo
}

a: func(b: bar)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
type foo = u8

record bar {
x: foo
}

a: func(b: bar)
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
(module
(import "foo" "a" (func (param i32)))
(memory (export "memory") 1)
(func (export "canonical_abi_realloc") (param i32 i32 i32 i32) (result i32) unreachable)
(func (export "a") (param i32) unreachable)
)
20 changes: 10 additions & 10 deletions crates/wit-component/tests/components/import-export/component.wat
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
(component
(type (;0;) (func (result string)))
(type (;1;)
(type (;0;) (tuple string u32 string))
(type (;1;) (func (param "x" string) (result 0)))
(type (;2;) (func))
(type (;3;) (func (result string)))
(type (;4;)
(instance
(alias outer 1 0 (type (;0;)))
(alias outer 1 3 (type (;0;)))
(export "a" (func (type 0)))
)
)
(type (;2;) (tuple string u32 string))
(type (;3;) (func (param "x" string) (result 2)))
(type (;4;) (func))
(import "foo" (instance (;0;) (type 1)))
(import "foo" (instance (;0;) (type 4)))
(core module (;0;)
(type (;0;) (func (param i32)))
(type (;1;) (func (param i32 i32 i32 i32) (result i32)))
Expand Down Expand Up @@ -76,11 +76,11 @@
)
)
(core alias export 2 "a" (func (;3;)))
(func (;1;) (type 3) (canon lift (core func 3) (memory 0) (realloc 1) string-encoding=utf8))
(func (;1;) (type 1) (canon lift (core func 3) (memory 0) (realloc 1) string-encoding=utf8))
(core alias export 2 "bar#a" (func (;4;)))
(core alias export 2 "bar#b" (func (;5;)))
(func (;2;) (type 4) (canon lift (core func 4)))
(func (;3;) (type 0) (canon lift (core func 5) (memory 0) (realloc 1) string-encoding=utf8))
(func (;2;) (type 2) (canon lift (core func 4)))
(func (;3;) (type 3) (canon lift (core func 5) (memory 0) (realloc 1) string-encoding=utf8))
(instance (;1;)
(export "a" (func 2))
(export "b" (func 3))
Expand Down