Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(516)

Side by Side Diff: src/json-stringifier.h

Issue 187603002: Handle exception when retrieving toJSON function in JSON.stringify. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: test Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/json2.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 353
354 354
355 Handle<Object> BasicJsonStringifier::ApplyToJsonFunction( 355 Handle<Object> BasicJsonStringifier::ApplyToJsonFunction(
356 Handle<Object> object, Handle<Object> key) { 356 Handle<Object> object, Handle<Object> key) {
357 LookupResult lookup(isolate_); 357 LookupResult lookup(isolate_);
358 JSObject::cast(*object)->LookupRealNamedProperty(*tojson_string_, &lookup); 358 JSObject::cast(*object)->LookupRealNamedProperty(*tojson_string_, &lookup);
359 if (!lookup.IsProperty()) return object; 359 if (!lookup.IsProperty()) return object;
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.is_null()) return Handle<Object>::null();
363 if (!fun->IsJSFunction()) return object; 364 if (!fun->IsJSFunction()) return object;
364 365
365 // Call toJSON function. 366 // Call toJSON function.
366 if (key->IsSmi()) key = factory_->NumberToString(key); 367 if (key->IsSmi()) key = factory_->NumberToString(key);
367 Handle<Object> argv[] = { key }; 368 Handle<Object> argv[] = { key };
368 bool has_exception = false; 369 bool has_exception = false;
369 HandleScope scope(isolate_); 370 HandleScope scope(isolate_);
370 object = Execution::Call(isolate_, fun, object, 1, argv, &has_exception); 371 object = Execution::Call(isolate_, fun, object, 1, argv, &has_exception);
371 // Return empty handle to signal an exception. 372 // Return empty handle to signal an exception.
372 if (has_exception) return Handle<Object>::null(); 373 if (has_exception) return Handle<Object>::null();
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
846 SerializeString_<false, uint8_t>(object); 847 SerializeString_<false, uint8_t>(object);
847 } else { 848 } else {
848 SerializeString_<false, uc16>(object); 849 SerializeString_<false, uc16>(object);
849 } 850 }
850 } 851 }
851 } 852 }
852 853
853 } } // namespace v8::internal 854 } } // namespace v8::internal
854 855
855 #endif // V8_JSON_STRINGIFIER_H_ 856 #endif // V8_JSON_STRINGIFIER_H_
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/json2.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698