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 653 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
664 Handle<String> key = Handle<String>::cast(name); | 664 Handle<String> key = Handle<String>::cast(name); |
665 PropertyDetails details = map->instance_descriptors()->GetDetails(i); | 665 PropertyDetails details = map->instance_descriptors()->GetDetails(i); |
666 if (details.IsDontEnum()) continue; | 666 if (details.IsDontEnum()) continue; |
667 Handle<Object> property; | 667 Handle<Object> property; |
668 if (details.type() == FIELD && *map == object->map()) { | 668 if (details.type() == FIELD && *map == object->map()) { |
669 property = Handle<Object>( | 669 property = Handle<Object>( |
670 object->RawFastPropertyAt( | 670 object->RawFastPropertyAt( |
671 map->instance_descriptors()->GetFieldIndex(i)), | 671 map->instance_descriptors()->GetFieldIndex(i)), |
672 isolate_); | 672 isolate_); |
673 } else { | 673 } else { |
674 property = GetProperty(isolate_, object, key); | 674 property = Object::GetPropertyOrElement(object, key); |
675 RETURN_IF_EMPTY_HANDLE_VALUE(isolate_, property, EXCEPTION); | 675 RETURN_IF_EMPTY_HANDLE_VALUE(isolate_, property, EXCEPTION); |
676 } | 676 } |
677 Result result = SerializeProperty(property, comma, key); | 677 Result result = SerializeProperty(property, comma, key); |
678 if (!comma && result == SUCCESS) comma = true; | 678 if (!comma && result == SUCCESS) comma = true; |
679 if (result >= EXCEPTION) return result; | 679 if (result >= EXCEPTION) return result; |
680 } | 680 } |
681 } else { | 681 } else { |
682 bool has_exception = false; | 682 bool has_exception = false; |
683 Handle<FixedArray> contents = | 683 Handle<FixedArray> contents = |
684 GetKeysInFixedArrayFor(object, LOCAL_ONLY, &has_exception); | 684 GetKeysInFixedArrayFor(object, LOCAL_ONLY, &has_exception); |
685 if (has_exception) return EXCEPTION; | 685 if (has_exception) return EXCEPTION; |
686 | 686 |
687 for (int i = 0; i < contents->length(); i++) { | 687 for (int i = 0; i < contents->length(); i++) { |
688 Object* key = contents->get(i); | 688 Object* key = contents->get(i); |
689 Handle<String> key_handle; | 689 Handle<String> key_handle; |
690 Handle<Object> property; | 690 Handle<Object> property; |
691 if (key->IsString()) { | 691 if (key->IsString()) { |
692 key_handle = Handle<String>(String::cast(key), isolate_); | 692 key_handle = Handle<String>(String::cast(key), isolate_); |
693 property = GetProperty(isolate_, object, key_handle); | 693 property = Object::GetPropertyOrElement(object, key_handle); |
694 } else { | 694 } else { |
695 ASSERT(key->IsNumber()); | 695 ASSERT(key->IsNumber()); |
696 key_handle = factory_->NumberToString(Handle<Object>(key, isolate_)); | 696 key_handle = factory_->NumberToString(Handle<Object>(key, isolate_)); |
697 uint32_t index; | 697 uint32_t index; |
698 if (key->IsSmi()) { | 698 if (key->IsSmi()) { |
699 property = Object::GetElement( | 699 property = Object::GetElement( |
700 isolate_, object, Smi::cast(key)->value()); | 700 isolate_, object, Smi::cast(key)->value()); |
701 } else if (key_handle->AsArrayIndex(&index)) { | 701 } else if (key_handle->AsArrayIndex(&index)) { |
702 property = Object::GetElement(isolate_, object, index); | 702 property = Object::GetElement(isolate_, object, index); |
703 } else { | 703 } else { |
704 property = GetProperty(isolate_, object, key_handle); | 704 property = Object::GetPropertyOrElement(object, key_handle); |
705 } | 705 } |
706 } | 706 } |
707 RETURN_IF_EMPTY_HANDLE_VALUE(isolate_, property, EXCEPTION); | 707 RETURN_IF_EMPTY_HANDLE_VALUE(isolate_, property, EXCEPTION); |
708 Result result = SerializeProperty(property, comma, key_handle); | 708 Result result = SerializeProperty(property, comma, key_handle); |
709 if (!comma && result == SUCCESS) comma = true; | 709 if (!comma && result == SUCCESS) comma = true; |
710 if (result >= EXCEPTION) return result; | 710 if (result >= EXCEPTION) return result; |
711 } | 711 } |
712 } | 712 } |
713 | 713 |
714 Append('}'); | 714 Append('}'); |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 SerializeString_<false, uint8_t>(object); | 877 SerializeString_<false, uint8_t>(object); |
878 } else { | 878 } else { |
879 SerializeString_<false, uc16>(object); | 879 SerializeString_<false, uc16>(object); |
880 } | 880 } |
881 } | 881 } |
882 } | 882 } |
883 | 883 |
884 } } // namespace v8::internal | 884 } } // namespace v8::internal |
885 | 885 |
886 #endif // V8_JSON_STRINGIFIER_H_ | 886 #endif // V8_JSON_STRINGIFIER_H_ |
OLD | NEW |