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

Unified Diff: src/js/json.js

Issue 2026563002: [json] implement InternalizeJSONProperty in C++. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase and address comments Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/api.cc ('k') | src/json-parser.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/js/json.js
diff --git a/src/js/json.js b/src/js/json.js
index a7b692000870b1722be6d914383559675eed23f1..16f55c5cd80a2b5438a132b20226d509a66f430c 100644
--- a/src/js/json.js
+++ b/src/js/json.js
@@ -19,50 +19,8 @@ var toStringTagSymbol = utils.ImportNow("to_string_tag_symbol");
// -------------------------------------------------------------------
-function CreateDataProperty(o, p, v) {
- var desc = {value: v, enumerable: true, writable: true, configurable: true};
- return %reflect_define_property(o, p, desc);
-}
-
-
-function InternalizeJSONProperty(holder, name, reviver) {
- var val = holder[name];
- if (IS_RECEIVER(val)) {
- if (%is_arraylike(val)) {
- var length = TO_LENGTH(val.length);
- for (var i = 0; i < length; i++) {
- var newElement =
- InternalizeJSONProperty(val, %_NumberToString(i), reviver);
- if (IS_UNDEFINED(newElement)) {
- %reflect_delete_property(val, i);
- } else {
- CreateDataProperty(val, i, newElement);
- }
- }
- } else {
- var keys = %object_keys(val);
- for (var i = 0; i < keys.length; i++) {
- var p = keys[i];
- var newElement = InternalizeJSONProperty(val, p, reviver);
- if (IS_UNDEFINED(newElement)) {
- %reflect_delete_property(val, p);
- } else {
- CreateDataProperty(val, p, newElement);
- }
- }
- }
- }
- return %_Call(reviver, holder, name, val);
-}
-
-
function JSONParse(text, reviver) {
- var unfiltered = %ParseJson(text);
- if (IS_CALLABLE(reviver)) {
- return InternalizeJSONProperty({'': unfiltered}, '', reviver);
- } else {
- return unfiltered;
- }
+ return %ParseJson(text, reviver);
}
// -------------------------------------------------------------------
« no previous file with comments | « src/api.cc ('k') | src/json-parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698