summaryrefslogtreecommitdiffstats
path: root/js/src
diff options
context:
space:
mode:
authorwolfbeast <mcwerewolf@wolfbeast.com>2019-04-06 04:22:27 +0200
committerwolfbeast <mcwerewolf@wolfbeast.com>2019-04-06 04:22:27 +0200
commit96899aa847ab7495e3b7baaa413cf50a5eaaffff (patch)
tree33a9beed5f0769d3e50a1d382f65927d26707fcb /js/src
parentdcf64bd2ffd24d1c0d046af810c3270656081663 (diff)
downloadUXP-96899aa847ab7495e3b7baaa413cf50a5eaaffff.tar
UXP-96899aa847ab7495e3b7baaa413cf50a5eaaffff.tar.gz
UXP-96899aa847ab7495e3b7baaa413cf50a5eaaffff.tar.lz
UXP-96899aa847ab7495e3b7baaa413cf50a5eaaffff.tar.xz
UXP-96899aa847ab7495e3b7baaa413cf50a5eaaffff.zip
Move part of Parser::functionDefinition into callers.
Diffstat (limited to 'js/src')
-rw-r--r--js/src/frontend/Parser.cpp46
-rw-r--r--js/src/frontend/Parser.h5
2 files changed, 31 insertions, 20 deletions
diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp
index 5981881d3..8466d7c1c 100644
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -3188,22 +3188,14 @@ Parser<ParseHandler>::templateLiteral(YieldHandling yieldHandling)
template <typename ParseHandler>
typename ParseHandler::Node
-Parser<ParseHandler>::functionDefinition(uint32_t preludeStart, InHandling inHandling,
+Parser<ParseHandler>::functionDefinition(uint32_t preludeStart, Node pn, InHandling inHandling,
YieldHandling yieldHandling,
HandleAtom funName, FunctionSyntaxKind kind,
- GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
- InvokedPrediction invoked)
+ GeneratorKind generatorKind, FunctionAsyncKind asyncKind)
{
MOZ_ASSERT_IF(kind == Statement, funName);
MOZ_ASSERT_IF(asyncKind == AsyncFunction, generatorKind == StarGenerator);
- Node pn = handler.newFunctionDefinition();
- if (!pn)
- return null();
-
- if (invoked)
- pn = handler.setLikelyIIFE(pn);
-
// Note the declared name and check for early errors.
bool tryAnnexB = false;
if (!checkFunctionDefinition(funName, pn, kind, generatorKind, &tryAnnexB))
@@ -3665,9 +3657,13 @@ Parser<ParseHandler>::functionStmt(uint32_t preludeStart, YieldHandling yieldHan
return null();
}
+ Node pn = handler.newFunctionDefinition();
+ if (!pn)
+ return null();
+
YieldHandling newYieldHandling = GetYieldHandling(generatorKind, asyncKind);
- Node fun = functionDefinition(preludeStart, InAllowed, newYieldHandling, name, Statement,
- generatorKind, asyncKind, PredictUninvoked);
+ Node fun = functionDefinition(preludeStart, pn, InAllowed, newYieldHandling,
+ name, Statement, generatorKind, asyncKind);
if (!fun)
return null();
@@ -3716,8 +3712,15 @@ Parser<ParseHandler>::functionExpr(uint32_t preludeStart, InvokedPrediction invo
tokenStream.ungetToken();
}
- return functionDefinition(preludeStart, InAllowed, yieldHandling, name, Expression,
- generatorKind, asyncKind, invoked);
+ Node pn = handler.newFunctionDefinition();
+ if (!pn)
+ return null();
+
+ if (invoked)
+ pn = handler.setLikelyIIFE(pn);
+
+ return functionDefinition(preludeStart, pn, InAllowed, yieldHandling, name, Expression,
+ generatorKind, asyncKind);
}
/*
@@ -7783,7 +7786,11 @@ Parser<ParseHandler>::assignExpr(InHandling inHandling, YieldHandling yieldHandl
}
}
- Node arrowFunc = functionDefinition(preludeStart, inHandling, yieldHandling, nullptr,
+ Node pn = handler.newFunctionDefinition();
+ if (!pn)
+ return null();
+
+ Node arrowFunc = functionDefinition(preludeStart, pn, inHandling, yieldHandling, nullptr,
Arrow, generatorKind, asyncKind);
if (!arrowFunc)
return null();
@@ -9429,8 +9436,13 @@ Parser<ParseHandler>::methodDefinition(uint32_t preludeStart, PropertyType propT
GeneratorKind generatorKind = GeneratorKindFromPropertyType(propType);
FunctionAsyncKind asyncKind = AsyncKindFromPropertyType(propType);
YieldHandling yieldHandling = GetYieldHandling(generatorKind, asyncKind);
- return functionDefinition(preludeStart, InAllowed, yieldHandling, funName, kind,
- generatorKind, asyncKind);
+
+ Node pn = handler.newFunctionDefinition();
+ if (!pn)
+ return null();
+
+ return functionDefinition(preludeStart, pn, InAllowed, yieldHandling, funName,
+ kind, generatorKind, asyncKind);
}
template <typename ParseHandler>
diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h
index c8914a2d7..3bfb4ae31 100644
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -1259,11 +1259,10 @@ class Parser final : private JS::AutoGCRooter, public StrictModeGetter
bool functionArguments(YieldHandling yieldHandling, FunctionSyntaxKind kind,
Node funcpn);
- Node functionDefinition(uint32_t preludeStart,
+ Node functionDefinition(uint32_t preludeStart, Node pn,
InHandling inHandling, YieldHandling yieldHandling, HandleAtom name,
FunctionSyntaxKind kind,
- GeneratorKind generatorKind, FunctionAsyncKind asyncKind,
- InvokedPrediction invoked = PredictUninvoked);
+ GeneratorKind generatorKind, FunctionAsyncKind asyncKind);
// Parse a function body. Pass StatementListBody if the body is a list of
// statements; pass ExpressionBody if the body is a single expression.