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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | src/runtime.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« 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