| 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 735 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 746 LexicalScope lexical_scope(&this->top_scope_, &this->with_nesting_level_, | 746 LexicalScope lexical_scope(&this->top_scope_, &this->with_nesting_level_, |
| 747 scope); | 747 scope); |
| 748 TemporaryScope temp_scope(&this->temp_scope_); | 748 TemporaryScope temp_scope(&this->temp_scope_); |
| 749 | 749 |
| 750 FunctionLiteralType type = | 750 FunctionLiteralType type = |
| 751 info->is_expression() ? EXPRESSION : DECLARATION; | 751 info->is_expression() ? EXPRESSION : DECLARATION; |
| 752 bool ok = true; | 752 bool ok = true; |
| 753 result = ParseFunctionLiteral(name, RelocInfo::kNoPosition, type, &ok); | 753 result = ParseFunctionLiteral(name, RelocInfo::kNoPosition, type, &ok); |
| 754 // Make sure the results agree. | 754 // Make sure the results agree. |
| 755 ASSERT(ok == (result != NULL)); | 755 ASSERT(ok == (result != NULL)); |
| 756 // The only errors should be stack overflows. | |
| 757 ASSERT(ok || stack_overflow_); | |
| 758 } | 756 } |
| 759 | 757 |
| 760 // Make sure the target stack is empty. | 758 // Make sure the target stack is empty. |
| 761 ASSERT(target_stack_ == NULL); | 759 ASSERT(target_stack_ == NULL); |
| 762 | 760 |
| 763 // If there was a stack overflow we have to get rid of AST and it is | 761 // If there was a stack overflow we have to get rid of AST and it is |
| 764 // not safe to do before scope has been deleted. | 762 // not safe to do before scope has been deleted. |
| 765 if (result == NULL) { | 763 if (result == NULL) { |
| 766 Top::StackOverflow(); | |
| 767 zone_scope->DeleteOnExit(); | 764 zone_scope->DeleteOnExit(); |
| 765 if (stack_overflow_) Top::StackOverflow(); |
| 768 } else { | 766 } else { |
| 769 Handle<String> inferred_name(info->inferred_name()); | 767 Handle<String> inferred_name(info->inferred_name()); |
| 770 result->set_inferred_name(inferred_name); | 768 result->set_inferred_name(inferred_name); |
| 771 } | 769 } |
| 772 return result; | 770 return result; |
| 773 } | 771 } |
| 774 | 772 |
| 775 | 773 |
| 776 Handle<String> Parser::GetSymbol(bool* ok) { | 774 Handle<String> Parser::GetSymbol(bool* ok) { |
| 777 int symbol_id = -1; | 775 int symbol_id = -1; |
| (...skipping 2685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3463 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) { | 3461 if (!name_loc.IsValid() && IsEvalOrArguments(param_name)) { |
| 3464 name_loc = scanner().location(); | 3462 name_loc = scanner().location(); |
| 3465 } | 3463 } |
| 3466 if (!dupe_loc.IsValid() && top_scope_->IsDeclared(param_name)) { | 3464 if (!dupe_loc.IsValid() && top_scope_->IsDeclared(param_name)) { |
| 3467 dupe_loc = scanner().location(); | 3465 dupe_loc = scanner().location(); |
| 3468 } | 3466 } |
| 3469 | 3467 |
| 3470 Variable* parameter = top_scope_->DeclareLocal(param_name, Variable::VAR); | 3468 Variable* parameter = top_scope_->DeclareLocal(param_name, Variable::VAR); |
| 3471 top_scope_->AddParameter(parameter); | 3469 top_scope_->AddParameter(parameter); |
| 3472 num_parameters++; | 3470 num_parameters++; |
| 3471 if (num_parameters > kMaxNumFunctionParameters) { |
| 3472 ReportMessageAt(scanner().location(), "too_many_parameters", |
| 3473 Vector<const char*>::empty()); |
| 3474 *ok = false; |
| 3475 return NULL; |
| 3476 } |
| 3473 done = (peek() == Token::RPAREN); | 3477 done = (peek() == Token::RPAREN); |
| 3474 if (!done) Expect(Token::COMMA, CHECK_OK); | 3478 if (!done) Expect(Token::COMMA, CHECK_OK); |
| 3475 } | 3479 } |
| 3476 Expect(Token::RPAREN, CHECK_OK); | 3480 Expect(Token::RPAREN, CHECK_OK); |
| 3477 | 3481 |
| 3478 Expect(Token::LBRACE, CHECK_OK); | 3482 Expect(Token::LBRACE, CHECK_OK); |
| 3479 ZoneList<Statement*>* body = new ZoneList<Statement*>(8); | 3483 ZoneList<Statement*>* body = new ZoneList<Statement*>(8); |
| 3480 | 3484 |
| 3481 // If we have a named function expression, we add a local variable | 3485 // If we have a named function expression, we add a local variable |
| 3482 // declaration to the body of the function with the name of the | 3486 // declaration to the body of the function with the name of the |
| (...skipping 1544 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5027 Handle<String> source = Handle<String>(String::cast(script->source())); | 5031 Handle<String> source = Handle<String>(String::cast(script->source())); |
| 5028 result = parser.ParseProgram(source, info->is_global()); | 5032 result = parser.ParseProgram(source, info->is_global()); |
| 5029 } | 5033 } |
| 5030 } | 5034 } |
| 5031 | 5035 |
| 5032 info->SetFunction(result); | 5036 info->SetFunction(result); |
| 5033 return (result != NULL); | 5037 return (result != NULL); |
| 5034 } | 5038 } |
| 5035 | 5039 |
| 5036 } } // namespace v8::internal | 5040 } } // namespace v8::internal |
| OLD | NEW |