| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 |
| 11 // with the distribution. | 11 // with the distribution. |
| (...skipping 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 658 top_scope_, | 658 top_scope_, |
| 659 body, | 659 body, |
| 660 lexical_scope.materialized_literal_count(), | 660 lexical_scope.materialized_literal_count(), |
| 661 lexical_scope.expected_property_count(), | 661 lexical_scope.expected_property_count(), |
| 662 lexical_scope.only_simple_this_property_assignments(), | 662 lexical_scope.only_simple_this_property_assignments(), |
| 663 lexical_scope.this_property_assignments(), | 663 lexical_scope.this_property_assignments(), |
| 664 0, | 664 0, |
| 665 0, | 665 0, |
| 666 source->length(), | 666 source->length(), |
| 667 false, | 667 false, |
| 668 lexical_scope.ContainsLoops()); | 668 lexical_scope.ContainsLoops(), |
| 669 false); |
| 669 } else if (stack_overflow_) { | 670 } else if (stack_overflow_) { |
| 670 isolate()->StackOverflow(); | 671 isolate()->StackOverflow(); |
| 671 } | 672 } |
| 672 } | 673 } |
| 673 | 674 |
| 674 // Make sure the target stack is empty. | 675 // Make sure the target stack is empty. |
| 675 ASSERT(target_stack_ == NULL); | 676 ASSERT(target_stack_ == NULL); |
| 676 | 677 |
| 677 // If there was a syntax error we have to get rid of the AST | 678 // If there was a syntax error we have to get rid of the AST |
| 678 // and it is not safe to do so before the scope has been deleted. | 679 // and it is not safe to do so before the scope has been deleted. |
| (...skipping 2859 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3538 LexicalScope lexical_scope(this, scope, isolate()); | 3539 LexicalScope lexical_scope(this, scope, isolate()); |
| 3539 top_scope_->SetScopeName(name); | 3540 top_scope_->SetScopeName(name); |
| 3540 | 3541 |
| 3541 // FormalParameterList :: | 3542 // FormalParameterList :: |
| 3542 // '(' (Identifier)*[','] ')' | 3543 // '(' (Identifier)*[','] ')' |
| 3543 Expect(Token::LPAREN, CHECK_OK); | 3544 Expect(Token::LPAREN, CHECK_OK); |
| 3544 int start_pos = scanner().location().beg_pos; | 3545 int start_pos = scanner().location().beg_pos; |
| 3545 Scanner::Location name_loc = Scanner::NoLocation(); | 3546 Scanner::Location name_loc = Scanner::NoLocation(); |
| 3546 Scanner::Location dupe_loc = Scanner::NoLocation(); | 3547 Scanner::Location dupe_loc = Scanner::NoLocation(); |
| 3547 Scanner::Location reserved_loc = Scanner::NoLocation(); | 3548 Scanner::Location reserved_loc = Scanner::NoLocation(); |
| 3549 bool has_duplicate_parameters = false; |
| 3548 | 3550 |
| 3549 bool done = (peek() == Token::RPAREN); | 3551 bool done = (peek() == Token::RPAREN); |
| 3550 while (!done) { | 3552 while (!done) { |
| 3551 bool is_reserved = false; | 3553 bool is_reserved = false; |
| 3552 Handle<String> param_name = | 3554 Handle<String> param_name = |
| 3553 ParseIdentifierOrReservedWord(&is_reserved, CHECK_OK); | 3555 ParseIdentifierOrReservedWord(&is_reserved, CHECK_OK); |
| 3554 | 3556 |
| 3555 // Store locations for possible future error reports. | 3557 // Store locations for possible future error reports. |
| 3556 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) { | 3558 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) { |
| 3557 name_loc = scanner().location(); | 3559 name_loc = scanner().location(); |
| 3558 } | 3560 } |
| 3559 if (!dupe_loc.IsValid() && top_scope_->IsDeclared(param_name)) { | 3561 if (!dupe_loc.IsValid() && top_scope_->IsDeclared(param_name)) { |
| 3562 has_duplicate_parameters = true; |
| 3560 dupe_loc = scanner().location(); | 3563 dupe_loc = scanner().location(); |
| 3561 } | 3564 } |
| 3562 if (!reserved_loc.IsValid() && is_reserved) { | 3565 if (!reserved_loc.IsValid() && is_reserved) { |
| 3563 reserved_loc = scanner().location(); | 3566 reserved_loc = scanner().location(); |
| 3564 } | 3567 } |
| 3565 | 3568 |
| 3566 Variable* parameter = top_scope_->DeclareLocal(param_name, Variable::VAR); | 3569 Variable* parameter = top_scope_->DeclareLocal(param_name, Variable::VAR); |
| 3567 top_scope_->AddParameter(parameter); | 3570 top_scope_->AddParameter(parameter); |
| 3568 num_parameters++; | 3571 num_parameters++; |
| 3569 if (num_parameters > kMaxNumFunctionParameters) { | 3572 if (num_parameters > kMaxNumFunctionParameters) { |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3681 ReportMessageAt(reserved_loc, "strict_reserved_word", | 3684 ReportMessageAt(reserved_loc, "strict_reserved_word", |
| 3682 Vector<const char*>::empty()); | 3685 Vector<const char*>::empty()); |
| 3683 *ok = false; | 3686 *ok = false; |
| 3684 return NULL; | 3687 return NULL; |
| 3685 } | 3688 } |
| 3686 CheckOctalLiteral(start_pos, end_pos, CHECK_OK); | 3689 CheckOctalLiteral(start_pos, end_pos, CHECK_OK); |
| 3687 } | 3690 } |
| 3688 | 3691 |
| 3689 FunctionLiteral* function_literal = | 3692 FunctionLiteral* function_literal = |
| 3690 new(zone()) FunctionLiteral(name, | 3693 new(zone()) FunctionLiteral(name, |
| 3691 top_scope_, | 3694 top_scope_, |
| 3692 body, | 3695 body, |
| 3693 materialized_literal_count, | 3696 materialized_literal_count, |
| 3694 expected_property_count, | 3697 expected_property_count, |
| 3695 only_simple_this_property_assignments, | 3698 only_simple_this_property_assignments, |
| 3696 this_property_assignments, | 3699 this_property_assignments, |
| 3697 num_parameters, | 3700 num_parameters, |
| 3698 start_pos, | 3701 start_pos, |
| 3699 end_pos, | 3702 end_pos, |
| 3700 function_name->length() > 0, | 3703 function_name->length() > 0, |
| 3701 lexical_scope.ContainsLoops()); | 3704 lexical_scope.ContainsLoops(), |
| 3705 has_duplicate_parameters); |
| 3702 function_literal->set_function_token_position(function_token_position); | 3706 function_literal->set_function_token_position(function_token_position); |
| 3703 | 3707 |
| 3704 if (fni_ != NULL && !is_named) fni_->AddFunction(function_literal); | 3708 if (fni_ != NULL && !is_named) fni_->AddFunction(function_literal); |
| 3705 return function_literal; | 3709 return function_literal; |
| 3706 } | 3710 } |
| 3707 } | 3711 } |
| 3708 | 3712 |
| 3709 | 3713 |
| 3710 Expression* Parser::ParseV8Intrinsic(bool* ok) { | 3714 Expression* Parser::ParseV8Intrinsic(bool* ok) { |
| 3711 // CallRuntime :: | 3715 // CallRuntime :: |
| (...skipping 1447 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5159 info->is_global(), | 5163 info->is_global(), |
| 5160 info->StrictMode()); | 5164 info->StrictMode()); |
| 5161 } | 5165 } |
| 5162 } | 5166 } |
| 5163 | 5167 |
| 5164 info->SetFunction(result); | 5168 info->SetFunction(result); |
| 5165 return (result != NULL); | 5169 return (result != NULL); |
| 5166 } | 5170 } |
| 5167 | 5171 |
| 5168 } } // namespace v8::internal | 5172 } } // namespace v8::internal |
| OLD | NEW |