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

Side by Side Diff: src/json.js

Issue 181453002: Reset trunk to 3.24.35.4 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: Created 6 years, 10 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 | « src/isolate.cc ('k') | src/jsregexp.cc » ('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 // 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 gap = %_SubString(" ", 0, space); 203 gap = %_SubString(" ", 0, space);
204 } else if (IS_STRING(space)) { 204 } else if (IS_STRING(space)) {
205 if (space.length > 10) { 205 if (space.length > 10) {
206 gap = %_SubString(space, 0, 10); 206 gap = %_SubString(space, 0, 10);
207 } else { 207 } else {
208 gap = space; 208 gap = space;
209 } 209 }
210 } else { 210 } else {
211 gap = ""; 211 gap = "";
212 } 212 }
213 if (IS_ARRAY(replacer)) {
214 // Deduplicate replacer array items.
215 var property_list = new InternalArray();
216 var seen_properties = {};
217 var length = replacer.length;
218 for (var i = 0; i < length; i++) {
219 var item = replacer[i];
220 if (IS_NUMBER(item)) item = %_NumberToString(item);
221 if (IS_STRING(item) && !(item in seen_properties)) {
222 property_list.push(item);
223 seen_properties[item] = true;
224 }
225 }
226 replacer = property_list;
227 }
228 return JSONSerialize('', {'': value}, replacer, new InternalArray(), "", gap); 213 return JSONSerialize('', {'': value}, replacer, new InternalArray(), "", gap);
229 } 214 }
230 215
231 216
232 // ------------------------------------------------------------------- 217 // -------------------------------------------------------------------
233 218
234 function SetUpJSON() { 219 function SetUpJSON() {
235 %CheckIsBootstrapping(); 220 %CheckIsBootstrapping();
236 221
237 // Set up non-enumerable properties of the JSON object. 222 // Set up non-enumerable properties of the JSON object.
238 InstallFunctions($JSON, DONT_ENUM, $Array( 223 InstallFunctions($JSON, DONT_ENUM, $Array(
239 "parse", JSONParse, 224 "parse", JSONParse,
240 "stringify", JSONStringify 225 "stringify", JSONStringify
241 )); 226 ));
242 } 227 }
243 228
244 SetUpJSON(); 229 SetUpJSON();
245 230
246 231
247 // ------------------------------------------------------------------- 232 // -------------------------------------------------------------------
248 // JSON Builtins 233 // JSON Builtins
249 234
250 function JSONSerializeAdapter(key, object) { 235 function JSONSerializeAdapter(key, object) {
251 var holder = {}; 236 var holder = {};
252 holder[key] = object; 237 holder[key] = object;
253 // No need to pass the actual holder since there is no replacer function. 238 // No need to pass the actual holder since there is no replacer function.
254 return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", ""); 239 return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", "");
255 } 240 }
OLDNEW
« no previous file with comments | « src/isolate.cc ('k') | src/jsregexp.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698