| 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 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 635 scope = NewScope(scope, GLOBAL_SCOPE); | 635 scope = NewScope(scope, GLOBAL_SCOPE); |
| 636 } | 636 } |
| 637 scope->set_start_position(0); | 637 scope->set_start_position(0); |
| 638 scope->set_end_position(source->length()); | 638 scope->set_end_position(source->length()); |
| 639 | 639 |
| 640 FunctionState function_state(this, scope, isolate()); // Enters 'scope'. | 640 FunctionState function_state(this, scope, isolate()); // Enters 'scope'. |
| 641 top_scope_->SetLanguageMode(info->language_mode()); | 641 top_scope_->SetLanguageMode(info->language_mode()); |
| 642 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); | 642 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(16, zone()); |
| 643 bool ok = true; | 643 bool ok = true; |
| 644 int beg_loc = scanner().location().beg_pos; | 644 int beg_loc = scanner().location().beg_pos; |
| 645 ParseSourceElements(body, Token::EOS, info->is_eval(), &ok); | 645 ParseSourceElements(body, Token::EOS, info->is_eval(), true, &ok); |
| 646 if (ok && !top_scope_->is_classic_mode()) { | 646 if (ok && !top_scope_->is_classic_mode()) { |
| 647 CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok); | 647 CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok); |
| 648 } | 648 } |
| 649 | 649 |
| 650 if (ok && is_extended_mode()) { | 650 if (ok && is_extended_mode()) { |
| 651 CheckConflictingVarDeclarations(top_scope_, &ok); | 651 CheckConflictingVarDeclarations(top_scope_, &ok); |
| 652 } | 652 } |
| 653 | 653 |
| 654 if (ok) { | 654 if (ok) { |
| 655 result = factory()->NewFunctionLiteral( | 655 result = factory()->NewFunctionLiteral( |
| (...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1000 ZoneStringList names_; | 1000 ZoneStringList names_; |
| 1001 ZoneList<int> assigned_arguments_; | 1001 ZoneList<int> assigned_arguments_; |
| 1002 ZoneObjectList assigned_constants_; | 1002 ZoneObjectList assigned_constants_; |
| 1003 Zone* zone_; | 1003 Zone* zone_; |
| 1004 }; | 1004 }; |
| 1005 | 1005 |
| 1006 | 1006 |
| 1007 void* Parser::ParseSourceElements(ZoneList<Statement*>* processor, | 1007 void* Parser::ParseSourceElements(ZoneList<Statement*>* processor, |
| 1008 int end_token, | 1008 int end_token, |
| 1009 bool is_eval, | 1009 bool is_eval, |
| 1010 bool is_global, |
| 1010 bool* ok) { | 1011 bool* ok) { |
| 1011 // SourceElements :: | 1012 // SourceElements :: |
| 1012 // (ModuleElement)* <end_token> | 1013 // (ModuleElement)* <end_token> |
| 1013 | 1014 |
| 1014 // Allocate a target stack to use for this set of source | 1015 // Allocate a target stack to use for this set of source |
| 1015 // elements. This way, all scripts and functions get their own | 1016 // elements. This way, all scripts and functions get their own |
| 1016 // target stack thus avoiding illegal breaks and continues across | 1017 // target stack thus avoiding illegal breaks and continues across |
| 1017 // functions. | 1018 // functions. |
| 1018 TargetScope scope(&this->target_stack_); | 1019 TargetScope scope(&this->target_stack_); |
| 1019 | 1020 |
| 1020 ASSERT(processor != NULL); | 1021 ASSERT(processor != NULL); |
| 1021 ThisNamedPropertyAssignmentFinder this_property_assignment_finder(isolate(), | 1022 ThisNamedPropertyAssignmentFinder this_property_assignment_finder(isolate(), |
| 1022 zone()); | 1023 zone()); |
| 1023 bool directive_prologue = true; // Parsing directive prologue. | 1024 bool directive_prologue = true; // Parsing directive prologue. |
| 1024 | 1025 |
| 1025 while (peek() != end_token) { | 1026 while (peek() != end_token) { |
| 1026 if (directive_prologue && peek() != Token::STRING) { | 1027 if (directive_prologue && peek() != Token::STRING) { |
| 1027 directive_prologue = false; | 1028 directive_prologue = false; |
| 1028 } | 1029 } |
| 1029 | 1030 |
| 1030 Scanner::Location token_loc = scanner().peek_location(); | 1031 Scanner::Location token_loc = scanner().peek_location(); |
| 1031 Statement* stat = ParseModuleElement(NULL, CHECK_OK); | 1032 Statement* stat; |
| 1033 if (is_global && !is_eval) { |
| 1034 stat = ParseModuleElement(NULL, CHECK_OK); |
| 1035 } else { |
| 1036 stat = ParseBlockElement(NULL, CHECK_OK); |
| 1037 } |
| 1032 if (stat == NULL || stat->IsEmpty()) { | 1038 if (stat == NULL || stat->IsEmpty()) { |
| 1033 directive_prologue = false; // End of directive prologue. | 1039 directive_prologue = false; // End of directive prologue. |
| 1034 continue; | 1040 continue; |
| 1035 } | 1041 } |
| 1036 | 1042 |
| 1037 if (directive_prologue) { | 1043 if (directive_prologue) { |
| 1038 // A shot at a directive. | 1044 // A shot at a directive. |
| 1039 ExpressionStatement* e_stat; | 1045 ExpressionStatement* e_stat; |
| 1040 Literal* literal; | 1046 Literal* literal; |
| 1041 // Still processing directive prologue? | 1047 // Still processing directive prologue? |
| (...skipping 3482 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4524 VariableProxy* fproxy = top_scope_->NewUnresolved( | 4530 VariableProxy* fproxy = top_scope_->NewUnresolved( |
| 4525 factory(), function_name, Interface::NewConst()); | 4531 factory(), function_name, Interface::NewConst()); |
| 4526 fproxy->BindTo(fvar); | 4532 fproxy->BindTo(fvar); |
| 4527 body->Add(factory()->NewExpressionStatement( | 4533 body->Add(factory()->NewExpressionStatement( |
| 4528 factory()->NewAssignment(fvar_init_op, | 4534 factory()->NewAssignment(fvar_init_op, |
| 4529 fproxy, | 4535 fproxy, |
| 4530 factory()->NewThisFunction(), | 4536 factory()->NewThisFunction(), |
| 4531 RelocInfo::kNoPosition)), | 4537 RelocInfo::kNoPosition)), |
| 4532 zone()); | 4538 zone()); |
| 4533 } | 4539 } |
| 4534 ParseSourceElements(body, Token::RBRACE, false, CHECK_OK); | 4540 ParseSourceElements(body, Token::RBRACE, false, false, CHECK_OK); |
| 4535 | 4541 |
| 4536 materialized_literal_count = function_state.materialized_literal_count(); | 4542 materialized_literal_count = function_state.materialized_literal_count(); |
| 4537 expected_property_count = function_state.expected_property_count(); | 4543 expected_property_count = function_state.expected_property_count(); |
| 4538 handler_count = function_state.handler_count(); | 4544 handler_count = function_state.handler_count(); |
| 4539 only_simple_this_property_assignments = | 4545 only_simple_this_property_assignments = |
| 4540 function_state.only_simple_this_property_assignments(); | 4546 function_state.only_simple_this_property_assignments(); |
| 4541 this_property_assignments = function_state.this_property_assignments(); | 4547 this_property_assignments = function_state.this_property_assignments(); |
| 4542 | 4548 |
| 4543 Expect(Token::RBRACE, CHECK_OK); | 4549 Expect(Token::RBRACE, CHECK_OK); |
| 4544 scope->set_end_position(scanner().location().end_pos); | 4550 scope->set_end_position(scanner().location().end_pos); |
| (...skipping 1423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5968 ASSERT(info->isolate()->has_pending_exception()); | 5974 ASSERT(info->isolate()->has_pending_exception()); |
| 5969 } else { | 5975 } else { |
| 5970 result = parser.ParseProgram(); | 5976 result = parser.ParseProgram(); |
| 5971 } | 5977 } |
| 5972 } | 5978 } |
| 5973 info->SetFunction(result); | 5979 info->SetFunction(result); |
| 5974 return (result != NULL); | 5980 return (result != NULL); |
| 5975 } | 5981 } |
| 5976 | 5982 |
| 5977 } } // namespace v8::internal | 5983 } } // namespace v8::internal |
| OLD | NEW |