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 <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 3526 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3537 if (expr->IsAssignment()) { | 3537 if (expr->IsAssignment()) { |
3538 Assignment* assignment = expr->AsAssignment(); | 3538 Assignment* assignment = expr->AsAssignment(); |
3539 DCHECK(!assignment->is_compound()); | 3539 DCHECK(!assignment->is_compound()); |
3540 initializer = assignment->value(); | 3540 initializer = assignment->value(); |
3541 expr = assignment->target(); | 3541 expr = assignment->target(); |
3542 } | 3542 } |
3543 | 3543 |
3544 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); | 3544 AddFormalParameter(parameters, expr, initializer, end_pos, is_rest); |
3545 } | 3545 } |
3546 | 3546 |
3547 void Parser::DesugarAsyncFunctionBody(const AstRawString* function_name, | 3547 void Parser::DesugarAsyncFunctionBody(Scope* scope, ZoneList<Statement*>* body, |
3548 Scope* scope, ZoneList<Statement*>* body, | |
3549 FunctionKind kind, | 3548 FunctionKind kind, |
3550 FunctionBodyType body_type, | 3549 FunctionBodyType body_type, |
3551 bool accept_IN, int pos, bool* ok) { | 3550 bool accept_IN, int pos, bool* ok) { |
3552 // function async_function() { | 3551 // function async_function() { |
3553 // .generator_object = %CreateGeneratorObject(); | 3552 // .generator_object = %CreateGeneratorObject(); |
3554 // BuildRejectPromiseOnException({ | 3553 // BuildRejectPromiseOnException({ |
3555 // ... function body ... | 3554 // ... function body ... |
3556 // return %ResolvePromise(.promise, expr), .promise; | 3555 // return %ResolvePromise(.promise, expr), .promise; |
3557 // }) | 3556 // }) |
3558 // } | 3557 // } |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4378 Expression* call = factory()->NewCallRuntime( | 4377 Expression* call = factory()->NewCallRuntime( |
4379 Runtime::kInlineGeneratorClose, args, kNoSourcePosition); | 4378 Runtime::kInlineGeneratorClose, args, kNoSourcePosition); |
4380 finally_block->statements()->Add( | 4379 finally_block->statements()->Add( |
4381 factory()->NewExpressionStatement(call, kNoSourcePosition), zone()); | 4380 factory()->NewExpressionStatement(call, kNoSourcePosition), zone()); |
4382 | 4381 |
4383 body->Add(factory()->NewTryFinallyStatement(try_block, finally_block, | 4382 body->Add(factory()->NewTryFinallyStatement(try_block, finally_block, |
4384 kNoSourcePosition), | 4383 kNoSourcePosition), |
4385 zone()); | 4384 zone()); |
4386 } else if (IsAsyncFunction(kind)) { | 4385 } else if (IsAsyncFunction(kind)) { |
4387 const bool accept_IN = true; | 4386 const bool accept_IN = true; |
4388 DesugarAsyncFunctionBody(function_name, inner_scope, body, kind, | 4387 DesugarAsyncFunctionBody(inner_scope, body, kind, |
4389 FunctionBodyType::kNormal, accept_IN, pos, | 4388 FunctionBodyType::kNormal, accept_IN, pos, |
4390 CHECK_OK); | 4389 CHECK_OK); |
4391 } else { | 4390 } else { |
4392 ParseStatementList(body, Token::RBRACE, CHECK_OK); | 4391 ParseStatementList(body, Token::RBRACE, CHECK_OK); |
4393 } | 4392 } |
4394 | 4393 |
4395 if (IsSubclassConstructor(kind)) { | 4394 if (IsSubclassConstructor(kind)) { |
4396 body->Add(factory()->NewReturnStatement(ThisExpression(kNoSourcePosition), | 4395 body->Add(factory()->NewReturnStatement(ThisExpression(kNoSourcePosition), |
4397 kNoSourcePosition), | 4396 kNoSourcePosition), |
4398 zone()); | 4397 zone()); |
(...skipping 2091 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
6490 node->Print(Isolate::Current()); | 6489 node->Print(Isolate::Current()); |
6491 } | 6490 } |
6492 #endif // DEBUG | 6491 #endif // DEBUG |
6493 | 6492 |
6494 #undef CHECK_OK | 6493 #undef CHECK_OK |
6495 #undef CHECK_OK_VOID | 6494 #undef CHECK_OK_VOID |
6496 #undef CHECK_FAILED | 6495 #undef CHECK_FAILED |
6497 | 6496 |
6498 } // namespace internal | 6497 } // namespace internal |
6499 } // namespace v8 | 6498 } // namespace v8 |
OLD | NEW |