| 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-rewriter.h" | 9 #include "src/ast/ast-expression-rewriter.h" |
| 10 #include "src/ast/ast-expression-visitor.h" | 10 #include "src/ast/ast-expression-visitor.h" |
| (...skipping 4518 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4529 | 4529 |
| 4530 class InitializerRewriter : public AstExpressionVisitor { | 4530 class InitializerRewriter : public AstExpressionVisitor { |
| 4531 public: | 4531 public: |
| 4532 InitializerRewriter(uintptr_t stack_limit, Expression* root, Parser* parser, | 4532 InitializerRewriter(uintptr_t stack_limit, Expression* root, Parser* parser, |
| 4533 Scope* scope) | 4533 Scope* scope) |
| 4534 : AstExpressionVisitor(stack_limit, root), | 4534 : AstExpressionVisitor(stack_limit, root), |
| 4535 parser_(parser), | 4535 parser_(parser), |
| 4536 scope_(scope) {} | 4536 scope_(scope) {} |
| 4537 | 4537 |
| 4538 private: | 4538 private: |
| 4539 void VisitExpression(Expression* expr) { | 4539 void VisitExpression(Expression* expr) override { |
| 4540 RewritableExpression* to_rewrite = expr->AsRewritableExpression(); | 4540 RewritableExpression* to_rewrite = expr->AsRewritableExpression(); |
| 4541 if (to_rewrite == nullptr || to_rewrite->is_rewritten()) return; | 4541 if (to_rewrite == nullptr || to_rewrite->is_rewritten()) return; |
| 4542 | 4542 |
| 4543 Parser::PatternRewriter::RewriteDestructuringAssignment(parser_, to_rewrite, | 4543 Parser::PatternRewriter::RewriteDestructuringAssignment(parser_, to_rewrite, |
| 4544 scope_); | 4544 scope_); |
| 4545 } | 4545 } |
| 4546 | 4546 |
| 4547 // Code in function literals does not need to be eagerly rewritten, it will be |
| 4548 // rewritten when scheduled. |
| 4549 void VisitFunctionLiteral(FunctionLiteral* expr) override {} |
| 4550 |
| 4547 private: | 4551 private: |
| 4548 Parser* parser_; | 4552 Parser* parser_; |
| 4549 Scope* scope_; | 4553 Scope* scope_; |
| 4550 }; | 4554 }; |
| 4551 | 4555 |
| 4552 | 4556 |
| 4553 void Parser::RewriteParameterInitializer(Expression* expr, Scope* scope) { | 4557 void Parser::RewriteParameterInitializer(Expression* expr, Scope* scope) { |
| 4554 InitializerRewriter rewriter(stack_limit_, expr, this, scope); | 4558 InitializerRewriter rewriter(stack_limit_, expr, this, scope); |
| 4555 rewriter.Run(); | 4559 rewriter.Run(); |
| 4556 } | 4560 } |
| (...skipping 2343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6900 new_body->statements()->Add(loop->body(), zone); | 6904 new_body->statements()->Add(loop->body(), zone); |
| 6901 new_body->statements()->Add(set_completion_normal, zone); | 6905 new_body->statements()->Add(set_completion_normal, zone); |
| 6902 | 6906 |
| 6903 loop->set_body(new_body); | 6907 loop->set_body(new_body); |
| 6904 return final_loop; | 6908 return final_loop; |
| 6905 } | 6909 } |
| 6906 | 6910 |
| 6907 | 6911 |
| 6908 } // namespace internal | 6912 } // namespace internal |
| 6909 } // namespace v8 | 6913 } // namespace v8 |
| OLD | NEW |