Index: src/mirror-debugger.js |
diff --git a/src/mirror-debugger.js b/src/mirror-debugger.js |
index e717f6e0706fc232a2c252deb848b51243871b6e..35f34a91d48edcd1c26e3aa1a54fbbec06731e41 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.values = function() { |
+ if (IS_WEAKSET(this.value_)) { |
+ return %GetWeakSetValues(this.value_); |
+ } |
+ |
+ var result = []; |
+ var iter = %_CallFunction(this.value_, builtins.SetValues); |
+ var next; |
+ while (!(next = iter.next()).done) { |
+ result.push(next.value); |
+ } |
+ return result; |
+}; |
+ |
+ |
/** |
* Base mirror object for properties. |
* @param {ObjectMirror} mirror The mirror object having this property |