diff options
author | Alon Zakai <azakai@google.com> | 2020-11-13 17:46:40 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-13 17:46:40 -0800 |
commit | 5f45ce70c02f1f51aa3558d6933cb271da0c6479 (patch) | |
tree | 664e6a02fb0bcc5648282199ab2ca3c73580714c /src | |
parent | dd618f11660fc6f89211b864a3bd9dcbd14bb013 (diff) | |
download | binaryen-5f45ce70c02f1f51aa3558d6933cb271da0c6479.tar.gz binaryen-5f45ce70c02f1f51aa3558d6933cb271da0c6479.tar.bz2 binaryen-5f45ce70c02f1f51aa3558d6933cb271da0c6479.zip |
[s-parsing] Store full function signatures (#3356)
We will need this for typed function references support, as then we need
to know full function signatures for all functions when we reach a ref.func,
whose type is then that signature and not the generic funcref.
Diffstat (limited to 'src')
-rw-r--r-- | src/wasm-s-parser.h | 2 | ||||
-rw-r--r-- | src/wasm/wasm-s-parser.cpp | 8 |
2 files changed, 5 insertions, 5 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index ac1b6d0e5..085b58ba0 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -123,7 +123,7 @@ class SExpressionWasmBuilder { int tableCounter = 0; int memoryCounter = 0; // we need to know function return types before we parse their contents - std::map<Name, Type> functionTypes; + std::map<Name, Signature> functionSignatures; std::unordered_map<cashew::IString, Index> debugInfoFileIndices; public: diff --git a/src/wasm/wasm-s-parser.cpp b/src/wasm/wasm-s-parser.cpp index 34e1eb8a6..0636836d7 100644 --- a/src/wasm/wasm-s-parser.cpp +++ b/src/wasm/wasm-s-parser.cpp @@ -673,7 +673,7 @@ void SExpressionWasmBuilder::preParseFunctionType(Element& s) { functionCounter++; Signature sig; parseTypeUse(s, i, sig); - functionTypes[name] = sig.results; + functionSignatures[name] = sig; } size_t SExpressionWasmBuilder::parseFunctionNames(Element& s, @@ -765,7 +765,7 @@ void SExpressionWasmBuilder::parseFunction(Element& s, bool preParseImport) { im->module = importModule; im->base = importBase; im->sig = sig; - functionTypes[name] = sig.results; + functionSignatures[name] = sig; if (wasm.getFunctionOrNull(im->name)) { throw ParseException("duplicate import", s.line, s.col); } @@ -1773,7 +1773,7 @@ Expression* SExpressionWasmBuilder::makeCall(Element& s, bool isReturn) { auto target = getFunctionName(*s[1]); auto ret = allocator.alloc<Call>(); ret->target = target; - ret->type = functionTypes[ret->target]; + ret->type = functionSignatures[ret->target].results; parseCallOperands(s, 2, s.size(), ret); ret->isReturn = isReturn; ret->finalize(); @@ -2444,7 +2444,7 @@ void SExpressionWasmBuilder::parseImport(Element& s) { func->setName(name, hasExplicitName); func->module = module; func->base = base; - functionTypes[name] = func->sig.results; + functionSignatures[name] = func->sig; wasm.addFunction(func.release()); } else if (kind == ExternalKind::Global) { Type type; |