summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-s-parser.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2021-01-23 04:27:20 +0900
committerGitHub <noreply@github.com>2021-01-23 04:27:20 +0900
commit27a5a7101d20ce5fc51648e775587ab3d640114e (patch)
treebd8427f8b01a998d708847be0cfd08052b57a9ee /src/wasm/wasm-s-parser.cpp
parent69952a98c7c86286518d559958e35cd3639bd3a0 (diff)
downloadbinaryen-27a5a7101d20ce5fc51648e775587ab3d640114e.tar.gz
binaryen-27a5a7101d20ce5fc51648e775587ab3d640114e.tar.bz2
binaryen-27a5a7101d20ce5fc51648e775587ab3d640114e.zip
Reorder i31ref and dataref (#3509)
The binary spec (https://docs.google.com/document/d/1yAWU3dbs8kUa_wcnnirDxUu9nEBsNfq0Xo90OWx6yuo/edit#) lists `dataref` after `i31ref`, and `dataref` also comes after `i31ref` in its binary code in the value-increasing order. This reorders these two in wasm-type.h and other places, although in most of those places the order is irrelevant. This also adds C and JS API for `dataref`.
Diffstat (limited to 'src/wasm/wasm-s-parser.cpp')
-rw-r--r--src/wasm/wasm-s-parser.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp
index d34698131..857c0143b 100644
--- a/src/wasm/wasm-s-parser.cpp
+++ b/src/wasm/wasm-s-parser.cpp
@@ -864,14 +864,14 @@ Type SExpressionWasmBuilder::stringToType(const char* str,
if (strncmp(str, "eqref", 5) == 0 && (prefix || str[5] == 0)) {
return Type::eqref;
}
- if (strncmp(str, "dataref", 7) == 0 && (prefix || str[7] == 0)) {
- // FIXME: for now, force all inputs to be nullable
- return Type(HeapType::BasicHeapType::data, Nullable);
- }
if (strncmp(str, "i31ref", 6) == 0 && (prefix || str[6] == 0)) {
// FIXME: for now, force all inputs to be nullable
return Type(HeapType::BasicHeapType::i31, Nullable);
}
+ if (strncmp(str, "dataref", 7) == 0 && (prefix || str[7] == 0)) {
+ // FIXME: for now, force all inputs to be nullable
+ return Type(HeapType::BasicHeapType::data, Nullable);
+ }
if (allowError) {
return Type::none;
}
@@ -880,9 +880,10 @@ Type SExpressionWasmBuilder::stringToType(const char* str,
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::any;
+ if (str[0] == 'f') {
+ if (str[1] == 'u' && str[2] == 'n' && str[3] == 'c' &&
+ (prefix || str[4] == 0)) {
+ return HeapType::func;
}
}
if (str[0] == 'e') {
@@ -894,17 +895,16 @@ HeapType SExpressionWasmBuilder::stringToHeapType(const char* str,
return HeapType::ext;
}
}
+ if (str[0] == 'a') {
+ if (str[1] == 'n' && str[2] == 'y' && (prefix || str[3] == 0)) {
+ return HeapType::any;
+ }
+ }
if (str[0] == 'i') {
if (str[1] == '3' && str[2] == '1' && (prefix || str[3] == 0)) {
return HeapType::i31;
}
}
- if (str[0] == 'f') {
- if (str[1] == 'u' && str[2] == 'n' && str[3] == 'c' &&
- (prefix || str[4] == 0)) {
- return HeapType::func;
- }
- }
if (str[0] == 'd') {
if (str[1] == 'a' && str[2] == 't' && str[3] == 'a' &&
(prefix || str[4] == 0)) {