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/api.h" | 7 #include "src/api.h" |
8 #include "src/ast.h" | 8 #include "src/ast.h" |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/bootstrapper.h" | 10 #include "src/bootstrapper.h" |
(...skipping 2491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2502 tok == Token::EOS) { | 2502 tok == Token::EOS) { |
2503 return_value = GetLiteralUndefined(position()); | 2503 return_value = GetLiteralUndefined(position()); |
2504 } else { | 2504 } else { |
2505 return_value = ParseExpression(true, CHECK_OK); | 2505 return_value = ParseExpression(true, CHECK_OK); |
2506 } | 2506 } |
2507 ExpectSemicolon(CHECK_OK); | 2507 ExpectSemicolon(CHECK_OK); |
2508 if (is_generator()) { | 2508 if (is_generator()) { |
2509 Expression* generator = factory()->NewVariableProxy( | 2509 Expression* generator = factory()->NewVariableProxy( |
2510 function_state_->generator_object_variable()); | 2510 function_state_->generator_object_variable()); |
2511 Expression* yield = factory()->NewYield( | 2511 Expression* yield = factory()->NewYield( |
2512 generator, return_value, Yield::FINAL, loc.beg_pos); | 2512 generator, return_value, Yield::kFinal, loc.beg_pos); |
2513 result = factory()->NewExpressionStatement(yield, loc.beg_pos); | 2513 result = factory()->NewExpressionStatement(yield, loc.beg_pos); |
2514 } else { | 2514 } else { |
2515 result = factory()->NewReturnStatement(return_value, loc.beg_pos); | 2515 result = factory()->NewReturnStatement(return_value, loc.beg_pos); |
2516 } | 2516 } |
2517 | 2517 |
2518 Scope* decl_scope = scope_->DeclarationScope(); | 2518 Scope* decl_scope = scope_->DeclarationScope(); |
2519 if (decl_scope->is_global_scope() || decl_scope->is_eval_scope()) { | 2519 if (decl_scope->is_global_scope() || decl_scope->is_eval_scope()) { |
2520 ReportMessageAt(loc, "illegal_return"); | 2520 ReportMessageAt(loc, "illegal_return"); |
2521 *ok = false; | 2521 *ok = false; |
2522 return NULL; | 2522 return NULL; |
(...skipping 1205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3728 ast_value_factory_->empty_string(), | 3728 ast_value_factory_->empty_string(), |
3729 Runtime::FunctionForId(Runtime::kCreateJSGeneratorObject), | 3729 Runtime::FunctionForId(Runtime::kCreateJSGeneratorObject), |
3730 arguments, pos); | 3730 arguments, pos); |
3731 VariableProxy* init_proxy = factory()->NewVariableProxy( | 3731 VariableProxy* init_proxy = factory()->NewVariableProxy( |
3732 function_state_->generator_object_variable()); | 3732 function_state_->generator_object_variable()); |
3733 Assignment* assignment = factory()->NewAssignment( | 3733 Assignment* assignment = factory()->NewAssignment( |
3734 Token::INIT_VAR, init_proxy, allocation, RelocInfo::kNoPosition); | 3734 Token::INIT_VAR, init_proxy, allocation, RelocInfo::kNoPosition); |
3735 VariableProxy* get_proxy = factory()->NewVariableProxy( | 3735 VariableProxy* get_proxy = factory()->NewVariableProxy( |
3736 function_state_->generator_object_variable()); | 3736 function_state_->generator_object_variable()); |
3737 Yield* yield = factory()->NewYield( | 3737 Yield* yield = factory()->NewYield( |
3738 get_proxy, assignment, Yield::INITIAL, RelocInfo::kNoPosition); | 3738 get_proxy, assignment, Yield::kInitial, RelocInfo::kNoPosition); |
3739 body->Add(factory()->NewExpressionStatement( | 3739 body->Add(factory()->NewExpressionStatement( |
3740 yield, RelocInfo::kNoPosition), zone()); | 3740 yield, RelocInfo::kNoPosition), zone()); |
3741 } | 3741 } |
3742 | 3742 |
3743 ParseSourceElements(body, Token::RBRACE, false, false, CHECK_OK); | 3743 ParseSourceElements(body, Token::RBRACE, false, false, CHECK_OK); |
3744 | 3744 |
3745 if (is_generator) { | 3745 if (is_generator) { |
3746 VariableProxy* get_proxy = factory()->NewVariableProxy( | 3746 VariableProxy* get_proxy = factory()->NewVariableProxy( |
3747 function_state_->generator_object_variable()); | 3747 function_state_->generator_object_variable()); |
3748 Expression* undefined = | 3748 Expression* undefined = |
3749 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition); | 3749 factory()->NewUndefinedLiteral(RelocInfo::kNoPosition); |
3750 Yield* yield = factory()->NewYield(get_proxy, undefined, Yield::FINAL, | 3750 Yield* yield = factory()->NewYield(get_proxy, undefined, Yield::kFinal, |
3751 RelocInfo::kNoPosition); | 3751 RelocInfo::kNoPosition); |
3752 body->Add(factory()->NewExpressionStatement( | 3752 body->Add(factory()->NewExpressionStatement( |
3753 yield, RelocInfo::kNoPosition), zone()); | 3753 yield, RelocInfo::kNoPosition), zone()); |
3754 } | 3754 } |
3755 | 3755 |
3756 Expect(Token::RBRACE, CHECK_OK); | 3756 Expect(Token::RBRACE, CHECK_OK); |
3757 scope_->set_end_position(scanner()->location().end_pos); | 3757 scope_->set_end_position(scanner()->location().end_pos); |
3758 | 3758 |
3759 return body; | 3759 return body; |
3760 } | 3760 } |
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4839 info()->SetAstValueFactory(ast_value_factory_); | 4839 info()->SetAstValueFactory(ast_value_factory_); |
4840 } | 4840 } |
4841 ast_value_factory_ = NULL; | 4841 ast_value_factory_ = NULL; |
4842 | 4842 |
4843 InternalizeUseCounts(); | 4843 InternalizeUseCounts(); |
4844 | 4844 |
4845 return (result != NULL); | 4845 return (result != NULL); |
4846 } | 4846 } |
4847 | 4847 |
4848 } } // namespace v8::internal | 4848 } } // namespace v8::internal |
OLD | NEW |