| 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/conversions.h" | 8 #include "src/conversions.h" |
| 9 #include "src/lookup.h" | 9 #include "src/lookup.h" |
| 10 #include "src/messages.h" | 10 #include "src/messages.h" |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 494 return SUCCESS; | 494 return SUCCESS; |
| 495 } | 495 } |
| 496 | 496 |
| 497 | 497 |
| 498 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSArraySlow( | 498 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSArraySlow( |
| 499 Handle<JSArray> object, uint32_t start, uint32_t length) { | 499 Handle<JSArray> object, uint32_t start, uint32_t length) { |
| 500 for (uint32_t i = start; i < length; i++) { | 500 for (uint32_t i = start; i < length; i++) { |
| 501 if (i > 0) builder_.AppendCharacter(','); | 501 if (i > 0) builder_.AppendCharacter(','); |
| 502 Handle<Object> element; | 502 Handle<Object> element; |
| 503 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 503 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 504 isolate_, element, | 504 isolate_, element, JSReceiver::GetElement(isolate_, object, i), |
| 505 Object::GetElement(isolate_, object, i), | |
| 506 EXCEPTION); | 505 EXCEPTION); |
| 507 if (element->IsUndefined()) { | 506 if (element->IsUndefined()) { |
| 508 builder_.AppendCString("null"); | 507 builder_.AppendCString("null"); |
| 509 } else { | 508 } else { |
| 510 Result result = SerializeElement(isolate_, element, i); | 509 Result result = SerializeElement(isolate_, element, i); |
| 511 if (result == SUCCESS) continue; | 510 if (result == SUCCESS) continue; |
| 512 if (result == UNCHANGED) { | 511 if (result == UNCHANGED) { |
| 513 builder_.AppendCString("null"); | 512 builder_.AppendCString("null"); |
| 514 } else { | 513 } else { |
| 515 return result; | 514 return result; |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 Object* key = contents->get(i); | 572 Object* key = contents->get(i); |
| 574 Handle<String> key_handle; | 573 Handle<String> key_handle; |
| 575 MaybeHandle<Object> maybe_property; | 574 MaybeHandle<Object> maybe_property; |
| 576 if (key->IsString()) { | 575 if (key->IsString()) { |
| 577 key_handle = Handle<String>(String::cast(key), isolate_); | 576 key_handle = Handle<String>(String::cast(key), isolate_); |
| 578 maybe_property = Object::GetPropertyOrElement(object, key_handle); | 577 maybe_property = Object::GetPropertyOrElement(object, key_handle); |
| 579 } else { | 578 } else { |
| 580 DCHECK(key->IsNumber()); | 579 DCHECK(key->IsNumber()); |
| 581 key_handle = factory()->NumberToString(Handle<Object>(key, isolate_)); | 580 key_handle = factory()->NumberToString(Handle<Object>(key, isolate_)); |
| 582 if (key->IsSmi()) { | 581 if (key->IsSmi()) { |
| 583 maybe_property = Object::GetElement( | 582 maybe_property = |
| 584 isolate_, object, Smi::cast(key)->value()); | 583 JSReceiver::GetElement(isolate_, object, Smi::cast(key)->value()); |
| 585 } else { | 584 } else { |
| 586 maybe_property = Object::GetPropertyOrElement(object, key_handle); | 585 maybe_property = Object::GetPropertyOrElement(object, key_handle); |
| 587 } | 586 } |
| 588 } | 587 } |
| 589 Handle<Object> property; | 588 Handle<Object> property; |
| 590 ASSIGN_RETURN_ON_EXCEPTION_VALUE( | 589 ASSIGN_RETURN_ON_EXCEPTION_VALUE( |
| 591 isolate_, property, maybe_property, EXCEPTION); | 590 isolate_, property, maybe_property, EXCEPTION); |
| 592 Result result = SerializeProperty(property, comma, key_handle); | 591 Result result = SerializeProperty(property, comma, key_handle); |
| 593 if (!comma && result == SUCCESS) comma = true; | 592 if (!comma && result == SUCCESS) comma = true; |
| 594 if (result == EXCEPTION) return result; | 593 if (result == EXCEPTION) return result; |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 678 } else { | 677 } else { |
| 679 SerializeString_<uc16, uc16>(object); | 678 SerializeString_<uc16, uc16>(object); |
| 680 } | 679 } |
| 681 } | 680 } |
| 682 } | 681 } |
| 683 | 682 |
| 684 } // namespace internal | 683 } // namespace internal |
| 685 } // namespace v8 | 684 } // namespace v8 |
| 686 | 685 |
| 687 #endif // V8_JSON_STRINGIFIER_H_ | 686 #endif // V8_JSON_STRINGIFIER_H_ |
| OLD | NEW |