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

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

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: Move computed property names check to parser and runtime function 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
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 3492 matching lines...) Expand 10 before | Expand all | Expand 10 after
3503 } 3503 }
3504 3504
3505 // This method rewrites a class literal into a do-expression. 3505 // This method rewrites a class literal into a do-expression.
3506 // It uses the following fields of class_info: 3506 // It uses the following fields of class_info:
3507 // - constructor (if missing, it updates it with a default constructor) 3507 // - constructor (if missing, it updates it with a default constructor)
3508 // - proxy 3508 // - proxy
3509 // - extends 3509 // - extends
3510 // - static_initializer_var 3510 // - static_initializer_var
3511 // - instance_field_initializers 3511 // - instance_field_initializers
3512 // - properties 3512 // - properties
3513 // - has_name_static_property
3514 // - has_static_computed_names
3513 Expression* Parser::RewriteClassLiteral(const AstRawString* name, 3515 Expression* Parser::RewriteClassLiteral(const AstRawString* name,
3514 ClassInfo* class_info, int pos, 3516 ClassInfo* class_info, int pos,
3515 bool* ok) { 3517 bool* ok) {
3516 int end_pos = scanner()->location().end_pos; 3518 int end_pos = scanner()->location().end_pos;
3517 Block* do_block = factory()->NewBlock(nullptr, 1, false, pos); 3519 Block* do_block = factory()->NewBlock(nullptr, 1, false, pos);
3518 Variable* result_var = NewTemporary(ast_value_factory()->empty_string()); 3520 Variable* result_var = NewTemporary(ast_value_factory()->empty_string());
3519 DoExpression* do_expr = factory()->NewDoExpression(do_block, result_var, pos); 3521 DoExpression* do_expr = factory()->NewDoExpression(do_block, result_var, pos);
3520 3522
3521 bool has_extends = class_info->extends != nullptr; 3523 bool has_extends = class_info->extends != nullptr;
3522 bool has_instance_fields = 3524 bool has_instance_fields =
(...skipping 14 matching lines...) Expand all
3537 3539
3538 scope()->set_end_position(end_pos); 3540 scope()->set_end_position(end_pos);
3539 3541
3540 if (name != nullptr) { 3542 if (name != nullptr) {
3541 DCHECK_NOT_NULL(class_info->proxy); 3543 DCHECK_NOT_NULL(class_info->proxy);
3542 class_info->proxy->var()->set_initializer_position(end_pos); 3544 class_info->proxy->var()->set_initializer_position(end_pos);
3543 } 3545 }
3544 3546
3545 ClassLiteral* class_literal = factory()->NewClassLiteral( 3547 ClassLiteral* class_literal = factory()->NewClassLiteral(
3546 class_info->proxy, class_info->extends, class_info->constructor, 3548 class_info->proxy, class_info->extends, class_info->constructor,
3547 class_info->properties, pos, end_pos); 3549 class_info->properties, pos, end_pos,
3550 class_info->has_name_static_property,
3551 class_info->has_static_computed_names);
3548 3552
3549 if (class_info->static_initializer_var != nullptr) { 3553 if (class_info->static_initializer_var != nullptr) {
3550 class_literal->set_static_initializer_proxy( 3554 class_literal->set_static_initializer_proxy(
3551 factory()->NewVariableProxy(class_info->static_initializer_var)); 3555 factory()->NewVariableProxy(class_info->static_initializer_var));
3552 } 3556 }
3553 3557
3554 do_block->statements()->Add( 3558 do_block->statements()->Add(
3555 factory()->NewExpressionStatement( 3559 factory()->NewExpressionStatement(
3556 factory()->NewAssignment(Token::ASSIGN, 3560 factory()->NewAssignment(Token::ASSIGN,
3557 factory()->NewVariableProxy(result_var), 3561 factory()->NewVariableProxy(result_var),
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after
5408 5412
5409 return final_loop; 5413 return final_loop;
5410 } 5414 }
5411 5415
5412 #undef CHECK_OK 5416 #undef CHECK_OK
5413 #undef CHECK_OK_VOID 5417 #undef CHECK_OK_VOID
5414 #undef CHECK_FAILED 5418 #undef CHECK_FAILED
5415 5419
5416 } // namespace internal 5420 } // namespace internal
5417 } // namespace v8 5421 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698