| 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/rewriter.h" | 7 #include "src/rewriter.h" |
| 8 | 8 |
| 9 #include "src/ast.h" | 9 #include "src/ast.h" |
| 10 #include "src/compiler.h" | 10 #include "src/compiler.h" |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 222 #undef DEF_VISIT | 222 #undef DEF_VISIT |
| 223 | 223 |
| 224 | 224 |
| 225 // Assumes code has been parsed. Mutates the AST, so the AST should not | 225 // Assumes code has been parsed. Mutates the AST, so the AST should not |
| 226 // continue to be used in the case of failure. | 226 // continue to be used in the case of failure. |
| 227 bool Rewriter::Rewrite(CompilationInfo* info) { | 227 bool Rewriter::Rewrite(CompilationInfo* info) { |
| 228 FunctionLiteral* function = info->function(); | 228 FunctionLiteral* function = info->function(); |
| 229 DCHECK(function != NULL); | 229 DCHECK(function != NULL); |
| 230 Scope* scope = function->scope(); | 230 Scope* scope = function->scope(); |
| 231 DCHECK(scope != NULL); | 231 DCHECK(scope != NULL); |
| 232 if (!scope->is_global_scope() && !scope->is_eval_scope()) return true; | 232 if (!scope->is_script_scope() && !scope->is_eval_scope()) return true; |
| 233 | 233 |
| 234 ZoneList<Statement*>* body = function->body(); | 234 ZoneList<Statement*>* body = function->body(); |
| 235 if (!body->is_empty()) { | 235 if (!body->is_empty()) { |
| 236 Variable* result = | 236 Variable* result = |
| 237 scope->NewTemporary(info->ast_value_factory()->dot_result_string()); | 237 scope->NewTemporary(info->ast_value_factory()->dot_result_string()); |
| 238 // The name string must be internalized at this point. | 238 // The name string must be internalized at this point. |
| 239 DCHECK(!result->name().is_null()); | 239 DCHECK(!result->name().is_null()); |
| 240 Processor processor(result, info->ast_value_factory()); | 240 Processor processor(result, info->ast_value_factory()); |
| 241 processor.Process(body); | 241 processor.Process(body); |
| 242 if (processor.HasStackOverflow()) return false; | 242 if (processor.HasStackOverflow()) return false; |
| (...skipping 13 matching lines...) Expand all Loading... |
| 256 processor.factory()->NewReturnStatement(result_proxy, pos); | 256 processor.factory()->NewReturnStatement(result_proxy, pos); |
| 257 body->Add(result_statement, info->zone()); | 257 body->Add(result_statement, info->zone()); |
| 258 } | 258 } |
| 259 } | 259 } |
| 260 | 260 |
| 261 return true; | 261 return true; |
| 262 } | 262 } |
| 263 | 263 |
| 264 | 264 |
| 265 } } // namespace v8::internal | 265 } } // namespace v8::internal |
| OLD | NEW |