From 27a5a7101d20ce5fc51648e775587ab3d640114e Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Sat, 23 Jan 2021 04:27:20 +0900 Subject: 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`. --- src/wasm/wasm-s-parser.cpp | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) (limited to 'src/wasm/wasm-s-parser.cpp') 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)) { -- cgit v1.2.3