| OLD | NEW |
| 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-visitor.h" | 9 #include "src/ast/ast-expression-visitor.h" |
| 10 #include "src/ast/ast-literal-reindexer.h" | 10 #include "src/ast/ast-literal-reindexer.h" |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 function_scope->set_end_position(pos); | 354 function_scope->set_end_position(pos); |
| 355 ZoneList<Statement*>* body = NULL; | 355 ZoneList<Statement*>* body = NULL; |
| 356 | 356 |
| 357 { | 357 { |
| 358 AstNodeFactory function_factory(ast_value_factory()); | 358 AstNodeFactory function_factory(ast_value_factory()); |
| 359 FunctionState function_state(&function_state_, &scope_, function_scope, | 359 FunctionState function_state(&function_state_, &scope_, function_scope, |
| 360 kind, &function_factory); | 360 kind, &function_factory); |
| 361 | 361 |
| 362 body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone()); | 362 body = new (zone()) ZoneList<Statement*>(call_super ? 2 : 1, zone()); |
| 363 if (call_super) { | 363 if (call_super) { |
| 364 // %_DefaultConstructorCallSuper(new.target, %GetPrototype(<this-fun>)) | 364 // let super_constructor = %_GetSuperConstructor(<this-function>) |
| 365 // %_DefaultConstructorCallSuper(new.target, super_constructor) |
| 365 ZoneList<Expression*>* args = | 366 ZoneList<Expression*>* args = |
| 366 new (zone()) ZoneList<Expression*>(2, zone()); | 367 new (zone()) ZoneList<Expression*>(2, zone()); |
| 367 VariableProxy* new_target_proxy = scope_->NewUnresolved( | 368 VariableProxy* new_target_proxy = scope_->NewUnresolved( |
| 368 factory(), ast_value_factory()->new_target_string(), Variable::NORMAL, | 369 factory(), ast_value_factory()->new_target_string(), Variable::NORMAL, |
| 369 pos); | 370 pos); |
| 370 args->Add(new_target_proxy, zone()); | 371 args->Add(new_target_proxy, zone()); |
| 371 VariableProxy* this_function_proxy = scope_->NewUnresolved( | 372 VariableProxy* this_function_proxy = scope_->NewUnresolved( |
| 372 factory(), ast_value_factory()->this_function_string(), | 373 factory(), ast_value_factory()->this_function_string(), |
| 373 Variable::NORMAL, pos); | 374 Variable::NORMAL, pos); |
| 374 ZoneList<Expression*>* tmp = | 375 ZoneList<Expression*>* tmp = |
| 375 new (zone()) ZoneList<Expression*>(1, zone()); | 376 new (zone()) ZoneList<Expression*>(1, zone()); |
| 376 tmp->Add(this_function_proxy, zone()); | 377 tmp->Add(this_function_proxy, zone()); |
| 377 Expression* get_prototype = | 378 Expression* super_constructor = factory()->NewCallRuntime( |
| 378 factory()->NewCallRuntime(Runtime::kGetPrototype, tmp, pos); | 379 Runtime::kInlineGetSuperConstructor, tmp, pos); |
| 379 args->Add(get_prototype, zone()); | 380 args->Add(super_constructor, zone()); |
| 380 CallRuntime* call = factory()->NewCallRuntime( | 381 CallRuntime* call = factory()->NewCallRuntime( |
| 381 Runtime::kInlineDefaultConstructorCallSuper, args, pos); | 382 Runtime::kInlineDefaultConstructorCallSuper, args, pos); |
| 382 body->Add(factory()->NewReturnStatement(call, pos), zone()); | 383 body->Add(factory()->NewReturnStatement(call, pos), zone()); |
| 383 } | 384 } |
| 384 | 385 |
| 385 materialized_literal_count = function_state.materialized_literal_count(); | 386 materialized_literal_count = function_state.materialized_literal_count(); |
| 386 expected_property_count = function_state.expected_property_count(); | 387 expected_property_count = function_state.expected_property_count(); |
| 387 } | 388 } |
| 388 | 389 |
| 389 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( | 390 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( |
| (...skipping 6036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6426 } | 6427 } |
| 6427 UNREACHABLE(); | 6428 UNREACHABLE(); |
| 6428 } | 6429 } |
| 6429 | 6430 |
| 6430 | 6431 |
| 6431 Expression* Parser::SpreadCall(Expression* function, | 6432 Expression* Parser::SpreadCall(Expression* function, |
| 6432 ZoneList<v8::internal::Expression*>* args, | 6433 ZoneList<v8::internal::Expression*>* args, |
| 6433 int pos) { | 6434 int pos) { |
| 6434 if (function->IsSuperCallReference()) { | 6435 if (function->IsSuperCallReference()) { |
| 6435 // Super calls | 6436 // Super calls |
| 6436 // %reflect_construct(%GetPrototype(<this-function>), args, new.target)) | 6437 // let super_constructor = %_GetSuperConstructor(<this-function>) |
| 6438 // %reflect_construct(super_constructor, args, new.target) |
| 6437 ZoneList<Expression*>* tmp = new (zone()) ZoneList<Expression*>(1, zone()); | 6439 ZoneList<Expression*>* tmp = new (zone()) ZoneList<Expression*>(1, zone()); |
| 6438 tmp->Add(function->AsSuperCallReference()->this_function_var(), zone()); | 6440 tmp->Add(function->AsSuperCallReference()->this_function_var(), zone()); |
| 6439 Expression* get_prototype = | 6441 Expression* super_constructor = factory()->NewCallRuntime( |
| 6440 factory()->NewCallRuntime(Runtime::kGetPrototype, tmp, pos); | 6442 Runtime::kInlineGetSuperConstructor, tmp, pos); |
| 6441 args->InsertAt(0, get_prototype, zone()); | 6443 args->InsertAt(0, super_constructor, zone()); |
| 6442 args->Add(function->AsSuperCallReference()->new_target_var(), zone()); | 6444 args->Add(function->AsSuperCallReference()->new_target_var(), zone()); |
| 6443 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, | 6445 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, |
| 6444 pos); | 6446 pos); |
| 6445 } else { | 6447 } else { |
| 6446 if (function->IsProperty()) { | 6448 if (function->IsProperty()) { |
| 6447 // Method calls | 6449 // Method calls |
| 6448 if (function->AsProperty()->IsSuperAccess()) { | 6450 if (function->AsProperty()->IsSuperAccess()) { |
| 6449 Expression* home = | 6451 Expression* home = |
| 6450 ThisExpression(scope_, factory(), RelocInfo::kNoPosition); | 6452 ThisExpression(scope_, factory(), RelocInfo::kNoPosition); |
| 6451 args->InsertAt(0, function, zone()); | 6453 args->InsertAt(0, function, zone()); |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6534 | 6536 |
| 6535 void ParserTraits::QueueDestructuringAssignmentForRewriting(Expression* expr) { | 6537 void ParserTraits::QueueDestructuringAssignmentForRewriting(Expression* expr) { |
| 6536 DCHECK(expr->IsRewritableAssignmentExpression()); | 6538 DCHECK(expr->IsRewritableAssignmentExpression()); |
| 6537 parser_->function_state_->AddDestructuringAssignment( | 6539 parser_->function_state_->AddDestructuringAssignment( |
| 6538 Parser::DestructuringAssignment(expr, parser_->scope_)); | 6540 Parser::DestructuringAssignment(expr, parser_->scope_)); |
| 6539 } | 6541 } |
| 6540 | 6542 |
| 6541 | 6543 |
| 6542 } // namespace internal | 6544 } // namespace internal |
| 6543 } // namespace v8 | 6545 } // namespace v8 |
| OLD | NEW |