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