wasm-encoder: Return Indices from builder functions where applicable#876
wasm-encoder: Return Indices from builder functions where applicable#876esoterra wants to merge 7 commits intobytecodealliance:mainfrom
Conversation
|
That makes sense, I've reverted all the component model indexing logic for now and we can revisit it at a future point. From the spec:
Reviewing the index spaces, only a few make sense to include:
So, I'm going to further pare this down to types, elements, and data. |
|
@alexcrichton is, as usual, correct! We'd have to move to a pattern similar to the nested encoders in component type encoding where the module being encoded hands out new section encoders so that the index spaces are tracked across all sections being encoded in the module. That'd be a pretty big breaking change, although it sure would be nice if component encoding tools didn't have to manually track the index spaces as component index spaces are a bit more complicated than index spaces in a module. Stepping back for a second, I do wonder if it's worth taking the pared-down change when the index of the added item can be retrieved from the section with the |
|
I personally think it's ok to remove the For consistency though it might make the most sense to have |
This refactor changes the returns of builder methods which create indexed entries (e.g. types) so that they return the index of the newly created entry. This means users don't need to otherwise calculate the value or know what it will be.
For example, the README no longer needs the line
let type_index = 0;since it can be obtained whentypes.function(...)is called.