OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_JSON_STRINGIFIER_H_ | 5 #ifndef V8_JSON_STRINGIFIER_H_ |
6 #define V8_JSON_STRINGIFIER_H_ | 6 #define V8_JSON_STRINGIFIER_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/conversions.h" | 10 #include "src/conversions.h" |
(...skipping 562 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
573 for (int i = 0; i < contents->length(); i++) { | 573 for (int i = 0; i < contents->length(); i++) { |
574 Object* key = contents->get(i); | 574 Object* key = contents->get(i); |
575 Handle<String> key_handle; | 575 Handle<String> key_handle; |
576 MaybeHandle<Object> maybe_property; | 576 MaybeHandle<Object> maybe_property; |
577 if (key->IsString()) { | 577 if (key->IsString()) { |
578 key_handle = Handle<String>(String::cast(key), isolate_); | 578 key_handle = Handle<String>(String::cast(key), isolate_); |
579 maybe_property = Object::GetPropertyOrElement(object, key_handle); | 579 maybe_property = Object::GetPropertyOrElement(object, key_handle); |
580 } else { | 580 } else { |
581 DCHECK(key->IsNumber()); | 581 DCHECK(key->IsNumber()); |
582 key_handle = factory()->NumberToString(Handle<Object>(key, isolate_)); | 582 key_handle = factory()->NumberToString(Handle<Object>(key, isolate_)); |
583 uint32_t index; | |
584 if (key->IsSmi()) { | 583 if (key->IsSmi()) { |
585 maybe_property = Object::GetElement( | 584 maybe_property = Object::GetElement( |
586 isolate_, object, Smi::cast(key)->value()); | 585 isolate_, object, Smi::cast(key)->value()); |
587 } else if (key_handle->AsArrayIndex(&index)) { | |
588 maybe_property = Object::GetElement(isolate_, object, index); | |
589 } else { | 586 } else { |
590 maybe_property = Object::GetPropertyOrElement(object, key_handle); | 587 maybe_property = Object::GetPropertyOrElement(object, key_handle); |
591 } | 588 } |
592 } | 589 } |
593 Handle<Object> property; | 590 Handle<Object> property; |
594 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 591 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
595 isolate_, property, maybe_property, EXCEPTION); | 592 isolate_, property, maybe_property, EXCEPTION); |
596 Result result = SerializeProperty(property, comma, key_handle); | 593 Result result = SerializeProperty(property, comma, key_handle); |
597 if (!comma && result == SUCCESS) comma = true; | 594 if (!comma && result == SUCCESS) comma = true; |
598 if (result == EXCEPTION) return result; | 595 if (result == EXCEPTION) return result; |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
681 SerializeString_<uint8_t, uc16>(object); | 678 SerializeString_<uint8_t, uc16>(object); |
682 } else { | 679 } else { |
683 SerializeString_<uc16, uc16>(object); | 680 SerializeString_<uc16, uc16>(object); |
684 } | 681 } |
685 } | 682 } |
686 } | 683 } |
687 | 684 |
688 } } // namespace v8::internal | 685 } } // namespace v8::internal |
689 | 686 |
690 #endif // V8_JSON_STRINGIFIER_H_ | 687 #endif // V8_JSON_STRINGIFIER_H_ |
OLD | NEW |