OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 584 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
595 StackPop(); | 595 StackPop(); |
596 current_part_ = handle_scope.CloseAndEscape(current_part_); | 596 current_part_ = handle_scope.CloseAndEscape(current_part_); |
597 return SUCCESS; | 597 return SUCCESS; |
598 } | 598 } |
599 | 599 |
600 | 600 |
601 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSArraySlow( | 601 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSArraySlow( |
602 Handle<JSArray> object, int length) { | 602 Handle<JSArray> object, int length) { |
603 for (int i = 0; i < length; i++) { | 603 for (int i = 0; i < length; i++) { |
604 if (i > 0) Append(','); | 604 if (i > 0) Append(','); |
605 Handle<Object> element = Object::GetElement(object, i); | 605 Handle<Object> element = Object::GetElement(isolate_, object, i); |
606 RETURN_IF_EMPTY_HANDLE_VALUE(isolate_, element, EXCEPTION); | 606 RETURN_IF_EMPTY_HANDLE_VALUE(isolate_, element, EXCEPTION); |
607 if (element->IsUndefined()) { | 607 if (element->IsUndefined()) { |
608 AppendAscii("null"); | 608 AppendAscii("null"); |
609 } else { | 609 } else { |
610 Result result = SerializeElement(object->GetIsolate(), element, i); | 610 Result result = SerializeElement(isolate_, element, i); |
611 if (result == SUCCESS) continue; | 611 if (result == SUCCESS) continue; |
612 if (result == UNCHANGED) { | 612 if (result == UNCHANGED) { |
613 AppendAscii("null"); | 613 AppendAscii("null"); |
614 } else { | 614 } else { |
615 return result; | 615 return result; |
616 } | 616 } |
617 } | 617 } |
618 } | 618 } |
619 return SUCCESS; | 619 return SUCCESS; |
620 } | 620 } |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 Handle<String> key_handle; | 671 Handle<String> key_handle; |
672 Handle<Object> property; | 672 Handle<Object> property; |
673 if (key->IsString()) { | 673 if (key->IsString()) { |
674 key_handle = Handle<String>(String::cast(key), isolate_); | 674 key_handle = Handle<String>(String::cast(key), isolate_); |
675 property = GetProperty(isolate_, object, key_handle); | 675 property = GetProperty(isolate_, object, key_handle); |
676 } else { | 676 } else { |
677 ASSERT(key->IsNumber()); | 677 ASSERT(key->IsNumber()); |
678 key_handle = factory_->NumberToString(Handle<Object>(key, isolate_)); | 678 key_handle = factory_->NumberToString(Handle<Object>(key, isolate_)); |
679 uint32_t index; | 679 uint32_t index; |
680 if (key->IsSmi()) { | 680 if (key->IsSmi()) { |
681 property = Object::GetElement(object, Smi::cast(key)->value()); | 681 property = Object::GetElement( |
| 682 isolate_, object, Smi::cast(key)->value()); |
682 } else if (key_handle->AsArrayIndex(&index)) { | 683 } else if (key_handle->AsArrayIndex(&index)) { |
683 property = Object::GetElement(object, index); | 684 property = Object::GetElement(isolate_, object, index); |
684 } else { | 685 } else { |
685 property = GetProperty(isolate_, object, key_handle); | 686 property = GetProperty(isolate_, object, key_handle); |
686 } | 687 } |
687 } | 688 } |
688 if (property.is_null()) return EXCEPTION; | 689 if (property.is_null()) return EXCEPTION; |
689 Result result = SerializeProperty(property, comma, key_handle); | 690 Result result = SerializeProperty(property, comma, key_handle); |
690 if (!comma && result == SUCCESS) comma = true; | 691 if (!comma && result == SUCCESS) comma = true; |
691 if (result >= EXCEPTION) return result; | 692 if (result >= EXCEPTION) return result; |
692 } | 693 } |
693 } | 694 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
845 SerializeString_<false, uint8_t>(object); | 846 SerializeString_<false, uint8_t>(object); |
846 } else { | 847 } else { |
847 SerializeString_<false, uc16>(object); | 848 SerializeString_<false, uc16>(object); |
848 } | 849 } |
849 } | 850 } |
850 } | 851 } |
851 | 852 |
852 } } // namespace v8::internal | 853 } } // namespace v8::internal |
853 | 854 |
854 #endif // V8_JSON_STRINGIFIER_H_ | 855 #endif // V8_JSON_STRINGIFIER_H_ |
OLD | NEW |