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 FunctionSourceString; | 12 var FunctionSourceString; |
12 var GlobalArray = global.Array; | 13 var GlobalArray = global.Array; |
13 var IsNaN = global.isNaN; | 14 var IsNaN = global.isNaN; |
14 var JSONStringify = global.JSON.stringify; | 15 var JSONStringify = global.JSON.stringify; |
| 16 var MapEntries; |
| 17 var MapIteratorNext; |
15 var MathMin = global.Math.min; | 18 var MathMin = global.Math.min; |
16 var promiseStatusSymbol = utils.ImportNow("promise_status_symbol"); | 19 var promiseStatusSymbol = utils.ImportNow("promise_status_symbol"); |
17 var promiseValueSymbol = utils.ImportNow("promise_value_symbol"); | 20 var promiseValueSymbol = utils.ImportNow("promise_value_symbol"); |
| 21 var SetIteratorNext; |
| 22 var SetValues; |
18 var SymbolToString; | 23 var SymbolToString; |
19 | 24 |
20 utils.Import(function(from) { | 25 utils.Import(function(from) { |
| 26 ErrorToString = from.ErrorToString; |
21 FunctionSourceString = from.FunctionSourceString; | 27 FunctionSourceString = from.FunctionSourceString; |
| 28 MapEntries = from.MapEntries; |
| 29 MapIteratorNext = from.MapIteratorNext; |
| 30 SetIteratorNext = from.SetIteratorNext; |
| 31 SetValues = from.SetValues; |
22 SymbolToString = from.SymbolToString; | 32 SymbolToString = from.SymbolToString; |
23 }); | 33 }); |
24 | 34 |
25 // ---------------------------------------------------------------------------- | 35 // ---------------------------------------------------------------------------- |
26 | 36 |
27 // Mirror hierarchy: | 37 // Mirror hierarchy: |
28 // - Mirror | 38 // - Mirror |
29 // - ValueMirror | 39 // - ValueMirror |
30 // - UndefinedMirror | 40 // - UndefinedMirror |
31 // - NullMirror | 41 // - NullMirror |
(...skipping 1259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 */ | 1301 */ |
1292 ErrorMirror.prototype.message = function() { | 1302 ErrorMirror.prototype.message = function() { |
1293 return this.value_.message; | 1303 return this.value_.message; |
1294 }; | 1304 }; |
1295 | 1305 |
1296 | 1306 |
1297 ErrorMirror.prototype.toText = function() { | 1307 ErrorMirror.prototype.toText = function() { |
1298 // Use the same text representation as in messages.js. | 1308 // Use the same text representation as in messages.js. |
1299 var text; | 1309 var text; |
1300 try { | 1310 try { |
1301 text = %_CallFunction(this.value_, builtins.$errorToString); | 1311 text = %_CallFunction(this.value_, ErrorToString); |
1302 } catch (e) { | 1312 } catch (e) { |
1303 text = '#<Error>'; | 1313 text = '#<Error>'; |
1304 } | 1314 } |
1305 return text; | 1315 return text; |
1306 }; | 1316 }; |
1307 | 1317 |
1308 | 1318 |
1309 /** | 1319 /** |
1310 * Mirror object for a Promise object. | 1320 * Mirror object for a Promise object. |
1311 * @param {Object} value The Promise object | 1321 * @param {Object} value The Promise object |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1361 var entries = %GetWeakMapEntries(this.value_, opt_limit || 0); | 1371 var entries = %GetWeakMapEntries(this.value_, opt_limit || 0); |
1362 for (var i = 0; i < entries.length; i += 2) { | 1372 for (var i = 0; i < entries.length; i += 2) { |
1363 result.push({ | 1373 result.push({ |
1364 key: entries[i], | 1374 key: entries[i], |
1365 value: entries[i + 1] | 1375 value: entries[i + 1] |
1366 }); | 1376 }); |
1367 } | 1377 } |
1368 return result; | 1378 return result; |
1369 } | 1379 } |
1370 | 1380 |
1371 var iter = %_CallFunction(this.value_, builtins.$mapEntries); | 1381 var iter = %_CallFunction(this.value_, MapEntries); |
1372 var next; | 1382 var next; |
1373 while ((!opt_limit || result.length < opt_limit) && | 1383 while ((!opt_limit || result.length < opt_limit) && |
1374 !(next = iter.next()).done) { | 1384 !(next = iter.next()).done) { |
1375 result.push({ | 1385 result.push({ |
1376 key: next.value[0], | 1386 key: next.value[0], |
1377 value: next.value[1] | 1387 value: next.value[1] |
1378 }); | 1388 }); |
1379 } | 1389 } |
1380 return result; | 1390 return result; |
1381 }; | 1391 }; |
(...skipping 21 matching lines...) Expand all Loading... |
1403 * This will keep elements alive for WeakSets. | 1413 * This will keep elements alive for WeakSets. |
1404 * | 1414 * |
1405 * @param {number=} opt_limit Max elements to return. | 1415 * @param {number=} opt_limit Max elements to return. |
1406 * @returns {Array.<Object>} Array of elements of a set. | 1416 * @returns {Array.<Object>} Array of elements of a set. |
1407 */ | 1417 */ |
1408 SetMirror.prototype.values = function(opt_limit) { | 1418 SetMirror.prototype.values = function(opt_limit) { |
1409 if (IS_WEAKSET(this.value_)) { | 1419 if (IS_WEAKSET(this.value_)) { |
1410 return %GetWeakSetValues(this.value_, opt_limit || 0); | 1420 return %GetWeakSetValues(this.value_, opt_limit || 0); |
1411 } | 1421 } |
1412 | 1422 |
1413 var iter = %_CallFunction(this.value_, builtins.$setValues); | 1423 var iter = %_CallFunction(this.value_, SetValues); |
1414 return IteratorGetValues_(iter, builtins.$setIteratorNext, opt_limit); | 1424 return IteratorGetValues_(iter, SetIteratorNext, opt_limit); |
1415 }; | 1425 }; |
1416 | 1426 |
1417 | 1427 |
1418 function IteratorMirror(value) { | 1428 function IteratorMirror(value) { |
1419 %_CallFunction(this, value, MirrorType.ITERATOR_TYPE, ObjectMirror); | 1429 %_CallFunction(this, value, MirrorType.ITERATOR_TYPE, ObjectMirror); |
1420 } | 1430 } |
1421 inherits(IteratorMirror, ObjectMirror); | 1431 inherits(IteratorMirror, ObjectMirror); |
1422 | 1432 |
1423 | 1433 |
1424 /** | 1434 /** |
1425 * Returns a preview of elements of an iterator. | 1435 * Returns a preview of elements of an iterator. |
1426 * Does not change the backing iterator state. | 1436 * Does not change the backing iterator state. |
1427 * | 1437 * |
1428 * @param {number=} opt_limit Max elements to return. | 1438 * @param {number=} opt_limit Max elements to return. |
1429 * @returns {Array.<Object>} Array of elements of an iterator. | 1439 * @returns {Array.<Object>} Array of elements of an iterator. |
1430 */ | 1440 */ |
1431 IteratorMirror.prototype.preview = function(opt_limit) { | 1441 IteratorMirror.prototype.preview = function(opt_limit) { |
1432 if (IS_MAP_ITERATOR(this.value_)) { | 1442 if (IS_MAP_ITERATOR(this.value_)) { |
1433 return IteratorGetValues_(%MapIteratorClone(this.value_), | 1443 return IteratorGetValues_(%MapIteratorClone(this.value_), |
1434 builtins.$mapIteratorNext, | 1444 MapIteratorNext, |
1435 opt_limit); | 1445 opt_limit); |
1436 } else if (IS_SET_ITERATOR(this.value_)) { | 1446 } else if (IS_SET_ITERATOR(this.value_)) { |
1437 return IteratorGetValues_(%SetIteratorClone(this.value_), | 1447 return IteratorGetValues_(%SetIteratorClone(this.value_), |
1438 builtins.$setIteratorNext, | 1448 SetIteratorNext, |
1439 opt_limit); | 1449 opt_limit); |
1440 } | 1450 } |
1441 }; | 1451 }; |
1442 | 1452 |
1443 | 1453 |
1444 /** | 1454 /** |
1445 * Mirror object for a Generator object. | 1455 * Mirror object for a Generator object. |
1446 * @param {Object} data The Generator object | 1456 * @param {Object} data The Generator object |
1447 * @constructor | 1457 * @constructor |
1448 * @extends Mirror | 1458 * @extends Mirror |
(...skipping 1661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3110 // Functions needed by the debugger runtime. | 3120 // Functions needed by the debugger runtime. |
3111 utils.InstallFunctions(utils, DONT_ENUM, [ | 3121 utils.InstallFunctions(utils, DONT_ENUM, [ |
3112 "ClearMirrorCache", ClearMirrorCache | 3122 "ClearMirrorCache", ClearMirrorCache |
3113 ]); | 3123 ]); |
3114 | 3124 |
3115 // Export to debug.js | 3125 // Export to debug.js |
3116 utils.Export(function(to) { | 3126 utils.Export(function(to) { |
3117 to.MirrorType = MirrorType; | 3127 to.MirrorType = MirrorType; |
3118 }); | 3128 }); |
3119 }) | 3129 }) |
OLD | NEW |