Chromium Code Reviews| Index: src/mirror-debugger.js |
| diff --git a/src/mirror-debugger.js b/src/mirror-debugger.js |
| index e717f6e0706fc232a2c252deb848b51243871b6e..3fd7a8882fe4909e133121d6dcbf45a141fe498f 100644 |
| --- a/src/mirror-debugger.js |
| +++ b/src/mirror-debugger.js |
| @@ -83,6 +83,8 @@ function MakeMirror(value, opt_transient) { |
| mirror = new ScriptMirror(value); |
| } else if (IS_MAP(value) || IS_WEAKMAP(value)) { |
| mirror = new MapMirror(value); |
| + } else if (IS_SET(value) || IS_WEAKSET(value)) { |
| + mirror = new SetMirror(value); |
| } else if (ObjectIsPromise(value)) { |
| mirror = new PromiseMirror(value); |
| } else { |
| @@ -158,6 +160,7 @@ var CONTEXT_TYPE = 'context'; |
| var SCOPE_TYPE = 'scope'; |
| var PROMISE_TYPE = 'promise'; |
| var MAP_TYPE = 'map'; |
| +var SET_TYPE = 'set'; |
| // Maximum length when sending strings through the JSON protocol. |
| var kMaxProtocolStringLength = 80; |
| @@ -214,6 +217,7 @@ var ScopeType = { Global: 0, |
| // - ErrorMirror |
| // - PromiseMirror |
| // - MapMirror |
| +// - SetMirror |
| // - PropertyMirror |
| // - InternalPropertyMirror |
| // - FrameMirror |
| @@ -434,6 +438,15 @@ Mirror.prototype.isMap = function() { |
| /** |
| + * Check whether the mirror reflects a set. |
| + * @returns {boolean} True if the mirror reflects a set |
| + */ |
| +Mirror.prototype.isSet = function() { |
| + return this instanceof SetMirror; |
| +}; |
| + |
| + |
| +/** |
| * Allocate a handle id for this object. |
| */ |
| Mirror.prototype.allocateHandle_ = function() { |
| @@ -1304,6 +1317,33 @@ MapMirror.prototype.entries = function() { |
| }; |
| +function SetMirror(value) { |
| + %_CallFunction(this, value, SET_TYPE, ObjectMirror); |
| +} |
| +inherits(SetMirror, ObjectMirror); |
| + |
| + |
| +/** |
| + * Returns an array of elements of a set. |
| + * This will keep elements alive for WeakSets. |
| + * |
| + * @returns {Array.<Object>} Array of elements of a set. |
| + */ |
| +SetMirror.prototype.entries = function() { |
| + if (IS_WEAKSET(this.value_)) { |
| + return %GetWeakSetEntries(this.value_); |
| + } |
| + |
| + var result = []; |
| + var iter = %_CallFunction(this.value_, builtins.SetEntries); |
|
arv (Not doing code reviews)
2014/07/22 15:15:10
You can do SetValues here instead. No need for the
Alexandra Mikhaylova
2014/07/22 16:01:18
Thanks, fixed it.
|
| + var next; |
| + while (!(next = iter.next()).done) { |
| + result.push(next.value[0]); |
| + } |
| + return result; |
| +}; |
| + |
| + |
| /** |
| * Base mirror object for properties. |
| * @param {ObjectMirror} mirror The mirror object having this property |