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/objects-inl.h" | 9 #include "src/objects-inl.h" |
10 #include "src/parsing/parse-info.h" | 10 #include "src/parsing/parse-info.h" |
(...skipping 368 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
379 info->ast_value_factory()->dot_result_string()); | 379 info->ast_value_factory()->dot_result_string()); |
380 Processor processor(info->stack_limit(), scope->AsDeclarationScope(), | 380 Processor processor(info->stack_limit(), scope->AsDeclarationScope(), |
381 result, info->ast_value_factory()); | 381 result, info->ast_value_factory()); |
382 processor.Process(body); | 382 processor.Process(body); |
383 | 383 |
384 DCHECK_IMPLIES(scope->is_module_scope(), processor.result_assigned()); | 384 DCHECK_IMPLIES(scope->is_module_scope(), processor.result_assigned()); |
385 if (processor.result_assigned()) { | 385 if (processor.result_assigned()) { |
386 int pos = kNoSourcePosition; | 386 int pos = kNoSourcePosition; |
387 Expression* result_value = | 387 Expression* result_value = |
388 processor.factory()->NewVariableProxy(result, pos); | 388 processor.factory()->NewVariableProxy(result, pos); |
389 if (scope->is_module_scope()) { | |
390 auto args = new (info->zone()) ZoneList<Expression*>(2, info->zone()); | |
391 args->Add(result_value, info->zone()); | |
392 args->Add(processor.factory()->NewBooleanLiteral(true, pos), | |
393 info->zone()); | |
394 result_value = processor.factory()->NewCallRuntime( | |
395 Runtime::kInlineCreateIterResultObject, args, pos); | |
396 } | |
397 Statement* result_statement = | 389 Statement* result_statement = |
398 processor.factory()->NewReturnStatement(result_value, pos); | 390 processor.factory()->NewReturnStatement(result_value, pos); |
399 body->Add(result_statement, info->zone()); | 391 body->Add(result_statement, info->zone()); |
400 } | 392 } |
401 | 393 |
402 // TODO(leszeks): Remove this check and releases once internalization is | 394 // TODO(leszeks): Remove this check and releases once internalization is |
403 // moved out of parsing/analysis. Also remove the parameter once done. | 395 // moved out of parsing/analysis. Also remove the parameter once done. |
404 DCHECK(ThreadId::Current().Equals(isolate->thread_id())); | 396 DCHECK(ThreadId::Current().Equals(isolate->thread_id())); |
405 no_deref.Release(); | 397 no_deref.Release(); |
406 no_handles.Release(); | 398 no_handles.Release(); |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 processor.SetResult(undef), expr->position()); | 432 processor.SetResult(undef), expr->position()); |
441 body->Add(completion, factory->zone()); | 433 body->Add(completion, factory->zone()); |
442 } | 434 } |
443 } | 435 } |
444 return true; | 436 return true; |
445 } | 437 } |
446 | 438 |
447 | 439 |
448 } // namespace internal | 440 } // namespace internal |
449 } // namespace v8 | 441 } // namespace v8 |
OLD | NEW |