OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 2605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2616 | 2616 |
2617 | 2617 |
2618 void Parser::InitializeForEachStatement(ForEachStatement* stmt, | 2618 void Parser::InitializeForEachStatement(ForEachStatement* stmt, |
2619 Expression* each, | 2619 Expression* each, |
2620 Expression* subject, | 2620 Expression* subject, |
2621 Statement* body) { | 2621 Statement* body) { |
2622 ForOfStatement* for_of = stmt->AsForOfStatement(); | 2622 ForOfStatement* for_of = stmt->AsForOfStatement(); |
2623 | 2623 |
2624 if (for_of != NULL) { | 2624 if (for_of != NULL) { |
2625 Factory* heap_factory = isolate()->factory(); | 2625 Factory* heap_factory = isolate()->factory(); |
2626 Handle<String> iterator_str = heap_factory->InternalizeOneByteString( | 2626 Variable* iterator = top_scope_->DeclarationScope()->NewTemporary( |
2627 STATIC_ASCII_VECTOR(".iterator")); | 2627 heap_factory->dot_iterator_string()); |
2628 Handle<String> result_str = heap_factory->InternalizeOneByteString( | 2628 Variable* result = top_scope_->DeclarationScope()->NewTemporary( |
2629 STATIC_ASCII_VECTOR(".result")); | 2629 heap_factory->dot_result_string()); |
2630 Variable* iterator = | |
2631 top_scope_->DeclarationScope()->NewTemporary(iterator_str); | |
2632 Variable* result = top_scope_->DeclarationScope()->NewTemporary(result_str); | |
2633 | 2630 |
2634 Expression* assign_iterator; | 2631 Expression* assign_iterator; |
2635 Expression* next_result; | 2632 Expression* next_result; |
2636 Expression* result_done; | 2633 Expression* result_done; |
2637 Expression* assign_each; | 2634 Expression* assign_each; |
2638 | 2635 |
2639 // var iterator = iterable; | 2636 // var iterator = iterable; |
2640 { | 2637 { |
2641 Expression* iterator_proxy = factory()->NewVariableProxy(iterator); | 2638 Expression* iterator_proxy = factory()->NewVariableProxy(iterator); |
2642 assign_iterator = factory()->NewAssignment( | 2639 assign_iterator = factory()->NewAssignment( |
(...skipping 1450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4093 if (is_generator) { | 4090 if (is_generator) { |
4094 // For generators, allocating variables in contexts is currently a win | 4091 // For generators, allocating variables in contexts is currently a win |
4095 // because it minimizes the work needed to suspend and resume an | 4092 // because it minimizes the work needed to suspend and resume an |
4096 // activation. | 4093 // activation. |
4097 top_scope_->ForceContextAllocation(); | 4094 top_scope_->ForceContextAllocation(); |
4098 | 4095 |
4099 // Calling a generator returns a generator object. That object is stored | 4096 // Calling a generator returns a generator object. That object is stored |
4100 // in a temporary variable, a definition that is used by "yield" | 4097 // in a temporary variable, a definition that is used by "yield" |
4101 // expressions. Presence of a variable for the generator object in the | 4098 // expressions. Presence of a variable for the generator object in the |
4102 // FunctionState indicates that this function is a generator. | 4099 // FunctionState indicates that this function is a generator. |
4103 Handle<String> tempname = isolate()->factory()->InternalizeOneByteString( | 4100 Variable* temp = top_scope_->DeclarationScope()->NewTemporary( |
4104 STATIC_ASCII_VECTOR(".generator_object")); | 4101 isolate()->factory()->dot_generator_object_string()); |
4105 Variable* temp = top_scope_->DeclarationScope()->NewTemporary(tempname); | |
4106 function_state.set_generator_object_variable(temp); | 4102 function_state.set_generator_object_variable(temp); |
4107 } | 4103 } |
4108 | 4104 |
4109 // FormalParameterList :: | 4105 // FormalParameterList :: |
4110 // '(' (Identifier)*[','] ')' | 4106 // '(' (Identifier)*[','] ')' |
4111 Expect(Token::LPAREN, CHECK_OK); | 4107 Expect(Token::LPAREN, CHECK_OK); |
4112 scope->set_start_position(scanner().location().beg_pos); | 4108 scope->set_start_position(scanner().location().beg_pos); |
4113 Scanner::Location name_loc = Scanner::Location::invalid(); | 4109 Scanner::Location name_loc = Scanner::Location::invalid(); |
4114 Scanner::Location dupe_loc = Scanner::Location::invalid(); | 4110 Scanner::Location dupe_loc = Scanner::Location::invalid(); |
4115 Scanner::Location reserved_loc = Scanner::Location::invalid(); | 4111 Scanner::Location reserved_loc = Scanner::Location::invalid(); |
(...skipping 1582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5698 ASSERT(info()->isolate()->has_pending_exception()); | 5694 ASSERT(info()->isolate()->has_pending_exception()); |
5699 } else { | 5695 } else { |
5700 result = ParseProgram(); | 5696 result = ParseProgram(); |
5701 } | 5697 } |
5702 } | 5698 } |
5703 info()->SetFunction(result); | 5699 info()->SetFunction(result); |
5704 return (result != NULL); | 5700 return (result != NULL); |
5705 } | 5701 } |
5706 | 5702 |
5707 } } // namespace v8::internal | 5703 } } // namespace v8::internal |
OLD | NEW |