-
Notifications
You must be signed in to change notification settings - Fork 13
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
Reimplement wac-parser
on wac-graph
.
#82
Conversation
This commit is a complete reimplementation of `wac-parser`'s resolution to be based on `wac-graph`. It also contains an overhaul of the `wac-graph` API to facilitate its use from `wac-parser`: * Reimplements `CompositionGraph` on top of `petgraph::StableDiGraph`, which eliminates needing to keep track of nodes internally to `CompositionGraph`. * Packages now populate their type information into the graph's types collection rather than having their own collections. * Splits the `Error` enum into discrete error types for each graph operation; this allows the AST resolver to properly attach span information to errors. * Add type dependency edges for defined types, ensuring topological ordering. * Fix encoding of defined type aliases so that each encoded alias refers to the export index of the previously encoded type. * Added a debug formatter for `CompositionGraph` that outputs a DOT representation (used in resolution tests as well). * Graph encoding now includes an optional producers custom section. * Fixed toposort to be in ascending node index order for independent nodes. The subtype checker implementation was reverted to the previous implementation, where `invert` and `revert` are called at specific points to change the type of check being performed; the newer implementation did not give the correct "expected, found" error messages for AST resolution. `wac resolve` now outputs a DOT representation of the resolved composition graph instead of JSON. Most of the deleted code comes from code that has already moved into `wac-types` and `wac-graph`. Closes bytecodealliance#79. Fixes bytecodealliance#78. Fixes bytecodealliance#76.
When this and a fix for #81 lands, I plan on adding a publish script to CI and creating a |
fcf76f4
to
0970c6d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm seeing a stack overflow when running this against my own project. It seems that for some reason, a particular interface that we're merging into the types collection has an export (a resource) that depends on the interface itself - specifically the resource alias owner is the interface being merged. This causes an infinite loop since we've not yet registered this interface as being remapped.
Co-authored-by: Ryan Levick <[email protected]>
Co-authored-by: Ryan Levick <[email protected]>
Co-authored-by: Ryan Levick <[email protected]>
Co-authored-by: Ryan Levick <[email protected]>
Co-authored-by: Ryan Levick <[email protected]>
Co-authored-by: Ryan Levick <[email protected]>
Co-authored-by: Ryan Levick <[email protected]>
Co-authored-by: Ryan Levick <[email protected]>
This commit fixes an existing bug exposed by the refactoring (likely due to the changes in the order in which nodes are processed for implicit arguments). Previously, an interface might contain a type alias for another resource it owns; this lead to the alias information of the resource being self-referential for the interface containing the aliased resource. It would then lead to infinite recursion in an attempt to remap such an interface when populating implicit instantiation arguments. The fix is to clear the self-referencing information while converting an interface during package parsing.
Co-authored-by: Ryan Levick <[email protected]>
The `NodeInfo` struct should have been removed with the changes in bytecodealliance#82 as it is no longer needed.
This PR is a complete reimplementation of
wac-parser
's resolution to be based onwac-graph
.It also contains an overhaul of the
wac-graph
API to facilitate its use fromwac-parser
:CompositionGraph
on top ofpetgraph::StableDiGraph
, which eliminates needing to keep track of nodes internally toCompositionGraph
.Error
enum into discrete error types for each graph operation; this allows the AST resolver to properly attach span information to errors.CompositionGraph
that outputs a DOT representation (used in resolution tests as well).The subtype checker implementation was reverted to the previous implementation, where
invert
andrevert
are called at specific points to change the type of check being performed; the newer implementation did not give the correct "expected, found" error messages for AST resolution.wac resolve
now outputs a DOT representation of the resolved composition graph instead of JSON.A names custom section is now included in the output of an encoded WAC document.
Most of the deleted code comes from code that has already moved into
wac-types
andwac-graph
.Closes #79.
Fixes #78.
Fixes #76.
Closes #37.