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

Unified Diff: src/mirror-debugger.js

Issue 693813002: Add debug mirror support for ES6 Map/Set iterators. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: added TODO Created 6 years, 1 month 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 | « src/factory.cc ('k') | src/runtime/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 c36d6fd720b7bf1096de432cd180b797a0d77ad8..da031d3383b55321827fee2d8bbb8e14477e7049 100644
--- a/src/mirror-debugger.js
+++ b/src/mirror-debugger.js
@@ -85,6 +85,8 @@ function MakeMirror(value, opt_transient) {
mirror = new MapMirror(value);
} else if (IS_SET(value) || IS_WEAKSET(value)) {
mirror = new SetMirror(value);
+ } else if (IS_MAP_ITERATOR(value) || IS_SET_ITERATOR(value)) {
+ mirror = new IteratorMirror(value);
} else if (ObjectIsPromise(value)) {
mirror = new PromiseMirror(value);
} else if (IS_GENERATOR(value)) {
@@ -163,6 +165,7 @@ var SCOPE_TYPE = 'scope';
var PROMISE_TYPE = 'promise';
var MAP_TYPE = 'map';
var SET_TYPE = 'set';
+var ITERATOR_TYPE = 'iterator';
var GENERATOR_TYPE = 'generator';
// Maximum length when sending strings through the JSON protocol.
@@ -217,6 +220,7 @@ var ScopeType = { Global: 0,
// - PromiseMirror
// - MapMirror
// - SetMirror
+// - IteratorMirror
// - GeneratorMirror
// - PropertyMirror
// - InternalPropertyMirror
@@ -456,6 +460,15 @@ Mirror.prototype.isSet = function() {
/**
+ * Check whether the mirror reflects an iterator.
+ * @returns {boolean} True if the mirror reflects an iterator
+ */
+Mirror.prototype.isIterator = function() {
+ return this instanceof IteratorMirror;
+};
+
+
+/**
* Allocate a handle id for this object.
*/
Mirror.prototype.allocateHandle_ = function() {
@@ -1343,6 +1356,16 @@ function SetMirror(value) {
inherits(SetMirror, ObjectMirror);
+function IteratorGetValues_(iter, next_function) {
+ var result = [];
+ var next;
+ while (!(next = %_CallFunction(iter, next_function)).done) {
+ result.push(next.value);
+ }
+ return result;
+}
+
+
/**
* Returns an array of elements of a set.
* This will keep elements alive for WeakSets.
@@ -1354,13 +1377,31 @@ SetMirror.prototype.values = function() {
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 IteratorGetValues_(iter, builtins.SetIteratorNextJS);
+};
+
+
+function IteratorMirror(value) {
+ %_CallFunction(this, value, ITERATOR_TYPE, ObjectMirror);
+}
+inherits(IteratorMirror, ObjectMirror);
+
+
+/**
+ * Returns a preview of elements of an iterator.
+ * Does not change the backing iterator state.
+ *
+ * @returns {Array.<Object>} Array of elements of an iterator.
+ */
+IteratorMirror.prototype.preview = function() {
+ if (IS_MAP_ITERATOR(this.value_)) {
+ return IteratorGetValues_(%MapIteratorClone(this.value_),
+ builtins.MapIteratorNextJS);
+ } else if (IS_SET_ITERATOR(this.value_)) {
+ return IteratorGetValues_(%SetIteratorClone(this.value_),
+ builtins.SetIteratorNextJS);
}
- return result;
};
« no previous file with comments | « src/factory.cc ('k') | src/runtime/runtime.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698