| 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/rewriter.h" | 5 #include "src/parsing/rewriter.h" |
| 6 | 6 |
| 7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
| 8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
| 9 #include "src/parsing/parser.h" | 9 #include "src/parsing/parser.h" |
| 10 | 10 |
| 11 namespace v8 { | 11 namespace v8 { |
| 12 namespace internal { | 12 namespace internal { |
| 13 | 13 |
| 14 class Processor: public AstVisitor { | 14 class Processor : public AstVisitor { |
| 15 public: | 15 public: |
| 16 Processor(Isolate* isolate, Scope* scope, Variable* result, | 16 Processor(Isolate* isolate, Scope* scope, Variable* result, |
| 17 AstValueFactory* ast_value_factory) | 17 AstValueFactory* ast_value_factory) |
| 18 : result_(result), | 18 : result_(result), |
| 19 result_assigned_(false), | 19 result_assigned_(false), |
| 20 replacement_(nullptr), | 20 replacement_(nullptr), |
| 21 is_set_(false), | 21 is_set_(false), |
| 22 zone_(ast_value_factory->zone()), | 22 zone_(ast_value_factory->zone()), |
| 23 scope_(scope), | 23 scope_(scope), |
| 24 factory_(ast_value_factory) { | 24 factory_(ast_value_factory) { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 // To avoid storing to .result all the time, we eliminate some of | 72 // To avoid storing to .result all the time, we eliminate some of |
| 73 // the stores by keeping track of whether or not we're sure .result | 73 // the stores by keeping track of whether or not we're sure .result |
| 74 // will be overwritten anyway. This is a bit more tricky than what I | 74 // will be overwritten anyway. This is a bit more tricky than what I |
| 75 // was hoping for. | 75 // was hoping for. |
| 76 bool is_set_; | 76 bool is_set_; |
| 77 | 77 |
| 78 Zone* zone_; | 78 Zone* zone_; |
| 79 Scope* scope_; | 79 Scope* scope_; |
| 80 AstNodeFactory factory_; | 80 AstNodeFactory factory_; |
| 81 | 81 |
| 82 // Node visitors. | 82 // Node visitors. |
| 83 #define DEF_VISIT(type) void Visit##type(type* node) override; | 83 #define DEF_VISIT(type) void Visit##type(type* node) override; |
| 84 AST_NODE_LIST(DEF_VISIT) | 84 AST_NODE_LIST(DEF_VISIT) |
| 85 #undef DEF_VISIT | 85 #undef DEF_VISIT |
| 86 | 86 |
| 87 void VisitIterationStatement(IterationStatement* stmt); | 87 void VisitIterationStatement(IterationStatement* stmt); |
| 88 | 88 |
| 89 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); | 89 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); |
| 90 }; | 90 }; |
| 91 | 91 |
| 92 | 92 |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 312 replacement_ = node; | 312 replacement_ = node; |
| 313 } | 313 } |
| 314 | 314 |
| 315 | 315 |
| 316 void Processor::VisitDebuggerStatement(DebuggerStatement* node) { | 316 void Processor::VisitDebuggerStatement(DebuggerStatement* node) { |
| 317 replacement_ = node; | 317 replacement_ = node; |
| 318 } | 318 } |
| 319 | 319 |
| 320 | 320 |
| 321 // Expressions are never visited. | 321 // Expressions are never visited. |
| 322 #define DEF_VISIT(type) \ | 322 #define DEF_VISIT(type) \ |
| 323 void Processor::Visit##type(type* expr) { UNREACHABLE(); } | 323 void Processor::Visit##type(type* expr) { UNREACHABLE(); } |
| 324 EXPRESSION_NODE_LIST(DEF_VISIT) | 324 EXPRESSION_NODE_LIST(DEF_VISIT) |
| 325 #undef DEF_VISIT | 325 #undef DEF_VISIT |
| 326 | 326 |
| 327 | 327 |
| 328 // Declarations are never visited. | 328 // Declarations are never visited. |
| 329 #define DEF_VISIT(type) \ | 329 #define DEF_VISIT(type) \ |
| 330 void Processor::Visit##type(type* expr) { UNREACHABLE(); } | 330 void Processor::Visit##type(type* expr) { UNREACHABLE(); } |
| 331 DECLARATION_NODE_LIST(DEF_VISIT) | 331 DECLARATION_NODE_LIST(DEF_VISIT) |
| 332 #undef DEF_VISIT | 332 #undef DEF_VISIT |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 processor.SetResult(undef), expr->position()); | 394 processor.SetResult(undef), expr->position()); |
| 395 body->Add(completion, factory->zone()); | 395 body->Add(completion, factory->zone()); |
| 396 } | 396 } |
| 397 } | 397 } |
| 398 return true; | 398 return true; |
| 399 } | 399 } |
| 400 | 400 |
| 401 | 401 |
| 402 } // namespace internal | 402 } // namespace internal |
| 403 } // namespace v8 | 403 } // namespace v8 |
| OLD | NEW |