| OLD | NEW |
| 1 // Copyright 2006-2012 the V8 project authors. All rights reserved. | 1 // Copyright 2006-2012 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 "use strict"; | 6 "use strict"; |
| 7 | 7 |
| 8 // ---------------------------------------------------------------------------- | 8 // ---------------------------------------------------------------------------- |
| 9 // Imports | 9 // Imports |
| 10 | 10 |
| 11 var ErrorToString; | 11 var ErrorToString; |
| 12 var GlobalArray = global.Array; | 12 var GlobalArray = global.Array; |
| 13 var IsNaN = global.isNaN; | 13 var IsNaN = global.isNaN; |
| 14 var JSONStringify = global.JSON.stringify; | 14 var JSONStringify = global.JSON.stringify; |
| 15 var MakeError; | 15 var MakeError; |
| 16 var MapEntries; | 16 var MapEntries; |
| 17 var MapIteratorNext; | 17 var MapIteratorNext; |
| 18 var MathMin = global.Math.min; | 18 var MathMin = global.Math.min; |
| 19 var promiseStatusSymbol = utils.ImportNow("promise_status_symbol"); | 19 var promiseStateSymbol = utils.ImportNow("promise_state_symbol"); |
| 20 var promiseValueSymbol = utils.ImportNow("promise_value_symbol"); | 20 var promiseResultSymbol = utils.ImportNow("promise_result_symbol"); |
| 21 var SetIteratorNext; | 21 var SetIteratorNext; |
| 22 var SetValues; | 22 var SetValues; |
| 23 var SymbolToString; | 23 var SymbolToString; |
| 24 | 24 |
| 25 utils.Import(function(from) { | 25 utils.Import(function(from) { |
| 26 ErrorToString = from.ErrorToString; | 26 ErrorToString = from.ErrorToString; |
| 27 MakeError = from.MakeError; | 27 MakeError = from.MakeError; |
| 28 MapEntries = from.MapEntries; | 28 MapEntries = from.MapEntries; |
| 29 MapIteratorNext = from.MapIteratorNext; | 29 MapIteratorNext = from.MapIteratorNext; |
| 30 SetIteratorNext = from.SetIteratorNext; | 30 SetIteratorNext = from.SetIteratorNext; |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 | 108 |
| 109 | 109 |
| 110 function ClearMirrorCache(value) { | 110 function ClearMirrorCache(value) { |
| 111 next_handle_ = 0; | 111 next_handle_ = 0; |
| 112 mirror_cache_ = []; | 112 mirror_cache_ = []; |
| 113 } | 113 } |
| 114 | 114 |
| 115 | 115 |
| 116 function ObjectIsPromise(value) { | 116 function ObjectIsPromise(value) { |
| 117 return IS_RECEIVER(value) && | 117 return IS_RECEIVER(value) && |
| 118 !IS_UNDEFINED(%DebugGetProperty(value, promiseStatusSymbol)); | 118 !IS_UNDEFINED(%DebugGetProperty(value, promiseStateSymbol)); |
| 119 } | 119 } |
| 120 | 120 |
| 121 | 121 |
| 122 /** | 122 /** |
| 123 * Returns the mirror for a specified value or object. | 123 * Returns the mirror for a specified value or object. |
| 124 * | 124 * |
| 125 * @param {value or Object} value the value or object to retreive the mirror for | 125 * @param {value or Object} value the value or object to retreive the mirror for |
| 126 * @param {boolean} transient indicate whether this object is transient and | 126 * @param {boolean} transient indicate whether this object is transient and |
| 127 * should not be added to the mirror cache. The default is not transient. | 127 * should not be added to the mirror cache. The default is not transient. |
| 128 * @returns {Mirror} the mirror reflects the passed value or object | 128 * @returns {Mirror} the mirror reflects the passed value or object |
| (...skipping 1136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1265 * @constructor | 1265 * @constructor |
| 1266 * @extends ObjectMirror | 1266 * @extends ObjectMirror |
| 1267 */ | 1267 */ |
| 1268 function PromiseMirror(value) { | 1268 function PromiseMirror(value) { |
| 1269 %_Call(ObjectMirror, this, value, MirrorType.PROMISE_TYPE); | 1269 %_Call(ObjectMirror, this, value, MirrorType.PROMISE_TYPE); |
| 1270 } | 1270 } |
| 1271 inherits(PromiseMirror, ObjectMirror); | 1271 inherits(PromiseMirror, ObjectMirror); |
| 1272 | 1272 |
| 1273 | 1273 |
| 1274 function PromiseGetStatus_(value) { | 1274 function PromiseGetStatus_(value) { |
| 1275 var status = %DebugGetProperty(value, promiseStatusSymbol); | 1275 var status = %DebugGetProperty(value, promiseStateSymbol); |
| 1276 if (status == 0) return "pending"; | 1276 if (status == 0) return "pending"; |
| 1277 if (status == 1) return "resolved"; | 1277 if (status == 1) return "resolved"; |
| 1278 return "rejected"; | 1278 return "rejected"; |
| 1279 } | 1279 } |
| 1280 | 1280 |
| 1281 | 1281 |
| 1282 function PromiseGetValue_(value) { | 1282 function PromiseGetValue_(value) { |
| 1283 return %DebugGetProperty(value, promiseValueSymbol); | 1283 return %DebugGetProperty(value, promiseResultSymbol); |
| 1284 } | 1284 } |
| 1285 | 1285 |
| 1286 | 1286 |
| 1287 PromiseMirror.prototype.status = function() { | 1287 PromiseMirror.prototype.status = function() { |
| 1288 return PromiseGetStatus_(this.value_); | 1288 return PromiseGetStatus_(this.value_); |
| 1289 }; | 1289 }; |
| 1290 | 1290 |
| 1291 | 1291 |
| 1292 PromiseMirror.prototype.promiseValue = function() { | 1292 PromiseMirror.prototype.promiseValue = function() { |
| 1293 return MakeMirror(PromiseGetValue_(this.value_)); | 1293 return MakeMirror(PromiseGetValue_(this.value_)); |
| (...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3043 // Functions needed by the debugger runtime. | 3043 // Functions needed by the debugger runtime. |
| 3044 utils.InstallFunctions(utils, DONT_ENUM, [ | 3044 utils.InstallFunctions(utils, DONT_ENUM, [ |
| 3045 "ClearMirrorCache", ClearMirrorCache | 3045 "ClearMirrorCache", ClearMirrorCache |
| 3046 ]); | 3046 ]); |
| 3047 | 3047 |
| 3048 // Export to debug.js | 3048 // Export to debug.js |
| 3049 utils.Export(function(to) { | 3049 utils.Export(function(to) { |
| 3050 to.MirrorType = MirrorType; | 3050 to.MirrorType = MirrorType; |
| 3051 }); | 3051 }); |
| 3052 }) | 3052 }) |
| OLD | NEW |