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

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

Issue 2423053002: Install the 'name' property in classes at runtime (Closed)
Patch Set: Check for 'name' properties at parse-time 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
3513 Expression* Parser::RewriteClassLiteral(const AstRawString* name, 3514 Expression* Parser::RewriteClassLiteral(const AstRawString* name,
3514 ClassInfo* class_info, int pos, 3515 ClassInfo* class_info, int pos,
3515 bool* ok) { 3516 bool* ok) {
3516 int end_pos = scanner()->location().end_pos; 3517 int end_pos = scanner()->location().end_pos;
3517 Block* do_block = factory()->NewBlock(nullptr, 1, false, pos); 3518 Block* do_block = factory()->NewBlock(nullptr, 1, false, pos);
3518 Variable* result_var = NewTemporary(ast_value_factory()->empty_string()); 3519 Variable* result_var = NewTemporary(ast_value_factory()->empty_string());
3519 DoExpression* do_expr = factory()->NewDoExpression(do_block, result_var, pos); 3520 DoExpression* do_expr = factory()->NewDoExpression(do_block, result_var, pos);
3520 3521
3521 bool has_extends = class_info->extends != nullptr; 3522 bool has_extends = class_info->extends != nullptr;
3522 bool has_instance_fields = 3523 bool has_instance_fields =
(...skipping 14 matching lines...) Expand all
3537 3538
3538 scope()->set_end_position(end_pos); 3539 scope()->set_end_position(end_pos);
3539 3540
3540 if (name != nullptr) { 3541 if (name != nullptr) {
3541 DCHECK_NOT_NULL(class_info->proxy); 3542 DCHECK_NOT_NULL(class_info->proxy);
3542 class_info->proxy->var()->set_initializer_position(end_pos); 3543 class_info->proxy->var()->set_initializer_position(end_pos);
3543 } 3544 }
3544 3545
3545 ClassLiteral* class_literal = factory()->NewClassLiteral( 3546 ClassLiteral* class_literal = factory()->NewClassLiteral(
3546 class_info->proxy, class_info->extends, class_info->constructor, 3547 class_info->proxy, class_info->extends, class_info->constructor,
3547 class_info->properties, pos, end_pos); 3548 class_info->properties, pos, end_pos,
3549 class_info->has_name_static_property);
3548 3550
3549 if (class_info->static_initializer_var != nullptr) { 3551 if (class_info->static_initializer_var != nullptr) {
3550 class_literal->set_static_initializer_proxy( 3552 class_literal->set_static_initializer_proxy(
3551 factory()->NewVariableProxy(class_info->static_initializer_var)); 3553 factory()->NewVariableProxy(class_info->static_initializer_var));
3552 } 3554 }
3553 3555
3554 do_block->statements()->Add( 3556 do_block->statements()->Add(
3555 factory()->NewExpressionStatement( 3557 factory()->NewExpressionStatement(
3556 factory()->NewAssignment(Token::ASSIGN, 3558 factory()->NewAssignment(Token::ASSIGN,
3557 factory()->NewVariableProxy(result_var), 3559 factory()->NewVariableProxy(result_var),
(...skipping 1850 matching lines...) Expand 10 before | Expand all | Expand 10 after
5408 5410
5409 return final_loop; 5411 return final_loop;
5410 } 5412 }
5411 5413
5412 #undef CHECK_OK 5414 #undef CHECK_OK
5413 #undef CHECK_OK_VOID 5415 #undef CHECK_OK_VOID
5414 #undef CHECK_FAILED 5416 #undef CHECK_FAILED
5415 5417
5416 } // namespace internal 5418 } // namespace internal
5417 } // namespace v8 5419 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698