diff options
author | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-02-27 20:09:26 +0100 |
---|---|---|
committer | wolfbeast <mcwerewolf@wolfbeast.com> | 2020-02-27 20:09:26 +0100 |
commit | ae8eb4d4c42d96c264d5036e1c50e8c1d0d55425 (patch) | |
tree | 061997488fc462caeae817e6547d3a30351c8a8d /js/src/builtin | |
parent | 793da7dd6238ce156e29c71304e24b2c05edc11d (diff) | |
download | UXP-ae8eb4d4c42d96c264d5036e1c50e8c1d0d55425.tar UXP-ae8eb4d4c42d96c264d5036e1c50e8c1d0d55425.tar.gz UXP-ae8eb4d4c42d96c264d5036e1c50e8c1d0d55425.tar.lz UXP-ae8eb4d4c42d96c264d5036e1c50e8c1d0d55425.tar.xz UXP-ae8eb4d4c42d96c264d5036e1c50e8c1d0d55425.zip |
Issue #1465 - Implement optional catch binding.
Diffstat (limited to 'js/src/builtin')
-rw-r--r-- | js/src/builtin/ReflectParse.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/js/src/builtin/ReflectParse.cpp b/js/src/builtin/ReflectParse.cpp index 22c958d4c..a8065d6d1 100644 --- a/js/src/builtin/ReflectParse.cpp +++ b/js/src/builtin/ReflectParse.cpp @@ -1547,7 +1547,7 @@ NodeBuilder::catchClause(HandleValue var, HandleValue guard, HandleValue body, T { RootedValue cb(cx, callbacks[AST_CATCH]); if (!cb.isNull()) - return callback(cb, var, opt(guard), body, pos, dst); + return callback(cb, opt(var), opt(guard), body, pos, dst); return newNode(AST_CATCH, pos, "param", var, @@ -1803,6 +1803,14 @@ class ASTSerializer bool identifier(ParseNode* pn, MutableHandleValue dst); bool literal(ParseNode* pn, MutableHandleValue dst); + bool optPattern(ParseNode* pn, MutableHandleValue dst) { + if (!pn) { + dst.setMagic(JS_SERIALIZE_NO_NODE); + return true; + } + return pattern(pn, dst); + } + bool pattern(ParseNode* pn, MutableHandleValue dst); bool arrayPattern(ParseNode* pn, MutableHandleValue dst); bool objectPattern(ParseNode* pn, MutableHandleValue dst); @@ -2265,13 +2273,13 @@ ASTSerializer::switchStatement(ParseNode* pn, MutableHandleValue dst) bool ASTSerializer::catchClause(ParseNode* pn, bool* isGuarded, MutableHandleValue dst) { - MOZ_ASSERT(pn->pn_pos.encloses(pn->pn_kid1->pn_pos)); + MOZ_ASSERT_IF(pn->pn_kid1, pn->pn_pos.encloses(pn->pn_kid1->pn_pos)); MOZ_ASSERT_IF(pn->pn_kid2, pn->pn_pos.encloses(pn->pn_kid2->pn_pos)); MOZ_ASSERT(pn->pn_pos.encloses(pn->pn_kid3->pn_pos)); RootedValue var(cx), guard(cx), body(cx); - if (!pattern(pn->pn_kid1, &var) || + if (!optPattern(pn->pn_kid1, &var) || !optExpression(pn->pn_kid2, &guard)) { return false; } |