Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(584)

Side by Side Diff: src/parsing/parser.cc

Issue 1901413002: [debugger] Hide scopes that originate from desugaring. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: fix test Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/debug/debug-scopes.cc ('k') | test/mjsunit/debug-scopes.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/parsing/parser.h" 5 #include "src/parsing/parser.h"
6 6
7 #include "src/api.h" 7 #include "src/api.h"
8 #include "src/ast/ast.h" 8 #include "src/ast/ast.h"
9 #include "src/ast/ast-expression-rewriter.h" 9 #include "src/ast/ast-expression-rewriter.h"
10 #include "src/ast/ast-expression-visitor.h" 10 #include "src/ast/ast-expression-visitor.h"
(...skipping 3417 matching lines...) Expand 10 before | Expand all | Expand 10 after
3428 if (is_strict(language_mode()) || peek() != Token::FUNCTION || 3428 if (is_strict(language_mode()) || peek() != Token::FUNCTION ||
3429 (legacy && allow_harmony_restrictive_declarations())) { 3429 (legacy && allow_harmony_restrictive_declarations())) {
3430 return ParseSubStatement(labels, kDisallowLabelledFunctionStatement, ok); 3430 return ParseSubStatement(labels, kDisallowLabelledFunctionStatement, ok);
3431 } else { 3431 } else {
3432 if (legacy) { 3432 if (legacy) {
3433 ++use_counts_[v8::Isolate::kLegacyFunctionDeclaration]; 3433 ++use_counts_[v8::Isolate::kLegacyFunctionDeclaration];
3434 } 3434 }
3435 // Make a block around the statement for a lexical binding 3435 // Make a block around the statement for a lexical binding
3436 // is introduced by a FunctionDeclaration. 3436 // is introduced by a FunctionDeclaration.
3437 Scope* body_scope = NewScope(scope_, BLOCK_SCOPE); 3437 Scope* body_scope = NewScope(scope_, BLOCK_SCOPE);
3438 body_scope->set_start_position(scanner()->location().beg_pos);
3438 BlockState block_state(&scope_, body_scope); 3439 BlockState block_state(&scope_, body_scope);
3439 Block* block = factory()->NewBlock(NULL, 1, false, RelocInfo::kNoPosition); 3440 Block* block = factory()->NewBlock(NULL, 1, false, RelocInfo::kNoPosition);
3440 Statement* body = ParseFunctionDeclaration(NULL, CHECK_OK); 3441 Statement* body = ParseFunctionDeclaration(NULL, CHECK_OK);
3441 block->statements()->Add(body, zone()); 3442 block->statements()->Add(body, zone());
3442 body_scope->set_end_position(scanner()->location().end_pos); 3443 body_scope->set_end_position(scanner()->location().end_pos);
3443 body_scope = body_scope->FinalizeBlockScope(); 3444 body_scope = body_scope->FinalizeBlockScope();
3444 block->set_scope(body_scope); 3445 block->set_scope(body_scope);
3445 return block; 3446 return block;
3446 } 3447 }
3447 } 3448 }
3448 3449
3449 Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels, 3450 Statement* Parser::ParseForStatement(ZoneList<const AstRawString*>* labels,
3450 bool* ok) { 3451 bool* ok) {
3451 int stmt_pos = peek_position(); 3452 int stmt_pos = peek_position();
3452 Statement* init = NULL; 3453 Statement* init = NULL;
3453 ZoneList<const AstRawString*> lexical_bindings(1, zone()); 3454 ZoneList<const AstRawString*> lexical_bindings(1, zone());
3454 3455
3455 // Create an in-between scope for let-bound iteration variables. 3456 // Create an in-between scope for let-bound iteration variables.
3456 Scope* for_scope = NewScope(scope_, BLOCK_SCOPE); 3457 Scope* for_scope = NewScope(scope_, BLOCK_SCOPE);
3457 3458
3458 BlockState block_state(&scope_, for_scope); 3459 BlockState block_state(&scope_, for_scope);
3459 Expect(Token::FOR, CHECK_OK); 3460 Expect(Token::FOR, CHECK_OK);
3460 Expect(Token::LPAREN, CHECK_OK); 3461 Expect(Token::LPAREN, CHECK_OK);
3461 for_scope->set_start_position(scanner()->location().beg_pos); 3462 for_scope->set_start_position(scanner()->location().beg_pos);
3463 for_scope->set_is_hidden();
3462 DeclarationParsingResult parsing_result; 3464 DeclarationParsingResult parsing_result;
3463 if (peek() != Token::SEMICOLON) { 3465 if (peek() != Token::SEMICOLON) {
3464 if (peek() == Token::VAR || peek() == Token::CONST || 3466 if (peek() == Token::VAR || peek() == Token::CONST ||
3465 (peek() == Token::LET && IsNextLetKeyword())) { 3467 (peek() == Token::LET && IsNextLetKeyword())) {
3466 ParseVariableDeclarations(kForStatement, &parsing_result, nullptr, 3468 ParseVariableDeclarations(kForStatement, &parsing_result, nullptr,
3467 CHECK_OK); 3469 CHECK_OK);
3468 3470
3469 ForEachStatement::VisitMode mode = ForEachStatement::ENUMERATE; 3471 ForEachStatement::VisitMode mode = ForEachStatement::ENUMERATE;
3470 int each_beg_pos = scanner()->location().beg_pos; 3472 int each_beg_pos = scanner()->location().beg_pos;
3471 int each_end_pos = scanner()->location().end_pos; 3473 int each_end_pos = scanner()->location().end_pos;
(...skipping 908 matching lines...) Expand 10 before | Expand all | Expand 10 after
4380 initializer_position = parameter.initializer_end_position; 4382 initializer_position = parameter.initializer_end_position;
4381 } 4383 }
4382 4384
4383 Scope* param_scope = scope_; 4385 Scope* param_scope = scope_;
4384 Block* param_block = init_block; 4386 Block* param_block = init_block;
4385 if (!parameter.is_simple() && scope_->calls_sloppy_eval()) { 4387 if (!parameter.is_simple() && scope_->calls_sloppy_eval()) {
4386 param_scope = NewScope(scope_, BLOCK_SCOPE); 4388 param_scope = NewScope(scope_, BLOCK_SCOPE);
4387 param_scope->set_is_declaration_scope(); 4389 param_scope->set_is_declaration_scope();
4388 param_scope->set_start_position(parameter.pattern->position()); 4390 param_scope->set_start_position(parameter.pattern->position());
4389 param_scope->set_end_position(RelocInfo::kNoPosition); 4391 param_scope->set_end_position(RelocInfo::kNoPosition);
4392 param_scope->set_is_hidden();
adamk 2016/04/21 19:59:20 Should this scope really be hidden? Could you add
4390 param_scope->RecordEvalCall(); 4393 param_scope->RecordEvalCall();
4391 param_block = factory()->NewBlock(NULL, 8, true, RelocInfo::kNoPosition); 4394 param_block = factory()->NewBlock(NULL, 8, true, RelocInfo::kNoPosition);
4392 param_block->set_scope(param_scope); 4395 param_block->set_scope(param_scope);
4393 descriptor.hoist_scope = scope_; 4396 descriptor.hoist_scope = scope_;
4394 } 4397 }
4395 4398
4396 { 4399 {
4397 BlockState block_state(&scope_, param_scope); 4400 BlockState block_state(&scope_, param_scope);
4398 DeclarationParsingResult::Declaration decl( 4401 DeclarationParsingResult::Declaration decl(
4399 parameter.pattern, initializer_position, initial_value); 4402 parameter.pattern, initializer_position, initial_value);
(...skipping 1568 matching lines...) Expand 10 before | Expand all | Expand 10 after
5968 Statement* try_catch; 5971 Statement* try_catch;
5969 { 5972 {
5970 Block* try_block = factory->NewBlock(nullptr, 2, false, nopos); 5973 Block* try_block = factory->NewBlock(nullptr, 2, false, nopos);
5971 try_block->statements()->Add(yield_output, zone); 5974 try_block->statements()->Add(yield_output, zone);
5972 try_block->statements()->Add(set_mode_next, zone); 5975 try_block->statements()->Add(set_mode_next, zone);
5973 5976
5974 Block* catch_block = factory->NewBlock(nullptr, 1, false, nopos); 5977 Block* catch_block = factory->NewBlock(nullptr, 1, false, nopos);
5975 catch_block->statements()->Add(set_mode_throw, zone); 5978 catch_block->statements()->Add(set_mode_throw, zone);
5976 5979
5977 Scope* catch_scope = NewScope(scope, CATCH_SCOPE); 5980 Scope* catch_scope = NewScope(scope, CATCH_SCOPE);
5981 catch_scope->set_is_hidden();
5978 const AstRawString* name = avfactory->dot_catch_string(); 5982 const AstRawString* name = avfactory->dot_catch_string();
5979 Variable* catch_variable = 5983 Variable* catch_variable =
5980 catch_scope->DeclareLocal(name, VAR, kCreatedInitialized, 5984 catch_scope->DeclareLocal(name, VAR, kCreatedInitialized,
5981 Variable::NORMAL); 5985 Variable::NORMAL);
5982 5986
5983 try_catch = factory->NewTryCatchStatement( 5987 try_catch = factory->NewTryCatchStatement(
5984 try_block, catch_scope, catch_variable, catch_block, nopos); 5988 try_block, catch_scope, catch_variable, catch_block, nopos);
5985 } 5989 }
5986 5990
5987 5991
(...skipping 461 matching lines...) Expand 10 before | Expand all | Expand 10 after
6449 // catch(e) { 6453 // catch(e) {
6450 // #set_completion_throw; 6454 // #set_completion_throw;
6451 // %ReThrow(e); 6455 // %ReThrow(e);
6452 // } 6456 // }
6453 Statement* try_catch; 6457 Statement* try_catch;
6454 { 6458 {
6455 Scope* catch_scope = parser_->NewScope(scope, CATCH_SCOPE); 6459 Scope* catch_scope = parser_->NewScope(scope, CATCH_SCOPE);
6456 Variable* catch_variable = 6460 Variable* catch_variable =
6457 catch_scope->DeclareLocal(avfactory->dot_catch_string(), VAR, 6461 catch_scope->DeclareLocal(avfactory->dot_catch_string(), VAR,
6458 kCreatedInitialized, Variable::NORMAL); 6462 kCreatedInitialized, Variable::NORMAL);
6463 catch_scope->set_is_hidden();
6459 6464
6460 Statement* rethrow; 6465 Statement* rethrow;
6461 // We use %ReThrow rather than the ordinary throw because we want to 6466 // We use %ReThrow rather than the ordinary throw because we want to
6462 // preserve the original exception message. This is also why we create a 6467 // preserve the original exception message. This is also why we create a
6463 // TryCatchStatementForReThrow below (which does not clear the pending 6468 // TryCatchStatementForReThrow below (which does not clear the pending
6464 // message), rather than a TryCatchStatement. 6469 // message), rather than a TryCatchStatement.
6465 { 6470 {
6466 auto args = new (zone) ZoneList<Expression*>(1, zone); 6471 auto args = new (zone) ZoneList<Expression*>(1, zone);
6467 args->Add(factory->NewVariableProxy(catch_variable), zone); 6472 args->Add(factory->NewVariableProxy(catch_variable), zone);
6468 rethrow = factory->NewExpressionStatement( 6473 rethrow = factory->NewExpressionStatement(
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
6560 Block* try_block = factory->NewBlock(nullptr, 1, false, nopos); 6565 Block* try_block = factory->NewBlock(nullptr, 1, false, nopos);
6561 try_block->statements()->Add(factory->NewExpressionStatement(call, nopos), 6566 try_block->statements()->Add(factory->NewExpressionStatement(call, nopos),
6562 zone); 6567 zone);
6563 6568
6564 Block* catch_block = factory->NewBlock(nullptr, 0, false, nopos); 6569 Block* catch_block = factory->NewBlock(nullptr, 0, false, nopos);
6565 6570
6566 Scope* catch_scope = NewScope(scope, CATCH_SCOPE); 6571 Scope* catch_scope = NewScope(scope, CATCH_SCOPE);
6567 Variable* catch_variable = catch_scope->DeclareLocal( 6572 Variable* catch_variable = catch_scope->DeclareLocal(
6568 avfactory->dot_catch_string(), VAR, kCreatedInitialized, 6573 avfactory->dot_catch_string(), VAR, kCreatedInitialized,
6569 Variable::NORMAL); 6574 Variable::NORMAL);
6575 catch_scope->set_is_hidden();
6570 6576
6571 try_call_return = factory->NewTryCatchStatement( 6577 try_call_return = factory->NewTryCatchStatement(
6572 try_block, catch_scope, catch_variable, catch_block, nopos); 6578 try_block, catch_scope, catch_variable, catch_block, nopos);
6573 } 6579 }
6574 6580
6575 // let output = %_Call(iteratorReturn, iterator); 6581 // let output = %_Call(iteratorReturn, iterator);
6576 // if (!IS_RECEIVER(output)) { 6582 // if (!IS_RECEIVER(output)) {
6577 // %ThrowIteratorResultNotAnObject(output); 6583 // %ThrowIteratorResultNotAnObject(output);
6578 // } 6584 // }
6579 Block* validate_return; 6585 Block* validate_return;
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
6787 try_block, target); 6793 try_block, target);
6788 final_loop = target; 6794 final_loop = target;
6789 } 6795 }
6790 6796
6791 return final_loop; 6797 return final_loop;
6792 } 6798 }
6793 6799
6794 6800
6795 } // namespace internal 6801 } // namespace internal
6796 } // namespace v8 6802 } // namespace v8
OLDNEW
« no previous file with comments | « src/debug/debug-scopes.cc ('k') | test/mjsunit/debug-scopes.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698