summaryrefslogtreecommitdiffstats
path: root/js/src/builtin
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2020-02-27 20:09:26 +0100
committerwolfbeast <mcwerewolf@wolfbeast.com>2020-04-14 13:00:11 +0200
commite7841ab5d740eb70f2975212de4a1066d8714438 (patch)
treed699b22a0de4ab35e953c6fe205c90374956b30b /js/src/builtin
parentdba09fa5c43276bb455cc4da6bd0ec302f798189 (diff)
downloadUXP-e7841ab5d740eb70f2975212de4a1066d8714438.tar
UXP-e7841ab5d740eb70f2975212de4a1066d8714438.tar.gz
UXP-e7841ab5d740eb70f2975212de4a1066d8714438.tar.lz
UXP-e7841ab5d740eb70f2975212de4a1066d8714438.tar.xz
UXP-e7841ab5d740eb70f2975212de4a1066d8714438.zip
Issue #1465 - Implement optional catch binding.
Diffstat (limited to 'js/src/builtin')
-rw-r--r--js/src/builtin/ReflectParse.cpp14
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;
}