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

Side by Side Diff: src/json.js

Issue 1325573004: [runtime] Replace many buggy uses of %_CallFunction with %_Call. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address feedback. Created 5 years, 3 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
« no previous file with comments | « src/interface-descriptors.cc ('k') | src/macros.py » ('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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 (function(global, utils) { 5 (function(global, utils) {
6 6
7 "use strict"; 7 "use strict";
8 8
9 %CheckIsBootstrapping(); 9 %CheckIsBootstrapping();
10 10
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 var newElement = Revive(val, p, reviver); 45 var newElement = Revive(val, p, reviver);
46 if (IS_UNDEFINED(newElement)) { 46 if (IS_UNDEFINED(newElement)) {
47 delete val[p]; 47 delete val[p];
48 } else { 48 } else {
49 val[p] = newElement; 49 val[p] = newElement;
50 } 50 }
51 } 51 }
52 } 52 }
53 } 53 }
54 } 54 }
55 return %_CallFunction(holder, name, val, reviver); 55 return %_Call(reviver, holder, name, val);
56 } 56 }
57 57
58 58
59 function JSONParse(text, reviver) { 59 function JSONParse(text, reviver) {
60 var unfiltered = %ParseJson(TO_STRING_INLINE(text)); 60 var unfiltered = %ParseJson(TO_STRING_INLINE(text));
61 if (IS_CALLABLE(reviver)) { 61 if (IS_CALLABLE(reviver)) {
62 return Revive({'': unfiltered}, '', reviver); 62 return Revive({'': unfiltered}, '', reviver);
63 } else { 63 } else {
64 return unfiltered; 64 return unfiltered;
65 } 65 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
140 stack.pop(); 140 stack.pop();
141 return final; 141 return final;
142 } 142 }
143 143
144 144
145 function JSONSerialize(key, holder, replacer, stack, indent, gap) { 145 function JSONSerialize(key, holder, replacer, stack, indent, gap) {
146 var value = holder[key]; 146 var value = holder[key];
147 if (IS_SPEC_OBJECT(value)) { 147 if (IS_SPEC_OBJECT(value)) {
148 var toJSON = value.toJSON; 148 var toJSON = value.toJSON;
149 if (IS_CALLABLE(toJSON)) { 149 if (IS_CALLABLE(toJSON)) {
150 value = %_CallFunction(value, key, toJSON); 150 value = %_Call(toJSON, value, key);
151 } 151 }
152 } 152 }
153 if (IS_CALLABLE(replacer)) { 153 if (IS_CALLABLE(replacer)) {
154 value = %_CallFunction(holder, key, value, replacer); 154 value = %_Call(replacer, holder, key, value);
155 } 155 }
156 if (IS_STRING(value)) { 156 if (IS_STRING(value)) {
157 return %QuoteJSONString(value); 157 return %QuoteJSONString(value);
158 } else if (IS_NUMBER(value)) { 158 } else if (IS_NUMBER(value)) {
159 return JSON_NUMBER_TO_STRING(value); 159 return JSON_NUMBER_TO_STRING(value);
160 } else if (IS_BOOLEAN(value)) { 160 } else if (IS_BOOLEAN(value)) {
161 return value ? "true" : "false"; 161 return value ? "true" : "false";
162 } else if (IS_NULL(value)) { 162 } else if (IS_NULL(value)) {
163 return "null"; 163 return "null";
164 } else if (IS_SPEC_OBJECT(value) && !(typeof value == "function")) { 164 } else if (IS_SPEC_OBJECT(value) && !(typeof value == "function")) {
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
249 function JsonSerializeAdapter(key, object) { 249 function JsonSerializeAdapter(key, object) {
250 var holder = {}; 250 var holder = {};
251 holder[key] = object; 251 holder[key] = object;
252 // No need to pass the actual holder since there is no replacer function. 252 // No need to pass the actual holder since there is no replacer function.
253 return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", ""); 253 return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", "");
254 } 254 }
255 255
256 %InstallToContext(["json_serialize_adapter", JsonSerializeAdapter]); 256 %InstallToContext(["json_serialize_adapter", JsonSerializeAdapter]);
257 257
258 }) 258 })
OLDNEW
« no previous file with comments | « src/interface-descriptors.cc ('k') | src/macros.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698