| 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" | 7 #include "src/ast.h" |
| 8 #include "src/parser.h" | 8 #include "src/parser.h" |
| 9 #include "src/rewriter.h" | 9 #include "src/rewriter.h" |
| 10 #include "src/scopes.h" | 10 #include "src/scopes.h" |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 228 if (processor.HasStackOverflow()) return false; | 228 if (processor.HasStackOverflow()) return false; |
| 229 | 229 |
| 230 if (processor.result_assigned()) { | 230 if (processor.result_assigned()) { |
| 231 DCHECK(function->end_position() != RelocInfo::kNoPosition); | 231 DCHECK(function->end_position() != RelocInfo::kNoPosition); |
| 232 // Set the position of the assignment statement one character past the | 232 // Set the position of the assignment statement one character past the |
| 233 // source code, such that it definitely is not in the source code range | 233 // source code, such that it definitely is not in the source code range |
| 234 // of an immediate inner scope. For example in | 234 // of an immediate inner scope. For example in |
| 235 // eval('with ({x:1}) x = 1'); | 235 // eval('with ({x:1}) x = 1'); |
| 236 // the end position of the function generated for executing the eval code | 236 // the end position of the function generated for executing the eval code |
| 237 // coincides with the end of the with scope which is the position of '1'. | 237 // coincides with the end of the with scope which is the position of '1'. |
| 238 // Note that this may mean the position is outside the source code | |
| 239 // completely if there is no terminal newline, curly brace, or semicolon, | |
| 240 // often the case for 'eval'. | |
| 241 int pos = function->end_position(); | 238 int pos = function->end_position(); |
| 242 VariableProxy* result_proxy = | 239 VariableProxy* result_proxy = |
| 243 processor.factory()->NewVariableProxy(result, pos); | 240 processor.factory()->NewVariableProxy(result, pos); |
| 244 Statement* result_statement = | 241 Statement* result_statement = |
| 245 processor.factory()->NewReturnStatement(result_proxy, pos); | 242 processor.factory()->NewReturnStatement(result_proxy, pos); |
| 246 body->Add(result_statement, info->zone()); | 243 body->Add(result_statement, info->zone()); |
| 247 } | 244 } |
| 248 } | 245 } |
| 249 | 246 |
| 250 return true; | 247 return true; |
| 251 } | 248 } |
| 252 | 249 |
| 253 | 250 |
| 254 } // namespace internal | 251 } // namespace internal |
| 255 } // namespace v8 | 252 } // namespace v8 |
| OLD | NEW |