source: webkit/trunk/JavaScriptCore/kjs/PropertyNameArray.h@ 34607

Last change on this file since 34607 was 34607, checked in by [email protected], 17 years ago

Reviewed by Geoff Garen.

Make Identifier construction use an explicitly passed IdentifierTable.

No change on SunSpider total.

  • Property svn:eol-style set to native
File size: 2.2 KB
Line 
1// -*- mode: c++; c-basic-offset: 4 -*-
2/*
3 * Copyright (C) 2006, 2008 Apple Inc. All rights reserved.
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Library General Public License for more details.
14 *
15 * You should have received a copy of the GNU Library General Public License
16 * along with this library; see the file COPYING.LIB. If not, write to
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 * Boston, MA 02110-1301, USA.
19 *
20 */
21
22#ifndef PropertyNameArray_h
23#define PropertyNameArray_h
24
25#include "identifier.h"
26#include <wtf/HashSet.h>
27#include <wtf/Vector.h>
28
29namespace KJS {
30
31 class PropertyNameArray {
32 public:
33 typedef Identifier ValueType;
34 typedef Vector<Identifier>::const_iterator const_iterator;
35
36 PropertyNameArray(JSGlobalData* globalData) : m_globalData(globalData) {}
37 PropertyNameArray(ExecState* exec) : m_globalData(&exec->globalData()) {}
38
39 void add(const Identifier& identifier) { add(identifier.ustring().rep()); }
40 void add(UString::Rep*);
41 void addKnownUnique(UString::Rep* identifier) { m_vector.append(Identifier(m_globalData, identifier)); }
42
43 const_iterator begin() const { return m_vector.begin(); }
44 const_iterator end() const { return m_vector.end(); }
45
46 size_t size() const { return m_vector.size(); }
47
48 Identifier& operator[](unsigned i) { return m_vector[i]; }
49 const Identifier& operator[](unsigned i) const { return m_vector[i]; }
50
51 Identifier* releaseIdentifiers() { return size() ? m_vector.releaseBuffer() : 0; }
52
53 private:
54 typedef HashSet<UString::Rep*, PtrHash<UString::Rep*> > IdentifierSet;
55
56 Vector<Identifier, 20> m_vector;
57 IdentifierSet m_set;
58 JSGlobalData* m_globalData;
59 };
60
61} // namespace KJS
62
63#endif // PropertyNameArray_h
Note: See TracBrowser for help on using the repository browser.