-
Notifications
You must be signed in to change notification settings - Fork 245
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
json-from-wast
: differences to wabt's wast2json
#1471
Comments
Hello and thanks for the report! Yeah I noticed these differences as well when writing it, and while they could be fixed it felt a bit odd given the implementation in this repository to go out of our way to represent that. Are these differences causing issues for consumption? If you'd like I think it'd be reasonable to change the output in most of the cases here. I had my own reasons for not matching wabt exactly in some of these cases (mostly that it required "going out of the way" to exactly match as opposed to do what this repository does natively), but other cases (like the filename bits) I just didn't realized. I think it'd be totally fine to have a PR to update things, if you're willing.
That could be added, we've in theory got all the tooling to support this. It would be a pretty big lift though because we'd have to (a) maintain a mapping of named modules to know which module is being referred to with |
Ok, I see. How about adding a flag to switch between the current
Yes, I know this is not trivial. I already have some code to manage these mappings, at least for the core commands (the |
Heh I actually originally implemented a flag, but I decided against it since I don't think there's much benefit in having two modes. If you're interseted to change the output to match wabt exactly I think it'd be reasonable to just change the output and avoid a flag for it. Out of curiosity, what's the use case for |
I just saw the new
json-from-wast
command. It is great to see awast2json
-like tool as part ofwasm-tools
, especially since it supports many more proposed features thanwabt
.However, I've noticed that
json-from-wast
outputs slightly different JSON thanwabt
. In particular:wabt
writes the module names in their$
-prefixed form, whilejson-from-wast
drops the$
from the module names.wabt
writes all numeric values in their unsigned representation (even if the corresponding type itself is signed likei32
andi64
), whilejson-from-wast
writes negative numbers as they are, with a minus sign.Another difference is how the filenames for the associated modules are derived:
wabt
derives these names from the given output filename. IMHO, this has the advantage that both the JSON file and the associated module files share the same base name.As noted in the commit,
json-from-wast
also doesn't write theexpected
return types for commands likeassert_trap
. Are there any plans to add this feature in the future?I also experimented with my own
wast2json
implementation in the past. My approach was to parse and analyze the associated modules after encoding and store their exported function and global types so that they could be queried when needed.The text was updated successfully, but these errors were encountered: