summaryrefslogtreecommitdiff
path: root/js
diff options
context:
space:
mode:
Diffstat (limited to 'js')
-rw-r--r--js/src/frontend/Parser.cpp58
-rw-r--r--js/src/frontend/Parser.h10
2 files changed, 37 insertions, 31 deletions
diff --git a/js/src/frontend/Parser.cpp b/js/src/frontend/Parser.cpp
index 82057f62e8..322f428e51 100644
--- a/js/src/frontend/Parser.cpp
+++ b/js/src/frontend/Parser.cpp
@@ -8617,8 +8617,8 @@ Parser<ParseHandler>::newName(PropertyName* name, TokenPos pos)
}
template <typename ParseHandler>
-PropertyName*
-Parser<ParseHandler>::checkLabelOrIdentifierReference(PropertyName* ident,
+bool
+Parser<ParseHandler>::checkLabelOrIdentifierReference(HandlePropertyName ident,
uint32_t offset,
YieldHandling yieldHandling)
{
@@ -8627,81 +8627,81 @@ Parser<ParseHandler>::checkLabelOrIdentifierReference(PropertyName* ident,
versionNumber() >= JSVERSION_1_7)
{
errorAt(offset, JSMSG_RESERVED_ID, "yield");
- return nullptr;
+ return false;
}
if (pc->sc()->needStrictChecks()) {
if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "yield"))
- return nullptr;
+ return false;
}
- return ident;
+ return true;
}
if (ident == context->names().await) {
if (awaitIsKeyword()) {
errorAt(offset, JSMSG_RESERVED_ID, "await");
- return nullptr;
+ return false;
}
- return ident;
+ return true;
}
if (IsKeyword(ident) || IsReservedWordLiteral(ident)) {
errorAt(offset, JSMSG_INVALID_ID, ReservedWordToCharZ(ident));
- return nullptr;
+ return false;
}
if (IsFutureReservedWord(ident)) {
errorAt(offset, JSMSG_RESERVED_ID, ReservedWordToCharZ(ident));
- return nullptr;
+ return false;
}
if (pc->sc()->needStrictChecks()) {
if (IsStrictReservedWord(ident)) {
if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, ReservedWordToCharZ(ident)))
- return nullptr;
- return ident;
+ return false;
+ return true;
}
if (ident == context->names().let) {
if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "let"))
- return nullptr;
- return ident;
+ return false;
+ return true;
}
if (ident == context->names().static_) {
if (!strictModeErrorAt(offset, JSMSG_RESERVED_ID, "static"))
- return nullptr;
- return ident;
+ return false;
+ return true;
}
}
- return ident;
+ return true;
}
template <typename ParseHandler>
-PropertyName*
-Parser<ParseHandler>::checkBindingIdentifier(PropertyName* ident,
+bool
+Parser<ParseHandler>::checkBindingIdentifier(HandlePropertyName ident,
uint32_t offset,
YieldHandling yieldHandling)
{
if (!checkLabelOrIdentifierReference(ident, offset, yieldHandling))
- return nullptr;
+ return false;
if (pc->sc()->needStrictChecks()) {
if (ident == context->names().arguments) {
if (!strictModeErrorAt(offset, JSMSG_BAD_STRICT_ASSIGN, "arguments"))
- return nullptr;
- return ident;
+ return false;
+ return true;
}
if (ident == context->names().eval) {
if (!strictModeErrorAt(offset, JSMSG_BAD_STRICT_ASSIGN, "eval"))
- return nullptr;
- return ident;
+ return false;
+ return true;
}
}
- return ident;
+ return true;
}
template <typename ParseHandler>
@@ -8715,14 +8715,20 @@ Parser<ParseHandler>::labelOrIdentifierReference(YieldHandling yieldHandling)
//
// Use PropertyName* instead of TokenKind to reflect the normalization.
- return checkLabelOrIdentifierReference(tokenStream.currentName(), pos().begin, yieldHandling);
+ RootedPropertyName ident(context, tokenStream.currentName());
+ if (!checkLabelOrIdentifierReference(ident, pos().begin, yieldHandling))
+ return nullptr;
+ return ident;
}
template <typename ParseHandler>
PropertyName*
Parser<ParseHandler>::bindingIdentifier(YieldHandling yieldHandling)
{
- return checkBindingIdentifier(tokenStream.currentName(), pos().begin, yieldHandling);
+ RootedPropertyName ident(context, tokenStream.currentName());
+ if (!checkBindingIdentifier(ident, pos().begin, yieldHandling))
+ return nullptr;
+ return ident;
}
template <typename ParseHandler>
diff --git a/js/src/frontend/Parser.h b/js/src/frontend/Parser.h
index d53a64eebd..4eb0f5a393 100644
--- a/js/src/frontend/Parser.h
+++ b/js/src/frontend/Parser.h
@@ -1331,14 +1331,14 @@ class Parser final : public ParserBase, private JS::AutoGCRooter
Node classDefinition(YieldHandling yieldHandling, ClassContext classContext,
DefaultHandling defaultHandling);
- PropertyName* checkLabelOrIdentifierReference(PropertyName* ident,
- uint32_t offset,
- YieldHandling yieldHandling);
-
- PropertyName* checkBindingIdentifier(PropertyName* ident,
+ bool checkLabelOrIdentifierReference(HandlePropertyName ident,
uint32_t offset,
YieldHandling yieldHandling);
+ bool checkBindingIdentifier(HandlePropertyName ident,
+ uint32_t offset,
+ YieldHandling yieldHandling);
+
PropertyName* labelOrIdentifierReference(YieldHandling yieldHandling);
PropertyName* labelIdentifier(YieldHandling yieldHandling) {