Commit e5132af
authored
Extract "world elaboration" to a separate function (#1800)
* Extract "world elaboration" to a separate function
This commit extracts the process of elaborating a worlds imports/exports
to a dedicated function. This function ensures the transitive closure of
all imports/exports are listed in the world in proper topograhical
order. This additionally validates that the world has a coherent
definition given WIT today, notably that imports don't accidentally try
to use exported types.
This functionality was all present previously during the process of
taking a WIT document and creating `Resolve`. This moves the logic
around and refactors it slightly given its new surroundings. This
reorders a few imports/exports in worlds from what was previously
present but the underlying meaning of worlds should be the same.
The goal of this commit is to enable `Resolve`-mutating transformations
to not need to preserve all these invariants each time a world is
modified. Instead a world can be modified and then this function can be
called to "clean up" the world afterwards.
* Simplify the `Resolve::importize` operation
This commit updates the `importize` operation to be a much simpler "just
move the exports to the imports" operation where care is only taken to
preserve imported types and to additionally error on overlap of imported
types and exported functions/interfaces. The previous `elaborate_world`
method helps make this method much simpler than before.1 parent 5a83828 commit e5132af
19 files changed
Lines changed: 397 additions & 455 deletions
File tree
- crates
- wit-component/tests/interfaces
- wit-parser
- src
- tests/ui
- parse-fail
- tests/cli
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
108 | | - | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | 103 | | |
118 | 104 | | |
119 | 105 | | |
| |||
131 | 117 | | |
132 | 118 | | |
133 | 119 | | |
134 | | - | |
135 | | - | |
136 | | - | |
137 | | - | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
138 | 124 | | |
139 | | - | |
| 125 | + | |
140 | 126 | | |
141 | | - | |
| 127 | + | |
142 | 128 | | |
143 | 129 | | |
144 | 130 | | |
| |||
148 | 134 | | |
149 | 135 | | |
150 | 136 | | |
151 | | - | |
152 | | - | |
153 | | - | |
154 | | - | |
155 | | - | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
159 | | - | |
| 159 | + | |
160 | 160 | | |
161 | 161 | | |
162 | 162 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| 53 | + | |
| 54 | + | |
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
56 | 58 | | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
60 | | - | |
61 | | - | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
7 | 11 | | |
8 | 12 | | |
9 | | - | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
| 13 | + | |
| 14 | + | |
15 | 15 | | |
16 | 16 | | |
17 | 17 | | |
| |||
Lines changed: 2 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
5 | | - | |
6 | 4 | | |
7 | 5 | | |
| 6 | + | |
| 7 | + | |
8 | 8 | | |
9 | 9 | | |
10 | 10 | | |
| |||
0 commit comments