summaryrefslogtreecommitdiff
path: root/Source/JavaScriptCore/runtime/BooleanConstructor.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Source/JavaScriptCore/runtime/BooleanConstructor.cpp')
-rw-r--r--Source/JavaScriptCore/runtime/BooleanConstructor.cpp27
1 files changed, 13 insertions, 14 deletions
diff --git a/Source/JavaScriptCore/runtime/BooleanConstructor.cpp b/Source/JavaScriptCore/runtime/BooleanConstructor.cpp
index 09fa26096..a0fff5840 100644
--- a/Source/JavaScriptCore/runtime/BooleanConstructor.cpp
+++ b/Source/JavaScriptCore/runtime/BooleanConstructor.cpp
@@ -1,6 +1,6 @@
/*
* Copyright (C) 1999-2000 Harri Porten (porten@kde.org)
- * Copyright (C) 2003, 2008 Apple Inc. All rights reserved.
+ * Copyright (C) 2003, 2008, 2016 Apple Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -23,13 +23,13 @@
#include "BooleanPrototype.h"
#include "JSGlobalObject.h"
-#include "Operations.h"
+#include "JSCInlines.h"
namespace JSC {
STATIC_ASSERT_IS_TRIVIALLY_DESTRUCTIBLE(BooleanConstructor);
-const ClassInfo BooleanConstructor::s_info = { "Function", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(BooleanConstructor) };
+const ClassInfo BooleanConstructor::s_info = { "Function", &Base::s_info, 0, CREATE_METHOD_TABLE(BooleanConstructor) };
BooleanConstructor::BooleanConstructor(VM& vm, Structure* structure)
: InternalFunction(vm, structure)
@@ -46,23 +46,22 @@ void BooleanConstructor::finishCreation(VM& vm, BooleanPrototype* booleanPrototy
}
// ECMA 15.6.2
-JSObject* constructBoolean(ExecState* exec, const ArgList& args)
-{
- BooleanObject* obj = BooleanObject::create(exec->vm(), asInternalFunction(exec->callee())->globalObject()->booleanObjectStructure());
- obj->setInternalValue(exec->vm(), jsBoolean(args.at(0).toBoolean(exec)));
- return obj;
-}
-
static EncodedJSValue JSC_HOST_CALL constructWithBooleanConstructor(ExecState* exec)
{
- ArgList args(exec);
- return JSValue::encode(constructBoolean(exec, args));
+ VM& vm = exec->vm();
+ auto scope = DECLARE_THROW_SCOPE(vm);
+ JSValue boolean = jsBoolean(exec->argument(0).toBoolean(exec));
+ Structure* booleanStructure = InternalFunction::createSubclassStructure(exec, exec->newTarget(), asInternalFunction(exec->jsCallee())->globalObject()->booleanObjectStructure());
+ RETURN_IF_EXCEPTION(scope, encodedJSValue());
+ BooleanObject* obj = BooleanObject::create(vm, booleanStructure);
+ obj->setInternalValue(vm, boolean);
+ return JSValue::encode(obj);
}
ConstructType BooleanConstructor::getConstructData(JSCell*, ConstructData& constructData)
{
constructData.native.function = constructWithBooleanConstructor;
- return ConstructTypeHost;
+ return ConstructType::Host;
}
// ECMA 15.6.1
@@ -74,7 +73,7 @@ static EncodedJSValue JSC_HOST_CALL callBooleanConstructor(ExecState* exec)
CallType BooleanConstructor::getCallData(JSCell*, CallData& callData)
{
callData.native.function = callBooleanConstructor;
- return CallTypeHost;
+ return CallType::Host;
}
JSObject* constructBooleanFromImmediateBoolean(ExecState* exec, JSGlobalObject* globalObject, JSValue immediateBooleanValue)