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

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

Issue 1626423003: Support computed properties for ES2015 Function.name (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Mostly working Created 4 years, 10 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
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 5720 matching lines...) Expand 10 before | Expand all | Expand 10 after
5731 parser_->function_state_->AddDestructuringAssignment( 5731 parser_->function_state_->AddDestructuringAssignment(
5732 Parser::DestructuringAssignment(expr, parser_->scope_)); 5732 Parser::DestructuringAssignment(expr, parser_->scope_));
5733 } 5733 }
5734 5734
5735 5735
5736 void ParserTraits::SetFunctionNameFromPropertyName( 5736 void ParserTraits::SetFunctionNameFromPropertyName(
5737 ObjectLiteralProperty* property, const AstRawString* name) { 5737 ObjectLiteralProperty* property, const AstRawString* name) {
5738 Expression* value = property->value(); 5738 Expression* value = property->value();
5739 if (!value->IsAnonymousFunctionDefinition()) return; 5739 if (!value->IsAnonymousFunctionDefinition()) return;
5740 5740
5741 // TODO(adamk): Support computed names. 5741 // Computed name setting must happen at runtime.
5742 if (property->is_computed_name()) return; 5742 if (property->is_computed_name()) return;
5743
5743 DCHECK_NOT_NULL(name); 5744 DCHECK_NOT_NULL(name);
5744 5745
5745 // Ignore "__proto__" as a name when it's being used to set the [[Prototype]] 5746 // Ignore "__proto__" as a name when it's being used to set the [[Prototype]]
5746 // of an object literal. 5747 // of an object literal.
5747 if (property->kind() == ObjectLiteralProperty::PROTOTYPE) return; 5748 if (property->kind() == ObjectLiteralProperty::PROTOTYPE) return;
5748 5749
5749 auto function = value->AsFunctionLiteral(); 5750 auto function = value->AsFunctionLiteral();
5750 if (function != nullptr) { 5751 if (function != nullptr) {
5751 if (property->kind() == ObjectLiteralProperty::GETTER) { 5752 if (property->kind() == ObjectLiteralProperty::GETTER) {
5752 function->set_raw_name(parser_->ast_value_factory()->NewConsString( 5753 function->set_raw_name(parser_->ast_value_factory()->NewConsString(
(...skipping 26 matching lines...) Expand all
5779 function->set_raw_name(name); 5780 function->set_raw_name(name);
5780 } else { 5781 } else {
5781 DCHECK(value->IsClassLiteral()); 5782 DCHECK(value->IsClassLiteral());
5782 value->AsClassLiteral()->constructor()->set_raw_name(name); 5783 value->AsClassLiteral()->constructor()->set_raw_name(name);
5783 } 5784 }
5784 } 5785 }
5785 5786
5786 5787
5787 } // namespace internal 5788 } // namespace internal
5788 } // namespace v8 5789 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698