Add wasm2wat function and CLI - #305
Conversation
| import WasmTypes | ||
|
|
||
| /// Collected information from all sections of a WebAssembly binary module. | ||
| struct ModuleInfo { |
There was a problem hiding this comment.
@kateinoigakukun do you have a strong opinion whether introducing this new internal struct is fine, or should we collect into the existing public struct Wat that uses NameMapping?
There was a problem hiding this comment.
Reviewing it more, I see that Wat has let parser: Parser text parser, which doesn't make sense to have when converting in an opposite direction: from binary to text. I don't think we can reuse Wat here.
There was a problem hiding this comment.
Do we need to collect all information here before emitting text? Can we streamingly emit text without collecting them?
There was a problem hiding this comment.
The main problem is that name section is the last section, but we need that to arrive before we can emit any named declarations (which is all if not most of them?). Do you think it still makes sense to consider streaming here?
There was a problem hiding this comment.
Hmm, good point. How about skimming all sections first without parsing contents, then parse dependent sections that we need to emit the rest of sections, then streamingly parse/emit the rest of sections?
My main concern for collecting everything as Swift data structure is that we need to model every Wasm entity in Swift even though we rarely manipulate them.
930b432 to
13e1f64
Compare
e9f27b5 to
4007331
Compare
4c4599e to
2f3c1a2
Compare
412c21f to
23de740
Compare
5975f10 to
0ba91d3
Compare
499aed9 to
f2e1399
Compare
Co-authored-by: Max Desiatov <m_desiatov@apple.com>
# Conflicts: # Sources/WasmParser/Stream/FileHandleStream.swift # Sources/WasmParser/WasmParser.swift
Counterpart to the existing
wat2wasmfunction.