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

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

Issue 2445993002: Drop unused end-position from VariableProxy (Closed)
Patch Set: Addressed comment Created 4 years, 1 month 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/parsing/parser.h ('k') | src/parsing/parser-base.h » ('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 <memory> 7 #include <memory>
8 8
9 #include "src/api.h" 9 #include "src/api.h"
10 #include "src/ast/ast-expression-rewriter.h" 10 #include "src/ast/ast-expression-rewriter.h"
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
471 VariableProxy* new_target_proxy = 471 VariableProxy* new_target_proxy =
472 NewUnresolved(ast_value_factory()->new_target_string(), pos); 472 NewUnresolved(ast_value_factory()->new_target_string(), pos);
473 VariableProxy* this_function_proxy = 473 VariableProxy* this_function_proxy =
474 NewUnresolved(ast_value_factory()->this_function_string(), pos); 474 NewUnresolved(ast_value_factory()->this_function_string(), pos);
475 return factory()->NewSuperCallReference( 475 return factory()->NewSuperCallReference(
476 ThisExpression(pos)->AsVariableProxy(), new_target_proxy, 476 ThisExpression(pos)->AsVariableProxy(), new_target_proxy,
477 this_function_proxy, pos); 477 this_function_proxy, pos);
478 } 478 }
479 479
480 Expression* Parser::NewTargetExpression(int pos) { 480 Expression* Parser::NewTargetExpression(int pos) {
481 static const int kNewTargetStringLength = 10; 481 auto proxy = NewUnresolved(ast_value_factory()->new_target_string(), pos);
482 auto proxy = NewUnresolved(ast_value_factory()->new_target_string(), pos,
483 pos + kNewTargetStringLength);
484 proxy->set_is_new_target(); 482 proxy->set_is_new_target();
485 return proxy; 483 return proxy;
486 } 484 }
487 485
488 Expression* Parser::FunctionSentExpression(int pos) { 486 Expression* Parser::FunctionSentExpression(int pos) {
489 // We desugar function.sent into %_GeneratorGetInputOrDebugPos(generator). 487 // We desugar function.sent into %_GeneratorGetInputOrDebugPos(generator).
490 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone()); 488 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(1, zone());
491 VariableProxy* generator = 489 VariableProxy* generator =
492 factory()->NewVariableProxy(function_state_->generator_object_variable()); 490 factory()->NewVariableProxy(function_state_->generator_object_variable());
493 args->Add(generator, zone()); 491 args->Add(generator, zone());
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 for (int i = 0; i < names.length(); ++i) { 1439 for (int i = 0; i < names.length(); ++i) {
1442 // TODO(neis): Provide better location. 1440 // TODO(neis): Provide better location.
1443 descriptor->AddExport(names[i], names[i], scanner()->location(), zone()); 1441 descriptor->AddExport(names[i], names[i], scanner()->location(), zone());
1444 } 1442 }
1445 1443
1446 DCHECK_NOT_NULL(result); 1444 DCHECK_NOT_NULL(result);
1447 return result; 1445 return result;
1448 } 1446 }
1449 1447
1450 VariableProxy* Parser::NewUnresolved(const AstRawString* name, int begin_pos, 1448 VariableProxy* Parser::NewUnresolved(const AstRawString* name, int begin_pos,
1451 int end_pos, VariableKind kind) { 1449 VariableKind kind) {
1452 return scope()->NewUnresolved(factory(), name, begin_pos, end_pos, kind); 1450 return scope()->NewUnresolved(factory(), name, begin_pos, kind);
1453 } 1451 }
1454 1452
1455 VariableProxy* Parser::NewUnresolved(const AstRawString* name) { 1453 VariableProxy* Parser::NewUnresolved(const AstRawString* name) {
1456 return scope()->NewUnresolved(factory(), name, scanner()->location().beg_pos, 1454 return scope()->NewUnresolved(factory(), name, scanner()->location().beg_pos);
1457 scanner()->location().end_pos);
1458 } 1455 }
1459 1456
1460 Declaration* Parser::DeclareVariable(const AstRawString* name, 1457 Declaration* Parser::DeclareVariable(const AstRawString* name,
1461 VariableMode mode, int pos, bool* ok) { 1458 VariableMode mode, int pos, bool* ok) {
1462 return DeclareVariable(name, mode, Variable::DefaultInitializationFlag(mode), 1459 return DeclareVariable(name, mode, Variable::DefaultInitializationFlag(mode),
1463 pos, ok); 1460 pos, ok);
1464 } 1461 }
1465 1462
1466 Declaration* Parser::DeclareVariable(const AstRawString* name, 1463 Declaration* Parser::DeclareVariable(const AstRawString* name,
1467 VariableMode mode, InitializationFlag init, 1464 VariableMode mode, InitializationFlag init,
1468 int pos, bool* ok) { 1465 int pos, bool* ok) {
1469 DCHECK_NOT_NULL(name); 1466 DCHECK_NOT_NULL(name);
1470 VariableProxy* proxy = factory()->NewVariableProxy( 1467 VariableProxy* proxy = factory()->NewVariableProxy(
1471 name, NORMAL_VARIABLE, scanner()->location().beg_pos, 1468 name, NORMAL_VARIABLE, scanner()->location().beg_pos);
1472 scanner()->location().end_pos);
1473 Declaration* declaration = 1469 Declaration* declaration =
1474 factory()->NewVariableDeclaration(proxy, this->scope(), pos); 1470 factory()->NewVariableDeclaration(proxy, this->scope(), pos);
1475 Declare(declaration, DeclarationDescriptor::NORMAL, mode, init, CHECK_OK); 1471 Declare(declaration, DeclarationDescriptor::NORMAL, mode, init, CHECK_OK);
1476 return declaration; 1472 return declaration;
1477 } 1473 }
1478 1474
1479 Declaration* Parser::DeclareModuleImport(const AstRawString* name, int pos, 1475 Declaration* Parser::DeclareModuleImport(const AstRawString* name, int pos,
1480 bool* ok) { 1476 bool* ok) {
1481 DCHECK_EQ(MODULE_SCOPE, scope()->scope_type()); 1477 DCHECK_EQ(MODULE_SCOPE, scope()->scope_type());
1482 Declaration* decl = 1478 Declaration* decl =
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after
2005 return; 2001 return;
2006 } 2002 }
2007 } 2003 }
2008 catch_scope = catch_scope->outer_scope(); 2004 catch_scope = catch_scope->outer_scope();
2009 } 2005 }
2010 } 2006 }
2011 } 2007 }
2012 2008
2013 *body_block = factory()->NewBlock(nullptr, 3, false, kNoSourcePosition); 2009 *body_block = factory()->NewBlock(nullptr, 3, false, kNoSourcePosition);
2014 (*body_block)->statements()->Add(each_initialization_block, zone()); 2010 (*body_block)->statements()->Add(each_initialization_block, zone());
2015 *each_variable = factory()->NewVariableProxy(temp, for_info->each_loc.beg_pos, 2011 *each_variable = factory()->NewVariableProxy(temp, for_info->position);
2016 for_info->each_loc.end_pos);
2017 } 2012 }
2018 2013
2019 // Create a TDZ for any lexically-bound names in for in/of statements. 2014 // Create a TDZ for any lexically-bound names in for in/of statements.
2020 Block* Parser::CreateForEachStatementTDZ(Block* init_block, 2015 Block* Parser::CreateForEachStatementTDZ(Block* init_block,
2021 const ForInfo& for_info, bool* ok) { 2016 const ForInfo& for_info, bool* ok) {
2022 if (IsLexicalVariableMode(for_info.parsing_result.descriptor.mode)) { 2017 if (IsLexicalVariableMode(for_info.parsing_result.descriptor.mode)) {
2023 DCHECK_NULL(init_block); 2018 DCHECK_NULL(init_block);
2024 2019
2025 init_block = factory()->NewBlock(nullptr, 1, false, kNoSourcePosition); 2020 init_block = factory()->NewBlock(nullptr, 1, false, kNoSourcePosition);
2026 2021
(...skipping 1381 matching lines...) Expand 10 before | Expand all | Expand 10 after
3408 return function_literal; 3403 return function_literal;
3409 } 3404 }
3410 3405
3411 FunctionLiteral* Parser::InsertClassFieldInitializer( 3406 FunctionLiteral* Parser::InsertClassFieldInitializer(
3412 FunctionLiteral* constructor) { 3407 FunctionLiteral* constructor) {
3413 Statement* call_initializer = factory()->NewExpressionStatement( 3408 Statement* call_initializer = factory()->NewExpressionStatement(
3414 CallClassFieldInitializer( 3409 CallClassFieldInitializer(
3415 constructor->scope(), 3410 constructor->scope(),
3416 constructor->scope()->NewUnresolved( 3411 constructor->scope()->NewUnresolved(
3417 factory(), ast_value_factory()->this_string(), kNoSourcePosition, 3412 factory(), ast_value_factory()->this_string(), kNoSourcePosition,
3418 kNoSourcePosition + 4, THIS_VARIABLE)), 3413 THIS_VARIABLE)),
3419 kNoSourcePosition); 3414 kNoSourcePosition);
3420 constructor->body()->InsertAt(0, call_initializer, zone()); 3415 constructor->body()->InsertAt(0, call_initializer, zone());
3421 return constructor; 3416 return constructor;
3422 } 3417 }
3423 3418
3424 // If a class name is specified, this method declares the class variable 3419 // If a class name is specified, this method declares the class variable
3425 // and sets class_info->proxy to point to that name. 3420 // and sets class_info->proxy to point to that name.
3426 void Parser::DeclareClassVariable(const AstRawString* name, Scope* block_scope, 3421 void Parser::DeclareClassVariable(const AstRawString* name, Scope* block_scope,
3427 ClassInfo* class_info, int class_token_pos, 3422 ClassInfo* class_info, int class_token_pos,
3428 bool* ok) { 3423 bool* ok) {
(...skipping 866 matching lines...) Expand 10 before | Expand all | Expand 10 after
4295 } 4290 }
4296 4291
4297 Expression* Parser::RewriteAssignExponentiation(Expression* left, 4292 Expression* Parser::RewriteAssignExponentiation(Expression* left,
4298 Expression* right, int pos) { 4293 Expression* right, int pos) {
4299 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone()); 4294 ZoneList<Expression*>* args = new (zone()) ZoneList<Expression*>(2, zone());
4300 if (left->IsVariableProxy()) { 4295 if (left->IsVariableProxy()) {
4301 VariableProxy* lhs = left->AsVariableProxy(); 4296 VariableProxy* lhs = left->AsVariableProxy();
4302 4297
4303 Expression* result; 4298 Expression* result;
4304 DCHECK_NOT_NULL(lhs->raw_name()); 4299 DCHECK_NOT_NULL(lhs->raw_name());
4305 result = ExpressionFromIdentifier(lhs->raw_name(), lhs->position(), 4300 result = ExpressionFromIdentifier(lhs->raw_name(), lhs->position());
4306 lhs->end_position());
4307 args->Add(left, zone()); 4301 args->Add(left, zone());
4308 args->Add(right, zone()); 4302 args->Add(right, zone());
4309 Expression* call = 4303 Expression* call =
4310 factory()->NewCallRuntime(Context::MATH_POW_INDEX, args, pos); 4304 factory()->NewCallRuntime(Context::MATH_POW_INDEX, args, pos);
4311 return factory()->NewAssignment(Token::ASSIGN, result, call, pos); 4305 return factory()->NewAssignment(Token::ASSIGN, result, call, pos);
4312 } else if (left->IsProperty()) { 4306 } else if (left->IsProperty()) {
4313 Property* prop = left->AsProperty(); 4307 Property* prop = left->AsProperty();
4314 auto temp_obj = NewTemporary(ast_value_factory()->empty_string()); 4308 auto temp_obj = NewTemporary(ast_value_factory()->empty_string());
4315 auto temp_key = NewTemporary(ast_value_factory()->empty_string()); 4309 auto temp_key = NewTemporary(ast_value_factory()->empty_string());
4316 Expression* assign_obj = factory()->NewAssignment( 4310 Expression* assign_obj = factory()->NewAssignment(
(...skipping 1092 matching lines...) Expand 10 before | Expand all | Expand 10 after
5409 5403
5410 return final_loop; 5404 return final_loop;
5411 } 5405 }
5412 5406
5413 #undef CHECK_OK 5407 #undef CHECK_OK
5414 #undef CHECK_OK_VOID 5408 #undef CHECK_OK_VOID
5415 #undef CHECK_FAILED 5409 #undef CHECK_FAILED
5416 5410
5417 } // namespace internal 5411 } // namespace internal
5418 } // namespace v8 5412 } // namespace v8
OLDNEW
« no previous file with comments | « src/parsing/parser.h ('k') | src/parsing/parser-base.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698