Skip to content

Implement a composition graph library.#63

Merged
peterhuene merged 12 commits intomainfrom
api
Apr 5, 2024
Merged

Implement a composition graph library.#63
peterhuene merged 12 commits intomainfrom
api

Conversation

@peterhuene
Copy link
Copy Markdown
Member

@peterhuene peterhuene commented Apr 2, 2024

This PR implements a composition graph library that will serve as the basis for how WAC does AST resolution in the near future.

The inspiration comes from the existing CompositionGraph API in wasm-compose, except this API is more flexible, allowing a composition graph to define its own types, have explicit imports and aliases, and export any node in the graph.

The type representation present in wac-parser has been extracted to its own crate, wac-types. It will be shared in the future between the parser and the graph library.

As a result, a chunk of this new code is just copied out of wac-parser. Once the graph library is merged, a follow-up commit will eliminate the duplicated code and change wac-parser to resolve ASTs to a CompositionGraph.

@peterhuene peterhuene requested a review from fibonacci1729 April 2, 2024 21:44
@peterhuene
Copy link
Copy Markdown
Member Author

Note that the new crates/wac-types/src/component.rs, crates/wac-types/src/core.rs, and crates/wac-types/src/package.rs files are mostly a direct copy of what's in the wac-parser crate.

Once this merges, I plan on updating wac-parser and eliminating a huge chunk of the duplicated code.

I'll be pushing up more test cases shortly.

This commit implements a composition graph library that will serve as the basis
for how WAC does AST resolution in the near future.

The inspiration comes from the existing `CompositionGraph` API in
`wasm-compose`, except this API is more flexible, allowing a composition graph
to define its own types, have explicit exports, and export any node in the
graph.

The type representation present in `wac-parser` has been extracted to its own
crate, `wac-types`. It will be shared in the future between the parser and the
graph library.

As a result, a chunk of this new code is just copied out of `wac-parser`. Once
the graph library is merged, a follow-up commit will eliminate the duplicated
code and change `wac-parser` to resolve ASTs to a `CompositionGraph`.
This includes a rename of `float32` to `f32` and `float64` to `f64`.
The parser should depend on the graph, not the resolver crate.
Copy link
Copy Markdown
Collaborator

@rylev rylev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome! I've already given the API a try here, and overall, while it's not the absolute easiest API to use, I think it's a good basis to build on top of.

Most of my feedback was on naming and error messages.

Comment thread crates/wac-graph/src/encoding.rs
Comment thread crates/wac-graph/src/encoding.rs Outdated
Comment thread crates/wac-graph/src/encoding.rs Outdated
Comment thread crates/wac-graph/src/encoding.rs Outdated
Comment thread crates/wac-graph/src/encoding.rs
Comment thread crates/wac-graph/src/graph.rs Outdated
Comment thread crates/wac-graph/src/graph.rs Outdated
Comment thread crates/wac-graph/src/graph.rs Outdated
Comment thread crates/wac-graph/src/graph.rs
Comment thread crates/wac-graph/src/graph.rs Outdated
peterhuene and others added 4 commits April 3, 2024 23:04
@peterhuene peterhuene requested a review from rylev April 4, 2024 16:56
@peterhuene peterhuene linked an issue Apr 4, 2024 that may be closed by this pull request
@peterhuene peterhuene merged commit 2705320 into main Apr 5, 2024
@peterhuene peterhuene deleted the api branch April 5, 2024 16:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement a programmatic API for defining compositions

3 participants