-
Notifications
You must be signed in to change notification settings - Fork 725
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
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! |
src/wast-parser.cc
Outdated
@@ -762,6 +762,13 @@ Result WastParser::ErrorIfLpar(const std::vector<std::string>& expected, | |||
|
|||
bool WastParser::ParseBindVarOpt(std::string* name) { | |||
WABT_TRACE(ParseBindVarOpt); | |||
if (PeekIsAnnotation("name")) { |
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.
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 |
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.
lgtm % comments
@sbc100 do you want to weigh in?
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:
BinaryReader
has 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
BinaryReader
has 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.