| Index: src/parsing/preparser.cc
|
| diff --git a/src/parsing/preparser.cc b/src/parsing/preparser.cc
|
| index 08d5eafd4de581828aaa0d3090f2b0db9ddb1a64..310c81e1178b562821adaa85b13453f08e44afc2 100644
|
| --- a/src/parsing/preparser.cc
|
| +++ b/src/parsing/preparser.cc
|
| @@ -109,15 +109,16 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction(
|
| log_ = log;
|
| use_counts_ = use_counts;
|
| // Lazy functions always have trivial outer scopes (no with/catch scopes).
|
| - Scope* top_scope = NewScope(scope_, SCRIPT_SCOPE);
|
| - PreParserFactory top_factory(NULL);
|
| - FunctionState top_state(&function_state_, &scope_, top_scope, kNormalFunction,
|
| + DCHECK_NULL(state_);
|
| + Scope* top_scope = NewScope(nullptr, SCRIPT_SCOPE);
|
| + PreParserFactory top_factory(nullptr);
|
| + FunctionState top_state(&function_state_, &state_, top_scope, kNormalFunction,
|
| &top_factory);
|
| - scope_->SetLanguageMode(language_mode);
|
| - Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind);
|
| + scope()->SetLanguageMode(language_mode);
|
| + Scope* function_scope = NewScope(scope(), FUNCTION_SCOPE, kind);
|
| if (!has_simple_parameters) function_scope->SetHasNonSimpleParameters();
|
| - PreParserFactory function_factory(NULL);
|
| - FunctionState function_state(&function_state_, &scope_, function_scope, kind,
|
| + PreParserFactory function_factory(nullptr);
|
| + FunctionState function_state(&function_state_, &state_, function_scope, kind,
|
| &function_factory);
|
| DCHECK_EQ(Token::LBRACE, scanner()->current_token());
|
| bool ok = true;
|
| @@ -132,7 +133,7 @@ PreParser::PreParseResult PreParser::PreParseLazyFunction(
|
| ReportUnexpectedToken(scanner()->current_token());
|
| } else {
|
| DCHECK_EQ(Token::RBRACE, scanner()->peek());
|
| - if (is_strict(scope_->language_mode())) {
|
| + if (is_strict(scope()->language_mode())) {
|
| int end_pos = scanner()->location().end_pos;
|
| CheckStrictOctalLiteral(start_position, end_pos, &ok);
|
| CheckDecimalLiteralWithLeadingZero(use_counts, start_position, end_pos);
|
| @@ -233,13 +234,13 @@ void PreParser::ParseStatementList(int end_token, bool* ok,
|
| bool use_strict_found = statement.IsUseStrictLiteral();
|
|
|
| if (use_strict_found) {
|
| - scope_->SetLanguageMode(
|
| - static_cast<LanguageMode>(scope_->language_mode() | STRICT));
|
| + scope()->SetLanguageMode(
|
| + static_cast<LanguageMode>(scope()->language_mode() | STRICT));
|
| } else if (!statement.IsStringLiteral()) {
|
| directive_prologue = false;
|
| }
|
|
|
| - if (use_strict_found && !scope_->HasSimpleParameters()) {
|
| + if (use_strict_found && !scope()->HasSimpleParameters()) {
|
| // TC39 deemed "use strict" directives to be an error when occurring
|
| // in the body of a function with non-simple parameter list, on
|
| // 29/7/2015. https://goo.gl/ueA7Ln
|
| @@ -292,8 +293,8 @@ PreParser::Statement PreParser::ParseScopedStatement(bool legacy, bool* ok) {
|
| (legacy && allow_harmony_restrictive_declarations())) {
|
| return ParseSubStatement(kDisallowLabelledFunctionStatement, ok);
|
| } else {
|
| - Scope* body_scope = NewScope(scope_, BLOCK_SCOPE);
|
| - BlockState block_state(&scope_, body_scope);
|
| + Scope* body_scope = NewScope(scope(), BLOCK_SCOPE);
|
| + BlockState block_state(&state_, body_scope);
|
| return ParseFunctionDeclaration(ok);
|
| }
|
| }
|
| @@ -463,11 +464,11 @@ PreParser::Statement PreParser::ParseBlock(bool* ok) {
|
| // Block ::
|
| // '{' StatementList '}'
|
|
|
| - Scope* block_scope = NewScope(scope_, BLOCK_SCOPE);
|
| + Scope* block_scope = NewScope(scope(), BLOCK_SCOPE);
|
| Expect(Token::LBRACE, CHECK_OK);
|
| Statement final = Statement::Default();
|
| {
|
| - BlockState block_state(&scope_, block_scope);
|
| + BlockState block_state(&state_, block_scope);
|
| while (peek() != Token::RBRACE) {
|
| final = ParseStatementListItem(CHECK_OK);
|
| }
|
| @@ -777,8 +778,8 @@ PreParser::Statement PreParser::ParseWithStatement(bool* ok) {
|
| ParseExpression(true, CHECK_OK);
|
| Expect(Token::RPAREN, CHECK_OK);
|
|
|
| - Scope* with_scope = NewScope(scope_, WITH_SCOPE);
|
| - BlockState block_state(&scope_, with_scope);
|
| + Scope* with_scope = NewScope(scope(), WITH_SCOPE);
|
| + BlockState block_state(&state_, with_scope);
|
| ParseScopedStatement(true, CHECK_OK);
|
| return Statement::Default();
|
| }
|
| @@ -793,9 +794,9 @@ PreParser::Statement PreParser::ParseSwitchStatement(bool* ok) {
|
| ParseExpression(true, CHECK_OK);
|
| Expect(Token::RPAREN, CHECK_OK);
|
|
|
| - Scope* cases_scope = NewScope(scope_, BLOCK_SCOPE);
|
| + Scope* cases_scope = NewScope(scope(), BLOCK_SCOPE);
|
| {
|
| - BlockState cases_block_state(&scope_, cases_scope);
|
| + BlockState cases_block_state(&state_, cases_scope);
|
| Expect(Token::LBRACE, CHECK_OK);
|
| Token::Value token = peek();
|
| while (token != Token::RBRACE) {
|
| @@ -854,10 +855,10 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
|
| // 'for' '(' Expression? ';' Expression? ';' Expression? ')' Statement
|
|
|
| // Create an in-between scope for let-bound iteration variables.
|
| - Scope* for_scope = NewScope(scope_, BLOCK_SCOPE);
|
| + Scope* for_scope = NewScope(scope(), BLOCK_SCOPE);
|
| bool has_lexical = false;
|
|
|
| - BlockState block_state(&scope_, for_scope);
|
| + BlockState block_state(&state_, for_scope);
|
| Expect(Token::FOR, CHECK_OK);
|
| Expect(Token::LPAREN, CHECK_OK);
|
| if (peek() != Token::SEMICOLON) {
|
| @@ -945,9 +946,9 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
|
| }
|
|
|
| Expect(Token::RPAREN, CHECK_OK);
|
| - Scope* body_scope = NewScope(scope_, BLOCK_SCOPE);
|
| + Scope* body_scope = NewScope(scope(), BLOCK_SCOPE);
|
| {
|
| - BlockState block_state(&scope_, body_scope);
|
| + BlockState block_state(&state_, body_scope);
|
| ParseScopedStatement(true, CHECK_OK);
|
| }
|
| return Statement::Default();
|
| @@ -960,11 +961,11 @@ PreParser::Statement PreParser::ParseForStatement(bool* ok) {
|
|
|
| // If there are let bindings, then condition and the next statement of the
|
| // for loop must be parsed in a new scope.
|
| - Scope* inner_scope = scope_;
|
| + Scope* inner_scope = scope();
|
| if (has_lexical) inner_scope = NewScope(for_scope, BLOCK_SCOPE);
|
|
|
| {
|
| - BlockState block_state(&scope_, inner_scope);
|
| + BlockState block_state(&state_, inner_scope);
|
|
|
| if (peek() != Token::SEMICOLON) {
|
| ParseExpression(true, CHECK_OK);
|
| @@ -1029,7 +1030,7 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) {
|
| if (tok == Token::CATCH) {
|
| Consume(Token::CATCH);
|
| Expect(Token::LPAREN, CHECK_OK);
|
| - Scope* catch_scope = NewScope(scope_, CATCH_SCOPE);
|
| + Scope* catch_scope = NewScope(scope(), CATCH_SCOPE);
|
| ExpressionClassifier pattern_classifier(this);
|
| ParsePrimaryExpression(&pattern_classifier, CHECK_OK);
|
| ValidateBindingPattern(&pattern_classifier, CHECK_OK);
|
| @@ -1038,10 +1039,10 @@ PreParser::Statement PreParser::ParseTryStatement(bool* ok) {
|
| CollectExpressionsInTailPositionToListScope
|
| collect_tail_call_expressions_scope(
|
| function_state_, &tail_call_expressions_in_catch_block);
|
| - BlockState block_state(&scope_, catch_scope);
|
| - Scope* block_scope = NewScope(scope_, BLOCK_SCOPE);
|
| + BlockState block_state(&state_, catch_scope);
|
| + Scope* block_scope = NewScope(scope(), BLOCK_SCOPE);
|
| {
|
| - BlockState block_state(&scope_, block_scope);
|
| + BlockState block_state(&state_, block_scope);
|
| ParseBlock(CHECK_OK);
|
| }
|
| }
|
| @@ -1095,11 +1096,11 @@ PreParser::Expression PreParser::ParseFunctionLiteral(
|
| // '(' FormalParameterList? ')' '{' FunctionBody '}'
|
|
|
| // Parse function body.
|
| - bool outer_is_script_scope = scope_->is_script_scope();
|
| - Scope* function_scope = NewScope(scope_, FUNCTION_SCOPE, kind);
|
| + bool outer_is_script_scope = scope()->is_script_scope();
|
| + Scope* function_scope = NewScope(scope(), FUNCTION_SCOPE, kind);
|
| function_scope->SetLanguageMode(language_mode);
|
| PreParserFactory factory(NULL);
|
| - FunctionState function_state(&function_state_, &scope_, function_scope, kind,
|
| + FunctionState function_state(&function_state_, &state_, function_scope, kind,
|
| &factory);
|
| DuplicateFinder duplicate_finder(scanner()->unicode_cache());
|
| ExpressionClassifier formals_classifier(this, &duplicate_finder);
|
| @@ -1195,7 +1196,7 @@ void PreParser::ParseLazyFunctionLiteralBody(bool* ok,
|
| log_->LogFunction(body_start, body_end,
|
| function_state_->materialized_literal_count(),
|
| function_state_->expected_property_count(), language_mode(),
|
| - scope_->uses_super_property(), scope_->calls_eval());
|
| + scope()->uses_super_property(), scope()->calls_eval());
|
| }
|
|
|
| PreParserExpression PreParser::ParseClassLiteral(
|
| @@ -1216,12 +1217,12 @@ PreParserExpression PreParser::ParseClassLiteral(
|
| }
|
|
|
| LanguageMode class_language_mode = language_mode();
|
| - Scope* scope = NewScope(scope_, BLOCK_SCOPE);
|
| - BlockState block_state(&scope_, scope);
|
| - scope_->SetLanguageMode(
|
| + Scope* scope = NewScope(this->scope(), BLOCK_SCOPE);
|
| + BlockState block_state(&state_, scope);
|
| + this->scope()->SetLanguageMode(
|
| static_cast<LanguageMode>(class_language_mode | STRICT));
|
| // TODO(marja): Make PreParser use scope names too.
|
| - // scope_->SetScopeName(name);
|
| + // this->scope()->SetScopeName(name);
|
|
|
| bool has_extends = Check(Token::EXTENDS);
|
| if (has_extends) {
|
| @@ -1298,7 +1299,7 @@ PreParserExpression PreParser::ParseDoExpression(bool* ok) {
|
| void PreParserTraits::ParseAsyncArrowSingleExpressionBody(
|
| PreParserStatementList body, bool accept_IN,
|
| Type::ExpressionClassifier* classifier, int pos, bool* ok) {
|
| - Scope* scope = pre_parser_->scope_;
|
| + Scope* scope = pre_parser_->scope();
|
| scope->ForceContextAllocation();
|
|
|
| PreParserExpression return_value =
|
|
|