| 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/rewriter.h" | 5 #include "src/rewriter.h" |
| 6 | 6 |
| 7 #include "src/ast.h" | 7 #include "src/ast.h" |
| 8 #include "src/parser.h" | 8 #include "src/parser.h" |
| 9 #include "src/scopes.h" | 9 #include "src/scopes.h" |
| 10 | 10 |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // Expressions are never visited yet. | 203 // Expressions are never visited yet. |
| 204 #define DEF_VISIT(type) \ | 204 #define DEF_VISIT(type) \ |
| 205 void Processor::Visit##type(type* expr) { UNREACHABLE(); } | 205 void Processor::Visit##type(type* expr) { UNREACHABLE(); } |
| 206 EXPRESSION_NODE_LIST(DEF_VISIT) | 206 EXPRESSION_NODE_LIST(DEF_VISIT) |
| 207 #undef DEF_VISIT | 207 #undef DEF_VISIT |
| 208 | 208 |
| 209 | 209 |
| 210 // Assumes code has been parsed. Mutates the AST, so the AST should not | 210 // Assumes code has been parsed. Mutates the AST, so the AST should not |
| 211 // continue to be used in the case of failure. | 211 // continue to be used in the case of failure. |
| 212 bool Rewriter::Rewrite(ParseInfo* info) { | 212 bool Rewriter::Rewrite(ParseInfo* info) { |
| 213 FunctionLiteral* function = info->function(); | 213 FunctionLiteral* function = info->literal(); |
| 214 DCHECK(function != NULL); | 214 DCHECK(function != NULL); |
| 215 Scope* scope = function->scope(); | 215 Scope* scope = function->scope(); |
| 216 DCHECK(scope != NULL); | 216 DCHECK(scope != NULL); |
| 217 if (!scope->is_script_scope() && !scope->is_eval_scope()) return true; | 217 if (!scope->is_script_scope() && !scope->is_eval_scope()) return true; |
| 218 | 218 |
| 219 ZoneList<Statement*>* body = function->body(); | 219 ZoneList<Statement*>* body = function->body(); |
| 220 if (!body->is_empty()) { | 220 if (!body->is_empty()) { |
| 221 Variable* result = | 221 Variable* result = |
| 222 scope->NewTemporary(info->ast_value_factory()->dot_result_string()); | 222 scope->NewTemporary(info->ast_value_factory()->dot_result_string()); |
| 223 // The name string must be internalized at this point. | 223 // The name string must be internalized at this point. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 242 body->Add(result_statement, info->zone()); | 242 body->Add(result_statement, info->zone()); |
| 243 } | 243 } |
| 244 } | 244 } |
| 245 | 245 |
| 246 return true; | 246 return true; |
| 247 } | 247 } |
| 248 | 248 |
| 249 | 249 |
| 250 } // namespace internal | 250 } // namespace internal |
| 251 } // namespace v8 | 251 } // namespace v8 |
| OLD | NEW |