source: webkit/trunk/JavaScriptCore/kjs/IdentifierSequencedSet.cpp@ 10744

Last change on this file since 10744 was 10744, checked in by mjs, 20 years ago

JavaScriptCore:

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.
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 2.0 KB
Line 
1// -*- mode: c++; c-basic-offset: 4 -*-
2/*
3 * This file is part of the KDE libraries
4 * Copyright (C) 2005 Apple Computer, Inc
5 *
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
10 *
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
15 *
16 * You should have received a copy of the GNU Library General Public License
17 * along with this library; see the file COPYING.LIB. If not, write to
18 * the Free Software Foundation, Inc., 51 Franklin Steet, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
20 *
21 */
22
23#include "config.h"
24#include "IdentifierSequencedSet.h"
25
26namespace KJS {
27
28IdentifierSequencedSet::IdentifierSequencedSet()
29 : m_vector(0),
30 m_vectorLength(0),
31 m_vectorCapacity(0)
32{
33}
34
35void IdentifierSequencedSet::deallocateVector()
36{
37 for (int i = 0; i < m_vectorLength; ++i) {
38 (m_vector + i)->~Identifier();
39 }
40 fastFree(m_vector);
41}
42
43IdentifierSequencedSet::~IdentifierSequencedSet()
44{
45 deallocateVector();
46}
47
48void IdentifierSequencedSet::insert(const Identifier& ident)
49{
50 if (!m_set.insert(ident.ustring().impl()).second)
51 return;
52
53 if (m_vectorLength == m_vectorCapacity) {
54 m_vectorCapacity = m_vectorCapacity == 0 ? 16 : m_vectorCapacity * 11 / 10;
55 Identifier *newVector = reinterpret_cast<Identifier *>(fastMalloc(m_vectorCapacity * sizeof(Identifier)));
56 for (int i = 0; i < m_vectorLength; ++i) {
57 new (newVector + i) Identifier(m_vector[i]);
58 }
59 deallocateVector();
60 m_vector = newVector;
61 }
62 new (m_vector + m_vectorLength) Identifier(ident);
63 ++m_vectorLength;
64}
65
66} // namespace KJS
67
Note: See TracBrowser for help on using the repository browser.