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

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

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: rebased Created 4 years 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 3550 matching lines...) Expand 10 before | Expand all | Expand 10 after
3561 } 3561 }
3562 3562
3563 // This method rewrites a class literal into a do-expression. 3563 // This method rewrites a class literal into a do-expression.
3564 // It uses the following fields of class_info: 3564 // It uses the following fields of class_info:
3565 // - constructor (if missing, it updates it with a default constructor) 3565 // - constructor (if missing, it updates it with a default constructor)
3566 // - proxy 3566 // - proxy
3567 // - extends 3567 // - extends
3568 // - static_initializer_var 3568 // - static_initializer_var
3569 // - instance_field_initializers 3569 // - instance_field_initializers
3570 // - properties 3570 // - properties
3571 // - has_name_static_property
3572 // - has_static_computed_names
3571 Expression* Parser::RewriteClassLiteral(const AstRawString* name, 3573 Expression* Parser::RewriteClassLiteral(const AstRawString* name,
3572 ClassInfo* class_info, int pos, 3574 ClassInfo* class_info, int pos,
3573 bool* ok) { 3575 bool* ok) {
3574 int end_pos = scanner()->location().end_pos; 3576 int end_pos = scanner()->location().end_pos;
3575 Block* do_block = factory()->NewBlock(nullptr, 1, false, pos); 3577 Block* do_block = factory()->NewBlock(nullptr, 1, false, pos);
3576 Variable* result_var = NewTemporary(ast_value_factory()->empty_string()); 3578 Variable* result_var = NewTemporary(ast_value_factory()->empty_string());
3577 DoExpression* do_expr = factory()->NewDoExpression(do_block, result_var, pos); 3579 DoExpression* do_expr = factory()->NewDoExpression(do_block, result_var, pos);
3578 3580
3579 bool has_extends = class_info->extends != nullptr; 3581 bool has_extends = class_info->extends != nullptr;
3580 bool has_instance_fields = 3582 bool has_instance_fields =
(...skipping 14 matching lines...) Expand all
3595 3597
3596 scope()->set_end_position(end_pos); 3598 scope()->set_end_position(end_pos);
3597 3599
3598 if (name != nullptr) { 3600 if (name != nullptr) {
3599 DCHECK_NOT_NULL(class_info->proxy); 3601 DCHECK_NOT_NULL(class_info->proxy);
3600 class_info->proxy->var()->set_initializer_position(end_pos); 3602 class_info->proxy->var()->set_initializer_position(end_pos);
3601 } 3603 }
3602 3604
3603 ClassLiteral* class_literal = factory()->NewClassLiteral( 3605 ClassLiteral* class_literal = factory()->NewClassLiteral(
3604 class_info->proxy, class_info->extends, class_info->constructor, 3606 class_info->proxy, class_info->extends, class_info->constructor,
3605 class_info->properties, pos, end_pos); 3607 class_info->properties, pos, end_pos,
3608 class_info->has_name_static_property,
3609 class_info->has_static_computed_names);
3606 3610
3607 if (class_info->static_initializer_var != nullptr) { 3611 if (class_info->static_initializer_var != nullptr) {
3608 class_literal->set_static_initializer_proxy( 3612 class_literal->set_static_initializer_proxy(
3609 factory()->NewVariableProxy(class_info->static_initializer_var)); 3613 factory()->NewVariableProxy(class_info->static_initializer_var));
3610 } 3614 }
3611 3615
3612 do_block->statements()->Add( 3616 do_block->statements()->Add(
3613 factory()->NewExpressionStatement( 3617 factory()->NewExpressionStatement(
3614 factory()->NewAssignment(Token::ASSIGN, 3618 factory()->NewAssignment(Token::ASSIGN,
3615 factory()->NewVariableProxy(result_var), 3619 factory()->NewVariableProxy(result_var),
(...skipping 1860 matching lines...) Expand 10 before | Expand all | Expand 10 after
5476 5480
5477 return final_loop; 5481 return final_loop;
5478 } 5482 }
5479 5483
5480 #undef CHECK_OK 5484 #undef CHECK_OK
5481 #undef CHECK_OK_VOID 5485 #undef CHECK_OK_VOID
5482 #undef CHECK_FAILED 5486 #undef CHECK_FAILED
5483 5487
5484 } // namespace internal 5488 } // namespace internal
5485 } // namespace v8 5489 } // 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