Commit 96cafa31 authored by oliver@apple.com's avatar oliver@apple.com

Implement Set iterators

https://bugs.webkit.org/show_bug.cgi?id=124129

Reviewed by Antti Koivisto.

Source/JavaScriptCore:

Add Set iterator classes and implementations

* JavaScriptCore.xcodeproj/project.pbxproj:
* runtime/CommonIdentifiers.h:
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
* runtime/JSSetIterator.cpp: Added.
(JSC::JSSetIterator::finishCreation):
(JSC::JSSetIterator::visitChildren):
(JSC::JSSetIterator::createPair):
* runtime/JSSetIterator.h: Added.
(JSC::JSSetIterator::createStructure):
(JSC::JSSetIterator::create):
(JSC::JSSetIterator::next):
(JSC::JSSetIterator::JSSetIterator):
* runtime/SetIteratorConstructor.cpp: Added.
(JSC::SetIteratorConstructor::finishCreation):
* runtime/SetIteratorConstructor.h: Added.
(JSC::SetIteratorConstructor::create):
(JSC::SetIteratorConstructor::createStructure):
(JSC::SetIteratorConstructor::SetIteratorConstructor):
* runtime/SetIteratorPrototype.cpp: Added.
(JSC::SetIteratorPrototype::finishCreation):
(JSC::SetIteratorPrototypeFuncIterator):
(JSC::SetIteratorPrototypeFuncNext):
* runtime/SetIteratorPrototype.h: Added.
(JSC::SetIteratorPrototype::create):
(JSC::SetIteratorPrototype::createStructure):
(JSC::SetIteratorPrototype::SetIteratorPrototype):
* runtime/SetPrototype.cpp:
(JSC::SetPrototype::finishCreation):
(JSC::setProtoFuncValues):
(JSC::setProtoFuncEntries):
(JSC::setProtoFuncKeys):

LayoutTests:

Move Set tests to more sensible location and add iterator tests

* js/basic-set-expected.txt: Renamed from LayoutTests/js/dom/basic-set-expected.txt.
* js/basic-set.html: Renamed from LayoutTests/js/dom/basic-set.html.
* js/script-tests/basic-set.js: Renamed from LayoutTests/js/dom/script-tests/basic-set.js.
(set new):
(otherString.string_appeared_here.set add):
(try.set forEach):
(set forEach):
(set gc):

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@159031 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent b39b467b
2013-11-10 Oliver Hunt <oliver@apple.com>
Implement Set iterators
https://bugs.webkit.org/show_bug.cgi?id=124129
Reviewed by Antti Koivisto.
Move Set tests to more sensible location and add iterator tests
* js/basic-set-expected.txt: Renamed from LayoutTests/js/dom/basic-set-expected.txt.
* js/basic-set.html: Renamed from LayoutTests/js/dom/basic-set.html.
* js/script-tests/basic-set.js: Renamed from LayoutTests/js/dom/script-tests/basic-set.js.
(set new):
(otherString.string_appeared_here.set add):
(try.set forEach):
(set forEach):
(set gc):
2013-11-10 Antti Koivisto <antti@apple.com>
Implement white-space property on simple line layout path
......
......@@ -121,6 +121,72 @@ PASS set.has("5") is true
PASS set.has(6) is true
PASS set.has("6") is true
PASS set.has(4) is true
set.@@iterator()
PASS key is 0
PASS key is '0'
PASS key is 1
PASS key is '1'
PASS key is 2
PASS key is '2'
PASS key is 3
PASS key is '3'
PASS key is 4
PASS key is '4'
PASS i is 10
set.entries()
PASS key is 0
PASS value is 0
PASS key is '0'
PASS value is '0'
PASS key is 1
PASS value is 1
PASS key is '1'
PASS value is '1'
PASS key is 2
PASS value is 2
PASS key is '2'
PASS value is '2'
PASS key is 3
PASS value is 3
PASS key is '3'
PASS value is '3'
PASS key is 4
PASS value is 4
PASS key is '4'
PASS value is '4'
PASS i is 10
set.keys()
PASS key is 0
PASS key is '0'
PASS key is 1
PASS key is '1'
PASS key is 2
PASS key is '2'
PASS key is 3
PASS key is '3'
PASS key is 4
PASS key is '4'
PASS i is 10
set.values()
PASS value is 0
PASS value is '0'
PASS value is 1
PASS value is '1'
PASS value is 2
PASS value is '2'
PASS value is 3
PASS value is '3'
PASS value is 4
PASS value is '4'
PASS i is 10
Set mutation with live iterator and GC
PASS key is 1
PASS key is 3
PASS key is 4
PASS key is 5
PASS key is 7
PASS i is 5
PASS set.size is 4
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -119,3 +119,81 @@ for (var i = 0; i < keys.length; i++) {
var expectedKey = keys[i]
shouldBeTrue("set.has("+JSON.stringify(expectedKey)+")");
}
set = new Set;
var count = 5;
var keys = [];
for (var i = 0; i < count; i++) {
set.add(i)
set.add("" + i)
keys.push("" + i)
keys.push("'" + i + "'")
}
var i = 0;
debug("set.@@iterator()")
for (var key of set) {
shouldBe("key", "" + keys[i])
i++;
}
shouldBe("i", "" + count * 2)
debug("set.entries()")
var i = 0;
for (var [key, value] of set.entries()) {
shouldBe("key", "" + keys[i])
shouldBe("value", "" + keys[i])
i++;
}
shouldBe("i", "" + count * 2)
debug("set.keys()")
var i = 0;
for (var key of set.keys()) {
shouldBe("key", "" + keys[i])
i++;
}
shouldBe("i", "" + count * 2)
var i = 0;
debug("set.values()")
for (var value of set.values()) {
shouldBe("value", "" + keys[i])
i++;
}
shouldBe("i", "" + count * 2)
debug("Set mutation with live iterator and GC")
set = new Set;
set.add(0)
set.add(1)
set.add(2)
set.add(3)
set.add(4)
set.add(5)
set.add(6)
set.add(7)
set.add(9)
set.add(14)
var keys = [1,3,4,5,7]
var keyIterator = set.keys();
gc();
set.delete(0)
gc()
var i = 0;
for (var key of keyIterator) {
shouldBe("key", "" + keys[i])
if (key == 7)
set.delete(9)
set.delete(1)
set.delete(key * 2)
gc()
i++
}
shouldBe("i", "5")
shouldBe("set.size", "4");
......@@ -354,6 +354,7 @@ set(JavaScriptCore_SOURCES
runtime/JSScope.cpp
runtime/JSSegmentedVariableObject.cpp
runtime/JSSet.cpp
runtime/JSSetIterator.cpp
runtime/JSStaticScopeObject.cpp
runtime/JSString.cpp
runtime/JSStringJoiner.cpp
......@@ -400,6 +401,8 @@ set(JavaScriptCore_SOURCES
runtime/RegExpPrototype.cpp
runtime/SamplingCounter.cpp
runtime/SetConstructor.cpp
runtime/SetIteratorConstructor.cpp
runtime/SetIteratorPrototype.cpp
runtime/SetPrototype.cpp
runtime/SimpleTypedArrayController.cpp
runtime/SmallStrings.cpp
......
2013-11-10 Oliver Hunt <oliver@apple.com>
Implement Set iterators
https://bugs.webkit.org/show_bug.cgi?id=124129
Reviewed by Antti Koivisto.
Add Set iterator classes and implementations
* JavaScriptCore.xcodeproj/project.pbxproj:
* runtime/CommonIdentifiers.h:
* runtime/JSGlobalObject.cpp:
* runtime/JSGlobalObject.h:
* runtime/JSSetIterator.cpp: Added.
(JSC::JSSetIterator::finishCreation):
(JSC::JSSetIterator::visitChildren):
(JSC::JSSetIterator::createPair):
* runtime/JSSetIterator.h: Added.
(JSC::JSSetIterator::createStructure):
(JSC::JSSetIterator::create):
(JSC::JSSetIterator::next):
(JSC::JSSetIterator::JSSetIterator):
* runtime/SetIteratorConstructor.cpp: Added.
(JSC::SetIteratorConstructor::finishCreation):
* runtime/SetIteratorConstructor.h: Added.
(JSC::SetIteratorConstructor::create):
(JSC::SetIteratorConstructor::createStructure):
(JSC::SetIteratorConstructor::SetIteratorConstructor):
* runtime/SetIteratorPrototype.cpp: Added.
(JSC::SetIteratorPrototype::finishCreation):
(JSC::SetIteratorPrototypeFuncIterator):
(JSC::SetIteratorPrototypeFuncNext):
* runtime/SetIteratorPrototype.h: Added.
(JSC::SetIteratorPrototype::create):
(JSC::SetIteratorPrototype::createStructure):
(JSC::SetIteratorPrototype::SetIteratorPrototype):
* runtime/SetPrototype.cpp:
(JSC::SetPrototype::finishCreation):
(JSC::setProtoFuncValues):
(JSC::setProtoFuncEntries):
(JSC::setProtoFuncKeys):
2013-11-09 Oliver Hunt <oliver@apple.com>
Add Map Iterators
......
......@@ -954,6 +954,8 @@ javascriptcore_sources += \
Source/JavaScriptCore/runtime/JSSegmentedVariableObject.h \
Source/JavaScriptCore/runtime/JSSet.cpp \
Source/JavaScriptCore/runtime/JSSet.h \
Source/JavaScriptCore/runtime/JSSetIterator.cpp \
Source/JavaScriptCore/runtime/JSSetIterator.h \
Source/JavaScriptCore/runtime/JSTypedArrayConstructors.cpp \
Source/JavaScriptCore/runtime/JSTypedArrayConstructors.h \
Source/JavaScriptCore/runtime/JSTypedArrayPrototypes.cpp \
......@@ -1068,6 +1070,10 @@ javascriptcore_sources += \
Source/JavaScriptCore/runtime/SamplingCounter.h \
Source/JavaScriptCore/runtime/SetConstructor.cpp \
Source/JavaScriptCore/runtime/SetConstructor.h\
Source/JavaScriptCore/runtime/SetIteratorConstructor.cpp \
Source/JavaScriptCore/runtime/SetIteratorConstructor.h\
Source/JavaScriptCore/runtime/SetIteratorPrototype.cpp \
Source/JavaScriptCore/runtime/SetIteratorPrototype.h \
Source/JavaScriptCore/runtime/SetPrototype.cpp \
Source/JavaScriptCore/runtime/SetPrototype.h \
Source/JavaScriptCore/runtime/SimpleTypedArrayController.cpp \
......
......@@ -592,6 +592,7 @@
<ClCompile Include="..\runtime\JSScope.cpp" />
<ClCompile Include="..\runtime\JSSegmentedVariableObject.cpp" />
<ClCompile Include="..\runtime\JSSet.cpp" />
<ClCompile Include="..\runtime\JSSetIterator.cpp" />
<ClCompile Include="..\runtime\JSString.cpp" />
<ClCompile Include="..\runtime\JSStringJoiner.cpp" />
<ClCompile Include="..\runtime\JSSymbolTableObject.cpp" />
......@@ -636,6 +637,8 @@
<ClCompile Include="..\runtime\RegExpPrototype.cpp" />
<ClCompile Include="..\runtime\SamplingCounter.cpp" />
<ClCompile Include="..\runtime\SetConstructor.cpp" />
<ClCompile Include="..\runtime\SetIteratorConstructor.cpp" />
<ClCompile Include="..\runtime\SetIteratorPrototype.cpp" />
<ClCompile Include="..\runtime\SetPrototype.cpp" />
<ClCompile Include="..\runtime\SimpleTypedArrayController.cpp" />
<ClCompile Include="..\runtime\SmallStrings.cpp" />
......@@ -1178,6 +1181,7 @@
<ClInclude Include="..\runtime\JSScope.h" />
<ClInclude Include="..\runtime\JSSegmentedVariableObject.h" />
<ClInclude Include="..\runtime\JSSet.h" />
<ClInclude Include="..\runtime\JSSetIterator.h" />
<ClInclude Include="..\runtime\JSString.h" />
<ClInclude Include="..\runtime\JSStringBuilder.h" />
<ClInclude Include="..\runtime\JSStringJoiner.h" />
......@@ -1240,6 +1244,8 @@
<ClInclude Include="..\runtime\Reject.h" />
<ClInclude Include="..\runtime\SamplingCounter.h" />
<ClInclude Include="..\runtime\SetConstructor.h" />
<ClInclude Include="..\runtime\SetIteratorConstructor.h" />
<ClInclude Include="..\runtime\SetIteratorPrototype.h" />
<ClInclude Include="..\runtime\SetPrototype.h" />
<ClInclude Include="..\runtime\SimpleTypedArrayController.h" />
<ClInclude Include="..\runtime\SmallStrings.h" />
......
......@@ -594,6 +594,9 @@
<ClCompile Include="..\runtime\JSSet.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\JSSetIterator.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\JSSegmentedVariableObject.cpp">
<Filter>runtime</Filter>
</ClCompile>
......@@ -711,9 +714,18 @@
<ClCompile Include="..\runtime\SetPrototype.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\SetIteratorPrototype.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\SetIteratorConstructor.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\SetConstructor.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\SetIteratorConstructor.cpp">
<Filter>runtime</Filter>
</ClCompile>
<ClCompile Include="..\runtime\SparseArrayValueMap.cpp">
<Filter>runtime</Filter>
</ClCompile>
......@@ -2607,6 +2619,9 @@
<ClInclude Include="..\runtime\JSSet.h">
<Filter>runtime</Filter>
</ClInclude>
<ClInclude Include="..\runtime\JSSetIterator.h">
<Filter>runtime</Filter>
</ClInclude>
<ClInclude Include="..\llint\LLIntEntrypoint.h">
<Filter>llint</Filter>
</ClInclude>
......@@ -2619,12 +2634,18 @@
<ClInclude Include="..\runtime\SetPrototype.h">
<Filter>runtime</Filter>
</ClInclude>
<ClInclude Include="..\runtime\SetIteratorPrototype.h">
<Filter>runtime</Filter>
</ClInclude>
<ClInclude Include="..\runtime\MapPrototype.h">
<Filter>runtime</Filter>
</ClInclude>
<ClInclude Include="..\runtime\SetConstructor.h">
<Filter>runtime</Filter>
</ClInclude>
<ClInclude Include="..\runtime\SetIteratorConstructor.h">
<Filter>runtime</Filter>
</ClInclude>
<ClInclude Include="..\dfg\DFGAbstractHeap.h">
<Filter>dfg</Filter>
</ClInclude>
......
......@@ -976,6 +976,12 @@
A78A977F179738D5009DF744 /* FTLGeneratedFunction.h in Headers */ = {isa = PBXBuildFile; fileRef = A78A977C179738D5009DF744 /* FTLGeneratedFunction.h */; };
A78A9780179738D5009DF744 /* FTLJITFinalizer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A78A977D179738D5009DF744 /* FTLJITFinalizer.cpp */; };
A78A9781179738D5009DF744 /* FTLJITFinalizer.h in Headers */ = {isa = PBXBuildFile; fileRef = A78A977E179738D5009DF744 /* FTLJITFinalizer.h */; };
A790DD6B182F499700588807 /* SetIteratorConstructor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A790DD65182F499700588807 /* SetIteratorConstructor.cpp */; };
A790DD6C182F499700588807 /* SetIteratorConstructor.h in Headers */ = {isa = PBXBuildFile; fileRef = A790DD66182F499700588807 /* SetIteratorConstructor.h */; };
A790DD6D182F499700588807 /* SetIteratorPrototype.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A790DD67182F499700588807 /* SetIteratorPrototype.cpp */; };
A790DD6E182F499700588807 /* SetIteratorPrototype.h in Headers */ = {isa = PBXBuildFile; fileRef = A790DD68182F499700588807 /* SetIteratorPrototype.h */; };
A790DD6F182F499700588807 /* JSSetIterator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A790DD69182F499700588807 /* JSSetIterator.cpp */; };
A790DD70182F499700588807 /* JSSetIterator.h in Headers */ = {isa = PBXBuildFile; fileRef = A790DD6A182F499700588807 /* JSSetIterator.h */; };
A7986D5717A0BB1E00A95DD0 /* DFGEdgeUsesStructure.h in Headers */ = {isa = PBXBuildFile; fileRef = A7986D5617A0BB1E00A95DD0 /* DFGEdgeUsesStructure.h */; settings = {ATTRIBUTES = (Private, ); }; };
A7A4AE0817973B26005612B1 /* MacroAssemblerX86Common.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A7A4AE0717973B26005612B1 /* MacroAssemblerX86Common.cpp */; };
A7A4AE1017973B4D005612B1 /* JITStubsX86Common.h in Headers */ = {isa = PBXBuildFile; fileRef = A7A4AE0C17973B4D005612B1 /* JITStubsX86Common.h */; };
......@@ -2266,6 +2272,12 @@
A78A977C179738D5009DF744 /* FTLGeneratedFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTLGeneratedFunction.h; path = ftl/FTLGeneratedFunction.h; sourceTree = "<group>"; };
A78A977D179738D5009DF744 /* FTLJITFinalizer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = FTLJITFinalizer.cpp; path = ftl/FTLJITFinalizer.cpp; sourceTree = "<group>"; };
A78A977E179738D5009DF744 /* FTLJITFinalizer.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = FTLJITFinalizer.h; path = ftl/FTLJITFinalizer.h; sourceTree = "<group>"; };
A790DD65182F499700588807 /* SetIteratorConstructor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SetIteratorConstructor.cpp; sourceTree = "<group>"; };
A790DD66182F499700588807 /* SetIteratorConstructor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SetIteratorConstructor.h; sourceTree = "<group>"; };
A790DD67182F499700588807 /* SetIteratorPrototype.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SetIteratorPrototype.cpp; sourceTree = "<group>"; };
A790DD68182F499700588807 /* SetIteratorPrototype.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SetIteratorPrototype.h; sourceTree = "<group>"; };
A790DD69182F499700588807 /* JSSetIterator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSSetIterator.cpp; sourceTree = "<group>"; };
A790DD6A182F499700588807 /* JSSetIterator.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSSetIterator.h; sourceTree = "<group>"; };
A7986D5617A0BB1E00A95DD0 /* DFGEdgeUsesStructure.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = DFGEdgeUsesStructure.h; path = dfg/DFGEdgeUsesStructure.h; sourceTree = "<group>"; };
A79E781E15EECBA80047C855 /* UnlinkedCodeBlock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UnlinkedCodeBlock.cpp; sourceTree = "<group>"; };
A79E781F15EECBA80047C855 /* UnlinkedCodeBlock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UnlinkedCodeBlock.h; sourceTree = "<group>"; };
......@@ -3656,6 +3668,12 @@
A74DEF8E182D991400522C22 /* MapIteratorPrototype.h */,
A74DEF8F182D991400522C22 /* JSMapIterator.cpp */,
A74DEF90182D991400522C22 /* JSMapIterator.h */,
A790DD65182F499700588807 /* SetIteratorConstructor.cpp */,
A790DD66182F499700588807 /* SetIteratorConstructor.h */,
A790DD67182F499700588807 /* SetIteratorPrototype.cpp */,
A790DD68182F499700588807 /* SetIteratorPrototype.h */,
A790DD69182F499700588807 /* JSSetIterator.cpp */,
A790DD6A182F499700588807 /* JSSetIterator.h */,
);
path = runtime;
sourceTree = "<group>";
......@@ -4454,6 +4472,7 @@
0FB14E1F18124ACE009B6B4D /* JITInlineCacheGenerator.h in Headers */,
86CC85A10EE79A4700288682 /* JITInlines.h in Headers */,
0F24E54D17EE274900ABB217 /* JITOperations.h in Headers */,
A790DD70182F499700588807 /* JSSetIterator.h in Headers */,
0F24E54E17EE274900ABB217 /* JITOperationWrappers.h in Headers */,
0F766D3115AA8112008F363E /* JITStubRoutine.h in Headers */,
0F766D2C15A8CC3A008F363E /* JITStubRoutineSet.h in Headers */,
......@@ -4626,6 +4645,7 @@
0FB5467B14F5C7E1002C2989 /* MethodOfGettingAValueProfile.h in Headers */,
86C568E211A213EE0007F7F0 /* MIPSAssembler.h in Headers */,
86EBF3001560F06A008E9222 /* NameConstructor.h in Headers */,
A790DD6E182F499700588807 /* SetIteratorPrototype.h in Headers */,
86EBF3021560F06A008E9222 /* NameInstance.h in Headers */,
86EBF3041560F06A008E9222 /* NamePrototype.h in Headers */,
BC02E9110E1839DB000F9297 /* NativeErrorConstructor.h in Headers */,
......@@ -4712,6 +4732,7 @@
A7299DA217D12848005F5FF9 /* SetPrototype.h in Headers */,
86AE64AA135E5E1C00963012 /* SH4Assembler.h in Headers */,
0F2B670517B6B5AB00A7AE3F /* SimpleTypedArrayController.h in Headers */,
A790DD6C182F499700588807 /* SetIteratorConstructor.h in Headers */,
14BA78F113AAB88F005B7C2C /* SlotVisitor.h in Headers */,
C2160FE715F7E95E00942DFC /* SlotVisitorInlines.h in Headers */,
A709F2F017A0AC0400512E98 /* SlowPathCall.h in Headers */,
......@@ -5228,6 +5249,7 @@
147F39BF107EC37600427A48 /* ArrayConstructor.cpp in Sources */,
A7BDAEC617F4EA1400F6140C /* ArrayIteratorConstructor.cpp in Sources */,
A7BDAEC817F4EA1400F6140C /* ArrayIteratorPrototype.cpp in Sources */,
A790DD6F182F499700588807 /* JSSetIterator.cpp in Sources */,
0F63945415D07055006A597C /* ArrayProfile.cpp in Sources */,
147F39C0107EC37600427A48 /* ArrayPrototype.cpp in Sources */,
0F24E54017EA9F5900ABB217 /* AssemblyHelpers.cpp in Sources */,
......@@ -5608,6 +5630,7 @@
A7299DA517D12858005F5FF9 /* SetConstructor.cpp in Sources */,
A7299DA117D12848005F5FF9 /* SetPrototype.cpp in Sources */,
0F2B670417B6B5AB00A7AE3F /* SimpleTypedArrayController.cpp in Sources */,
A790DD6D182F499700588807 /* SetIteratorPrototype.cpp in Sources */,
C225494315F7DBAA0065E898 /* SlotVisitor.cpp in Sources */,
9330402C0E6A764000786E6A /* SmallStrings.cpp in Sources */,
0F8F2B9E17306C8D007DBDA5 /* SourceCode.cpp in Sources */,
......@@ -5637,6 +5660,7 @@
0F2B670A17B6B5AB00A7AE3F /* TypedArrayType.cpp in Sources */,
0FF4274A158EBE91004CB9FF /* udis86.c in Sources */,
0FF42740158EBE8B004CB9FF /* udis86_decode.c in Sources */,
A790DD6B182F499700588807 /* SetIteratorConstructor.cpp in Sources */,
0FF42743158EBE91004CB9FF /* udis86_input.c in Sources */,
0FF4274D158EBFE6004CB9FF /* udis86_itab_holder.c in Sources */,
0FF42745158EBE91004CB9FF /* udis86_syn-att.c in Sources */,
......
......@@ -51,6 +51,7 @@
macro(ReferenceError) \
macro(RegExp) \
macro(Set)\
macro(SetIterator)\
macro(String) \
macro(SyntaxError) \
macro(TypeError) \
......
......@@ -76,6 +76,7 @@
#include "JSNameScope.h"
#include "JSONObject.h"
#include "JSSet.h"
#include "JSSetIterator.h"
#include "JSTypedArrayConstructors.h"
#include "JSTypedArrayPrototypes.h"
#include "JSTypedArrays.h"
......@@ -105,6 +106,8 @@
#include "RegExpObject.h"
#include "RegExpPrototype.h"
#include "SetConstructor.h"
#include "SetIteratorConstructor.h"
#include "SetIteratorPrototype.h"
#include "SetPrototype.h"
#include "StrictEvalActivation.h"
#include "StringConstructor.h"
......
......@@ -86,6 +86,7 @@ struct HashTable;
DEFINE_STANDARD_BUILTIN(macro, ArrayIterator, arrayIterator) \
DEFINE_STANDARD_BUILTIN(macro, ArgumentsIterator, argumentsIterator) \
DEFINE_STANDARD_BUILTIN(macro, MapIterator, mapIterator) \
DEFINE_STANDARD_BUILTIN(macro, SetIterator, setIterator) \
#define DECLARE_SIMPLE_BUILTIN_TYPE(capitalName, lowerName, properName, instanceType, jsName) \
......
/*
* Copyright (C) 2013 Apple, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "JSSetIterator.h"
#include "JSCJSValueInlines.h"
#include "JSCellInlines.h"
#include "JSSet.h"
#include "SlotVisitorInlines.h"
namespace JSC {
const ClassInfo JSSetIterator::s_info = { "Set Iterator", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(JSSetIterator) };
void JSSetIterator::finishCreation(VM& vm, JSSet* iteratedObject)
{
Base::finishCreation(vm);
m_iteratedObjectData.set(vm, this, iteratedObject->mapData());
}
void JSSetIterator::visitChildren(JSCell* cell, SlotVisitor& visitor)
{
JSSetIterator* thisObject = jsCast<JSSetIterator*>(cell);
ASSERT_GC_OBJECT_INHERITS(thisObject, info());
COMPILE_ASSERT(StructureFlags & OverridesVisitChildren, OverridesVisitChildrenWithoutSettingFlag);
ASSERT(thisObject->structure()->typeInfo().overridesVisitChildren());
Base::visitChildren(thisObject, visitor);
visitor.append(&thisObject->m_iteratedObjectData);
}
JSValue JSSetIterator::createPair(CallFrame* callFrame, JSValue key, JSValue value)
{
MarkedArgumentBuffer args;
args.append(key);
args.append(value);
JSGlobalObject* globalObject = callFrame->callee()->globalObject();
return constructArray(callFrame, 0, globalObject, args);
}
}
/*
* Copyright (C) 2013 Apple, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef JSSetIterator_h
#define JSSetIterator_h
#include "JSDestructibleObject.h"
#include "JSSet.h"
#include "MapData.h"
namespace JSC {
enum SetIterationKind : uint32_t {
SetIterateKey,
SetIterateValue,
SetIterateKeyValue,
};
class JSSetIterator : public JSDestructibleObject {
public:
typedef JSDestructibleObject Base;
DECLARE_EXPORT_INFO;
static Structure* createStructure(VM& vm, JSGlobalObject* globalObject, JSValue prototype)
{
return Structure::create(vm, globalObject, prototype, TypeInfo(ObjectType, StructureFlags), info());
}
static JSSetIterator* create(VM& vm, Structure* structure, JSSet* iteratedObject, SetIterationKind kind)
{
JSSetIterator* instance = new (NotNull, allocateCell<JSSetIterator>(vm.heap)) JSSetIterator(vm, structure, iteratedObject, kind);
instance->finishCreation(vm, iteratedObject);
return instance;
}
bool next(CallFrame* callFrame, JSValue& value)
{
if (!m_iterator.ensureSlot())
return false;
if (m_kind == SetIterateValue || m_kind == SetIterateKey)
value = m_iterator.key();
else
value = createPair(callFrame, m_iterator.key(), m_iterator.key());
++m_iterator;
return true;
}
private:
static const unsigned StructureFlags = Base::StructureFlags | OverridesVisitChildren;
JSSetIterator(VM& vm, Structure* structure, JSSet* iteratedObject, SetIterationKind kind)
: Base(vm, structure)
, m_iterator(iteratedObject->mapData()->begin())
, m_kind(kind)
{
}
void finishCreation(VM&, JSSet*);
JSValue createPair(CallFrame*, JSValue, JSValue);
static void visitChildren(JSCell*, SlotVisitor&);
WriteBarrier<MapData> m_iteratedObjectData;
MapData::const_iterator m_iterator;
SetIterationKind m_kind;
};
}
#endif // !defined(JSSetIterator_h)
/*
* Copyright (C) 2013 Apple, Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.