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 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
757 } | 757 } |
758 | 758 |
759 FunctionLiteralType type = | 759 FunctionLiteralType type = |
760 info->is_expression() ? EXPRESSION : DECLARATION; | 760 info->is_expression() ? EXPRESSION : DECLARATION; |
761 bool ok = true; | 761 bool ok = true; |
762 result = ParseFunctionLiteral(name, | 762 result = ParseFunctionLiteral(name, |
763 false, // Strict mode name already checked. | 763 false, // Strict mode name already checked. |
764 RelocInfo::kNoPosition, type, &ok); | 764 RelocInfo::kNoPosition, type, &ok); |
765 // Make sure the results agree. | 765 // Make sure the results agree. |
766 ASSERT(ok == (result != NULL)); | 766 ASSERT(ok == (result != NULL)); |
767 // The only errors should be stack overflows. | |
768 ASSERT(ok || stack_overflow_); | |
769 } | 767 } |
770 | 768 |
771 // Make sure the target stack is empty. | 769 // Make sure the target stack is empty. |
772 ASSERT(target_stack_ == NULL); | 770 ASSERT(target_stack_ == NULL); |
773 | 771 |
774 // If there was a stack overflow we have to get rid of AST and it is | 772 // If there was a stack overflow we have to get rid of AST and it is |
775 // not safe to do before scope has been deleted. | 773 // not safe to do before scope has been deleted. |
776 if (result == NULL) { | 774 if (result == NULL) { |
777 Top::StackOverflow(); | |
778 zone_scope->DeleteOnExit(); | 775 zone_scope->DeleteOnExit(); |
| 776 if (stack_overflow_) Top::StackOverflow(); |
779 } else { | 777 } else { |
780 Handle<String> inferred_name(info->inferred_name()); | 778 Handle<String> inferred_name(info->inferred_name()); |
781 result->set_inferred_name(inferred_name); | 779 result->set_inferred_name(inferred_name); |
782 } | 780 } |
783 return result; | 781 return result; |
784 } | 782 } |
785 | 783 |
786 | 784 |
787 Handle<String> Parser::GetSymbol(bool* ok) { | 785 Handle<String> Parser::GetSymbol(bool* ok) { |
788 int symbol_id = -1; | 786 int symbol_id = -1; |
(...skipping 2705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3494 if (!dupe_loc.IsValid() && top_scope_->IsDeclared(param_name)) { | 3492 if (!dupe_loc.IsValid() && top_scope_->IsDeclared(param_name)) { |
3495 dupe_loc = scanner().location(); | 3493 dupe_loc = scanner().location(); |
3496 } | 3494 } |
3497 if (!reserved_loc.IsValid() && is_reserved) { | 3495 if (!reserved_loc.IsValid() && is_reserved) { |
3498 reserved_loc = scanner().location(); | 3496 reserved_loc = scanner().location(); |
3499 } | 3497 } |
3500 | 3498 |
3501 Variable* parameter = top_scope_->DeclareLocal(param_name, Variable::VAR); | 3499 Variable* parameter = top_scope_->DeclareLocal(param_name, Variable::VAR); |
3502 top_scope_->AddParameter(parameter); | 3500 top_scope_->AddParameter(parameter); |
3503 num_parameters++; | 3501 num_parameters++; |
| 3502 if (num_parameters > kMaxNumFunctionParameters) { |
| 3503 ReportMessageAt(scanner().location(), "too_many_parameters", |
| 3504 Vector<const char*>::empty()); |
| 3505 *ok = false; |
| 3506 return NULL; |
| 3507 } |
3504 done = (peek() == Token::RPAREN); | 3508 done = (peek() == Token::RPAREN); |
3505 if (!done) Expect(Token::COMMA, CHECK_OK); | 3509 if (!done) Expect(Token::COMMA, CHECK_OK); |
3506 } | 3510 } |
3507 Expect(Token::RPAREN, CHECK_OK); | 3511 Expect(Token::RPAREN, CHECK_OK); |
3508 | 3512 |
3509 Expect(Token::LBRACE, CHECK_OK); | 3513 Expect(Token::LBRACE, CHECK_OK); |
3510 ZoneList<Statement*>* body = new ZoneList<Statement*>(8); | 3514 ZoneList<Statement*>* body = new ZoneList<Statement*>(8); |
3511 | 3515 |
3512 // If we have a named function expression, we add a local variable | 3516 // If we have a named function expression, we add a local variable |
3513 // declaration to the body of the function with the name of the | 3517 // declaration to the body of the function with the name of the |
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
4051 } | 4055 } |
4052 Handle<String> key = GetString(); | 4056 Handle<String> key = GetString(); |
4053 if (scanner_.Next() != Token::COLON) { | 4057 if (scanner_.Next() != Token::COLON) { |
4054 return ReportUnexpectedToken(); | 4058 return ReportUnexpectedToken(); |
4055 } | 4059 } |
4056 Handle<Object> value = ParseJsonValue(); | 4060 Handle<Object> value = ParseJsonValue(); |
4057 if (value.is_null()) return Handle<Object>::null(); | 4061 if (value.is_null()) return Handle<Object>::null(); |
4058 uint32_t index; | 4062 uint32_t index; |
4059 if (key->AsArrayIndex(&index)) { | 4063 if (key->AsArrayIndex(&index)) { |
4060 SetOwnElement(json_object, index, value); | 4064 SetOwnElement(json_object, index, value); |
| 4065 } else if (key->Equals(Heap::Proto_symbol())) { |
| 4066 // We can't remove the __proto__ accessor since it's hardcoded |
| 4067 // in several places. Instead go along and add the value as |
| 4068 // the prototype of the created object if possible. |
| 4069 SetPrototype(json_object, value); |
4061 } else { | 4070 } else { |
4062 SetLocalPropertyIgnoreAttributes(json_object, key, value, NONE); | 4071 SetLocalPropertyIgnoreAttributes(json_object, key, value, NONE); |
4063 } | 4072 } |
4064 } while (scanner_.Next() == Token::COMMA); | 4073 } while (scanner_.Next() == Token::COMMA); |
4065 if (scanner_.current_token() != Token::RBRACE) { | 4074 if (scanner_.current_token() != Token::RBRACE) { |
4066 return ReportUnexpectedToken(); | 4075 return ReportUnexpectedToken(); |
4067 } | 4076 } |
4068 } | 4077 } |
4069 return json_object; | 4078 return json_object; |
4070 } | 4079 } |
(...skipping 1023 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5094 info->is_global(), | 5103 info->is_global(), |
5095 info->StrictMode()); | 5104 info->StrictMode()); |
5096 } | 5105 } |
5097 } | 5106 } |
5098 | 5107 |
5099 info->SetFunction(result); | 5108 info->SetFunction(result); |
5100 return (result != NULL); | 5109 return (result != NULL); |
5101 } | 5110 } |
5102 | 5111 |
5103 } } // namespace v8::internal | 5112 } } // namespace v8::internal |
OLD | NEW |