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 // let super_constructor = %_GetSuperConstructor(<this-function>) | 364 // $super_constructor = %_GetSuperConstructor(<this-function>) |
365 // %_DefaultConstructorCallSuper(new.target, super_constructor) | 365 // %reflect_construct($super_constructor, arguments, new.target) |
366 ZoneList<Expression*>* args = | 366 ZoneList<Expression*>* args = |
367 new (zone()) ZoneList<Expression*>(2, zone()); | 367 new (zone()) ZoneList<Expression*>(2, zone()); |
368 VariableProxy* new_target_proxy = scope_->NewUnresolved( | |
369 factory(), ast_value_factory()->new_target_string(), Variable::NORMAL, | |
370 pos); | |
371 args->Add(new_target_proxy, zone()); | |
372 VariableProxy* this_function_proxy = scope_->NewUnresolved( | 368 VariableProxy* this_function_proxy = scope_->NewUnresolved( |
373 factory(), ast_value_factory()->this_function_string(), | 369 factory(), ast_value_factory()->this_function_string(), |
374 Variable::NORMAL, pos); | 370 Variable::NORMAL, pos); |
375 ZoneList<Expression*>* tmp = | 371 ZoneList<Expression*>* tmp = |
376 new (zone()) ZoneList<Expression*>(1, zone()); | 372 new (zone()) ZoneList<Expression*>(1, zone()); |
377 tmp->Add(this_function_proxy, zone()); | 373 tmp->Add(this_function_proxy, zone()); |
378 Expression* super_constructor = factory()->NewCallRuntime( | 374 Expression* super_constructor = factory()->NewCallRuntime( |
379 Runtime::kInlineGetSuperConstructor, tmp, pos); | 375 Runtime::kInlineGetSuperConstructor, tmp, pos); |
380 args->Add(super_constructor, zone()); | 376 args->Add(super_constructor, zone()); |
| 377 VariableProxy* arguments_proxy = scope_->NewUnresolved( |
| 378 factory(), ast_value_factory()->arguments_string(), Variable::NORMAL, |
| 379 pos); |
| 380 args->Add(arguments_proxy, zone()); |
| 381 VariableProxy* new_target_proxy = scope_->NewUnresolved( |
| 382 factory(), ast_value_factory()->new_target_string(), Variable::NORMAL, |
| 383 pos); |
| 384 args->Add(new_target_proxy, zone()); |
381 CallRuntime* call = factory()->NewCallRuntime( | 385 CallRuntime* call = factory()->NewCallRuntime( |
382 Runtime::kInlineDefaultConstructorCallSuper, args, pos); | 386 Context::REFLECT_CONSTRUCT_INDEX, args, pos); |
383 body->Add(factory()->NewReturnStatement(call, pos), zone()); | 387 body->Add(factory()->NewReturnStatement(call, pos), zone()); |
384 } | 388 } |
385 | 389 |
386 materialized_literal_count = function_state.materialized_literal_count(); | 390 materialized_literal_count = function_state.materialized_literal_count(); |
387 expected_property_count = function_state.expected_property_count(); | 391 expected_property_count = function_state.expected_property_count(); |
388 } | 392 } |
389 | 393 |
390 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( | 394 FunctionLiteral* function_literal = factory()->NewFunctionLiteral( |
391 name, ast_value_factory(), function_scope, body, | 395 name, ast_value_factory(), function_scope, body, |
392 materialized_literal_count, expected_property_count, parameter_count, | 396 materialized_literal_count, expected_property_count, parameter_count, |
(...skipping 6034 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6427 } | 6431 } |
6428 UNREACHABLE(); | 6432 UNREACHABLE(); |
6429 } | 6433 } |
6430 | 6434 |
6431 | 6435 |
6432 Expression* Parser::SpreadCall(Expression* function, | 6436 Expression* Parser::SpreadCall(Expression* function, |
6433 ZoneList<v8::internal::Expression*>* args, | 6437 ZoneList<v8::internal::Expression*>* args, |
6434 int pos) { | 6438 int pos) { |
6435 if (function->IsSuperCallReference()) { | 6439 if (function->IsSuperCallReference()) { |
6436 // Super calls | 6440 // Super calls |
6437 // let super_constructor = %_GetSuperConstructor(<this-function>) | 6441 // $super_constructor = %_GetSuperConstructor(<this-function>) |
6438 // %reflect_construct(super_constructor, args, new.target) | 6442 // %reflect_construct($super_constructor, args, new.target) |
6439 ZoneList<Expression*>* tmp = new (zone()) ZoneList<Expression*>(1, zone()); | 6443 ZoneList<Expression*>* tmp = new (zone()) ZoneList<Expression*>(1, zone()); |
6440 tmp->Add(function->AsSuperCallReference()->this_function_var(), zone()); | 6444 tmp->Add(function->AsSuperCallReference()->this_function_var(), zone()); |
6441 Expression* super_constructor = factory()->NewCallRuntime( | 6445 Expression* super_constructor = factory()->NewCallRuntime( |
6442 Runtime::kInlineGetSuperConstructor, tmp, pos); | 6446 Runtime::kInlineGetSuperConstructor, tmp, pos); |
6443 args->InsertAt(0, super_constructor, zone()); | 6447 args->InsertAt(0, super_constructor, zone()); |
6444 args->Add(function->AsSuperCallReference()->new_target_var(), zone()); | 6448 args->Add(function->AsSuperCallReference()->new_target_var(), zone()); |
6445 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, | 6449 return factory()->NewCallRuntime(Context::REFLECT_CONSTRUCT_INDEX, args, |
6446 pos); | 6450 pos); |
6447 } else { | 6451 } else { |
6448 if (function->IsProperty()) { | 6452 if (function->IsProperty()) { |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6536 | 6540 |
6537 void ParserTraits::QueueDestructuringAssignmentForRewriting(Expression* expr) { | 6541 void ParserTraits::QueueDestructuringAssignmentForRewriting(Expression* expr) { |
6538 DCHECK(expr->IsRewritableAssignmentExpression()); | 6542 DCHECK(expr->IsRewritableAssignmentExpression()); |
6539 parser_->function_state_->AddDestructuringAssignment( | 6543 parser_->function_state_->AddDestructuringAssignment( |
6540 Parser::DestructuringAssignment(expr, parser_->scope_)); | 6544 Parser::DestructuringAssignment(expr, parser_->scope_)); |
6541 } | 6545 } |
6542 | 6546 |
6543 | 6547 |
6544 } // namespace internal | 6548 } // namespace internal |
6545 } // namespace v8 | 6549 } // namespace v8 |
OLD | NEW |