JavaScriptCore:
authormjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Oct 2005 08:05:44 +0000 (08:05 +0000)
committermjs <mjs@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 5 Oct 2005 08:05:44 +0000 (08:05 +0000)
        Reviewed by Eric.

- fixed <rdar://problem/4260481> Remove Reference type from JavaScriptCore

Also fixed some bugs with for..in enumeration while I was at it. object
properties now come before prototype properties and duplicates
between object and prototype are listed only once.

        * JavaScriptCore.xcodeproj/project.pbxproj:
        * kjs/IdentifierSequencedSet.cpp: Added.
        (KJS::IdentifierSequencedSet::IdentifierSequencedSet):
        (KJS::IdentifierSequencedSet::deallocateVector):
        (KJS::IdentifierSequencedSet::~IdentifierSequencedSet):
        (KJS::IdentifierSequencedSet::insert):
        * kjs/IdentifierSequencedSet.h: Added.
        (KJS::IdentifierSequencedSetIterator::IdentifierSequencedSetIterator):
        (KJS::IdentifierSequencedSetIterator::operator*):
        (KJS::IdentifierSequencedSetIterator::operator->):
        (KJS::IdentifierSequencedSetIterator::operator++):
        (KJS::IdentifierSequencedSetIterator::operator==):
        (KJS::IdentifierSequencedSetIterator::operator!=):
        (KJS::IdentifierSequencedSet::begin):
        (KJS::IdentifierSequencedSet::end):
        (KJS::IdentifierSequencedSet::size):
        * kjs/array_instance.h:
        * kjs/array_object.cpp:
        (ArrayInstanceImp::getPropertyNames):
        (ArrayInstanceImp::setLength):
        (ArrayInstanceImp::pushUndefinedObjectsToEnd):
        * kjs/nodes.cpp:
        (ForInNode::execute):
        * kjs/nodes.h:
        * kjs/object.cpp:
        (KJS::ObjectImp::getPropertyNames):
        * kjs/object.h:
        * kjs/property_map.cpp:
        (KJS::PropertyMap::getEnumerablePropertyNames):
        (KJS::PropertyMap::getSparseArrayPropertyNames):
        * kjs/property_map.h:
        * kjs/protect.h:
        * kjs/protected_reference.h: Removed.
        * kjs/reference.cpp: Removed.
        * kjs/reference.h: Removed.
        * kjs/reference_list.cpp: Removed.
        * kjs/reference_list.h: Removed.
        * kjs/ustring.h:
        (KJS::UString::impl):
        * kxmlcore/HashSet.h:

LayoutTests:

        Reviewed by Eric.

        - test case for some fixes I made to for..in enumeration. object
properties now come before prototype properties and duplicates
between object and prototype are listed only once.

        * fast/js/for-in-expected.txt: Added.
        * fast/js/for-in.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@10744 268f45cc-cd09-0410-ab3c-d52691b4dbfc

23 files changed:
JavaScriptCore/ChangeLog
JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj
JavaScriptCore/kjs/IdentifierSequencedSet.cpp [new file with mode: 0644]
JavaScriptCore/kjs/IdentifierSequencedSet.h [new file with mode: 0644]
JavaScriptCore/kjs/array_instance.h
JavaScriptCore/kjs/array_object.cpp
JavaScriptCore/kjs/nodes.cpp
JavaScriptCore/kjs/nodes.h
JavaScriptCore/kjs/object.cpp
JavaScriptCore/kjs/object.h
JavaScriptCore/kjs/property_map.cpp
JavaScriptCore/kjs/property_map.h
JavaScriptCore/kjs/protect.h
JavaScriptCore/kjs/protected_reference.h [deleted file]
JavaScriptCore/kjs/reference.cpp [deleted file]
JavaScriptCore/kjs/reference.h [deleted file]
JavaScriptCore/kjs/reference_list.cpp [deleted file]
JavaScriptCore/kjs/reference_list.h [deleted file]
JavaScriptCore/kjs/ustring.h
JavaScriptCore/kxmlcore/HashSet.h
LayoutTests/ChangeLog
LayoutTests/fast/js/for-in-expected.txt [new file with mode: 0644]
LayoutTests/fast/js/for-in.html [new file with mode: 0644]

index bec5b53d4d8f202ec57d7f93d84dfc1a4a33c975..0341431fb396b929eff87bcc247fb91d01d130d4 100644 (file)
@@ -1,3 +1,54 @@
+2005-10-05  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Eric.
+
+       - fixed <rdar://problem/4260481> Remove Reference type from JavaScriptCore
+
+       Also fixed some bugs with for..in enumeration while I was at it. object
+       properties now come before prototype properties and duplicates
+       between object and prototype are listed only once.
+
+        * JavaScriptCore.xcodeproj/project.pbxproj:
+        * kjs/IdentifierSequencedSet.cpp: Added.
+        (KJS::IdentifierSequencedSet::IdentifierSequencedSet):
+        (KJS::IdentifierSequencedSet::deallocateVector):
+        (KJS::IdentifierSequencedSet::~IdentifierSequencedSet):
+        (KJS::IdentifierSequencedSet::insert):
+        * kjs/IdentifierSequencedSet.h: Added.
+        (KJS::IdentifierSequencedSetIterator::IdentifierSequencedSetIterator):
+        (KJS::IdentifierSequencedSetIterator::operator*):
+        (KJS::IdentifierSequencedSetIterator::operator->):
+        (KJS::IdentifierSequencedSetIterator::operator++):
+        (KJS::IdentifierSequencedSetIterator::operator==):
+        (KJS::IdentifierSequencedSetIterator::operator!=):
+        (KJS::IdentifierSequencedSet::begin):
+        (KJS::IdentifierSequencedSet::end):
+        (KJS::IdentifierSequencedSet::size):
+        * kjs/array_instance.h:
+        * kjs/array_object.cpp:
+        (ArrayInstanceImp::getPropertyNames):
+        (ArrayInstanceImp::setLength):
+        (ArrayInstanceImp::pushUndefinedObjectsToEnd):
+        * kjs/nodes.cpp:
+        (ForInNode::execute):
+        * kjs/nodes.h:
+        * kjs/object.cpp:
+        (KJS::ObjectImp::getPropertyNames):
+        * kjs/object.h:
+        * kjs/property_map.cpp:
+        (KJS::PropertyMap::getEnumerablePropertyNames):
+        (KJS::PropertyMap::getSparseArrayPropertyNames):
+        * kjs/property_map.h:
+        * kjs/protect.h:
+        * kjs/protected_reference.h: Removed.
+        * kjs/reference.cpp: Removed.
+        * kjs/reference.h: Removed.
+        * kjs/reference_list.cpp: Removed.
+        * kjs/reference_list.h: Removed.
+        * kjs/ustring.h:
+        (KJS::UString::impl):
+        * kxmlcore/HashSet.h:
+
 2005-10-04  Eric Seidel  <eseidel@apple.com>
 
         Reviewed by mjs.
index a320323ad912cf58114d79be1d3d76e2cb30ebbf..b6ba340ee1d449d782ab32b7dbf47ee5de532808 100644 (file)
                37B800EF08EBB65B0035B474 /* HashTable.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65DFC92D08EA173A00F7300B /* HashTable.cpp */; };
                37B800F008EBB65B0035B474 /* HashTable.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92E08EA173A00F7300B /* HashTable.h */; settings = {ATTRIBUTES = (Private, ); }; };
                37B800F108EBB65C0035B474 /* HashTraits.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92F08EA173A00F7300B /* HashTraits.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               6512E62B08F3BA8B004A15B6 /* IdentifierSequencedSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 65D6D61C08F2676800958B28 /* IdentifierSequencedSet.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               6512E63608F3BADE004A15B6 /* IdentifierSequencedSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65D6D61B08F2676800958B28 /* IdentifierSequencedSet.cpp */; };
                65162EEB08E6A1FE007556CD /* SharedPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 65162EEA08E6A1FE007556CD /* SharedPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
                65162F0208E6A2D0007556CD /* SharedPtr.h in Headers */ = {isa = PBXBuildFile; fileRef = 65162EEA08E6A1FE007556CD /* SharedPtr.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               652C107F08DA7B1E0020887D /* protected_reference.h in Headers */ = {isa = PBXBuildFile; fileRef = 652C107E08DA7B1E0020887D /* protected_reference.h */; };
                6541BD7208E80A17002CBEE7 /* TCPageMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 6541BD6E08E80A17002CBEE7 /* TCPageMap.h */; };
                6541BD7308E80A17002CBEE7 /* TCSpinLock.h in Headers */ = {isa = PBXBuildFile; fileRef = 6541BD6F08E80A17002CBEE7 /* TCSpinLock.h */; };
                6541BD7408E80A17002CBEE7 /* TCSystemAlloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6541BD7008E80A17002CBEE7 /* TCSystemAlloc.cpp */; };
@@ -44,6 +45,8 @@
                65621E6E089E859700760F35 /* property_slot.h in Headers */ = {isa = PBXBuildFile; fileRef = 65621E6C089E859700760F35 /* property_slot.h */; settings = {ATTRIBUTES = (Private, ); }; };
                65621E6F089E85D300760F35 /* property_slot.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65621E6B089E859700760F35 /* property_slot.cpp */; };
                65621E70089E85D300760F35 /* property_slot.h in Headers */ = {isa = PBXBuildFile; fileRef = 65621E6C089E859700760F35 /* property_slot.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               65D6D61D08F2676800958B28 /* IdentifierSequencedSet.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 65D6D61B08F2676800958B28 /* IdentifierSequencedSet.cpp */; };
+               65D6D61E08F2676800958B28 /* IdentifierSequencedSet.h in Headers */ = {isa = PBXBuildFile; fileRef = 65D6D61C08F2676800958B28 /* IdentifierSequencedSet.h */; settings = {ATTRIBUTES = (Private, ); }; };
                65D7D19C08F10B5B0015ABD8 /* FastMallocInternal.h in Headers */ = {isa = PBXBuildFile; fileRef = 65D7D19B08F10B5B0015ABD8 /* FastMallocInternal.h */; };
                65DFC93008EA173A00F7300B /* HashFunctions.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92A08EA173A00F7300B /* HashFunctions.h */; settings = {ATTRIBUTES = (Private, ); }; };
                65DFC93108EA173A00F7300B /* HashMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 65DFC92B08EA173A00F7300B /* HashMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -92,8 +95,6 @@
                932F5B600822A1C700736975 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = F68EBB8C0255D4C601FF60F7 /* config.h */; settings = {ATTRIBUTES = (Private, ); }; };
                932F5B610822A1C700736975 /* JavaScriptCorePrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = F5C290E60284F98E018635CA /* JavaScriptCorePrefix.h */; };
                932F5B620822A1C700736975 /* simple_number.h in Headers */ = {isa = PBXBuildFile; fileRef = F50888B6030BB74C012A967E /* simple_number.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               932F5B630822A1C700736975 /* reference_list.h in Headers */ = {isa = PBXBuildFile; fileRef = F54F0800030CD22001B5C2EB /* reference_list.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               932F5B640822A1C700736975 /* reference.h in Headers */ = {isa = PBXBuildFile; fileRef = F5341391030CEEB1018BE7F3 /* reference.h */; settings = {ATTRIBUTES = (Private, ); }; };
                932F5B650822A1C700736975 /* completion.h in Headers */ = {isa = PBXBuildFile; fileRef = F5BB2BC5030F772101FCFE1D /* completion.h */; settings = {ATTRIBUTES = (Private, ); }; };
                932F5B660822A1C700736975 /* identifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 933A349A038AE7C6008635CE /* identifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
                932F5B670822A1C700736975 /* array_instance.h in Headers */ = {isa = PBXBuildFile; fileRef = 938772E5038BFE19008635CE /* array_instance.h */; settings = {ATTRIBUTES = (Private, ); }; };
                932F5BA80822A1C700736975 /* ustring.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A8850255597D01FF60F7 /* ustring.cpp */; };
                932F5BA90822A1C700736975 /* value.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A8870255597D01FF60F7 /* value.cpp */; };
                932F5BAB0822A1C700736975 /* nodes2string.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5FFE656026B47A6018635CA /* nodes2string.cpp */; };
-               932F5BAC0822A1C700736975 /* reference.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5341390030CEEB1018BE7F3 /* reference.cpp */; settings = {ATTRIBUTES = (Private, ); }; };
-               932F5BAD0822A1C700736975 /* reference_list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5341394030CF5F8018BE7F3 /* reference_list.cpp */; settings = {ATTRIBUTES = (Private, ); }; };
                932F5BAE0822A1C700736975 /* identifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 933A349D038AE80F008635CE /* identifier.cpp */; };
                932F5BAF0822A1C700736975 /* scope_chain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9374D3A8038D9D74008635CE /* scope_chain.cpp */; };
                932F5BB00822A1C700736975 /* list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 931C6CF0038EE8DE008635CE /* list.cpp */; };
                A85D8210087B2822006A9172 /* config.h in Headers */ = {isa = PBXBuildFile; fileRef = F68EBB8C0255D4C601FF60F7 /* config.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A85D8211087B2822006A9172 /* JavaScriptCorePrefix.h in Headers */ = {isa = PBXBuildFile; fileRef = F5C290E60284F98E018635CA /* JavaScriptCorePrefix.h */; };
                A85D8212087B2822006A9172 /* simple_number.h in Headers */ = {isa = PBXBuildFile; fileRef = F50888B6030BB74C012A967E /* simple_number.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               A85D8213087B2822006A9172 /* reference_list.h in Headers */ = {isa = PBXBuildFile; fileRef = F54F0800030CD22001B5C2EB /* reference_list.h */; settings = {ATTRIBUTES = (Private, ); }; };
-               A85D8214087B2822006A9172 /* reference.h in Headers */ = {isa = PBXBuildFile; fileRef = F5341391030CEEB1018BE7F3 /* reference.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A85D8215087B2822006A9172 /* completion.h in Headers */ = {isa = PBXBuildFile; fileRef = F5BB2BC5030F772101FCFE1D /* completion.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A85D8216087B2822006A9172 /* identifier.h in Headers */ = {isa = PBXBuildFile; fileRef = 933A349A038AE7C6008635CE /* identifier.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A85D8217087B2822006A9172 /* array_instance.h in Headers */ = {isa = PBXBuildFile; fileRef = 938772E5038BFE19008635CE /* array_instance.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A85D8258087B2822006A9172 /* ustring.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A8850255597D01FF60F7 /* ustring.cpp */; };
                A85D8259087B2822006A9172 /* value.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F692A8870255597D01FF60F7 /* value.cpp */; };
                A85D825A087B2822006A9172 /* nodes2string.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5FFE656026B47A6018635CA /* nodes2string.cpp */; };
-               A85D825B087B2822006A9172 /* reference.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5341390030CEEB1018BE7F3 /* reference.cpp */; settings = {ATTRIBUTES = (Private, ); }; };
-               A85D825C087B2822006A9172 /* reference_list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F5341394030CF5F8018BE7F3 /* reference_list.cpp */; settings = {ATTRIBUTES = (Private, ); }; };
                A85D825D087B2822006A9172 /* identifier.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 933A349D038AE80F008635CE /* identifier.cpp */; };
                A85D825E087B2822006A9172 /* scope_chain.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 9374D3A8038D9D74008635CE /* scope_chain.cpp */; };
                A85D825F087B2822006A9172 /* list.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 931C6CF0038EE8DE008635CE /* list.cpp */; };
                A883C7F408EA12860051473E /* TCSpinLock.h in Headers */ = {isa = PBXBuildFile; fileRef = 6541BD6F08E80A17002CBEE7 /* TCSpinLock.h */; };
                A883C7F508EA12860051473E /* TCSystemAlloc.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 6541BD7008E80A17002CBEE7 /* TCSystemAlloc.cpp */; };
                A883C7F608EA12860051473E /* TCSystemAlloc.h in Headers */ = {isa = PBXBuildFile; fileRef = 6541BD7108E80A17002CBEE7 /* TCSystemAlloc.h */; };
-               A883C7F708EA12A20051473E /* protected_reference.h in Headers */ = {isa = PBXBuildFile; fileRef = 652C107E08DA7B1E0020887D /* protected_reference.h */; };
                A8BC0DFC08D43D6D00379918 /* ucptable.c in Headers */ = {isa = PBXBuildFile; fileRef = 93E26C0D08B1520900F85226 /* ucptable.c */; };
 /* End PBXBuildFile section */
 
                65162EEA08E6A1FE007556CD /* SharedPtr.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = SharedPtr.h; sourceTree = "<group>"; };
                651F6412039D5B5F0078395C /* dtoa.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = dtoa.cpp; sourceTree = "<group>"; };
                651F6413039D5B5F0078395C /* dtoa.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = dtoa.h; sourceTree = "<group>"; };
-               652C107E08DA7B1E0020887D /* protected_reference.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = protected_reference.h; sourceTree = "<group>"; };
                6541720E039E08B90058BFEB /* dftables.c */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.c; name = dftables.c; path = pcre/dftables.c; sourceTree = "<group>"; };
                6541720F039E08B90058BFEB /* pcre.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = pcre.h; path = pcre/pcre.h; sourceTree = "<group>"; };
                65417217039E0B280058BFEB /* pcre-config.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = "pcre-config.h"; path = "pcre/pcre-config.h"; sourceTree = "<group>"; };
                65621E6B089E859700760F35 /* property_slot.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = property_slot.cpp; sourceTree = "<group>"; };
                65621E6C089E859700760F35 /* property_slot.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = property_slot.h; sourceTree = "<group>"; };
                65C02FBB0637462A003E7EE6 /* protect.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = protect.h; sourceTree = "<group>"; };
+               65D6D61B08F2676800958B28 /* IdentifierSequencedSet.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = IdentifierSequencedSet.cpp; sourceTree = "<group>"; };
+               65D6D61C08F2676800958B28 /* IdentifierSequencedSet.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = IdentifierSequencedSet.h; sourceTree = "<group>"; };
                65D7D19B08F10B5B0015ABD8 /* FastMallocInternal.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FastMallocInternal.h; sourceTree = "<group>"; };
                65DFC92A08EA173A00F7300B /* HashFunctions.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HashFunctions.h; sourceTree = "<group>"; };
                65DFC92B08EA173A00F7300B /* HashMap.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HashMap.h; sourceTree = "<group>"; };
                93F1981A08245AAE001E9ABC /* keywords.table */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = keywords.table; sourceTree = "<group>"; };
                A85D8288087B2822006A9172 /* JavaScriptCore.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = JavaScriptCore.framework; sourceTree = BUILT_PRODUCTS_DIR; };
                F50888B6030BB74C012A967E /* simple_number.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = simple_number.h; sourceTree = "<group>"; };
-               F5341390030CEEB1018BE7F3 /* reference.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = reference.cpp; sourceTree = "<group>"; };
-               F5341391030CEEB1018BE7F3 /* reference.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = reference.h; sourceTree = "<group>"; };
-               F5341394030CF5F8018BE7F3 /* reference_list.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = reference_list.cpp; sourceTree = "<group>"; };
-               F54F0800030CD22001B5C2EB /* reference_list.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = reference_list.h; sourceTree = "<group>"; };
                F5BB2BC5030F772101FCFE1D /* completion.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = completion.h; sourceTree = "<group>"; };
                F5C290E60284F98E018635CA /* JavaScriptCorePrefix.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; name = JavaScriptCorePrefix.h; path = ../JavaScriptCorePrefix.h; sourceTree = "<group>"; };
                F5FFE656026B47A6018635CA /* nodes2string.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = nodes2string.cpp; sourceTree = "<group>"; };
                08FB77AEFE84172EC02AAC07 /* Classes */ = {
                        isa = PBXGroup;
                        children = (
+                               65D6D61B08F2676800958B28 /* IdentifierSequencedSet.cpp */,
+                               65D6D61C08F2676800958B28 /* IdentifierSequencedSet.h */,
                                65621E6B089E859700760F35 /* property_slot.cpp */,
                                65621E6C089E859700760F35 /* property_slot.h */,
                                938772E5038BFE19008635CE /* array_instance.h */,
                                650B68D80639033F009D42DE /* protected_values.cpp */,
-                               652C107E08DA7B1E0020887D /* protected_reference.h */,
                                650B68D90639033F009D42DE /* protected_values.h */,
                                F692A84E0255597D01FF60F7 /* array_object.h */,
                                F692A84D0255597D01FF60F7 /* array_object.cpp */,
                                F692A87A0255597D01FF60F7 /* property_map.h */,
                                F692A8790255597D01FF60F7 /* property_map.cpp */,
                                65C02FBB0637462A003E7EE6 /* protect.h */,
-                               F5341390030CEEB1018BE7F3 /* reference.cpp */,
-                               F5341391030CEEB1018BE7F3 /* reference.h */,
-                               F54F0800030CD22001B5C2EB /* reference_list.h */,
-                               F5341394030CF5F8018BE7F3 /* reference_list.cpp */,
                                F692A87B0255597D01FF60F7 /* regexp_object.cpp */,
                                F692A87C0255597D01FF60F7 /* regexp_object.h */,
                                F692A87D0255597D01FF60F7 /* regexp.cpp */,
                                932F5B600822A1C700736975 /* config.h in Headers */,
                                932F5B610822A1C700736975 /* JavaScriptCorePrefix.h in Headers */,
                                932F5B620822A1C700736975 /* simple_number.h in Headers */,
-                               932F5B630822A1C700736975 /* reference_list.h in Headers */,
-                               932F5B640822A1C700736975 /* reference.h in Headers */,
                                932F5B650822A1C700736975 /* completion.h in Headers */,
                                932F5B660822A1C700736975 /* identifier.h in Headers */,
                                932F5B670822A1C700736975 /* array_instance.h in Headers */,
                                93E26BFE08B151D400F85226 /* ucpinternal.h in Headers */,
                                93E26C1308B1523D00F85226 /* ucptable.c in Headers */,
                                93E26CCF08B2921900F85226 /* softlinking.h in Headers */,
-                               652C107F08DA7B1E0020887D /* protected_reference.h in Headers */,
                                65162EEB08E6A1FE007556CD /* SharedPtr.h in Headers */,
                                65E217BD08E7EECC0023E5F6 /* Assertions.h in Headers */,
                                65E217C008E7EECC0023E5F6 /* FastMalloc.h in Headers */,
                                65DFC93508EA173A00F7300B /* HashTraits.h in Headers */,
                                6557E8F808EA5D4D0049CDFC /* HashMapPtrSpec.h in Headers */,
                                65D7D19C08F10B5B0015ABD8 /* FastMallocInternal.h in Headers */,
+                               65D6D61E08F2676800958B28 /* IdentifierSequencedSet.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                A85D8210087B2822006A9172 /* config.h in Headers */,
                                A85D8211087B2822006A9172 /* JavaScriptCorePrefix.h in Headers */,
                                A85D8212087B2822006A9172 /* simple_number.h in Headers */,
-                               A85D8213087B2822006A9172 /* reference_list.h in Headers */,
-                               A85D8214087B2822006A9172 /* reference.h in Headers */,
                                A85D8215087B2822006A9172 /* completion.h in Headers */,
                                A85D8216087B2822006A9172 /* identifier.h in Headers */,
                                A85D8217087B2822006A9172 /* array_instance.h in Headers */,
                                A883C7F308EA12860051473E /* TCPageMap.h in Headers */,
                                A883C7F408EA12860051473E /* TCSpinLock.h in Headers */,
                                A883C7F608EA12860051473E /* TCSystemAlloc.h in Headers */,
-                               A883C7F708EA12A20051473E /* protected_reference.h in Headers */,
                                37B800EB08EBB6520035B474 /* HashFunctions.h in Headers */,
                                37B800EC08EBB6540035B474 /* HashMap.h in Headers */,
                                37B800ED08EBB6540035B474 /* HashMapPtrSpec.h in Headers */,
                                37B800EE08EBB65A0035B474 /* HashSet.h in Headers */,
                                37B800F008EBB65B0035B474 /* HashTable.h in Headers */,
                                37B800F108EBB65C0035B474 /* HashTraits.h in Headers */,
+                               6512E62B08F3BA8B004A15B6 /* IdentifierSequencedSet.h in Headers */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                932F5BA80822A1C700736975 /* ustring.cpp in Sources */,
                                932F5BA90822A1C700736975 /* value.cpp in Sources */,
                                932F5BAB0822A1C700736975 /* nodes2string.cpp in Sources */,
-                               932F5BAC0822A1C700736975 /* reference.cpp in Sources */,
-                               932F5BAD0822A1C700736975 /* reference_list.cpp in Sources */,
                                932F5BAE0822A1C700736975 /* identifier.cpp in Sources */,
                                932F5BAF0822A1C700736975 /* scope_chain.cpp in Sources */,
                                932F5BB00822A1C700736975 /* list.cpp in Sources */,
                                65E217BF08E7EECC0023E5F6 /* FastMalloc.cpp in Sources */,
                                6541BD7408E80A17002CBEE7 /* TCSystemAlloc.cpp in Sources */,
                                65DFC93308EA173A00F7300B /* HashTable.cpp in Sources */,
+                               65D6D61D08F2676800958B28 /* IdentifierSequencedSet.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
                                A85D8258087B2822006A9172 /* ustring.cpp in Sources */,
                                A85D8259087B2822006A9172 /* value.cpp in Sources */,
                                A85D825A087B2822006A9172 /* nodes2string.cpp in Sources */,
-                               A85D825B087B2822006A9172 /* reference.cpp in Sources */,
-                               A85D825C087B2822006A9172 /* reference_list.cpp in Sources */,
                                A85D825D087B2822006A9172 /* identifier.cpp in Sources */,
                                A85D825E087B2822006A9172 /* scope_chain.cpp in Sources */,
                                A85D825F087B2822006A9172 /* list.cpp in Sources */,
                                A883C7F008EA12860051473E /* FastMalloc.cpp in Sources */,
                                A883C7F508EA12860051473E /* TCSystemAlloc.cpp in Sources */,
                                37B800EF08EBB65B0035B474 /* HashTable.cpp in Sources */,
+                               6512E63608F3BADE004A15B6 /* IdentifierSequencedSet.cpp in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/JavaScriptCore/kjs/IdentifierSequencedSet.cpp b/JavaScriptCore/kjs/IdentifierSequencedSet.cpp
new file mode 100644 (file)
index 0000000..203b4d5
--- /dev/null
@@ -0,0 +1,67 @@
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ *  This file is part of the KDE libraries
+ *  Copyright (C) 2005 Apple Computer, Inc
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "IdentifierSequencedSet.h"
+
+namespace KJS {
+
+IdentifierSequencedSet::IdentifierSequencedSet()
+    : m_vector(0),
+      m_vectorLength(0),
+      m_vectorCapacity(0)
+{
+}
+
+void IdentifierSequencedSet::deallocateVector()
+{
+    for (int i = 0; i < m_vectorLength; ++i) {
+        (m_vector + i)->~Identifier();
+    }
+    fastFree(m_vector);
+}
+
+IdentifierSequencedSet::~IdentifierSequencedSet()
+{
+    deallocateVector();
+}
+
+void IdentifierSequencedSet::insert(const Identifier& ident)
+{
+    if (!m_set.insert(ident.ustring().impl()).second)
+        return;
+    
+    if (m_vectorLength == m_vectorCapacity) {
+        m_vectorCapacity = m_vectorCapacity == 0 ? 16 : m_vectorCapacity * 11 / 10;
+        Identifier *newVector = reinterpret_cast<Identifier *>(fastMalloc(m_vectorCapacity * sizeof(Identifier)));
+        for (int i = 0; i < m_vectorLength; ++i) {
+            new (newVector + i) Identifier(m_vector[i]);
+        }
+        deallocateVector();
+        m_vector = newVector;
+    }
+    new (m_vector + m_vectorLength) Identifier(ident);
+    ++m_vectorLength;
+}
+
+} // namespace KJS
+
diff --git a/JavaScriptCore/kjs/IdentifierSequencedSet.h b/JavaScriptCore/kjs/IdentifierSequencedSet.h
new file mode 100644 (file)
index 0000000..3788d55
--- /dev/null
@@ -0,0 +1,106 @@
+// -*- mode: c++; c-basic-offset: 4 -*-
+/*
+ *  This file is part of the KDE libraries
+ *  Copyright (C) 2005 Apple Computer, Inc
+ *
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Library General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Library General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Library General Public License
+ *  along with this library; see the file COPYING.LIB.  If not, write to
+ *  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
+ *  Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef KJS_IDENTIFIER_SEQUENCED_SET_H
+#define KJS_IDENTIFIER_SEQUENCED_SET_H
+
+#include "identifier.h"
+
+#include <kxmlcore/HashSet.h>
+
+namespace KJS {
+
+    class IdentifierSequencedSet;
+
+    class IdentifierSequencedSetIterator {
+    private:
+        friend class IdentifierSequencedSet;
+        IdentifierSequencedSetIterator(const Identifier *position) : m_position(position) {}
+
+    public:
+        typedef IdentifierSequencedSetIterator iterator;
+
+        IdentifierSequencedSetIterator() {}
+        
+        // default copy, assignment and destructor are ok
+        
+        const Identifier& operator*() const 
+        { 
+            return *m_position; 
+        }
+
+        const Identifier *operator->() const 
+        { 
+            return &(operator*()); 
+        }
+        
+        iterator& operator++() 
+        { 
+            ++m_position; 
+            return *this;
+        }
+        
+        // postfix ++ intentionally omitted
+        
+        // Comparison.
+        bool operator==(const iterator& other) const
+        { 
+            return m_position == other.m_position; 
+        }
+        
+        bool operator!=(const iterator& other) const 
+        { 
+            return m_position != other.m_position; 
+        }
+        
+    private:
+        const Identifier *m_position;
+    };
+
+    class IdentifierSequencedSet {
+    public:
+        typedef IdentifierSequencedSetIterator iterator;
+
+        IdentifierSequencedSet();
+        ~IdentifierSequencedSet();
+
+        void insert(const Identifier&);
+        iterator begin() const { return iterator(m_vector); }
+        iterator end() const { return iterator(m_vector + m_vectorLength); }
+        int size() const { return m_vectorLength; }
+
+    private:
+        void deallocateVector();
+
+        typedef HashSet<UString::Impl *, PointerHash<UString::Impl *> > IdentifierSet;
+        IdentifierSet m_set;
+
+        Identifier *m_vector;
+        int m_vectorLength;
+        int m_vectorCapacity;
+    };
+
+
+} // namespace KJS
+
+
+#endif // KJS_IDENTIFIER_SEQUENCED_SET_H
index afdeb5666d9ae96c554c3f2a315f81297fd53f05..3338629293733fefa653e5f6ef3be849bbbd7168 100644 (file)
@@ -39,7 +39,7 @@ namespace KJS {
     virtual void put(ExecState *exec, unsigned propertyName, ValueImp *value, int attr = None);
     virtual bool deleteProperty(ExecState *exec, const Identifier &propertyName);
     virtual bool deleteProperty(ExecState *exec, unsigned propertyName);
-    virtual ReferenceList propList(ExecState *exec, bool recursive);
+    virtual void getPropertyNames(ExecState *exec, IdentifierSequencedSet& propertyNames);
 
     virtual void mark();
 
index 63717828f2fbf36fb255f0eec9e041c46c4c29d2..957a94a32d2f1683f2d080914babb995aafae9cd 100644 (file)
@@ -28,9 +28,9 @@
 #include "interpreter.h"
 #include "object.h"
 #include "operations.h"
-#include "reference_list.h"
 #include "types.h"
 #include "value.h"
+#include "IdentifierSequencedSet.h"
 
 #include "array_object.lut.h"
 
@@ -185,20 +185,18 @@ bool ArrayInstanceImp::deleteProperty(ExecState *exec, unsigned index)
   return ObjectImp::deleteProperty(exec, Identifier::from(index));
 }
 
-ReferenceList ArrayInstanceImp::propList(ExecState *exec, bool recursive)
+void ArrayInstanceImp::getPropertyNames(ExecState *exec, IdentifierSequencedSet& propertyNames)
 {
-  ReferenceList properties = ObjectImp::propList(exec,recursive);
-
   // avoid fetching this every time through the loop
   ValueImp *undefined = jsUndefined();
 
   for (unsigned i = 0; i < storageLength; ++i) {
     ValueImp *imp = storage[i];
-    if (imp && imp != undefined) {
-      properties.append(Reference(this, i));
-    }
+    if (imp && imp != undefined)
+      propertyNames.insert(Identifier::from(i));
   }
-  return properties;
+
+  ObjectImp::getPropertyNames(exec, propertyNames);
 }
 
 void ArrayInstanceImp::resizeStorage(unsigned newLength)
@@ -230,18 +228,18 @@ void ArrayInstanceImp::setLength(unsigned newLength, ExecState *exec)
   }
 
   if (newLength < length) {
-    ReferenceList sparseProperties;
+    IdentifierSequencedSet sparseProperties;
     
-    _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, this);
+    _prop.getSparseArrayPropertyNames(sparseProperties);
+
+    IdentifierSequencedSetIterator end = sparseProperties.end();
     
-    ReferenceListIterator it = sparseProperties.begin();
-    while (it != sparseProperties.end()) {
-      Reference ref = it++;
+    for (IdentifierSequencedSetIterator it = sparseProperties.begin(); it != end; ++it) {
+      Identifier name = *it;
       bool ok;
-      unsigned index = ref.getPropertyName(exec).toArrayIndex(&ok);
-      if (ok && index > newLength) {
-       ref.deleteValue(exec);
-      }
+      unsigned index = name.toArrayIndex(&ok);
+      if (ok && index > newLength)
+        deleteProperty(exec, name);
     }
   }
   
@@ -348,19 +346,18 @@ unsigned ArrayInstanceImp::pushUndefinedObjectsToEnd(ExecState *exec)
         }
     }
     
-    ReferenceList sparseProperties;
-    _prop.addSparseArrayPropertiesToReferenceList(sparseProperties, this);
-    unsigned newLength = o + sparseProperties.length();
+    IdentifierSequencedSet sparseProperties;
+    _prop.getSparseArrayPropertyNames(sparseProperties);
+    unsigned newLength = o + sparseProperties.size();
 
-    if (newLength > storageLength) {
+    if (newLength > storageLength)
       resizeStorage(newLength);
-    } 
 
-    ReferenceListIterator it = sparseProperties.begin();
-    while (it != sparseProperties.end()) {
-      Reference ref = it++;
-      storage[o] = ref.getValue(exec);
-      ObjectImp::deleteProperty(exec, ref.getPropertyName(exec));
+    IdentifierSequencedSetIterator end = sparseProperties.end();
+    for (IdentifierSequencedSetIterator it = sparseProperties.begin(); it != end; ++it) {
+      Identifier name = *it;
+      storage[o] = get(exec, name);
+      ObjectImp::deleteProperty(exec, name);
       o++;
     }
     
index e8be53050facaeeac8c89f649cae6a8a0df84868..185e97548737b94211231cdc0e9f099058fb7ca1 100644 (file)
@@ -43,7 +43,7 @@
 #include "lexer.h"
 #include "operations.h"
 #include "ustring.h"
-#include "reference_list.h"
+#include "IdentifierSequencedSet.h"
 
 using namespace KJS;
 
@@ -1780,7 +1780,7 @@ Completion ForInNode::execute(ExecState *exec)
   ValueImp *retval = 0;
   ObjectImp *v;
   Completion c;
-  ReferenceList propList;
+  IdentifierSequencedSet propertyNames;
 
   if (varDecl) {
     varDecl->evaluate(exec);
@@ -1799,16 +1799,13 @@ Completion ForInNode::execute(ExecState *exec)
 
   KJS_CHECKEXCEPTION
   v = e->toObject(exec);
-  propList = v->propList(exec);
+  v->getPropertyNames(exec, propertyNames);
 
-  ReferenceListIterator propIt = propList.begin();
-
-  while (propIt != propList.end()) {
-    Identifier name = propIt->getPropertyName(exec);
-    if (!v->hasProperty(exec, name)) {
-      propIt++;
+  IdentifierSequencedSetIterator end = propertyNames.end();
+  for (IdentifierSequencedSetIterator it = propertyNames.begin(); it != end; ++it) {
+    const Identifier &name = *it;
+    if (!v->hasProperty(exec, name))
       continue;
-    }
 
     ValueImp *str = jsString(name.ustring());
 
@@ -1870,8 +1867,6 @@ Completion ForInNode::execute(ExecState *exec)
         return c;
       }
     }
-
-    propIt++;
   }
 
   // bail out on error
index fd60f8e7a4b312bea78aaae82fb9f2cda39f3834..334160941093fccdeec3bc7c9f8d2ef26cd3a130 100644 (file)
@@ -34,7 +34,6 @@ namespace KJS {
   class ProgramNode;
   class PropertyNode;
   class PropertyValueNode;
-  class Reference;
   class RegExp;
   class SourceElementsNode;
   class SourceStream;
index 4b23d49798d377c48ccd037c5d7341412ecf8a71..1b8c52087552bc18122741dc7fa302dc8aa3f1ff 100644 (file)
@@ -28,7 +28,7 @@
 #include "types.h"
 #include "interpreter.h"
 #include "lookup.h"
-#include "reference_list.h"
+#include "IdentifierSequencedSet.h"
 
 #include <assert.h>
 #include <math.h>
@@ -374,13 +374,9 @@ bool ObjectImp::hasInstance(ExecState */*exec*/, ValueImp */*value*/)
   return false;
 }
 
-ReferenceList ObjectImp::propList(ExecState *exec, bool recursive)
+void ObjectImp::getPropertyNames(ExecState *exec, IdentifierSequencedSet &propertyNames)
 {
-  ReferenceList list;
-  if (_proto->isObject() && recursive)
-    list = static_cast<ObjectImp*>(_proto)->propList(exec,recursive);
-
-  _prop.addEnumerablesToReferenceList(list, this);
+  _prop.getEnumerablePropertyNames(propertyNames);
 
   // Add properties from the static hashtable of properties
   const ClassInfo *info = classInfo();
@@ -389,14 +385,15 @@ ReferenceList ObjectImp::propList(ExecState *exec, bool recursive)
       int size = info->propHashTable->size;
       const HashEntry *e = info->propHashTable->entries;
       for (int i = 0; i < size; ++i, ++e) {
-        if ( e->s && !(e->attr & DontEnum) )
-          list.append(Reference(this, e->s)); /// ######### check for duplicates with the propertymap
+        if (e->s && !(e->attr & DontEnum))
+          propertyNames.insert(e->s);
       }
     }
     info = info->parentClass;
   }
 
-  return list;
+  if (_proto->isObject())
+    static_cast<ObjectImp*>(_proto)->getPropertyNames(exec, propertyNames);
 }
 
 ValueImp *ObjectImp::toPrimitive(ExecState *exec, Type preferredType) const
index debfdb18e94cceb880621b13ffa8e3d58fcdf4a3..3028b70dd43ddbbfc78b0c14a8bbf55e5628c527 100644 (file)
@@ -47,6 +47,7 @@ namespace KJS {
   class HashTable;
   class HashEntry;
   class ListImp;
+  class IdentifierSequencedSet;
 
   // ECMA 262-3 8.6.1
   // Property attributes
@@ -422,12 +423,9 @@ namespace KJS {
      * having extra properties other than those set specifically with put().
      *
      * @param exec The current execution state
-     * @param recursive Whether or not properties in the object's prototype
-     * chain should be
-     * included in the list.
-     * @return A List of References to properties of the object.
+     * @param propertyNames A list of property names to be filled in by this call
      **/
-    virtual ReferenceList propList(ExecState *exec, bool recursive = true);
+    virtual void getPropertyNames(ExecState *exec, IdentifierSequencedSet& propertyNames);
 
     /**
      * Returns the internal value of the object. This is used for objects such
index bcba9675abbcc90b71f38d5c36c06f95d63da217..6634997b92bd2f9843b3103e43f3c9f2bca4c719 100644 (file)
@@ -25,7 +25,7 @@
 #include <kxmlcore/FastMalloc.h>
 #include "object.h"
 #include "protect.h"
-#include "reference_list.h"
+#include "IdentifierSequencedSet.h"
 
 #include <algorithm>
 
@@ -74,7 +74,7 @@ PropertyMapStatisticsExitLogger::~PropertyMapStatisticsExitLogger()
 #endif
 
 // lastIndexUsed is an ever-increasing index used to identify the order items
-// were inserted into the property map. It's vital that addEnumerablesToReferenceList
+// were inserted into the property map. It's vital that getEnumerablePropertyNames
 // return the properties in the order they were added for compatibility with other
 // browsers' JavaScript implementations.
 struct PropertyMapHashTable
@@ -566,13 +566,13 @@ static int comparePropertyMapEntryIndices(const void *a, const void *b)
     return 0;
 }
 
-void PropertyMap::addEnumerablesToReferenceList(ReferenceList &list, ObjectImp *base) const
+void PropertyMap::getEnumerablePropertyNames(IdentifierSequencedSet& propertyNames) const
 {
     if (!_table) {
 #if USE_SINGLE_ENTRY
         UString::Rep *key = _singleEntry.key;
         if (key && !(_singleEntry.attributes & DontEnum))
-            list.append(Reference(base, Identifier(key)));
+            propertyNames.insert(Identifier(key));
 #endif
         return;
     }
@@ -598,17 +598,19 @@ void PropertyMap::addEnumerablesToReferenceList(ReferenceList &list, ObjectImp *
     // Sort the entries by index.
     qsort(sortedEnumerables, p - sortedEnumerables, sizeof(sortedEnumerables[0]), comparePropertyMapEntryIndices);
 
-    // Put the keys of the sorted entries into the reference list.
+    // Put the keys of the sorted entries into the list.
     Entry **q = sortedEnumerables;
-    while (q != p)
-        list.append(Reference(base, Identifier((*q++)->key)));
+    while (q != p) {
+        propertyNames.insert(Identifier(q[0]->key));
+        ++q;
+    }
 
     // Deallocate the buffer.
     if (sortedEnumerables != fixedSizeBuffer)
         delete [] sortedEnumerables;
 }
 
-void PropertyMap::addSparseArrayPropertiesToReferenceList(ReferenceList &list, ObjectImp *base) const
+void PropertyMap::getSparseArrayPropertyNames(IdentifierSequencedSet& propertyNames) const
 {
     if (!_table) {
 #if USE_SINGLE_ENTRY
@@ -618,7 +620,7 @@ void PropertyMap::addSparseArrayPropertiesToReferenceList(ReferenceList &list, O
             bool fitsInUInt32;
             k.toUInt32(&fitsInUInt32);
             if (fitsInUInt32)
-                list.append(Reference(base, Identifier(key)));
+                propertyNames.insert(Identifier(key));
         }
 #endif
         return;
@@ -633,7 +635,7 @@ void PropertyMap::addSparseArrayPropertiesToReferenceList(ReferenceList &list, O
             bool fitsInUInt32;
             k.toUInt32(&fitsInUInt32);
             if (fitsInUInt32)
-                list.append(Reference(base, Identifier(key)));
+                propertyNames.insert(Identifier(key));
         }
     }
 }
index 66f435f66a34c48e5be760b60a2842c23a0761f8..9cbe1685bad32e58b6a9ad310893fb1d10166a12 100644 (file)
@@ -27,8 +27,8 @@
 
 namespace KJS {
 
+    class IdentifierSequencedSet;
     class ObjectImp;
-    class ReferenceList;
     class ValueImp;
     
     class SavedProperty;
@@ -81,8 +81,8 @@ namespace KJS {
         ValueImp **getLocation(const Identifier &name);
 
         void mark() const;
-        void addEnumerablesToReferenceList(ReferenceList &, ObjectImp *) const;
-       void addSparseArrayPropertiesToReferenceList(ReferenceList &, ObjectImp *) const;
+        void getEnumerablePropertyNames(IdentifierSequencedSet&) const;
+        void getSparseArrayPropertyNames(IdentifierSequencedSet&) const;
 
         void save(SavedProperties &) const;
         void restore(const SavedProperties &p);
index 30897d6145763a0543f856b20c882f6fc562f6de..92da297d4e62b3b4274e2b4cc24462a985f9ff35 100644 (file)
@@ -24,7 +24,6 @@
 #ifndef _KJS_PROTECT_H_
 #define _KJS_PROTECT_H_
 
-#include "reference.h"
 #include "value.h"
 #include "protected_values.h"
 #include "interpreter.h"
diff --git a/JavaScriptCore/kjs/protected_reference.h b/JavaScriptCore/kjs/protected_reference.h
deleted file mode 100644 (file)
index 4e465ce..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-// -*- c-basic-offset: 4 -*-
-/*
- *  This file is part of the KDE libraries
- *  Copyright (C) 2005 Apple Computer, Inc.
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Library General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Library General Public License for more details.
- *
- *  You should have received a copy of the GNU Library General Public License
- *  along with this library; see the file COPYING.LIB.  If not, write to
- *  the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- *  Boston, MA 02111-1307, USA.
- *
- */
-
-#ifndef KJS_PROTECTED_REFERENCE_H
-#define KJS_PROTECTED_REFERENCE_H
-
-#include "protect.h"
-#include "reference.h"
-#include "interpreter.h" 
-
-namespace KJS {
-
-    class ProtectedReference : public Reference {
-    public:
-        ProtectedReference(const Reference& r) 
-            : Reference(r) 
-        {
-            InterpreterLock lock;
-            gcProtectNullTolerant(base); 
-        }
-
-        ~ProtectedReference()
-        { 
-            InterpreterLock lock;
-            gcUnprotectNullTolerant(base);
-        }
-
-        ProtectedReference& operator=(const Reference &r)
-       {
-            InterpreterLock lock;
-            ValueImp *old = base;
-            Reference::operator=(r); 
-            gcProtectNullTolerant(base);
-            gcUnprotectNullTolerant(old); 
-            return *this;
-       }
-
-    private:
-        ProtectedReference();
-        ProtectedReference(ObjectImp *b, const Identifier& p);
-        ProtectedReference(ObjectImp *b, unsigned p);
-        ProtectedReference(const Identifier& p);
-        ProtectedReference(unsigned p);
-    };
-
-} // namespace
-
-#endif
diff --git a/JavaScriptCore/kjs/reference.cpp b/JavaScriptCore/kjs/reference.cpp
deleted file mode 100644 (file)
index bc750ba..0000000
+++ /dev/null
@@ -1,83 +0,0 @@
-// -*- c-basic-offset: 2 -*-
-/*
- *  This file is part of the KDE libraries
- *  Copyright (C) 2004 Apple Computer, Inc
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Library General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Library General Public License for more details.
- *
- *  You should have received a copy of the GNU Library General Public License
- *  along with this library; see the file COPYING.LIB.  If not, write to
- *  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "reference.h"
-
-#include "internal.h"
-
-namespace KJS {
-
-// ------------------------------ Reference ------------------------------------
-
-Reference::Reference(ObjectImp *b, const Identifier& p)
-  : base(b),
-    propertyNameIsNumber(false),
-    prop(p)
-{
-}
-
-Reference::Reference(ObjectImp *b, unsigned p)
-  : base(b),
-    propertyNameAsNumber(p),
-    propertyNameIsNumber(true)
-{
-}
-
-Identifier Reference::getPropertyName(ExecState *exec) const
-{
-  if (propertyNameIsNumber && prop.isNull())
-    prop = Identifier::from(propertyNameAsNumber);
-  return prop;
-}
-
-ValueImp *Reference::getValue(ExecState *exec) const 
-{
-  ValueImp *o = base;
-  if (!o || !o->isObject()) {
-    if (!o || o->isNull())
-      return throwError(exec, ReferenceError, "Can't find variable: " + getPropertyName(exec).ustring());
-    return throwError(exec, ReferenceError, "Base is not an object");
-  }
-
-  if (propertyNameIsNumber)
-    return static_cast<ObjectImp*>(o)->get(exec, propertyNameAsNumber);
-  return static_cast<ObjectImp*>(o)->get(exec, prop);
-}
-
-bool Reference::deleteValue(ExecState *exec)
-{
-  ValueImp *o = base;
-  Type t = o ? o->type() : NullType;
-
-  // The spec doesn't mention what to do if the base is null... just return true
-  if (t != ObjectType) {
-    assert(t == NullType);
-    return true;
-  }
-
-  if (propertyNameIsNumber)
-    return static_cast<ObjectImp*>(o)->deleteProperty(exec,propertyNameAsNumber);
-  return static_cast<ObjectImp*>(o)->deleteProperty(exec,prop);
-}
-
-}
diff --git a/JavaScriptCore/kjs/reference.h b/JavaScriptCore/kjs/reference.h
deleted file mode 100644 (file)
index 73143c6..0000000
+++ /dev/null
@@ -1,71 +0,0 @@
-// -*- c-basic-offset: 2 -*-
-/*
- *  This file is part of the KDE libraries
- *  Copyright (C) 2003 Apple Computer, Inc
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Library General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Library General Public License for more details.
- *
- *  You should have received a copy of the GNU Library General Public License
- *  along with this library; see the file COPYING.LIB.  If not, write to
- *  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _KJS_REFERENCE_H_
-#define _KJS_REFERENCE_H_
-
-#include "identifier.h"
-#include "object.h"
-
-namespace KJS {
-
-  class ObjectImp;
-
-  class Reference {
-    friend class ReferenceList;
-    friend class ReferenceListIterator;
-  public:
-    Reference(ObjectImp *b, const Identifier& p);
-    Reference(ObjectImp *b, unsigned p);
-    
-    /**
-     * Performs the GetPropertyName type conversion operation on this value
-     * (ECMA 8.7)
-     */
-    Identifier getPropertyName(ExecState *exec) const;
-
-    /**
-     * Performs the GetValue type conversion operation on this value
-     * (ECMA 8.7.1)
-     */
-    ValueImp *getValue(ExecState *exec) const;
-
-    /**
-     * Performs the PutValue type conversion operation on this value
-     * (ECMA 8.7.1)
-     */
-    bool deleteValue(ExecState *exec);
-
-  protected:
-    ValueImp *base;
-
-  private:
-    Reference() { }
-
-    unsigned propertyNameAsNumber;
-    bool propertyNameIsNumber;
-    mutable Identifier prop;
-  };
-
-}
-
-#endif
diff --git a/JavaScriptCore/kjs/reference_list.cpp b/JavaScriptCore/kjs/reference_list.cpp
deleted file mode 100644 (file)
index 5627c40..0000000
+++ /dev/null
@@ -1,157 +0,0 @@
-// -*- c-basic-offset: 2 -*-
-/*
- *  This file is part of the KDE libraries
- *  Copyright (C) 2003 Apple Computer, Inc
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Library General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Library General Public License for more details.
- *
- *  You should have received a copy of the GNU Library General Public License
- *  along with this library; see the file COPYING.LIB.  If not, write to
- *  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#include "config.h"
-#include "reference_list.h"
-
-#include "protected_reference.h"
-
-namespace KJS {
-  class ReferenceListNode {
-    friend class ReferenceList;
-    friend class ReferenceListIterator;
-
-  protected:
-    ReferenceListNode(const Reference &ref) : reference(ref), next(NULL) {}
-
-  private:
-    ProtectedReference reference;
-    ReferenceListNode *next;
-  };
-
-  class ReferenceListHeadNode : ReferenceListNode {
-    friend class ReferenceList;
-    friend class ReferenceListIterator;
-    
-    ReferenceListHeadNode(const Reference &ref) : ReferenceListNode(ref), refcount(1) {}
-    int refcount;
-    int length;
-  };
-
-}
-
-using namespace KJS;
-
-// ReferenceList
-
-ReferenceList::ReferenceList() : 
-  head(NULL),
-  tail(NULL)
-{
-}
-
-ReferenceList::ReferenceList(const ReferenceList &list)
-{
-  head = list.head;
-  tail = list.tail;
-  if (head != NULL) {
-    head->refcount++;
-  }
-}
-
-ReferenceList &ReferenceList::operator=(const ReferenceList &list)
-{
-  ReferenceList tmp(list);
-  tmp.swap(*this);
-
-  return *this;
-}
-
-void ReferenceList::swap(ReferenceList &list)
-{
-  ReferenceListHeadNode *tmpHead = list.head;
-  list.head = head;
-  head = tmpHead;
-
-  ReferenceListNode *tmpTail = list.tail;
-  list.tail = tail;
-  tail = tmpTail;
-}
-
-
-void ReferenceList::append(const Reference& ref)
-{
-  if (tail == NULL) {
-    tail = head = new ReferenceListHeadNode(ref);
-  } else {
-    tail->next = new ReferenceListNode(ref);
-    tail = tail->next;
-  }
-  head->length++;
-}
-
-int ReferenceList::length()
-{
-  return head ? head->length : 0;
-}
-
-ReferenceList::~ReferenceList()
-{
-  if (head != NULL && --(head->refcount) == 0) {
-    ReferenceListNode *next;
-    
-    for (ReferenceListNode *p = head; p != NULL; p = next) {
-      next = p->next;
-      if (p == head) {
-       delete (ReferenceListHeadNode *)p;
-      } else {
-       delete p;
-      }
-    }
-  }
-}
-    
-ReferenceListIterator ReferenceList::begin() const
-{
-  return ReferenceListIterator(head);
-}
-
-ReferenceListIterator ReferenceList::end() const
-{
-  return ReferenceListIterator(NULL);
-}
-
-
-// ReferenceListIterator
-
-
-ReferenceListIterator::ReferenceListIterator(ReferenceListNode *n) :
-  node(n)
-{
-}
-
-bool ReferenceListIterator::operator!=(const ReferenceListIterator &it) const 
-{ 
-  return node != it.node;
-}
-
-const Reference *ReferenceListIterator::operator->() const 
-{ 
-  return &node->reference;
-}
-
-const Reference &ReferenceListIterator::operator++(int i) 
-{
-  const Reference &ref = node->reference;
-  node = node->next;
-  return ref;
-}
diff --git a/JavaScriptCore/kjs/reference_list.h b/JavaScriptCore/kjs/reference_list.h
deleted file mode 100644 (file)
index fcb62ac..0000000
+++ /dev/null
@@ -1,69 +0,0 @@
-// -*- c-basic-offset: 2 -*-
-/*
- *  This file is part of the KDE libraries
- *  Copyright (C) 2003 Apple Computer, Inc
- *
- *  This library is free software; you can redistribute it and/or
- *  modify it under the terms of the GNU Library General Public
- *  License as published by the Free Software Foundation; either
- *  version 2 of the License, or (at your option) any later version.
- *
- *  This library is distributed in the hope that it will be useful,
- *  but WITHOUT ANY WARRANTY; without even the implied warranty of
- *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
- *  Library General Public License for more details.
- *
- *  You should have received a copy of the GNU Library General Public License
- *  along with this library; see the file COPYING.LIB.  If not, write to
- *  the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
- *  Boston, MA 02110-1301, USA.
- *
- */
-
-#ifndef _KJS_REFERENCE_LIST_H_
-#define _KJS_REFERENCE_LIST_H_
-
-#include "types.h"
-#include "reference.h"
-
-namespace KJS {
-
-  class ReferenceListNode;
-  class ReferenceListHeadNode;
-
-  class ReferenceListIterator {
-    friend class ReferenceList;
-  
-  public:
-    bool operator!=(const ReferenceListIterator &it) const;
-    const Reference *operator->() const;
-    const Reference &operator++(int i);
-    
-  private:
-    ReferenceListIterator(ReferenceListNode *n);
-    ReferenceListIterator();
-    ReferenceListNode *node;
-  };
-  
-  class ReferenceList {
-  public:
-    ReferenceList();
-    ReferenceList(const ReferenceList &list);
-    ReferenceList &operator=(const ReferenceList &list);
-    ~ReferenceList();
-
-    void append(const Reference& val);
-    int length();
-
-    ReferenceListIterator begin() const;
-    ReferenceListIterator end() const;
-    
-  private:
-    void swap(ReferenceList &list);
-    ReferenceListHeadNode *head;
-    ReferenceListNode *tail;
-  }; 
-  
-}
-
-#endif
index 0ebd1893a14a3b784dd0d2bef7f678ab1fa9e98d..de38dc019a244999f986adddd1787673e91b04e6 100644 (file)
@@ -240,6 +240,8 @@ namespace KJS {
     };
 
   public:
+    typedef Rep Impl;
+
     /**
      * Constructs a null string.
      */
@@ -461,6 +463,8 @@ namespace KJS {
      */
     static void globalClear();
 #endif
+
+    Impl *impl() const { return rep; }
   private:
     UString(Rep *r) { attach(r); }
     void attach(Rep *r) { rep = r; r->ref(); }
index b6d32ad4e588bd01e333603a099f321861c4a026..ec94009c6ebbba920c9e65b0a870a1f17704ff75 100644 (file)
@@ -25,7 +25,7 @@
 
 #include "HashTable.h"
 #include "HashTraits.h"
-#include "hashfunctions.h"
+#include "HashFunctions.h"
 
 namespace KXMLCore {
 
index d4b0016779f7efde76c30e2f97199734e76417e6..9c99e528f4e6577b9533469ee13f8f2d2d0b5341 100644 (file)
@@ -1,3 +1,14 @@
+2005-10-05  Maciej Stachowiak  <mjs@apple.com>
+
+        Reviewed by Eric.
+
+        - test case for some fixes I made to for..in enumeration. object
+       properties now come before prototype properties and duplicates
+       between object and prototype are listed only once.
+
+        * fast/js/for-in-expected.txt: Added.
+        * fast/js/for-in.html: Added.
+
 2005-10-05  Anders Carlsson  <andersca@mac.com>
 
         Reviewed by Maciej.
diff --git a/LayoutTests/fast/js/for-in-expected.txt b/LayoutTests/fast/js/for-in-expected.txt
new file mode 100644 (file)
index 0000000..08c4156
--- /dev/null
@@ -0,0 +1,8 @@
+This test checks whether for..in iteration properly skips duplicate entries, and whether it lists the properties of objects before those of their prototypes. It should print the following one per line in this order: "obj", "overloaded", "proto", "protoProto".
+
+
+obj
+overloaded
+proto
+protoProto
+
diff --git a/LayoutTests/fast/js/for-in.html b/LayoutTests/fast/js/for-in.html
new file mode 100644 (file)
index 0000000..c3999bf
--- /dev/null
@@ -0,0 +1,34 @@
+<body>
+<p>
+This test checks whether for..in iteration properly skips duplicate
+entries, and whether it lists the properties of objects before those
+of their prototypes. It should print the following one per line in
+this order: "obj", "overloaded", "proto", "protoProto".
+<p>
+<hr>
+<pre id="console">
+</pre>
+<script>
+if (window.layoutTestController)
+    layoutTestController.dumpAsText();
+
+function log(s)
+{
+    document.getElementById('console').innerHTML += s + '<br>';
+}
+
+var protoProto = {protoProto: "protoProto", overloaded: "overloaded"};
+
+var proto = {proto: "proto", overloaded: "overloaded"};
+proto.__proto__ = protoProto;
+
+var obj = {obj: "obj", overloaded: "overloaded"};
+obj.__proto__ = proto;
+
+for (var prop in obj) {
+ log(prop);
+}
+
+
+</script>
+</body>