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

Side by Side Diff: src/json.js

Issue 1316933002: [es6] Initial steps towards a correct implementation of IsCallable. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase again. 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/ia32/lithium-codegen-ia32.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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 } 51 }
52 } 52 }
53 } 53 }
54 } 54 }
55 return %_CallFunction(holder, name, val, reviver); 55 return %_CallFunction(holder, name, val, reviver);
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_SPEC_FUNCTION(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 }
66 } 66 }
67 67
68 68
69 function SerializeArray(value, replacer, stack, indent, gap) { 69 function SerializeArray(value, replacer, stack, indent, gap) {
70 if (!%PushIfAbsent(stack, value)) throw MakeTypeError(kCircularStructure); 70 if (!%PushIfAbsent(stack, value)) throw MakeTypeError(kCircularStructure);
71 var stepback = indent; 71 var stepback = indent;
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 } 139 }
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_SPEC_FUNCTION(toJSON)) { 149 if (IS_CALLABLE(toJSON)) {
150 value = %_CallFunction(value, key, toJSON); 150 value = %_CallFunction(value, key, toJSON);
151 } 151 }
152 } 152 }
153 if (IS_SPEC_FUNCTION(replacer)) { 153 if (IS_CALLABLE(replacer)) {
154 value = %_CallFunction(holder, key, value, replacer); 154 value = %_CallFunction(holder, key, value, replacer);
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";
(...skipping 85 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/ia32/lithium-codegen-ia32.cc ('k') | src/macros.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698