summaryrefslogtreecommitdiff
path: root/src/wasm-s-parser.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2016-06-03 14:21:02 -0700
committerAlon Zakai <alonzakai@gmail.com>2016-06-03 14:21:02 -0700
commitb76818e23eab75876f1981800ef12d55ce2f579b (patch)
treed57a02368f8ee2cc4747f6805943623f290a3397 /src/wasm-s-parser.h
parent1826f4132d52a1c767f012fad5d1ab3e746e632b (diff)
parent74bc353d4fedd9fff308aecfae183b6b7525c7d3 (diff)
downloadbinaryen-b76818e23eab75876f1981800ef12d55ce2f579b.tar.gz
binaryen-b76818e23eab75876f1981800ef12d55ce2f579b.tar.bz2
binaryen-b76818e23eab75876f1981800ef12d55ce2f579b.zip
Merge pull request #567 from WebAssembly/spec-test-update
Misc fixes for new spec tests
Diffstat (limited to 'src/wasm-s-parser.h')
-rw-r--r--src/wasm-s-parser.h15
1 files changed, 11 insertions, 4 deletions
diff --git a/src/wasm-s-parser.h b/src/wasm-s-parser.h
index e6262c645..2f1a1bc1b 100644
--- a/src/wasm-s-parser.h
+++ b/src/wasm-s-parser.h
@@ -822,9 +822,15 @@ private:
}
Index getLocalIndex(Element& s) {
- if (s.dollared()) return currFunction->getLocalIndex(s.str());
+ if (s.dollared()) {
+ auto ret = s.str();
+ if (currFunction->localIndices.count(ret) == 0) throw ParseException("bad local name", s.line, s.col);
+ return currFunction->getLocalIndex(ret);
+ }
// this is a numeric index
- return atoi(s.c_str());
+ Index ret = atoi(s.c_str());
+ if (ret >= currFunction->getNumLocals()) throw ParseException("bad local index", s.line, s.col);
+ return ret;
}
Expression* makeGetLocal(Element& s) {
@@ -1088,7 +1094,8 @@ private:
Expression* makeCallIndirect(Element& s) {
auto ret = allocator.alloc<CallIndirect>();
IString type = s[1]->str();
- ret->fullType = wasm.getFunctionType(type);
+ ret->fullType = wasm.checkFunctionType(type);
+ if (!ret->fullType) throw ParseException("invalid call_indirect type", s.line, s.col);
assert(ret->fullType);
ret->type = ret->fullType->result;
ret->target = parseExpression(s[2]);
@@ -1109,7 +1116,7 @@ private:
} else {
// offset, break to nth outside label
uint64_t offset = std::stoll(s.c_str(), nullptr, 0);
- if (offset >= labelStack.size()) throw ParseException("total memory must be <= 4GB", s.line, s.col);
+ if (offset >= labelStack.size()) throw ParseException("invalid label", s.line, s.col);
return labelStack[labelStack.size() - 1 - offset];
}
}