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/parsing/rewriter.h" | 5 #include "src/parsing/rewriter.h" |
6 | 6 |
7 #include "src/ast/ast.h" | 7 #include "src/ast/ast.h" |
8 #include "src/ast/scopes.h" | 8 #include "src/ast/scopes.h" |
9 #include "src/parsing/parser.h" | 9 #include "src/parsing/parser.h" |
10 | 10 |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 Variable* result = | 348 Variable* result = |
349 scope->NewTemporary(info->ast_value_factory()->dot_result_string()); | 349 scope->NewTemporary(info->ast_value_factory()->dot_result_string()); |
350 // The name string must be internalized at this point. | 350 // The name string must be internalized at this point. |
351 DCHECK(!result->name().is_null()); | 351 DCHECK(!result->name().is_null()); |
352 Processor processor(info->isolate(), scope, result, | 352 Processor processor(info->isolate(), scope, result, |
353 info->ast_value_factory()); | 353 info->ast_value_factory()); |
354 processor.Process(body); | 354 processor.Process(body); |
355 if (processor.HasStackOverflow()) return false; | 355 if (processor.HasStackOverflow()) return false; |
356 | 356 |
357 if (processor.result_assigned()) { | 357 if (processor.result_assigned()) { |
358 DCHECK(function->end_position() != RelocInfo::kNoPosition); | 358 int pos = RelocInfo::kNoPosition; |
359 // Set the position of the assignment statement one character past the | |
360 // source code, such that it definitely is not in the source code range | |
361 // of an immediate inner scope. For example in | |
362 // eval('with ({x:1}) x = 1'); | |
363 // the end position of the function generated for executing the eval code | |
364 // coincides with the end of the with scope which is the position of '1'. | |
365 int pos = function->end_position(); | |
366 VariableProxy* result_proxy = | 359 VariableProxy* result_proxy = |
367 processor.factory()->NewVariableProxy(result, pos); | 360 processor.factory()->NewVariableProxy(result, pos); |
368 Statement* result_statement = | 361 Statement* result_statement = |
369 processor.factory()->NewReturnStatement(result_proxy, pos); | 362 processor.factory()->NewReturnStatement(result_proxy, pos); |
370 body->Add(result_statement, info->zone()); | 363 body->Add(result_statement, info->zone()); |
371 } | 364 } |
372 } | 365 } |
373 | 366 |
374 return true; | 367 return true; |
375 } | 368 } |
(...skipping 20 matching lines...) Expand all Loading... |
396 processor.SetResult(undef), expr->position()); | 389 processor.SetResult(undef), expr->position()); |
397 body->Add(completion, factory->zone()); | 390 body->Add(completion, factory->zone()); |
398 } | 391 } |
399 } | 392 } |
400 return true; | 393 return true; |
401 } | 394 } |
402 | 395 |
403 | 396 |
404 } // namespace internal | 397 } // namespace internal |
405 } // namespace v8 | 398 } // namespace v8 |
OLD | NEW |