| OLD | NEW |
| 1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 | 229 |
| 230 ZoneList<Statement*>* body = function->body(); | 230 ZoneList<Statement*>* body = function->body(); |
| 231 if (!body->is_empty()) { | 231 if (!body->is_empty()) { |
| 232 Variable* result = scope->NewTemporary( | 232 Variable* result = scope->NewTemporary( |
| 233 info->isolate()->factory()->result_symbol()); | 233 info->isolate()->factory()->result_symbol()); |
| 234 Processor processor(result); | 234 Processor processor(result); |
| 235 processor.Process(body); | 235 processor.Process(body); |
| 236 if (processor.HasStackOverflow()) return false; | 236 if (processor.HasStackOverflow()) return false; |
| 237 | 237 |
| 238 if (processor.result_assigned()) { | 238 if (processor.result_assigned()) { |
| 239 ASSERT(function->end_position() != RelocInfo::kNoPosition); | |
| 240 Isolate* isolate = info->isolate(); | 239 Isolate* isolate = info->isolate(); |
| 241 Zone* zone = isolate->zone(); | 240 Zone* zone = isolate->zone(); |
| 242 // Set the position of the assignment statement one character past the | 241 VariableProxy* result_proxy = new(zone) VariableProxy(isolate, result); |
| 243 // source code, such that it definitely is not in the source code range | 242 body->Add(new(zone) ReturnStatement(result_proxy)); |
| 244 // of an immediate inner scope. For example in | |
| 245 // eval('with ({x:1}) x = 1'); | |
| 246 // the end position of the function generated for executing the eval code | |
| 247 // coincides with the end of the with scope which is the position of '1'. | |
| 248 int position = function->end_position(); | |
| 249 VariableProxy* result_proxy = new(zone) VariableProxy( | |
| 250 isolate, result->name(), false, position); | |
| 251 result_proxy->BindTo(result); | |
| 252 Statement* result_statement = new(zone) ReturnStatement(result_proxy); | |
| 253 result_statement->set_statement_pos(position); | |
| 254 body->Add(result_statement); | |
| 255 } | 243 } |
| 256 } | 244 } |
| 257 | 245 |
| 258 return true; | 246 return true; |
| 259 } | 247 } |
| 260 | 248 |
| 261 | 249 |
| 262 } } // namespace v8::internal | 250 } } // namespace v8::internal |
| OLD | NEW |