]>
git.saurik.com Git - apple/javascriptcore.git/blob - runtime/Lookup.cpp
2 * Copyright (C) 2008 Apple Inc. All rights reserved.
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 #include "PrototypeFunction.h"
27 void HashTable::createTable(JSGlobalData
* globalData
) const
29 #if ENABLE(PERFECT_HASH_SIZE)
31 HashEntry
* entries
= new HashEntry
[hashSizeMask
+ 1];
32 for (int i
= 0; i
<= hashSizeMask
; ++i
)
34 for (int i
= 0; values
[i
].key
; ++i
) {
35 UString::Rep
* identifier
= Identifier::add(globalData
, values
[i
].key
).releaseRef();
36 int hashIndex
= identifier
->computedHash() & hashSizeMask
;
37 ASSERT(!entries
[hashIndex
].key());
38 entries
[hashIndex
].initialize(identifier
, values
[i
].attributes
, values
[i
].value1
, values
[i
].value2
);
43 int linkIndex
= compactHashSizeMask
+ 1;
44 HashEntry
* entries
= new HashEntry
[compactSize
];
45 for (int i
= 0; i
< compactSize
; ++i
)
47 for (int i
= 0; values
[i
].key
; ++i
) {
48 UString::Rep
* identifier
= Identifier::add(globalData
, values
[i
].key
).releaseRef();
49 int hashIndex
= identifier
->computedHash() & compactHashSizeMask
;
50 HashEntry
* entry
= &entries
[hashIndex
];
53 while (entry
->next()) {
54 entry
= entry
->next();
56 ASSERT(linkIndex
< compactSize
);
57 entry
->setNext(&entries
[linkIndex
++]);
58 entry
= entry
->next();
61 entry
->initialize(identifier
, values
[i
].attributes
, values
[i
].value1
, values
[i
].value2
);
67 void HashTable::deleteTable() const
70 #if ENABLE(PERFECT_HASH_SIZE)
71 int max
= hashSizeMask
+ 1;
73 int max
= compactSize
;
75 for (int i
= 0; i
!= max
; ++i
) {
76 if (UString::Rep
* key
= table
[i
].key())
84 void setUpStaticFunctionSlot(ExecState
* exec
, const HashEntry
* entry
, JSObject
* thisObj
, const Identifier
& propertyName
, PropertySlot
& slot
)
86 ASSERT(entry
->attributes() & Function
);
87 JSValuePtr
* location
= thisObj
->getDirectLocation(propertyName
);
90 PrototypeFunction
* function
= new (exec
) PrototypeFunction(exec
, entry
->functionLength(), propertyName
, entry
->function());
91 thisObj
->putDirect(propertyName
, function
, entry
->attributes());
92 location
= thisObj
->getDirectLocation(propertyName
);
95 slot
.setValueSlot(thisObj
, location
, thisObj
->offsetForLocation(location
));