| 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" |
| 11 #include "src/prototype-iterator.h" |
| 11 #include "src/utils.h" | 12 #include "src/utils.h" |
| 12 | 13 |
| 13 namespace v8 { | 14 namespace v8 { |
| 14 namespace internal { | 15 namespace internal { |
| 15 | 16 |
| 16 class BasicJsonStringifier BASE_EMBEDDED { | 17 class BasicJsonStringifier BASE_EMBEDDED { |
| 17 public: | 18 public: |
| 18 explicit BasicJsonStringifier(Isolate* isolate); | 19 explicit BasicJsonStringifier(Isolate* isolate); |
| 19 | 20 |
| 20 MUST_USE_RESULT MaybeHandle<Object> Stringify(Handle<Object> object); | 21 MUST_USE_RESULT MaybeHandle<Object> Stringify(Handle<Object> object); |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 return SUCCESS; | 624 return SUCCESS; |
| 624 } | 625 } |
| 625 | 626 |
| 626 | 627 |
| 627 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSObject( | 628 BasicJsonStringifier::Result BasicJsonStringifier::SerializeJSObject( |
| 628 Handle<JSObject> object) { | 629 Handle<JSObject> object) { |
| 629 HandleScope handle_scope(isolate_); | 630 HandleScope handle_scope(isolate_); |
| 630 Result stack_push = StackPush(object); | 631 Result stack_push = StackPush(object); |
| 631 if (stack_push != SUCCESS) return stack_push; | 632 if (stack_push != SUCCESS) return stack_push; |
| 632 if (object->IsJSGlobalProxy()) { | 633 if (object->IsJSGlobalProxy()) { |
| 633 object = Handle<JSObject>( | 634 object = Handle<JSObject>(JSObject::cast(SAFE_GET_PROTOTYPE_FAST(*object)), |
| 634 JSObject::cast(object->GetPrototype()), isolate_); | 635 isolate_); |
| 635 ASSERT(object->IsGlobalObject()); | 636 ASSERT(object->IsGlobalObject()); |
| 636 } | 637 } |
| 637 | 638 |
| 638 Append('{'); | 639 Append('{'); |
| 639 bool comma = false; | 640 bool comma = false; |
| 640 | 641 |
| 641 if (object->HasFastProperties() && | 642 if (object->HasFastProperties() && |
| 642 !object->HasIndexedInterceptor() && | 643 !object->HasIndexedInterceptor() && |
| 643 !object->HasNamedInterceptor() && | 644 !object->HasNamedInterceptor() && |
| 644 object->elements()->length() == 0) { | 645 object->elements()->length() == 0) { |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 870 SerializeString_<false, uint8_t>(object); | 871 SerializeString_<false, uint8_t>(object); |
| 871 } else { | 872 } else { |
| 872 SerializeString_<false, uc16>(object); | 873 SerializeString_<false, uc16>(object); |
| 873 } | 874 } |
| 874 } | 875 } |
| 875 } | 876 } |
| 876 | 877 |
| 877 } } // namespace v8::internal | 878 } } // namespace v8::internal |
| 878 | 879 |
| 879 #endif // V8_JSON_STRINGIFIER_H_ | 880 #endif // V8_JSON_STRINGIFIER_H_ |
| OLD | NEW |