| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 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 646 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 657 : Scope::EVAL_SCOPE; | 657 : Scope::EVAL_SCOPE; |
| 658 Handle<String> no_name = Factory::empty_symbol(); | 658 Handle<String> no_name = Factory::empty_symbol(); |
| 659 | 659 |
| 660 FunctionLiteral* result = NULL; | 660 FunctionLiteral* result = NULL; |
| 661 { Scope* scope = NewScope(top_scope_, type, inside_with()); | 661 { Scope* scope = NewScope(top_scope_, type, inside_with()); |
| 662 LexicalScope lexical_scope(&this->top_scope_, &this->with_nesting_level_, | 662 LexicalScope lexical_scope(&this->top_scope_, &this->with_nesting_level_, |
| 663 scope); | 663 scope); |
| 664 TemporaryScope temp_scope(&this->temp_scope_); | 664 TemporaryScope temp_scope(&this->temp_scope_); |
| 665 ZoneList<Statement*>* body = new ZoneList<Statement*>(16); | 665 ZoneList<Statement*>* body = new ZoneList<Statement*>(16); |
| 666 bool ok = true; | 666 bool ok = true; |
| 667 int beg_loc = scanner().location().beg_pos; |
| 667 ParseSourceElements(body, Token::EOS, &ok); | 668 ParseSourceElements(body, Token::EOS, &ok); |
| 669 if (ok && temp_scope_->StrictMode()) { |
| 670 CheckOctalLiteral(beg_loc, scanner().location().end_pos, &ok); |
| 671 } |
| 668 if (ok) { | 672 if (ok) { |
| 669 result = new FunctionLiteral( | 673 result = new FunctionLiteral( |
| 670 no_name, | 674 no_name, |
| 671 top_scope_, | 675 top_scope_, |
| 672 body, | 676 body, |
| 673 temp_scope.materialized_literal_count(), | 677 temp_scope.materialized_literal_count(), |
| 674 temp_scope.expected_property_count(), | 678 temp_scope.expected_property_count(), |
| 675 temp_scope.only_simple_this_property_assignments(), | 679 temp_scope.only_simple_this_property_assignments(), |
| 676 temp_scope.this_property_assignments(), | 680 temp_scope.this_property_assignments(), |
| 677 0, | 681 0, |
| (...skipping 2699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3377 if (temp_scope_->StrictMode()) { | 3381 if (temp_scope_->StrictMode()) { |
| 3378 if (IsEvalOrArguments(name)) { | 3382 if (IsEvalOrArguments(name)) { |
| 3379 int position = function_token_position != RelocInfo::kNoPosition | 3383 int position = function_token_position != RelocInfo::kNoPosition |
| 3380 ? function_token_position | 3384 ? function_token_position |
| 3381 : (start_pos > 0 ? start_pos - 1 : start_pos); | 3385 : (start_pos > 0 ? start_pos - 1 : start_pos); |
| 3382 ReportMessageAt(Scanner::Location(position, start_pos), | 3386 ReportMessageAt(Scanner::Location(position, start_pos), |
| 3383 "strict_function_name", Vector<const char*>::empty()); | 3387 "strict_function_name", Vector<const char*>::empty()); |
| 3384 *ok = false; | 3388 *ok = false; |
| 3385 return NULL; | 3389 return NULL; |
| 3386 } | 3390 } |
| 3387 // TODO(mmaly): Check for octal escape sequence here. | 3391 CheckOctalLiteral(start_pos, end_pos, CHECK_OK); |
| 3388 } | 3392 } |
| 3389 | 3393 |
| 3390 FunctionLiteral* function_literal = | 3394 FunctionLiteral* function_literal = |
| 3391 new FunctionLiteral(name, | 3395 new FunctionLiteral(name, |
| 3392 top_scope_, | 3396 top_scope_, |
| 3393 body, | 3397 body, |
| 3394 materialized_literal_count, | 3398 materialized_literal_count, |
| 3395 expected_property_count, | 3399 expected_property_count, |
| 3396 only_simple_this_property_assignments, | 3400 only_simple_this_property_assignments, |
| 3397 this_property_assignments, | 3401 this_property_assignments, |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3523 Handle<String> Parser::ParseIdentifierName(bool* ok) { | 3527 Handle<String> Parser::ParseIdentifierName(bool* ok) { |
| 3524 Token::Value next = Next(); | 3528 Token::Value next = Next(); |
| 3525 if (next != Token::IDENTIFIER && !Token::IsKeyword(next)) { | 3529 if (next != Token::IDENTIFIER && !Token::IsKeyword(next)) { |
| 3526 ReportUnexpectedToken(next); | 3530 ReportUnexpectedToken(next); |
| 3527 *ok = false; | 3531 *ok = false; |
| 3528 return Handle<String>(); | 3532 return Handle<String>(); |
| 3529 } | 3533 } |
| 3530 return GetSymbol(ok); | 3534 return GetSymbol(ok); |
| 3531 } | 3535 } |
| 3532 | 3536 |
| 3537 // Checks whether octal literal last seen is between beg_pos and end_pos. |
| 3538 // If so, reports an error. |
| 3539 void Parser::CheckOctalLiteral(int beg_pos, int end_pos, bool* ok) { |
| 3540 int octal = scanner().octal_position(); |
| 3541 if (beg_pos <= octal && octal <= end_pos) { |
| 3542 ReportMessageAt(Scanner::Location(octal, octal + 1), "strict_octal_literal", |
| 3543 Vector<const char*>::empty()); |
| 3544 scanner().clear_octal_position(); |
| 3545 *ok = false; |
| 3546 } |
| 3547 } |
| 3548 |
| 3533 | 3549 |
| 3534 // This function reads an identifier and determines whether or not it | 3550 // This function reads an identifier and determines whether or not it |
| 3535 // is 'get' or 'set'. The reason for not using ParseIdentifier and | 3551 // is 'get' or 'set'. The reason for not using ParseIdentifier and |
| 3536 // checking on the output is that this involves heap allocation which | 3552 // checking on the output is that this involves heap allocation which |
| 3537 // we can't do during preparsing. | 3553 // we can't do during preparsing. |
| 3538 Handle<String> Parser::ParseIdentifierOrGetOrSet(bool* is_get, | 3554 Handle<String> Parser::ParseIdentifierOrGetOrSet(bool* is_get, |
| 3539 bool* is_set, | 3555 bool* is_set, |
| 3540 bool* ok) { | 3556 bool* ok) { |
| 3541 Expect(Token::IDENTIFIER, ok); | 3557 Expect(Token::IDENTIFIER, ok); |
| 3542 if (!*ok) return Handle<String>(); | 3558 if (!*ok) return Handle<String>(); |
| (...skipping 1275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4818 Handle<String> source = Handle<String>(String::cast(script->source())); | 4834 Handle<String> source = Handle<String>(String::cast(script->source())); |
| 4819 result = parser.ParseProgram(source, info->is_global()); | 4835 result = parser.ParseProgram(source, info->is_global()); |
| 4820 } | 4836 } |
| 4821 } | 4837 } |
| 4822 | 4838 |
| 4823 info->SetFunction(result); | 4839 info->SetFunction(result); |
| 4824 return (result != NULL); | 4840 return (result != NULL); |
| 4825 } | 4841 } |
| 4826 | 4842 |
| 4827 } } // namespace v8::internal | 4843 } } // namespace v8::internal |
| OLD | NEW |