result.push(new InternalPropertyMirror("[[BoundArgs]]", boundArgs));
}
return result;
+ } else if (IS_MAP_ITERATOR(value) || IS_SET_ITERATOR(value)) {
+ var details = IS_MAP_ITERATOR(value) ? %MapIteratorDetails(value)
+ : %SetIteratorDetails(value);
+ var kind;
+ switch (details[2]) {
+ case 1: kind = "keys"; break;
+ case 2: kind = "values"; break;
+ case 3: kind = "entries"; break;
+ }
+ var result = [];
+ result.push(new InternalPropertyMirror("[[IteratorHasMore]]", details[0]));
+ result.push(new InternalPropertyMirror("[[IteratorIndex]]", details[1]));
+ if (kind) {
+ result.push(new InternalPropertyMirror("[[IteratorKind]]", kind));
+ }
+ return result;
} else if (ObjectIsPromise(value)) {
var result = [];
result.push(new InternalPropertyMirror("[[PromiseStatus]]",
}
+// The array returned contains the following information:
+// 0: HasMore flag
+// 1: Iteration index
+// 2: Iteration kind
+RUNTIME_FUNCTION(Runtime_SetIteratorDetails) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 1);
+ CONVERT_ARG_HANDLE_CHECKED(JSSetIterator, holder, 0);
+ Handle<FixedArray> details = isolate->factory()->NewFixedArray(4);
+ details->set(0, isolate->heap()->ToBoolean(holder->HasMore()));
+ details->set(1, holder->index());
+ details->set(2, holder->kind());
+ return *isolate->factory()->NewJSArrayWithElements(details);
+}
+
+
RUNTIME_FUNCTION(Runtime_MapInitialize) {
HandleScope scope(isolate);
DCHECK(args.length() == 1);
}
+// The array returned contains the following information:
+// 0: HasMore flag
+// 1: Iteration index
+// 2: Iteration kind
+RUNTIME_FUNCTION(Runtime_MapIteratorDetails) {
+ HandleScope scope(isolate);
+ DCHECK(args.length() == 1);
+ CONVERT_ARG_HANDLE_CHECKED(JSMapIterator, holder, 0);
+ Handle<FixedArray> details = isolate->factory()->NewFixedArray(4);
+ details->set(0, isolate->heap()->ToBoolean(holder->HasMore()));
+ details->set(1, holder->index());
+ details->set(2, holder->kind());
+ return *isolate->factory()->NewJSArrayWithElements(details);
+}
+
+
RUNTIME_FUNCTION(Runtime_GetWeakMapEntries) {
HandleScope scope(isolate);
DCHECK(args.length() == 2);
F(SetIteratorInitialize, 3, 1) \
F(SetIteratorClone, 1, 1) \
F(SetIteratorNext, 2, 1) \
+ F(SetIteratorDetails, 1, 1) \
\
/* Harmony maps */ \
F(MapInitialize, 1, 1) \
F(MapIteratorInitialize, 3, 1) \
F(MapIteratorClone, 1, 1) \
F(MapIteratorNext, 2, 1) \
+ F(MapIteratorDetails, 1, 1) \
\
/* Harmony weak maps and sets */ \
F(WeakCollectionInitialize, 1, 1) \
assertArrayEquals(expected, values);
}
+function testIteratorInternalProperties(iter, offset, kind, index, has_more) {
+ while (offset-- > 0) iter.next();
+
+ var mirror = debug.MakeMirror(iter);
+ assertTrue(mirror.isIterator());
+
+ var properties = mirror.internalProperties();
+ assertEquals(3, properties.length);
+ assertEquals("[[IteratorHasMore]]", properties[0].name());
+ assertEquals(has_more, properties[0].value().value());
+ assertEquals("[[IteratorIndex]]", properties[1].name());
+ assertEquals(index, properties[1].value().value());
+ assertEquals("[[IteratorKind]]", properties[2].name());
+ assertEquals(kind, properties[2].value().value());
+}
+
var o1 = { foo: 1 };
var o2 = { foo: 2 };
testIteratorMirror(map.values(), 0, [42], 1);
testIteratorMirror(map.entries(), 0, [[41, 42]], 1);
+testIteratorInternalProperties(map.keys(), 0, "keys", 0, true);
+testIteratorInternalProperties(map.values(), 1, "values", 1, true);
+testIteratorInternalProperties(map.entries(), 2, "entries", 2, false);
+testIteratorInternalProperties(map.keys(), 3, "keys", 2, false);
+
var set = new Set();
set.add(41);
set.add(42);
testIteratorMirror(set.keys(), 1, [42, o1], 2);
testIteratorMirror(set.values(), 1, [42, o1], 2);
testIteratorMirror(set.entries(), 1, [[42, 42], [o1, o1]], 2);
+
+testIteratorInternalProperties(set.keys(), 0, "values", 0, true);
+testIteratorInternalProperties(set.values(), 1, "values", 1, true);
+testIteratorInternalProperties(set.entries(), 2, "entries", 2, true);
+testIteratorInternalProperties(set.keys(), 3, "values", 3, true);
+testIteratorInternalProperties(set.values(), 4, "values", 4, false);
+testIteratorInternalProperties(set.entries(), 5, "entries", 4, false);