--- a/js/src/frontend/BinSource.cpp
+++ b/js/src/frontend/BinSource.cpp
@@ -2289,16 +2289,85 @@ ASTReader::parseSwitchCase(SimpleTokenRe
Unused << test.release();
Unused << statements.release();
out = Move(result);
return true;
}
bool
+ASTReader::parseCatchClause(SimpleTokenReader* reader, UniquePtr<ParseNode>& out) {
+ if (out) {
+ return this->raiseError();
+ }
+
+
+ BinKind kind;
+ SimpleTokenReader::BinFields fields(this->cx);
+ SimpleTokenReader sub(this->cx);
+
+ if (!reader->taggedTuple(kind, fields, &sub)) {
+ return false;
+ }
+
+ if (kind != BinKind::catch_clause) {
+ return this->raiseError();
+ }
+
+ UniquePtr<ParseNode> param;
+ UniquePtr<ParseNode> body;
+
+ for (auto field: fields) {
+ switch (field) {
+ case BinField::param:
+ if (!this->parsePattern(&sub, param)) {
+ return false;
+ }
+ break;
+ case BinField::body:
+ if (!this->parseStatementList(&sub, body)) {
+ return false;
+ }
+ break;
+ default:
+ return this->raiseError();
+ }
+ }
+
+ if (!param || !body) {
+ return this->raiseError();
+ }
+
+ UniquePtr<ParseNode> catchClause(new_<TernaryNode>(PNK_CATCH, JSOP_NOP, param.get(), nullptr, body.get()));
+ if (!catchClause) {
+ return false;
+ }
+
+ Unused << param.release();
+ Unused << body.release();
+
+ UniquePtr<ParseNode> lexNode(new_<LexicalScopeNode>(/*FIXME: Implement*/nullptr, catchClause.get()));
+ if (!lexNode) {
+ return false;
+ }
+ Unused << catchClause.release();
+
+ UniquePtr<ParseNode> catchList(new_<ListNode>(PNK_CATCHLIST, TokenPos()));// FIXME: We need a PNK_CATCHLIST of a single PNK_CATCH
+ if (!catchList) {
+ return false;
+ }
+
+ catchList->append(catchClause.release());
+
+ out = Move(catchList);
+ return true;
+}
+
+
+bool
ASTReader::readString(SimpleTokenReader* reader, MutableHandle<PropertyName*> out) {
if (out) {
return this->raiseError();
}
RootedAtom atom(cx);
if (!this->readString(reader, &atom)) {