]>
Commit | Line | Data |
---|---|---|
9dae56ea | 1 | /* |
93a37866 | 2 | * Copyright (C) 2008, 2012 Apple Inc. All rights reserved. |
9dae56ea A |
3 | * |
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. | |
8 | * | |
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. | |
13 | * | |
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 | |
17 | * | |
18 | */ | |
19 | ||
20 | #include "config.h" | |
21 | #include "Lookup.h" | |
22 | ||
14957cd0 | 23 | #include "Executable.h" |
ba379fdc | 24 | #include "JSFunction.h" |
81345200 | 25 | #include "JSCInlines.h" |
9dae56ea A |
26 | |
27 | namespace JSC { | |
28 | ||
81345200 | 29 | void HashTable::createTable(VM&) const |
9dae56ea | 30 | { |
81345200 A |
31 | ASSERT(!keys); |
32 | keys = static_cast<const char**>(fastMalloc(sizeof(char*) * numberOfValues)); | |
9dae56ea | 33 | |
81345200 A |
34 | for (int i = 0; i < numberOfValues; ++i) { |
35 | if (values[i].m_key) | |
36 | keys[i] = values[i].m_key; | |
37 | else | |
38 | keys[i] = 0; | |
9dae56ea | 39 | } |
9dae56ea A |
40 | } |
41 | ||
42 | void HashTable::deleteTable() const | |
43 | { | |
81345200 A |
44 | if (keys) { |
45 | fastFree(keys); | |
46 | keys = nullptr; | |
9dae56ea A |
47 | } |
48 | } | |
49 | ||
81345200 | 50 | bool setUpStaticFunctionSlot(ExecState* exec, const HashTableValue* entry, JSObject* thisObj, PropertyName propertyName, PropertySlot& slot) |
9dae56ea | 51 | { |
6fe7ccc8 | 52 | ASSERT(thisObj->globalObject()); |
81345200 A |
53 | ASSERT(entry->attributes() & BuiltinOrFunction); |
54 | VM& vm = exec->vm(); | |
55 | unsigned attributes; | |
56 | PropertyOffset offset = thisObj->getDirectOffset(vm, propertyName, attributes); | |
9dae56ea | 57 | |
93a37866 | 58 | if (!isValidOffset(offset)) { |
6fe7ccc8 A |
59 | // If a property is ever deleted from an object with a static table, then we reify |
60 | // all static functions at that time - after this we shouldn't be re-adding anything. | |
61 | if (thisObj->staticFunctionsReified()) | |
62 | return false; | |
63 | ||
81345200 A |
64 | if (entry->attributes() & Builtin) |
65 | thisObj->putDirectBuiltinFunction(vm, thisObj->globalObject(), propertyName, entry->builtinGenerator()(vm), entry->attributes()); | |
66 | else { | |
67 | thisObj->putDirectNativeFunction( | |
68 | vm, thisObj->globalObject(), propertyName, entry->functionLength(), | |
69 | entry->function(), entry->intrinsic(), entry->attributes()); | |
70 | } | |
71 | offset = thisObj->getDirectOffset(vm, propertyName, attributes); | |
93a37866 | 72 | ASSERT(isValidOffset(offset)); |
9dae56ea A |
73 | } |
74 | ||
81345200 | 75 | slot.setValue(thisObj, attributes, thisObj->getDirect(offset), offset); |
6fe7ccc8 | 76 | return true; |
9dae56ea A |
77 | } |
78 | ||
79 | } // namespace JSC |