| 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/v8.h" | 5 #include "src/v8.h" |
| 6 | 6 |
| 7 #include "src/ast.h" |
| 8 #include "src/parser.h" |
| 7 #include "src/rewriter.h" | 9 #include "src/rewriter.h" |
| 8 | |
| 9 #include "src/ast.h" | |
| 10 #include "src/compiler.h" | |
| 11 #include "src/scopes.h" | 10 #include "src/scopes.h" |
| 12 | 11 |
| 13 namespace v8 { | 12 namespace v8 { |
| 14 namespace internal { | 13 namespace internal { |
| 15 | 14 |
| 16 class Processor: public AstVisitor { | 15 class Processor: public AstVisitor { |
| 17 public: | 16 public: |
| 18 Processor(Isolate* isolate, Variable* result, | 17 Processor(Isolate* isolate, Variable* result, |
| 19 AstValueFactory* ast_value_factory) | 18 AstValueFactory* ast_value_factory) |
| 20 : result_(result), | 19 : result_(result), |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 | 214 |
| 216 // Expressions are never visited yet. | 215 // Expressions are never visited yet. |
| 217 #define DEF_VISIT(type) \ | 216 #define DEF_VISIT(type) \ |
| 218 void Processor::Visit##type(type* expr) { UNREACHABLE(); } | 217 void Processor::Visit##type(type* expr) { UNREACHABLE(); } |
| 219 EXPRESSION_NODE_LIST(DEF_VISIT) | 218 EXPRESSION_NODE_LIST(DEF_VISIT) |
| 220 #undef DEF_VISIT | 219 #undef DEF_VISIT |
| 221 | 220 |
| 222 | 221 |
| 223 // Assumes code has been parsed. Mutates the AST, so the AST should not | 222 // Assumes code has been parsed. Mutates the AST, so the AST should not |
| 224 // continue to be used in the case of failure. | 223 // continue to be used in the case of failure. |
| 225 bool Rewriter::Rewrite(CompilationInfo* info) { | 224 bool Rewriter::Rewrite(ParseInfo* info) { |
| 226 FunctionLiteral* function = info->function(); | 225 FunctionLiteral* function = info->function(); |
| 227 DCHECK(function != NULL); | 226 DCHECK(function != NULL); |
| 228 Scope* scope = function->scope(); | 227 Scope* scope = function->scope(); |
| 229 DCHECK(scope != NULL); | 228 DCHECK(scope != NULL); |
| 230 if (!scope->is_script_scope() && !scope->is_eval_scope()) return true; | 229 if (!scope->is_script_scope() && !scope->is_eval_scope()) return true; |
| 231 | 230 |
| 232 ZoneList<Statement*>* body = function->body(); | 231 ZoneList<Statement*>* body = function->body(); |
| 233 if (!body->is_empty()) { | 232 if (!body->is_empty()) { |
| 234 Variable* result = | 233 Variable* result = |
| 235 scope->NewTemporary(info->ast_value_factory()->dot_result_string()); | 234 scope->NewTemporary(info->ast_value_factory()->dot_result_string()); |
| (...skipping 18 matching lines...) Expand all Loading... |
| 254 processor.factory()->NewReturnStatement(result_proxy, pos); | 253 processor.factory()->NewReturnStatement(result_proxy, pos); |
| 255 body->Add(result_statement, info->zone()); | 254 body->Add(result_statement, info->zone()); |
| 256 } | 255 } |
| 257 } | 256 } |
| 258 | 257 |
| 259 return true; | 258 return true; |
| 260 } | 259 } |
| 261 | 260 |
| 262 | 261 |
| 263 } } // namespace v8::internal | 262 } } // namespace v8::internal |
| OLD | NEW |