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 #include "src/conversions.h" | 9 #include "src/conversions.h" |
10 #include "src/utils.h" | 10 #include "src/utils.h" |
(...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
331 | 331 |
332 | 332 |
333 template <bool is_ascii, typename Char> | 333 template <bool is_ascii, typename Char> |
334 void BasicJsonStringifier::Append_(const Char* chars) { | 334 void BasicJsonStringifier::Append_(const Char* chars) { |
335 for ( ; *chars != '\0'; chars++) Append_<is_ascii, Char>(*chars); | 335 for ( ; *chars != '\0'; chars++) Append_<is_ascii, Char>(*chars); |
336 } | 336 } |
337 | 337 |
338 | 338 |
339 MaybeHandle<Object> BasicJsonStringifier::ApplyToJsonFunction( | 339 MaybeHandle<Object> BasicJsonStringifier::ApplyToJsonFunction( |
340 Handle<Object> object, Handle<Object> key) { | 340 Handle<Object> object, Handle<Object> key) { |
341 LookupResult lookup(isolate_); | 341 LookupIterator it(object, tojson_string_, LookupIterator::SKIP_INTERCEPTOR); |
342 JSObject::cast(*object)->LookupRealNamedProperty(tojson_string_, &lookup); | |
343 if (!lookup.IsProperty()) return object; | |
344 PropertyAttributes attr; | |
345 Handle<Object> fun; | 342 Handle<Object> fun; |
346 ASSIGN_RETURN_ON_EXCEPTION( | 343 ASSIGN_RETURN_ON_EXCEPTION(isolate_, fun, Object::GetProperty(&it), Object); |
347 isolate_, fun, | |
348 Object::GetProperty(object, object, &lookup, tojson_string_, &attr), | |
349 Object); | |
350 if (!fun->IsJSFunction()) return object; | 344 if (!fun->IsJSFunction()) return object; |
351 | 345 |
352 // Call toJSON function. | 346 // Call toJSON function. |
353 if (key->IsSmi()) key = factory_->NumberToString(key); | 347 if (key->IsSmi()) key = factory_->NumberToString(key); |
354 Handle<Object> argv[] = { key }; | 348 Handle<Object> argv[] = { key }; |
355 HandleScope scope(isolate_); | 349 HandleScope scope(isolate_); |
356 ASSIGN_RETURN_ON_EXCEPTION( | 350 ASSIGN_RETURN_ON_EXCEPTION( |
357 isolate_, object, | 351 isolate_, object, |
358 Execution::Call(isolate_, fun, object, 1, argv), | 352 Execution::Call(isolate_, fun, object, 1, argv), |
359 Object); | 353 Object); |
(...skipping 515 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
875 SerializeString_<false, uint8_t>(object); | 869 SerializeString_<false, uint8_t>(object); |
876 } else { | 870 } else { |
877 SerializeString_<false, uc16>(object); | 871 SerializeString_<false, uc16>(object); |
878 } | 872 } |
879 } | 873 } |
880 } | 874 } |
881 | 875 |
882 } } // namespace v8::internal | 876 } } // namespace v8::internal |
883 | 877 |
884 #endif // V8_JSON_STRINGIFIER_H_ | 878 #endif // V8_JSON_STRINGIFIER_H_ |
OLD | NEW |