summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-s-parser.cpp
diff options
context:
space:
mode:
authorThomas Lively <7121787+tlively@users.noreply.github.com>2020-12-07 19:32:48 -0800
committerGitHub <noreply@github.com>2020-12-07 19:32:48 -0800
commit2a0059dec2fe01dcf1358e0120c32aadd2d765b6 (patch)
tree639e392e995c92140a242818663437f00fd2948a /src/wasm/wasm-s-parser.cpp
parenta84898c11df3d93fb69365fb274a9bb06d60ed47 (diff)
downloadbinaryen-2a0059dec2fe01dcf1358e0120c32aadd2d765b6.tar.gz
binaryen-2a0059dec2fe01dcf1358e0120c32aadd2d765b6.tar.bz2
binaryen-2a0059dec2fe01dcf1358e0120c32aadd2d765b6.zip
Intern HeapTypes and clean up types code (#3428)
Interns HeapTypes using the same patterns and utilities already used to intern Types. This allows HeapTypes to efficiently be compared for equality and hashed, which may be important for very large struct types in the future. This change also has the benefit of increasing symmetry between the APIs of Type and HeapType, which will make the developer experience more consistent. Finally, this change will make TypeBuilder (#3418) much simpler because it will no longer have to introduce TypeInfo variants to refer to HeapTypes indirectly.
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r--src/wasm/wasm-s-parser.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index 37592fcd5..21104d0fe 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -879,32 +879,32 @@ HeapType SExpressionWasmBuilder::stringToHeapType(const char* str,
bool prefix) {
if (str[0] == 'a') {
if (str[1] == 'n' && str[2] == 'y' && (prefix || str[3] == 0)) {
- return HeapType::AnyKind;
+ return HeapType::any;
}
}
if (str[0] == 'e') {
if (str[1] == 'q' && (prefix || str[2] == 0)) {
- return HeapType::EqKind;
+ return HeapType::eq;
}
if (str[1] == 'x') {
if (str[2] == 'n' && (prefix || str[3] == 0)) {
- return HeapType::ExnKind;
+ return HeapType::exn;
}
if (str[2] == 't' && str[3] == 'e' && str[4] == 'r' && str[5] == 'n' &&
(prefix || str[6] == 0)) {
- return HeapType::ExternKind;
+ return HeapType::ext;
}
}
}
if (str[0] == 'i') {
if (str[1] == '3' && str[2] == '1' && (prefix || str[3] == 0)) {
- return HeapType::I31Kind;
+ return HeapType::i31;
}
}
if (str[0] == 'f') {
if (str[1] == 'u' && str[2] == 'n' && str[3] == 'c' &&
(prefix || str[4] == 0)) {
- return HeapType::FuncKind;
+ return HeapType::func;
}
}
throw ParseException(std::string("invalid wasm heap type: ") + str);