diff options
author | Alon Zakai <azakai@google.com> | 2021-02-23 22:46:13 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-23 22:46:13 +0000 |
commit | a7c66754ba86854ea3e0381986796e6565b93199 (patch) | |
tree | 940abdbce4bcf5a10eab090c6b67c37dbb5d2c3b /src/wasm.h | |
parent | c127eccf753ab86a4d5deecbd0f3fa78a83e42ad (diff) | |
download | binaryen-a7c66754ba86854ea3e0381986796e6565b93199.tar.gz binaryen-a7c66754ba86854ea3e0381986796e6565b93199.tar.bz2 binaryen-a7c66754ba86854ea3e0381986796e6565b93199.zip |
Properly use text format type names in printing (#3591)
This adds a TypeNames entry to modules, which can store names for types. So
far this PR uses that to store type names from text format. Future PRs will add
support for field names and for the binary format.
(Field names are added to wasm.h here to see if we agree on this direction.)
Most of the work here is threading a module through the various functions in
Print.cpp. This keeps the module optional, so that we can still print an
expression independently of a module, which has always been the case, and
which I think we should keep (but, if a module was mandatory perhaps this
would be a little simpler, and could be refactored into a form that depends on
that).
99% of this diff are test updates, since almost all our tests use the text
format, and many of them specify a type name but we used to ignore it.
This is a step towards a proper solution for #3589
Diffstat (limited to 'src/wasm.h')
-rw-r--r-- | src/wasm.h | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/wasm.h b/src/wasm.h index 199257925..4060bac4d 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -1872,6 +1872,16 @@ public: // Module name, if specified. Serves a documentary role only. Name name; + // Optional type name information, used in printing only. Note that Types are + // globally interned, but type names are specific to a module. + struct TypeNames { + // The name of the type. + Name name; + // For a Struct, names of fields. + std::unordered_map<Index, Name> fieldNames; + }; + std::unordered_map<HeapType, TypeNames> typeNames; + MixedArena allocator; private: |