| 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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 return SUCCESS; | 624 return SUCCESS; |
| 625 } | 625 } |
| 626 | 626 |
| 627 | 627 |
| 628 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSObject( | 628 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSObject( |
| 629 Handle<JSObject> object) { | 629 Handle<JSObject> object) { |
| 630 HandleScope handle_scope(isolate_); | 630 HandleScope handle_scope(isolate_); |
| 631 Result stack_push = StackPush(object); | 631 Result stack_push = StackPush(object); |
| 632 if (stack_push != SUCCESS) return stack_push; | 632 if (stack_push != SUCCESS) return stack_push; |
| 633 if (object->IsJSGlobalProxy()) { | 633 if (object->IsJSGlobalProxy()) { |
| 634 object = Handle<JSObject>( | 634 // TODO(verwaest): This will crash if the global proxy is detached. |
| 635 JSObject::cast(object->GetPrototype()), isolate_); | 635 PrototypeIterator iter(isolate_, object); |
| 636 object = Handle<JSObject>::cast(PrototypeIterator::GetCurrent(iter)); |
| 636 ASSERT(object->IsGlobalObject()); | 637 ASSERT(object->IsGlobalObject()); |
| 637 } | 638 } |
| 638 | 639 |
| 639 Append('{'); | 640 Append('{'); |
| 640 bool comma = false; | 641 bool comma = false; |
| 641 | 642 |
| 642 if (object->HasFastProperties() && | 643 if (object->HasFastProperties() && |
| 643 !object->HasIndexedInterceptor() && | 644 !object->HasIndexedInterceptor() && |
| 644 !object->HasNamedInterceptor() && | 645 !object->HasNamedInterceptor() && |
| 645 object->elements()->length() == 0) { | 646 object->elements()->length() == 0) { |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 SerializeString_<false, uint8_t>(object); | 872 SerializeString_<false, uint8_t>(object); |
| 872 } else { | 873 } else { |
| 873 SerializeString_<false, uc16>(object); | 874 SerializeString_<false, uc16>(object); |
| 874 } | 875 } |
| 875 } | 876 } |
| 876 } | 877 } |
| 877 | 878 |
| 878 } } // namespace v8::internal | 879 } } // namespace v8::internal |
| 879 | 880 |
| 880 #endif // V8_JSON_STRINGIFIER_H_ | 881 #endif // V8_JSON_STRINGIFIER_H_ |
| OLD | NEW |