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

Side by Side Diff: src/ast-numbering.cc

Issue 1053773006: [es6] implement default/optional parameters (WIP / comments) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Experimental not-quite-TDZ support Created 5 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/ast.h ('k') | src/ast-value-factory.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/v8.h" 5 #include "src/v8.h"
6 6
7 #include "src/ast.h" 7 #include "src/ast.h"
8 #include "src/ast-numbering.h" 8 #include "src/ast-numbering.h"
9 #include "src/scopes.h" 9 #include "src/scopes.h"
10 10
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 void AstNumberingVisitor::VisitArguments(ZoneList<Expression*>* arguments) { 516 void AstNumberingVisitor::VisitArguments(ZoneList<Expression*>* arguments) {
517 for (int i = 0; i < arguments->length(); i++) { 517 for (int i = 0; i < arguments->length(); i++) {
518 Visit(arguments->at(i)); 518 Visit(arguments->at(i));
519 } 519 }
520 } 520 }
521 521
522 522
523 void AstNumberingVisitor::VisitFunctionLiteral(FunctionLiteral* node) { 523 void AstNumberingVisitor::VisitFunctionLiteral(FunctionLiteral* node) {
524 IncrementNodeCount(); 524 IncrementNodeCount();
525 node->set_base_id(ReserveIdRange(FunctionLiteral::num_ids())); 525 node->set_base_id(ReserveIdRange(FunctionLiteral::num_ids()));
526 if (node->default_values()->length()) {
527 VisitArguments(node->default_values());
528 }
529
526 // We don't recurse into the declarations or body of the function literal: 530 // We don't recurse into the declarations or body of the function literal:
527 // you have to separately Renumber() each FunctionLiteral that you compile. 531 // you have to separately Renumber() each FunctionLiteral that you compile.
528 } 532 }
529 533
530 534
531 bool AstNumberingVisitor::Finish(FunctionLiteral* node) { 535 bool AstNumberingVisitor::Finish(FunctionLiteral* node) {
532 node->set_ast_properties(&properties_); 536 node->set_ast_properties(&properties_);
533 node->set_dont_optimize_reason(dont_optimize_reason()); 537 node->set_dont_optimize_reason(dont_optimize_reason());
534 return !HasStackOverflow(); 538 return !HasStackOverflow();
535 } 539 }
536 540
537 541
538 bool AstNumberingVisitor::Renumber(FunctionLiteral* node) { 542 bool AstNumberingVisitor::Renumber(FunctionLiteral* node) {
539 Scope* scope = node->scope(); 543 Scope* scope = node->scope();
540 544
541 if (scope->HasIllegalRedeclaration()) { 545 if (scope->HasIllegalRedeclaration()) {
542 scope->VisitIllegalRedeclaration(this); 546 scope->VisitIllegalRedeclaration(this);
543 DisableOptimization(kFunctionWithIllegalRedeclaration); 547 DisableOptimization(kFunctionWithIllegalRedeclaration);
544 return Finish(node); 548 return Finish(node);
545 } 549 }
546 if (scope->calls_eval()) DisableOptimization(kFunctionCallsEval); 550 if (scope->calls_eval()) DisableOptimization(kFunctionCallsEval);
547 if (scope->arguments() != NULL && !scope->arguments()->IsStackAllocated()) { 551 if (scope->arguments() != NULL && !scope->arguments()->IsStackAllocated()) {
548 DisableOptimization(kContextAllocatedArguments); 552 DisableOptimization(kContextAllocatedArguments);
549 } 553 }
550 554
555 VisitExpressions(node->default_values());
556
551 VisitDeclarations(scope->declarations()); 557 VisitDeclarations(scope->declarations());
552 if (scope->is_function_scope() && scope->function() != NULL) { 558 if (scope->is_function_scope() && scope->function() != NULL) {
553 // Visit the name of the named function expression. 559 // Visit the name of the named function expression.
554 Visit(scope->function()); 560 Visit(scope->function());
555 } 561 }
556 VisitStatements(node->body()); 562 VisitStatements(node->body());
557 563
558 return Finish(node); 564 return Finish(node);
559 } 565 }
560 566
561 567
562 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone, 568 bool AstNumbering::Renumber(Isolate* isolate, Zone* zone,
563 FunctionLiteral* function) { 569 FunctionLiteral* function) {
564 AstNumberingVisitor visitor(isolate, zone); 570 AstNumberingVisitor visitor(isolate, zone);
565 return visitor.Renumber(function); 571 return visitor.Renumber(function);
566 } 572 }
567 } 573 }
568 } // namespace v8::internal 574 } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/ast.h ('k') | src/ast-value-factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698