Add BinaryenModuleWriteSExpr to write a module to a string in s-expr format#2106
Add BinaryenModuleWriteSExpr to write a module to a string in s-expr format#2106kripken merged 6 commits intoWebAssembly:masterfrom tweag:may-15-binaryen-module-write-sexpr
Conversation
…format. Closes Issue #2103
|
Squashed commits and pushed all changes in one commit. |
|
how do I stop the |
|
OK, I found |
|
I need this kind of API because the interface that I want is to print compiler logs to I can disable colors, but this will disable it forevermore, which is weird as well. |
|
I sent a PR to expose this color API through the raw C bindings: #2111 (edited to insert link) |
|
Sadly the test runner doesn't have an option to run just one test currently. The suite is short enough that it's often not that bad, but sometimes it can be annoying, yeah. I sometimes temporarily edit the python file to run just the relevant parts I'm working on. We should improve this. |
| std::stringstream ss; | ||
| WasmPrinter::printModule((Module*)module, ss); | ||
|
|
||
| const std::string temp = ss.str(); |
There was a problem hiding this comment.
can use const auto here and below.
There was a problem hiding this comment.
Why auto? it's a simple type, and someone new to C++ many not know the type of .str(). I don't see a benefit of using auto. I'm trying to understand the rationale here --- if this is the project style, then by all means, I'll change the code, but I see no advantage.
There was a problem hiding this comment.
It is clear enough by convention that .str() returns a string, so it is worth saving on the visual complexity of this line.
There was a problem hiding this comment.
OK. changed to const auto.
| WasmPrinter::printModule((Module*)module, ss); | ||
|
|
||
| std::string out = ss.str(); | ||
| const int l = out.length() + 1; |
| BinaryenModulePrint(module); | ||
|
|
||
| // write the s-expr representation of the module. | ||
| BinaryenModuleWriteSExpr(module, buffer, 1024); |
There was a problem hiding this comment.
please test the other new API call as well
- Import changes from binaryen PR#2106:
WebAssembly/binaryen#2106
- Add bindings to `Raw.hs` for the new APIs
- Use new APIs to print s-expressions to a debug file.
|
Done, all changes have been made and test cases pass :) |
|
Great, thanks! |
Add support for printing s-expressions
This is useful for debugging.
This patch also fixes some stray links which reflects the migration of TerrorJack/binaryen to tweag/binaryen.
- Import changes from binaryen PR#2106:
WebAssembly/binaryen#2106
- Add bindings to `Raw.hs` for the new APIs
- Use new APIs to print s-expressions to a debug file.
Closes Issue #2103.
I'd like some helping with adding and running the test case:
both try to run the entire test suite. I'd be glad if someone could help me understand how to run a single test case.