summaryrefslogtreecommitdiff
path: root/deps/v8/src/parsing/parser-base.h
diff options
context:
space:
mode:
Diffstat (limited to 'deps/v8/src/parsing/parser-base.h')
-rw-r--r--deps/v8/src/parsing/parser-base.h80
1 files changed, 43 insertions, 37 deletions
diff --git a/deps/v8/src/parsing/parser-base.h b/deps/v8/src/parsing/parser-base.h
index 7240e64777..df829ff8ca 100644
--- a/deps/v8/src/parsing/parser-base.h
+++ b/deps/v8/src/parsing/parser-base.h
@@ -15,6 +15,7 @@
#include "src/ast/scopes.h"
#include "src/base/flags.h"
#include "src/base/hashmap.h"
+#include "src/base/pointer-with-payload.h"
#include "src/base/v8-fallthrough.h"
#include "src/codegen/bailout-reason.h"
#include "src/common/globals.h"
@@ -28,7 +29,6 @@
#include "src/parsing/scanner.h"
#include "src/parsing/token.h"
#include "src/regexp/regexp.h"
-#include "src/utils/pointer-with-payload.h"
#include "src/zone/zone-chunk-list.h"
namespace v8 {
@@ -300,7 +300,7 @@ class ParserBase {
void ResetFunctionLiteralId() { function_literal_id_ = 0; }
// The Zone where the parsing outputs are stored.
- Zone* main_zone() const { return ast_value_factory()->zone(); }
+ Zone* main_zone() const { return ast_value_factory()->single_parse_zone(); }
// The current Zone, which might be the main zone or a temporary Zone.
Zone* zone() const { return zone_; }
@@ -482,7 +482,7 @@ class ParserBase {
}
private:
- PointerWithPayload<FunctionState, bool, 1> state_and_prev_value_;
+ base::PointerWithPayload<FunctionState, bool, 1> state_and_prev_value_;
};
class V8_NODISCARD LoopScope final {
@@ -1234,13 +1234,11 @@ class ParserBase {
ExpressionT ParseArrowFunctionLiteral(const FormalParametersT& parameters);
void ParseAsyncFunctionBody(Scope* scope, StatementListT* body);
ExpressionT ParseAsyncFunctionLiteral();
- ExpressionT ParseClassLiteral(IdentifierT name,
+ ExpressionT ParseClassExpression(Scope* outer_scope);
+ ExpressionT ParseClassLiteral(Scope* outer_scope, IdentifierT name,
Scanner::Location class_name_location,
bool name_is_strict_reserved,
int class_token_pos);
- ExpressionT DoParseClassLiteral(ClassScope* class_scope, IdentifierT name,
- Scanner::Location class_name_location,
- bool is_anonymous, int class_token_pos);
ExpressionT ParseTemplateLiteral(ExpressionT tag, int start, bool tagged);
ExpressionT ParseSuperExpression();
@@ -1974,7 +1972,11 @@ ParserBase<Impl>::ParsePrimaryExpression() {
case Token::LPAREN: {
Consume(Token::LPAREN);
+
if (Check(Token::RPAREN)) {
+ // clear last next_arrow_function_info tracked strict parameters error.
+ next_arrow_function_info_.ClearStrictParameterError();
+
// ()=>x. The continuation that consumes the => is in
// ParseAssignmentExpressionCoverGrammar.
if (peek() != Token::ARROW) ReportUnexpectedToken(Token::RPAREN);
@@ -2006,19 +2008,7 @@ ParserBase<Impl>::ParsePrimaryExpression() {
}
case Token::CLASS: {
- Consume(Token::CLASS);
- int class_token_pos = position();
- IdentifierT name = impl()->NullIdentifier();
- bool is_strict_reserved_name = false;
- Scanner::Location class_name_location = Scanner::Location::invalid();
- if (peek_any_identifier()) {
- name = ParseAndClassifyIdentifier(Next());
- class_name_location = scanner()->location();
- is_strict_reserved_name =
- Token::IsStrictReservedWord(scanner()->current_token());
- }
- return ParseClassLiteral(name, class_name_location,
- is_strict_reserved_name, class_token_pos);
+ return ParseClassExpression(scope());
}
case Token::TEMPLATE_SPAN:
@@ -3776,9 +3766,9 @@ ParserBase<Impl>::ParseSuperExpression() {
impl()->ReportMessage(MessageTemplate::kOptionalChainingNoSuper);
return impl()->FailureExpression();
}
- scope->RecordSuperPropertyUsage();
+ Scope* home_object_scope = scope->RecordSuperPropertyUsage();
UseThis();
- return impl()->NewSuperPropertyReference(pos);
+ return impl()->NewSuperPropertyReference(home_object_scope, pos);
}
// super() is only allowed in derived constructor. new super() is never
// allowed; it's reported as an error by
@@ -4262,7 +4252,7 @@ typename ParserBase<Impl>::StatementT ParserBase<Impl>::ParseClassDeclaration(
}
ExpressionParsingScope no_expression_scope(impl());
- ExpressionT value = ParseClassLiteral(name, scanner()->location(),
+ ExpressionT value = ParseClassLiteral(scope(), name, scanner()->location(),
is_strict_reserved, class_token_pos);
no_expression_scope.ValidateExpression();
int end_pos = position();
@@ -4419,6 +4409,16 @@ void ParserBase<Impl>::ParseFunctionBody(
impl()->ReportVarRedeclarationIn(conflict, inner_scope);
}
}
+
+ // According to ES#sec-functiondeclarationinstantiation step 27,28
+ // when hasParameterExpressions is true, we need bind var declared
+ // arguments to "arguments exotic object", so we here first declare
+ // "arguments exotic object", then var declared arguments will be
+ // initialized with "arguments exotic object"
+ if (!IsArrowFunction(kind)) {
+ function_scope->DeclareArguments(ast_value_factory());
+ }
+
impl()->InsertShadowingVarBindingInitializers(inner_block);
}
}
@@ -4427,9 +4427,6 @@ void ParserBase<Impl>::ParseFunctionBody(
allow_duplicate_parameters);
if (!IsArrowFunction(kind)) {
- // Declare arguments after parsing the function since lexical 'arguments'
- // masks the arguments object. Declare arguments before declaring the
- // function var since the arguments object masks 'function arguments'.
function_scope->DeclareArguments(ast_value_factory());
}
@@ -4668,8 +4665,26 @@ ParserBase<Impl>::ParseArrowFunctionLiteral(
}
template <typename Impl>
+typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseClassExpression(
+ Scope* outer_scope) {
+ Consume(Token::CLASS);
+ int class_token_pos = position();
+ IdentifierT name = impl()->NullIdentifier();
+ bool is_strict_reserved_name = false;
+ Scanner::Location class_name_location = Scanner::Location::invalid();
+ if (peek_any_identifier()) {
+ name = ParseAndClassifyIdentifier(Next());
+ class_name_location = scanner()->location();
+ is_strict_reserved_name =
+ Token::IsStrictReservedWord(scanner()->current_token());
+ }
+ return ParseClassLiteral(outer_scope, name, class_name_location,
+ is_strict_reserved_name, class_token_pos);
+}
+
+template <typename Impl>
typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseClassLiteral(
- IdentifierT name, Scanner::Location class_name_location,
+ Scope* outer_scope, IdentifierT name, Scanner::Location class_name_location,
bool name_is_strict_reserved, int class_token_pos) {
bool is_anonymous = impl()->IsNull(name);
@@ -4687,16 +4702,7 @@ typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::ParseClassLiteral(
}
}
- ClassScope* class_scope = NewClassScope(scope(), is_anonymous);
- return DoParseClassLiteral(class_scope, name, class_name_location,
- is_anonymous, class_token_pos);
-}
-
-template <typename Impl>
-typename ParserBase<Impl>::ExpressionT ParserBase<Impl>::DoParseClassLiteral(
- ClassScope* class_scope, IdentifierT name,
- Scanner::Location class_name_location, bool is_anonymous,
- int class_token_pos) {
+ ClassScope* class_scope = NewClassScope(outer_scope, is_anonymous);
BlockState block_state(&scope_, class_scope);
RaiseLanguageMode(LanguageMode::kStrict);