OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 bool Rewriter::Rewrite(CompilationInfo* info) { | 256 bool Rewriter::Rewrite(CompilationInfo* info) { |
257 FunctionLiteral* function = info->function(); | 257 FunctionLiteral* function = info->function(); |
258 ASSERT(function != NULL); | 258 ASSERT(function != NULL); |
259 Scope* scope = function->scope(); | 259 Scope* scope = function->scope(); |
260 ASSERT(scope != NULL); | 260 ASSERT(scope != NULL); |
261 if (!scope->is_global_scope() && !scope->is_eval_scope()) return true; | 261 if (!scope->is_global_scope() && !scope->is_eval_scope()) return true; |
262 | 262 |
263 ZoneList<Statement*>* body = function->body(); | 263 ZoneList<Statement*>* body = function->body(); |
264 if (!body->is_empty()) { | 264 if (!body->is_empty()) { |
265 Variable* result = scope->NewTemporary( | 265 Variable* result = scope->NewTemporary( |
266 info->isolate()->factory()->result_string()); | 266 info->isolate()->factory()->dot_result_string()); |
267 Processor processor(result, info->zone()); | 267 Processor processor(result, info->zone()); |
268 processor.Process(body); | 268 processor.Process(body); |
269 if (processor.HasStackOverflow()) return false; | 269 if (processor.HasStackOverflow()) return false; |
270 | 270 |
271 if (processor.result_assigned()) { | 271 if (processor.result_assigned()) { |
272 ASSERT(function->end_position() != RelocInfo::kNoPosition); | 272 ASSERT(function->end_position() != RelocInfo::kNoPosition); |
273 // Set the position of the assignment statement one character past the | 273 // Set the position of the assignment statement one character past the |
274 // source code, such that it definitely is not in the source code range | 274 // source code, such that it definitely is not in the source code range |
275 // of an immediate inner scope. For example in | 275 // of an immediate inner scope. For example in |
276 // eval('with ({x:1}) x = 1'); | 276 // eval('with ({x:1}) x = 1'); |
277 // the end position of the function generated for executing the eval code | 277 // the end position of the function generated for executing the eval code |
278 // coincides with the end of the with scope which is the position of '1'. | 278 // coincides with the end of the with scope which is the position of '1'. |
279 int pos = function->end_position(); | 279 int pos = function->end_position(); |
280 VariableProxy* result_proxy = processor.factory()->NewVariableProxy( | 280 VariableProxy* result_proxy = processor.factory()->NewVariableProxy( |
281 result->name(), false, result->interface(), pos); | 281 result->name(), false, result->interface(), pos); |
282 result_proxy->BindTo(result); | 282 result_proxy->BindTo(result); |
283 Statement* result_statement = | 283 Statement* result_statement = |
284 processor.factory()->NewReturnStatement(result_proxy, pos); | 284 processor.factory()->NewReturnStatement(result_proxy, pos); |
285 body->Add(result_statement, info->zone()); | 285 body->Add(result_statement, info->zone()); |
286 } | 286 } |
287 } | 287 } |
288 | 288 |
289 return true; | 289 return true; |
290 } | 290 } |
291 | 291 |
292 | 292 |
293 } } // namespace v8::internal | 293 } } // namespace v8::internal |
OLD | NEW |