Merged
Conversation
This giant commit implements encoding of resolved WAC documents, effectively enabling component composition. Changes to the grammar: * resource methods no longer accept references to function types (WIT compat). Changes to the AST: * The AST printer moved into the `ast` module. * Fixed `or` not printing correctly for printing lookahead failures. * Fixed segment spans in a package path not being calculated correctly. * Types now store their span; used in new resolution diagnostics. Changes to resolution: * The majority of the resolution logic has been refactored out into an `ast` submodule. * A check was added to ensure function result types do not contain a borrow. * There is now a package arena so that instantiations (and implicit imports) can keep track of the originating package for better diagnostic messages. * The value type enum was refactored such that borrows and owns of resources don't need allocations in the types arena (unless aliased with `type foo = borrow<x>`). * The `Item` struct and `ItemSource` enum were merged into a single `Item` enum. * Support for aliasing resources was added (e.g. `type r2 = r;`). * The `Resource` type no longer stores a collection of related methods as this *greatly* complicated merging of implicit imports; now resource methods are exported/imported directly in the exports/imports of an interface/world. * Consequently, merging of implicitly imported instances is now correctly implemented. * Subtype checking relating to resources has been improved so that the `ResourceMap` is no longer required. * Scope rules now better align with WIT; an interface or world may no longer reference top-level types. * Decoding binary packages now properly resolves resources and "used" types in interface and world definitions. Implementation of encoding: * Encoding of WIT subset of the grammar should match that of the existing WIT tooling; may be round-tripped with `wasm-tools component wit`. * Encoding of imports, instantiations, and exports should enable the output of actual WebAssembly compositions. CLI changes: * The `parse` command has been split into three different commands: * The `parse` command that outputs a JSON formatted AST. * The `resolve` command that outputs a JSON formatted resolved document. * The `encode` command that outputs with text or binary WebAssembly.
Member
Author
|
@fibonacci1729 absolutely no rush on this review; hopefully this is the last huge refactoring review I'll have for a while (🤞). |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This giant PR implements encoding of resolved WAC documents, effectively enabling component composition.
Changes to the grammar:
Changes to the AST:
astmodule.ornot printing correctly for printing lookahead failures.Changes to resolution:
astsubmodule.type foo = borrow<x>).Itemstruct andItemSourceenum were merged into a singleItemenum.type r2 = r;).Resourcetype no longer stores a collection of related methods as this greatly complicated merging of implicit imports; now resource methods are exported/imported directly in the exports/imports of an interface/world.ResourceMapis no longer required.Implementation of encoding:
wasm-tools component wit.CLI changes:
The
parsecommand has been split into three different commands:parsecommand that outputs a JSON formatted AST.resolvecommand that outputs a JSON formatted resolved document.encodecommand that outputs with text or binary WebAssembly.