summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-03-15 18:40:52 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-03-15 18:40:52 -0700
commit493998e54d63be8d7efcdd857334ee621295dd9d (patch)
treecd74245e18170da8e4ed34b45fe6b6b291ab0d42 /src
parent2f128693cd5b029aaa59d7cc51fe67f2fcbb529c (diff)
downloadbinaryen-493998e54d63be8d7efcdd857334ee621295dd9d.tar.gz
binaryen-493998e54d63be8d7efcdd857334ee621295dd9d.tar.bz2
binaryen-493998e54d63be8d7efcdd857334ee621295dd9d.zip
parse start properly when it is an offset
Diffstat (limited to 'src')
-rw-r--r--src/wasm-s-parser.h15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index feb09f333..2938c4d15 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -308,7 +308,20 @@ private:
return IString((prefix + std::to_string(otherIndex++)).c_str(), false);
}
- void parseStart(Element& s) { wasm.addStart(s[1]->str()); }
+ Name getFunctionName(Element& s) {
+ if (s.dollared()) {
+ return s.str();
+ } else {
+ // index
+ size_t offset = atoi(s.str().c_str());
+ if (offset >= functionNames.size()) onError();
+ return functionNames[offset];
+ }
+ }
+
+ void parseStart(Element& s) {
+ wasm.addStart(getFunctionName(*s[1]));
+ }
void parseFunction(Element& s) {
auto func = currFunction = allocator.alloc<Function>();