From 324962ecf1dd63eebfc94993df0d7e91c86a96f0 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Thu, 25 Feb 2016 10:33:39 -0800 Subject: support function indexes in tables --- src/wasm-s-parser.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h index 30a9e683f..d0206bcc2 100644 --- a/src/wasm-s-parser.h +++ b/src/wasm-s-parser.h @@ -222,6 +222,7 @@ class SExpressionWasmBuilder { AllocatingModule& wasm; MixedArena& allocator; std::function onError; + std::vector functionNames; int functionCounter; int importCounter; std::map functionTypes; // we need to know function return types before we parse their contents @@ -258,6 +259,7 @@ private: // unnamed, use an index name = Name::fromInt(functionCounter); } + functionNames.push_back(name); functionCounter++; for (;i < s.size(); i++) { Element& curr = *s[i]; @@ -1036,7 +1038,12 @@ private: void parseTable(Element& s) { for (size_t i = 1; i < s.size(); i++) { - wasm.table.names.push_back(s[i]->str()); + Name name = s[i]->str(); + if (!s[i]->dollared()) { + // index, we haven't + name = functionNames[atoi(name.str)]; + } + wasm.table.names.push_back(name); } } -- cgit v1.2.3