| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 360 PropertyAttributes attr; | 360 PropertyAttributes attr; |
| 361 Handle<Object> fun = | 361 Handle<Object> fun = |
| 362 Object::GetProperty(object, object, &lookup, tojson_string_, &attr); | 362 Object::GetProperty(object, object, &lookup, tojson_string_, &attr); |
| 363 if (!fun->IsJSFunction()) return object; | 363 if (!fun->IsJSFunction()) return object; |
| 364 | 364 |
| 365 // Call toJSON function. | 365 // Call toJSON function. |
| 366 if (key->IsSmi()) key = factory_->NumberToString(key); | 366 if (key->IsSmi()) key = factory_->NumberToString(key); |
| 367 Handle<Object> argv[] = { key }; | 367 Handle<Object> argv[] = { key }; |
| 368 bool has_exception = false; | 368 bool has_exception = false; |
| 369 HandleScope scope(isolate_); | 369 HandleScope scope(isolate_); |
| 370 object = Execution::Call(fun, object, 1, argv, &has_exception); | 370 object = Execution::Call(isolate_, fun, object, 1, argv, &has_exception); |
| 371 // Return empty handle to signal an exception. | 371 // Return empty handle to signal an exception. |
| 372 if (has_exception) return Handle<Object>::null(); | 372 if (has_exception) return Handle<Object>::null(); |
| 373 return scope.CloseAndEscape(object); | 373 return scope.CloseAndEscape(object); |
| 374 } | 374 } |
| 375 | 375 |
| 376 | 376 |
| 377 BasicJsonStringifier::Result BasicJsonStringifier::StackPush( | 377 BasicJsonStringifier::Result BasicJsonStringifier::StackPush( |
| 378 Handle<Object> object) { | 378 Handle<Object> object) { |
| 379 StackLimitCheck check(isolate_); | 379 StackLimitCheck check(isolate_); |
| 380 if (check.HasOverflowed()) return STACK_OVERFLOW; | 380 if (check.HasOverflowed()) return STACK_OVERFLOW; |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 Handle<Object> key, | 463 Handle<Object> key, |
| 464 bool deferred_comma, | 464 bool deferred_comma, |
| 465 bool deferred_key) { | 465 bool deferred_key) { |
| 466 Handle<JSObject> builtins(isolate_->native_context()->builtins()); | 466 Handle<JSObject> builtins(isolate_->native_context()->builtins()); |
| 467 Handle<JSFunction> builtin = | 467 Handle<JSFunction> builtin = |
| 468 Handle<JSFunction>::cast(GetProperty(builtins, "JSONSerializeAdapter")); | 468 Handle<JSFunction>::cast(GetProperty(builtins, "JSONSerializeAdapter")); |
| 469 | 469 |
| 470 Handle<Object> argv[] = { key, object }; | 470 Handle<Object> argv[] = { key, object }; |
| 471 bool has_exception = false; | 471 bool has_exception = false; |
| 472 Handle<Object> result = | 472 Handle<Object> result = |
| 473 Execution::Call(builtin, object, 2, argv, &has_exception); | 473 Execution::Call(isolate_, builtin, object, 2, argv, &has_exception); |
| 474 if (has_exception) return EXCEPTION; | 474 if (has_exception) return EXCEPTION; |
| 475 if (result->IsUndefined()) return UNCHANGED; | 475 if (result->IsUndefined()) return UNCHANGED; |
| 476 if (deferred_key) { | 476 if (deferred_key) { |
| 477 if (key->IsSmi()) key = factory_->NumberToString(key); | 477 if (key->IsSmi()) key = factory_->NumberToString(key); |
| 478 SerializeDeferredKey(deferred_comma, key); | 478 SerializeDeferredKey(deferred_comma, key); |
| 479 } | 479 } |
| 480 | 480 |
| 481 Handle<String> result_string = Handle<String>::cast(result); | 481 Handle<String> result_string = Handle<String>::cast(result); |
| 482 // Shrink current part, attach it to the accumulator, also attach the result | 482 // Shrink current part, attach it to the accumulator, also attach the result |
| 483 // string to the accumulator, and allocate a new part. | 483 // string to the accumulator, and allocate a new part. |
| (...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 846 SerializeString_<false, uint8_t>(object); | 846 SerializeString_<false, uint8_t>(object); |
| 847 } else { | 847 } else { |
| 848 SerializeString_<false, uc16>(object); | 848 SerializeString_<false, uc16>(object); |
| 849 } | 849 } |
| 850 } | 850 } |
| 851 } | 851 } |
| 852 | 852 |
| 853 } } // namespace v8::internal | 853 } } // namespace v8::internal |
| 854 | 854 |
| 855 #endif // V8_JSON_STRINGIFIER_H_ | 855 #endif // V8_JSON_STRINGIFIER_H_ |
| OLD | NEW |