Add newtypes for indices
There are different index spaces, and it would be awesome to have newtypes for each kind of index, to help folks write more correct code.
Would have been awesome if creating bugs like https://github.com/fitzgen/svelte/issues/24 weren't possible (unless you incorrectly construct an invalid index).
Ideally also have (fallible?) conversions from global indices into function indices, etc.
Yeah, that's sounds cool, here are some problems I encountered when thought about it
- Sections publish
Vecin it's API to allow the user to manipulate the entries. Users still have to use the raw indices to manipulate vec. - There is no way for users to get function by
funcidxin parity-wasm. However, it's used everywhere to index entities.
These are solvable, for (1) we can publish some generaly useful subset of vector operations that would be indexable with newtypes and for (2) we can either provide some utilities which will return FuncOrImport if given functions (and/or code) and imports sections or leave it up to the user.
But my personal opinion is that wasm code manipulation analysis requires more high-level API than that provided by parity-wasm.