#include "config.h"
#include "Lookup.h"
#include "Executable.h"
#include "JSFunction.h"
#include "JSCInlines.h"
namespace JSC {
void HashTable::createTable(VM&) const
{
ASSERT(!keys);
keys = static_cast<const char**>(fastMalloc(sizeof(char*) * numberOfValues));
for (int i = 0; i < numberOfValues; ++i) {
if (values[i].m_key)
keys[i] = values[i].m_key;
else
keys[i] = 0;
}
}
void HashTable::deleteTable() const
{
if (keys) {
fastFree(keys);
keys = nullptr;
}
}
bool setUpStaticFunctionSlot(ExecState* exec, const HashTableValue* entry, JSObject* thisObj, PropertyName propertyName, PropertySlot& slot)
{
ASSERT(thisObj->globalObject());
ASSERT(entry->attributes() & BuiltinOrFunction);
VM& vm = exec->vm();
unsigned attributes;
PropertyOffset offset = thisObj->getDirectOffset(vm, propertyName, attributes);
if (!isValidOffset(offset)) {
if (thisObj->staticFunctionsReified())
return false;
if (entry->attributes() & Builtin)
thisObj->putDirectBuiltinFunction(vm, thisObj->globalObject(), propertyName, entry->builtinGenerator()(vm), entry->attributes());
else {
thisObj->putDirectNativeFunction(
vm, thisObj->globalObject(), propertyName, entry->functionLength(),
entry->function(), entry->intrinsic(), entry->attributes());
}
offset = thisObj->getDirectOffset(vm, propertyName, attributes);
ASSERT(isValidOffset(offset));
}
slot.setValue(thisObj, attributes, thisObj->getDirect(offset), offset);
return true;
}
}