| OLD | NEW |
| 1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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 #include "src/json-stringifier.h" | 5 #include "src/json-stringifier.h" |
| 6 | 6 |
| 7 #include "src/conversions.h" | 7 #include "src/conversions.h" |
| 8 #include "src/lookup.h" | 8 #include "src/lookup.h" |
| 9 #include "src/messages.h" | 9 #include "src/messages.h" |
| 10 #include "src/objects-inl.h" | 10 #include "src/objects-inl.h" |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 84 JsonStringifier::JsonStringifier(Isolate* isolate) | 84 JsonStringifier::JsonStringifier(Isolate* isolate) |
| 85 : isolate_(isolate), builder_(isolate), gap_(nullptr), indent_(0) { | 85 : isolate_(isolate), builder_(isolate), gap_(nullptr), indent_(0) { |
| 86 tojson_string_ = factory()->toJSON_string(); | 86 tojson_string_ = factory()->toJSON_string(); |
| 87 stack_ = factory()->NewJSArray(8); | 87 stack_ = factory()->NewJSArray(8); |
| 88 } | 88 } |
| 89 | 89 |
| 90 MaybeHandle<Object> JsonStringifier::Stringify(Handle<Object> object, | 90 MaybeHandle<Object> JsonStringifier::Stringify(Handle<Object> object, |
| 91 Handle<Object> replacer, | 91 Handle<Object> replacer, |
| 92 Handle<Object> gap) { | 92 Handle<Object> gap) { |
| 93 if (!InitializeReplacer(replacer)) return MaybeHandle<Object>(); | 93 if (!InitializeReplacer(replacer)) return MaybeHandle<Object>(); |
| 94 if (!gap->IsUndefined() && !InitializeGap(gap)) return MaybeHandle<Object>(); | 94 if (!gap->IsUndefined(isolate_) && !InitializeGap(gap)) { |
| 95 return MaybeHandle<Object>(); |
| 96 } |
| 95 Result result = SerializeObject(object); | 97 Result result = SerializeObject(object); |
| 96 if (result == UNCHANGED) return factory()->undefined_value(); | 98 if (result == UNCHANGED) return factory()->undefined_value(); |
| 97 if (result == SUCCESS) return builder_.Finish(); | 99 if (result == SUCCESS) return builder_.Finish(); |
| 98 DCHECK(result == EXCEPTION); | 100 DCHECK(result == EXCEPTION); |
| 99 return MaybeHandle<Object>(); | 101 return MaybeHandle<Object>(); |
| 100 } | 102 } |
| 101 | 103 |
| 102 bool IsInList(Handle<String> key, List<Handle<String> >* list) { | 104 bool IsInList(Handle<String> key, List<Handle<String> >* list) { |
| 103 // TODO(yangguo): This is O(n^2) for n properties in the list. Deal with this | 105 // TODO(yangguo): This is O(n^2) for n properties in the list. Deal with this |
| 104 // if this becomes an issue. | 106 // if this becomes an issue. |
| (...skipping 577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 682 if (object->IsOneByteRepresentationUnderneath()) { | 684 if (object->IsOneByteRepresentationUnderneath()) { |
| 683 SerializeString_<uint8_t, uc16>(object); | 685 SerializeString_<uint8_t, uc16>(object); |
| 684 } else { | 686 } else { |
| 685 SerializeString_<uc16, uc16>(object); | 687 SerializeString_<uc16, uc16>(object); |
| 686 } | 688 } |
| 687 } | 689 } |
| 688 } | 690 } |
| 689 | 691 |
| 690 } // namespace internal | 692 } // namespace internal |
| 691 } // namespace v8 | 693 } // namespace v8 |
| OLD | NEW |