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

Side by Side Diff: src/mirror-debugger.js

Issue 402423003: Expose the content of Sets and WeakSets through SetMirror. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments Created 6 years, 5 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 | « no previous file | src/runtime.h » ('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 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 // Handle id counters. 5 // Handle id counters.
6 var next_handle_ = 0; 6 var next_handle_ = 0;
7 var next_transient_handle_ = -1; 7 var next_transient_handle_ = -1;
8 8
9 // Mirror cache. 9 // Mirror cache.
10 var mirror_cache_ = []; 10 var mirror_cache_ = [];
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 } else if (IS_FUNCTION(value)) { 76 } else if (IS_FUNCTION(value)) {
77 mirror = new FunctionMirror(value); 77 mirror = new FunctionMirror(value);
78 } else if (IS_REGEXP(value)) { 78 } else if (IS_REGEXP(value)) {
79 mirror = new RegExpMirror(value); 79 mirror = new RegExpMirror(value);
80 } else if (IS_ERROR(value)) { 80 } else if (IS_ERROR(value)) {
81 mirror = new ErrorMirror(value); 81 mirror = new ErrorMirror(value);
82 } else if (IS_SCRIPT(value)) { 82 } else if (IS_SCRIPT(value)) {
83 mirror = new ScriptMirror(value); 83 mirror = new ScriptMirror(value);
84 } else if (IS_MAP(value) || IS_WEAKMAP(value)) { 84 } else if (IS_MAP(value) || IS_WEAKMAP(value)) {
85 mirror = new MapMirror(value); 85 mirror = new MapMirror(value);
86 } else if (IS_SET(value) || IS_WEAKSET(value)) {
87 mirror = new SetMirror(value);
86 } else if (ObjectIsPromise(value)) { 88 } else if (ObjectIsPromise(value)) {
87 mirror = new PromiseMirror(value); 89 mirror = new PromiseMirror(value);
88 } else { 90 } else {
89 mirror = new ObjectMirror(value, OBJECT_TYPE, opt_transient); 91 mirror = new ObjectMirror(value, OBJECT_TYPE, opt_transient);
90 } 92 }
91 93
92 if (mirror_cache_enabled_) mirror_cache_[mirror.handle()] = mirror; 94 if (mirror_cache_enabled_) mirror_cache_[mirror.handle()] = mirror;
93 return mirror; 95 return mirror;
94 } 96 }
95 97
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 var REGEXP_TYPE = 'regexp'; 153 var REGEXP_TYPE = 'regexp';
152 var ERROR_TYPE = 'error'; 154 var ERROR_TYPE = 'error';
153 var PROPERTY_TYPE = 'property'; 155 var PROPERTY_TYPE = 'property';
154 var INTERNAL_PROPERTY_TYPE = 'internalProperty'; 156 var INTERNAL_PROPERTY_TYPE = 'internalProperty';
155 var FRAME_TYPE = 'frame'; 157 var FRAME_TYPE = 'frame';
156 var SCRIPT_TYPE = 'script'; 158 var SCRIPT_TYPE = 'script';
157 var CONTEXT_TYPE = 'context'; 159 var CONTEXT_TYPE = 'context';
158 var SCOPE_TYPE = 'scope'; 160 var SCOPE_TYPE = 'scope';
159 var PROMISE_TYPE = 'promise'; 161 var PROMISE_TYPE = 'promise';
160 var MAP_TYPE = 'map'; 162 var MAP_TYPE = 'map';
163 var SET_TYPE = 'set';
161 164
162 // Maximum length when sending strings through the JSON protocol. 165 // Maximum length when sending strings through the JSON protocol.
163 var kMaxProtocolStringLength = 80; 166 var kMaxProtocolStringLength = 80;
164 167
165 // Different kind of properties. 168 // Different kind of properties.
166 var PropertyKind = {}; 169 var PropertyKind = {};
167 PropertyKind.Named = 1; 170 PropertyKind.Named = 1;
168 PropertyKind.Indexed = 2; 171 PropertyKind.Indexed = 2;
169 172
170 173
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
207 // - SymbolMirror 210 // - SymbolMirror
208 // - ObjectMirror 211 // - ObjectMirror
209 // - FunctionMirror 212 // - FunctionMirror
210 // - UnresolvedFunctionMirror 213 // - UnresolvedFunctionMirror
211 // - ArrayMirror 214 // - ArrayMirror
212 // - DateMirror 215 // - DateMirror
213 // - RegExpMirror 216 // - RegExpMirror
214 // - ErrorMirror 217 // - ErrorMirror
215 // - PromiseMirror 218 // - PromiseMirror
216 // - MapMirror 219 // - MapMirror
220 // - SetMirror
217 // - PropertyMirror 221 // - PropertyMirror
218 // - InternalPropertyMirror 222 // - InternalPropertyMirror
219 // - FrameMirror 223 // - FrameMirror
220 // - ScriptMirror 224 // - ScriptMirror
221 225
222 226
223 /** 227 /**
224 * Base class for all mirror objects. 228 * Base class for all mirror objects.
225 * @param {string} type The type of the mirror 229 * @param {string} type The type of the mirror
226 * @constructor 230 * @constructor
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
427 /** 431 /**
428 * Check whether the mirror reflects a map. 432 * Check whether the mirror reflects a map.
429 * @returns {boolean} True if the mirror reflects a map 433 * @returns {boolean} True if the mirror reflects a map
430 */ 434 */
431 Mirror.prototype.isMap = function() { 435 Mirror.prototype.isMap = function() {
432 return this instanceof MapMirror; 436 return this instanceof MapMirror;
433 }; 437 };
434 438
435 439
436 /** 440 /**
441 * Check whether the mirror reflects a set.
442 * @returns {boolean} True if the mirror reflects a set
443 */
444 Mirror.prototype.isSet = function() {
445 return this instanceof SetMirror;
446 };
447
448
449 /**
437 * Allocate a handle id for this object. 450 * Allocate a handle id for this object.
438 */ 451 */
439 Mirror.prototype.allocateHandle_ = function() { 452 Mirror.prototype.allocateHandle_ = function() {
440 if (mirror_cache_enabled_) this.handle_ = next_handle_++; 453 if (mirror_cache_enabled_) this.handle_ = next_handle_++;
441 }; 454 };
442 455
443 456
444 /** 457 /**
445 * Allocate a transient handle id for this object. Transient handles are 458 * Allocate a transient handle id for this object. Transient handles are
446 * negative. 459 * negative.
(...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after
1297 while (!(next = iter.next()).done) { 1310 while (!(next = iter.next()).done) {
1298 result.push({ 1311 result.push({
1299 key: next.value[0], 1312 key: next.value[0],
1300 value: next.value[1] 1313 value: next.value[1]
1301 }); 1314 });
1302 } 1315 }
1303 return result; 1316 return result;
1304 }; 1317 };
1305 1318
1306 1319
1320 function SetMirror(value) {
1321 %_CallFunction(this, value, SET_TYPE, ObjectMirror);
1322 }
1323 inherits(SetMirror, ObjectMirror);
1324
1325
1326 /**
1327 * Returns an array of elements of a set.
1328 * This will keep elements alive for WeakSets.
1329 *
1330 * @returns {Array.<Object>} Array of elements of a set.
1331 */
1332 SetMirror.prototype.values = function() {
1333 if (IS_WEAKSET(this.value_)) {
1334 return %GetWeakSetValues(this.value_);
1335 }
1336
1337 var result = [];
1338 var iter = %_CallFunction(this.value_, builtins.SetValues);
1339 var next;
1340 while (!(next = iter.next()).done) {
1341 result.push(next.value);
1342 }
1343 return result;
1344 };
1345
1346
1307 /** 1347 /**
1308 * Base mirror object for properties. 1348 * Base mirror object for properties.
1309 * @param {ObjectMirror} mirror The mirror object having this property 1349 * @param {ObjectMirror} mirror The mirror object having this property
1310 * @param {string} name The name of the property 1350 * @param {string} name The name of the property
1311 * @param {Array} details Details about the property 1351 * @param {Array} details Details about the property
1312 * @constructor 1352 * @constructor
1313 * @extends Mirror 1353 * @extends Mirror
1314 */ 1354 */
1315 function PropertyMirror(mirror, name, details) { 1355 function PropertyMirror(mirror, name, details) {
1316 %_CallFunction(this, PROPERTY_TYPE, Mirror); 1356 %_CallFunction(this, PROPERTY_TYPE, Mirror);
(...skipping 1512 matching lines...) Expand 10 before | Expand all | Expand 10 after
2829 } 2869 }
2830 if (!NUMBER_IS_FINITE(value)) { 2870 if (!NUMBER_IS_FINITE(value)) {
2831 if (value > 0) { 2871 if (value > 0) {
2832 return 'Infinity'; 2872 return 'Infinity';
2833 } else { 2873 } else {
2834 return '-Infinity'; 2874 return '-Infinity';
2835 } 2875 }
2836 } 2876 }
2837 return value; 2877 return value;
2838 } 2878 }
OLDNEW
« no previous file with comments | « no previous file | src/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698