OLD | NEW |
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 var $jsonSerializeAdapter; | 5 var $jsonSerializeAdapter; |
6 | 6 |
7 (function(global, utils) { | 7 (function(global, shared, exports) { |
8 | 8 |
9 "use strict"; | 9 "use strict"; |
10 | 10 |
11 %CheckIsBootstrapping(); | 11 %CheckIsBootstrapping(); |
12 | 12 |
13 // ------------------------------------------------------------------- | 13 // ------------------------------------------------------------------- |
14 // Imports | 14 // Imports |
15 | 15 |
16 var GlobalJSON = global.JSON; | 16 var GlobalJSON = global.JSON; |
17 var InternalArray = utils.InternalArray; | 17 var InternalArray = shared.InternalArray; |
18 | |
19 var MathMax; | |
20 var MathMin; | |
21 | |
22 utils.Import(function(from) { | |
23 MathMax = from.MathMax; | |
24 MathMin = from.MathMin; | |
25 }); | |
26 | 18 |
27 // ------------------------------------------------------------------- | 19 // ------------------------------------------------------------------- |
28 | 20 |
29 function Revive(holder, name, reviver) { | 21 function Revive(holder, name, reviver) { |
30 var val = holder[name]; | 22 var val = holder[name]; |
31 if (IS_OBJECT(val)) { | 23 if (IS_OBJECT(val)) { |
32 if (IS_ARRAY(val)) { | 24 if (IS_ARRAY(val)) { |
33 var length = val.length; | 25 var length = val.length; |
34 for (var i = 0; i < length; i++) { | 26 for (var i = 0; i < length; i++) { |
35 var newElement = Revive(val, %_NumberToString(i), reviver); | 27 var newElement = Revive(val, %_NumberToString(i), reviver); |
(...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
184 if (IS_OBJECT(space)) { | 176 if (IS_OBJECT(space)) { |
185 // Unwrap 'space' if it is wrapped | 177 // Unwrap 'space' if it is wrapped |
186 if (IS_NUMBER_WRAPPER(space)) { | 178 if (IS_NUMBER_WRAPPER(space)) { |
187 space = $toNumber(space); | 179 space = $toNumber(space); |
188 } else if (IS_STRING_WRAPPER(space)) { | 180 } else if (IS_STRING_WRAPPER(space)) { |
189 space = $toString(space); | 181 space = $toString(space); |
190 } | 182 } |
191 } | 183 } |
192 var gap; | 184 var gap; |
193 if (IS_NUMBER(space)) { | 185 if (IS_NUMBER(space)) { |
194 space = MathMax(0, MathMin($toInteger(space), 10)); | 186 space = $max(0, $min($toInteger(space), 10)); |
195 gap = %_SubString(" ", 0, space); | 187 gap = %_SubString(" ", 0, space); |
196 } else if (IS_STRING(space)) { | 188 } else if (IS_STRING(space)) { |
197 if (space.length > 10) { | 189 if (space.length > 10) { |
198 gap = %_SubString(space, 0, 10); | 190 gap = %_SubString(space, 0, 10); |
199 } else { | 191 } else { |
200 gap = space; | 192 gap = space; |
201 } | 193 } |
202 } else { | 194 } else { |
203 gap = ""; | 195 gap = ""; |
204 } | 196 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
241 // JSON Builtins | 233 // JSON Builtins |
242 | 234 |
243 $jsonSerializeAdapter = function(key, object) { | 235 $jsonSerializeAdapter = function(key, object) { |
244 var holder = {}; | 236 var holder = {}; |
245 holder[key] = object; | 237 holder[key] = object; |
246 // 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. |
247 return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", ""); | 239 return JSONSerialize(key, holder, UNDEFINED, new InternalArray(), "", ""); |
248 } | 240 } |
249 | 241 |
250 }) | 242 }) |
OLD | NEW |