OLD | NEW |
1 // Copyright 2011 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 |
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
650 no_name, | 650 no_name, |
651 top_scope_, | 651 top_scope_, |
652 body, | 652 body, |
653 lexical_scope.materialized_literal_count(), | 653 lexical_scope.materialized_literal_count(), |
654 lexical_scope.expected_property_count(), | 654 lexical_scope.expected_property_count(), |
655 lexical_scope.only_simple_this_property_assignments(), | 655 lexical_scope.only_simple_this_property_assignments(), |
656 lexical_scope.this_property_assignments(), | 656 lexical_scope.this_property_assignments(), |
657 0, | 657 0, |
658 0, | 658 0, |
659 source->length(), | 659 source->length(), |
| 660 false, |
660 false); | 661 false); |
661 } else if (stack_overflow_) { | 662 } else if (stack_overflow_) { |
662 isolate()->StackOverflow(); | 663 isolate()->StackOverflow(); |
663 } | 664 } |
664 } | 665 } |
665 | 666 |
666 // Make sure the target stack is empty. | 667 // Make sure the target stack is empty. |
667 ASSERT(target_stack_ == NULL); | 668 ASSERT(target_stack_ == NULL); |
668 | 669 |
669 // If there was a syntax error we have to get rid of the AST | 670 // If there was a syntax error we have to get rid of the AST |
(...skipping 2872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3542 | 3543 |
3543 int num_parameters = 0; | 3544 int num_parameters = 0; |
3544 Scope* scope = NewScope(top_scope_, Scope::FUNCTION_SCOPE, inside_with()); | 3545 Scope* scope = NewScope(top_scope_, Scope::FUNCTION_SCOPE, inside_with()); |
3545 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(8); | 3546 ZoneList<Statement*>* body = new(zone()) ZoneList<Statement*>(8); |
3546 int materialized_literal_count; | 3547 int materialized_literal_count; |
3547 int expected_property_count; | 3548 int expected_property_count; |
3548 int start_pos; | 3549 int start_pos; |
3549 int end_pos; | 3550 int end_pos; |
3550 bool only_simple_this_property_assignments; | 3551 bool only_simple_this_property_assignments; |
3551 Handle<FixedArray> this_property_assignments; | 3552 Handle<FixedArray> this_property_assignments; |
| 3553 bool has_duplicate_parameters = false; |
3552 // Parse function body. | 3554 // Parse function body. |
3553 { LexicalScope lexical_scope(this, scope, isolate()); | 3555 { LexicalScope lexical_scope(this, scope, isolate()); |
3554 top_scope_->SetScopeName(name); | 3556 top_scope_->SetScopeName(name); |
3555 | 3557 |
3556 // FormalParameterList :: | 3558 // FormalParameterList :: |
3557 // '(' (Identifier)*[','] ')' | 3559 // '(' (Identifier)*[','] ')' |
3558 Expect(Token::LPAREN, CHECK_OK); | 3560 Expect(Token::LPAREN, CHECK_OK); |
3559 start_pos = scanner().location().beg_pos; | 3561 start_pos = scanner().location().beg_pos; |
3560 Scanner::Location name_loc = Scanner::Location::invalid(); | 3562 Scanner::Location name_loc = Scanner::Location::invalid(); |
3561 Scanner::Location dupe_loc = Scanner::Location::invalid(); | 3563 Scanner::Location dupe_loc = Scanner::Location::invalid(); |
3562 Scanner::Location reserved_loc = Scanner::Location::invalid(); | 3564 Scanner::Location reserved_loc = Scanner::Location::invalid(); |
3563 | 3565 |
3564 bool done = (peek() == Token::RPAREN); | 3566 bool done = (peek() == Token::RPAREN); |
3565 while (!done) { | 3567 while (!done) { |
3566 bool is_reserved = false; | 3568 bool is_reserved = false; |
3567 Handle<String> param_name = | 3569 Handle<String> param_name = |
3568 ParseIdentifierOrReservedWord(&is_reserved, CHECK_OK); | 3570 ParseIdentifierOrReservedWord(&is_reserved, CHECK_OK); |
3569 | 3571 |
3570 // Store locations for possible future error reports. | 3572 // Store locations for possible future error reports. |
3571 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) { | 3573 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) { |
3572 name_loc = scanner().location(); | 3574 name_loc = scanner().location(); |
3573 } | 3575 } |
3574 if (!dupe_loc.IsValid() && top_scope_->IsDeclared(param_name)) { | 3576 if (!dupe_loc.IsValid() && top_scope_->IsDeclared(param_name)) { |
| 3577 has_duplicate_parameters = true; |
3575 dupe_loc = scanner().location(); | 3578 dupe_loc = scanner().location(); |
3576 } | 3579 } |
3577 if (!reserved_loc.IsValid() && is_reserved) { | 3580 if (!reserved_loc.IsValid() && is_reserved) { |
3578 reserved_loc = scanner().location(); | 3581 reserved_loc = scanner().location(); |
3579 } | 3582 } |
3580 | 3583 |
3581 top_scope_->DeclareParameter(param_name); | 3584 top_scope_->DeclareParameter(param_name); |
3582 num_parameters++; | 3585 num_parameters++; |
3583 if (num_parameters > kMaxNumFunctionParameters) { | 3586 if (num_parameters > kMaxNumFunctionParameters) { |
3584 ReportMessageAt(scanner().location(), "too_many_parameters", | 3587 ReportMessageAt(scanner().location(), "too_many_parameters", |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3700 new(zone()) FunctionLiteral(name, | 3703 new(zone()) FunctionLiteral(name, |
3701 scope, | 3704 scope, |
3702 body, | 3705 body, |
3703 materialized_literal_count, | 3706 materialized_literal_count, |
3704 expected_property_count, | 3707 expected_property_count, |
3705 only_simple_this_property_assignments, | 3708 only_simple_this_property_assignments, |
3706 this_property_assignments, | 3709 this_property_assignments, |
3707 num_parameters, | 3710 num_parameters, |
3708 start_pos, | 3711 start_pos, |
3709 end_pos, | 3712 end_pos, |
3710 (function_name->length() > 0)); | 3713 (function_name->length() > 0), |
| 3714 has_duplicate_parameters); |
3711 function_literal->set_function_token_position(function_token_position); | 3715 function_literal->set_function_token_position(function_token_position); |
3712 | 3716 |
3713 if (fni_ != NULL && !is_named) fni_->AddFunction(function_literal); | 3717 if (fni_ != NULL && !is_named) fni_->AddFunction(function_literal); |
3714 return function_literal; | 3718 return function_literal; |
3715 } | 3719 } |
3716 | 3720 |
3717 | 3721 |
3718 Expression* Parser::ParseV8Intrinsic(bool* ok) { | 3722 Expression* Parser::ParseV8Intrinsic(bool* ok) { |
3719 // CallRuntime :: | 3723 // CallRuntime :: |
3720 // '%' Identifier Arguments | 3724 // '%' Identifier Arguments |
(...skipping 1270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4991 info->is_global(), | 4995 info->is_global(), |
4992 info->StrictMode()); | 4996 info->StrictMode()); |
4993 } | 4997 } |
4994 } | 4998 } |
4995 | 4999 |
4996 info->SetFunction(result); | 5000 info->SetFunction(result); |
4997 return (result != NULL); | 5001 return (result != NULL); |
4998 } | 5002 } |
4999 | 5003 |
5000 } } // namespace v8::internal | 5004 } } // namespace v8::internal |
OLD | NEW |