Implement custom section reading/writing#2284
Conversation
|
I used the backtracking method for reading the special custom sections handled by |
|
I had to update one of the test inputs to conform with the syntax of the Let me know if I missed something in this PR! |
|
This is looking really nice! Could you please add some roundtrip tests (including for custom sections that use a "place")? I'd also love to see a binary test that shows a custom "name" section for binary names that can't be represented as IDs in the text format, a la WebAssembly/spec#617 It's sort of unfortunate that the annotations proposal itself is never going to supply us with tests for |
I'll get working on this! I might have to change a few things, because
Sounds good! |
|
|
||
| bool WastParser::ParseBindVarOpt(std::string* name) { | ||
| WABT_TRACE(ParseBindVarOpt); | ||
| if (PeekIsAnnotation("name")) { |
There was a problem hiding this comment.
Is it okay that this is in ParseBindVarOpt? I'm not sure if the @name annotation is valid in every place that it's used.
I don't think this is required -- I just meant something like the other roundtrip tests, where it tracks the expected output (so we can tell if it changes in a future commit). |
|
I wrote a roundtrip test for custom sections. I also roundtripped the |
|
Hi, I'm sorry to go back and forth on this. When I commented earlier I had stupidly forgotten that representing a custom "name" section requires a different kind of annotation ( In general I think it's looking good and I'll be excited to have this merged. |
|
No problem; I reverted those commits. I'll open a PR for the |
Stricten the detection of a @Custom annotation, and preview double-writes.
1c73250 to
ebc7329
Compare
|
Okay, merging -- thank you for contributing this! I'm already enjoying seeing the custom sections from LLVM-produced modules in the wasm2wat output. |
Draft PR for #1376.
Not fully finished yet, still needs a few things:
BinaryReaderhas callbacks for:I'm not super familiar with all the quirks/idioms of C++, and so I generally followed along with the rest of the codebase. That being said, I could've overlooked some important nuances in this initial draft.
Continuing my conversation with @keithw, I'm still not sure about the best way to handle the custom sections
BinaryReaderhas callbacks for. Implementation wise, the backtracking method would be much easier. I go more in-depth on the topic in the second section of this comment.