BooleanConstructor.cpp [plain text]
#include "config.h"
#include "BooleanConstructor.h"
#include "BooleanPrototype.h"
#include "JSGlobalObject.h"
#include "JSCInlines.h"
namespace JSC {
STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(BooleanConstructor);
const ClassInfo BooleanConstructor::s_info = { "Function", &Base::s_info, 0, CREATE_METHOD_TABLE(BooleanConstructor) };
BooleanConstructor::BooleanConstructor(VM& vm, Structure* structure)
: InternalFunction(vm, structure)
{
}
void BooleanConstructor::finishCreation(VM& vm, BooleanPrototype* booleanPrototype)
{
Base::finishCreation(vm, booleanPrototype->classInfo()->className);
putDirectWithoutTransition(vm, vm.propertyNames->prototype, booleanPrototype, DontEnum | DontDelete | ReadOnly);
putDirectWithoutTransition(vm, vm.propertyNames->length, jsNumber(1), ReadOnly | DontDelete | DontEnum);
}
static EncodedJSValue JSC_HOST_CALL constructWithBooleanConstructor(ExecState* exec)
{
JSValue boolean = jsBoolean(exec->argument(0).toBoolean(exec));
Structure* booleanStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), asInternalFunction(exec->callee())->globalObject()->booleanObjectStructure());
if (exec->hadException())
return JSValue::encode(JSValue());
BooleanObject* obj = BooleanObject::create(exec->vm(), booleanStructure);
obj->setInternalValue(exec->vm(), boolean);
return JSValue::encode(obj);
}
ConstructType BooleanConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
constructData.native.function = constructWithBooleanConstructor;
return ConstructType::Host;
}
static EncodedJSValue JSC_HOST_CALL callBooleanConstructor(ExecState* exec)
{
return JSValue::encode(jsBoolean(exec->argument(0).toBoolean(exec)));
}
CallType BooleanConstructor::getCallData(JSCell*, CallData& callData)
{
callData.native.function = callBooleanConstructor;
return CallType::Host;
}
JSObject* constructBooleanFromImmediateBoolean(ExecState* exec, JSGlobalObject* globalObject, JSValue immediateBooleanValue)
{
BooleanObject* obj = BooleanObject::create(exec->vm(), globalObject->booleanObjectStructure());
obj->setInternalValue(exec->vm(), immediateBooleanValue);
return obj;
}
}