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

Preserve order during toposort in WIT #1078

Merged
merged 1 commit into from
Jun 20, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@
(type (;0;)
(instance
(type (;0;) u8)
(export (;1;) "t2" (type (eq 0)))
(export (;1;) "t1" (type (eq 0)))
)
)
(export (;0;) (interface "foo:foo/shared2") (instance (type 0)))
(export (;0;) (interface "foo:foo/shared1") (instance (type 0)))
(type (;1;)
(instance
(type (;0;) u8)
(export (;1;) "t1" (type (eq 0)))
(export (;1;) "t2" (type (eq 0)))
)
)
(export (;1;) (interface "foo:foo/shared1") (instance (type 1)))
(export (;1;) (interface "foo:foo/shared2") (instance (type 1)))
(type (;2;)
(component
(type (;0;)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package foo:foo

interface shared2 {
type t2 = u8
}

interface shared1 {
type t1 = u8
}

interface shared2 {
type t2 = u8
}

world w1 {
import shared1
import foo: interface {
Expand Down
22 changes: 11 additions & 11 deletions crates/wit-component/tests/interfaces/diamond.wat
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,17 @@
(export (;1;) "the-enum" (type (eq 0)))
)
)
(export (;1;) "bar" (instance (type 2)))
(import "foo" (instance (;1;) (type 2)))
(type (;3;)
(instance
(alias outer 1 1 (type (;0;)))
(export (;1;) "the-enum" (type (eq 0)))
)
)
(import "bar" (instance (;2;) (type 3)))
)
)
(export (;0;) (interface "foo:foo/w3") (component (type 1)))
(export (;0;) (interface "foo:foo/w1") (component (type 1)))
(type (;2;)
(component
(type (;0;)
Expand Down Expand Up @@ -71,17 +78,10 @@
(export (;1;) "the-enum" (type (eq 0)))
)
)
(import "foo" (instance (;1;) (type 2)))
(type (;3;)
(instance
(alias outer 1 1 (type (;0;)))
(export (;1;) "the-enum" (type (eq 0)))
)
)
(import "bar" (instance (;2;) (type 3)))
(export (;1;) "bar" (instance (type 2)))
)
)
(export (;2;) (interface "foo:foo/w1") (component (type 3)))
(export (;2;) (interface "foo:foo/w3") (component (type 3)))
)
)
(@producers
Expand Down
16 changes: 8 additions & 8 deletions crates/wit-component/tests/interfaces/diamond.wit.print
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,12 @@ interface shared-items {
}
}

world w3 {
world w1 {
import shared-items

export bar: interface {
import foo: interface {
use shared-items.{the-enum}
}
import bar: interface {
use shared-items.{the-enum}
}
}
Expand All @@ -23,12 +25,10 @@ world w2 {
use shared-items.{the-enum}
}
}
world w1 {
world w3 {
import shared-items
import foo: interface {
use shared-items.{the-enum}
}
import bar: interface {

export bar: interface {
use shared-items.{the-enum}
}
}
72 changes: 36 additions & 36 deletions crates/wit-component/tests/interfaces/flags.wat
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,33 @@
(component
(type (;0;)
(instance
(type (;0;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7"))
(export (;1;) "flag8" (type (eq 0)))
(type (;2;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7" "b8" "b9" "b10" "b11" "b12" "b13" "b14" "b15" "b16" "b17" "b18" "b19" "b20" "b21" "b22" "b23" "b24" "b25" "b26" "b27" "b28" "b29" "b30" "b31" "b32" "b33" "b34" "b35" "b36" "b37" "b38" "b39" "b40" "b41" "b42" "b43" "b44" "b45" "b46" "b47" "b48" "b49" "b50" "b51" "b52" "b53" "b54" "b55" "b56" "b57" "b58" "b59" "b60" "b61" "b62" "b63"))
(export (;3;) "flag64" (type (eq 2)))
(type (;0;) (flags "b0"))
(export (;1;) "flag1" (type (eq 0)))
(type (;2;) (flags "b0" "b1"))
(export (;3;) "flag2" (type (eq 2)))
(type (;4;) (flags "b0" "b1" "b2" "b3"))
(export (;5;) "flag4" (type (eq 4)))
(type (;6;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7" "b8" "b9" "b10" "b11" "b12" "b13" "b14" "b15" "b16" "b17" "b18" "b19" "b20" "b21" "b22" "b23" "b24" "b25" "b26" "b27" "b28" "b29" "b30" "b31"))
(export (;7;) "flag32" (type (eq 6)))
(type (;8;) (flags "b0" "b1"))
(export (;9;) "flag2" (type (eq 8)))
(type (;10;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7" "b8" "b9" "b10" "b11" "b12" "b13" "b14" "b15"))
(export (;11;) "flag16" (type (eq 10)))
(type (;12;) (flags "b0"))
(export (;13;) "flag1" (type (eq 12)))
(type (;14;) (func (param "x" 13) (result 13)))
(type (;6;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7"))
(export (;7;) "flag8" (type (eq 6)))
(type (;8;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7" "b8" "b9" "b10" "b11" "b12" "b13" "b14" "b15"))
(export (;9;) "flag16" (type (eq 8)))
(type (;10;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7" "b8" "b9" "b10" "b11" "b12" "b13" "b14" "b15" "b16" "b17" "b18" "b19" "b20" "b21" "b22" "b23" "b24" "b25" "b26" "b27" "b28" "b29" "b30" "b31"))
(export (;11;) "flag32" (type (eq 10)))
(type (;12;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7" "b8" "b9" "b10" "b11" "b12" "b13" "b14" "b15" "b16" "b17" "b18" "b19" "b20" "b21" "b22" "b23" "b24" "b25" "b26" "b27" "b28" "b29" "b30" "b31" "b32" "b33" "b34" "b35" "b36" "b37" "b38" "b39" "b40" "b41" "b42" "b43" "b44" "b45" "b46" "b47" "b48" "b49" "b50" "b51" "b52" "b53" "b54" "b55" "b56" "b57" "b58" "b59" "b60" "b61" "b62" "b63"))
(export (;13;) "flag64" (type (eq 12)))
(type (;14;) (func (param "x" 1) (result 1)))
(export (;0;) "roundtrip-flag1" (func (type 14)))
(type (;15;) (func (param "x" 9) (result 9)))
(type (;15;) (func (param "x" 3) (result 3)))
(export (;1;) "roundtrip-flag2" (func (type 15)))
(type (;16;) (func (param "x" 5) (result 5)))
(export (;2;) "roundtrip-flag4" (func (type 16)))
(type (;17;) (func (param "x" 1) (result 1)))
(type (;17;) (func (param "x" 7) (result 7)))
(export (;3;) "roundtrip-flag8" (func (type 17)))
(type (;18;) (func (param "x" 11) (result 11)))
(type (;18;) (func (param "x" 9) (result 9)))
(export (;4;) "roundtrip-flag16" (func (type 18)))
(type (;19;) (func (param "x" 7) (result 7)))
(type (;19;) (func (param "x" 11) (result 11)))
(export (;5;) "roundtrip-flag32" (func (type 19)))
(type (;20;) (func (param "x" 3) (result 3)))
(type (;20;) (func (param "x" 13) (result 13)))
(export (;6;) "roundtrip-flag64" (func (type 20)))
)
)
Expand All @@ -38,33 +38,33 @@
(component
(type (;0;)
(instance
(type (;0;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7"))
(export (;1;) "flag8" (type (eq 0)))
(type (;2;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7" "b8" "b9" "b10" "b11" "b12" "b13" "b14" "b15" "b16" "b17" "b18" "b19" "b20" "b21" "b22" "b23" "b24" "b25" "b26" "b27" "b28" "b29" "b30" "b31" "b32" "b33" "b34" "b35" "b36" "b37" "b38" "b39" "b40" "b41" "b42" "b43" "b44" "b45" "b46" "b47" "b48" "b49" "b50" "b51" "b52" "b53" "b54" "b55" "b56" "b57" "b58" "b59" "b60" "b61" "b62" "b63"))
(export (;3;) "flag64" (type (eq 2)))
(type (;0;) (flags "b0"))
(export (;1;) "flag1" (type (eq 0)))
(type (;2;) (flags "b0" "b1"))
(export (;3;) "flag2" (type (eq 2)))
(type (;4;) (flags "b0" "b1" "b2" "b3"))
(export (;5;) "flag4" (type (eq 4)))
(type (;6;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7" "b8" "b9" "b10" "b11" "b12" "b13" "b14" "b15" "b16" "b17" "b18" "b19" "b20" "b21" "b22" "b23" "b24" "b25" "b26" "b27" "b28" "b29" "b30" "b31"))
(export (;7;) "flag32" (type (eq 6)))
(type (;8;) (flags "b0" "b1"))
(export (;9;) "flag2" (type (eq 8)))
(type (;10;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7" "b8" "b9" "b10" "b11" "b12" "b13" "b14" "b15"))
(export (;11;) "flag16" (type (eq 10)))
(type (;12;) (flags "b0"))
(export (;13;) "flag1" (type (eq 12)))
(type (;14;) (func (param "x" 13) (result 13)))
(type (;6;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7"))
(export (;7;) "flag8" (type (eq 6)))
(type (;8;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7" "b8" "b9" "b10" "b11" "b12" "b13" "b14" "b15"))
(export (;9;) "flag16" (type (eq 8)))
(type (;10;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7" "b8" "b9" "b10" "b11" "b12" "b13" "b14" "b15" "b16" "b17" "b18" "b19" "b20" "b21" "b22" "b23" "b24" "b25" "b26" "b27" "b28" "b29" "b30" "b31"))
(export (;11;) "flag32" (type (eq 10)))
(type (;12;) (flags "b0" "b1" "b2" "b3" "b4" "b5" "b6" "b7" "b8" "b9" "b10" "b11" "b12" "b13" "b14" "b15" "b16" "b17" "b18" "b19" "b20" "b21" "b22" "b23" "b24" "b25" "b26" "b27" "b28" "b29" "b30" "b31" "b32" "b33" "b34" "b35" "b36" "b37" "b38" "b39" "b40" "b41" "b42" "b43" "b44" "b45" "b46" "b47" "b48" "b49" "b50" "b51" "b52" "b53" "b54" "b55" "b56" "b57" "b58" "b59" "b60" "b61" "b62" "b63"))
(export (;13;) "flag64" (type (eq 12)))
(type (;14;) (func (param "x" 1) (result 1)))
(export (;0;) "roundtrip-flag1" (func (type 14)))
(type (;15;) (func (param "x" 9) (result 9)))
(type (;15;) (func (param "x" 3) (result 3)))
(export (;1;) "roundtrip-flag2" (func (type 15)))
(type (;16;) (func (param "x" 5) (result 5)))
(export (;2;) "roundtrip-flag4" (func (type 16)))
(type (;17;) (func (param "x" 1) (result 1)))
(type (;17;) (func (param "x" 7) (result 7)))
(export (;3;) "roundtrip-flag8" (func (type 17)))
(type (;18;) (func (param "x" 11) (result 11)))
(type (;18;) (func (param "x" 9) (result 9)))
(export (;4;) "roundtrip-flag16" (func (type 18)))
(type (;19;) (func (param "x" 7) (result 7)))
(type (;19;) (func (param "x" 11) (result 11)))
(export (;5;) "roundtrip-flag32" (func (type 19)))
(type (;20;) (func (param "x" 3) (result 3)))
(type (;20;) (func (param "x" 13) (result 13)))
(export (;6;) "roundtrip-flag64" (func (type 20)))
)
)
Expand Down
132 changes: 66 additions & 66 deletions crates/wit-component/tests/interfaces/flags.wit.print
Original file line number Diff line number Diff line change
@@ -1,6 +1,22 @@
package foo:%flags

interface imports {
flags flag1 {
b0,
}

flags flag2 {
b0,
b1,
}

flags flag4 {
b0,
b1,
b2,
b3,
}

flags flag8 {
b0,
b1,
Expand All @@ -12,7 +28,7 @@ interface imports {
b7,
}

flags flag64 {
flags flag16 {
b0,
b1,
b2,
Expand All @@ -29,61 +45,6 @@ interface imports {
b13,
b14,
b15,
b16,
b17,
b18,
b19,
b20,
b21,
b22,
b23,
b24,
b25,
b26,
b27,
b28,
b29,
b30,
b31,
b32,
b33,
b34,
b35,
b36,
b37,
b38,
b39,
b40,
b41,
b42,
b43,
b44,
b45,
b46,
b47,
b48,
b49,
b50,
b51,
b52,
b53,
b54,
b55,
b56,
b57,
b58,
b59,
b60,
b61,
b62,
b63,
}

flags flag4 {
b0,
b1,
b2,
b3,
}

flags flag32 {
Expand Down Expand Up @@ -121,12 +82,7 @@ interface imports {
b31,
}

flags flag2 {
b0,
b1,
}

flags flag16 {
flags flag64 {
b0,
b1,
b2,
Expand All @@ -143,10 +99,54 @@ interface imports {
b13,
b14,
b15,
}

flags flag1 {
b0,
b16,
b17,
b18,
b19,
b20,
b21,
b22,
b23,
b24,
b25,
b26,
b27,
b28,
b29,
b30,
b31,
b32,
b33,
b34,
b35,
b36,
b37,
b38,
b39,
b40,
b41,
b42,
b43,
b44,
b45,
b46,
b47,
b48,
b49,
b50,
b51,
b52,
b53,
b54,
b55,
b56,
b57,
b58,
b59,
b60,
b61,
b62,
b63,
}

roundtrip-flag1: func(x: flag1) -> flag1
Expand Down
Loading