mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:57:45 +00:00
LibJS: Use OrdinaryCreateFromConstructor() in a bunch of constructors
Resolves various FIXMEs :^)
This commit is contained in:
parent
e5753443ae
commit
8f6ac0db1c
16 changed files with 173 additions and 102 deletions
|
@ -4,10 +4,9 @@
|
|||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibJS/Runtime/AbstractOperations.h>
|
||||
#include <LibJS/Runtime/BooleanConstructor.h>
|
||||
#include <LibJS/Runtime/BooleanObject.h>
|
||||
#include <LibJS/Runtime/BooleanPrototype.h>
|
||||
#include <LibJS/Runtime/GlobalObject.h>
|
||||
|
||||
namespace JS {
|
||||
|
@ -35,13 +34,20 @@ BooleanConstructor::~BooleanConstructor()
|
|||
// 20.3.1.1 Boolean ( value ), https://tc39.es/ecma262/#sec-boolean-constructor-boolean-value
|
||||
Value BooleanConstructor::call()
|
||||
{
|
||||
return Value(vm().argument(0).to_boolean());
|
||||
auto& vm = this->vm();
|
||||
|
||||
auto b = vm.argument(0).to_boolean();
|
||||
return Value(b);
|
||||
}
|
||||
|
||||
// 20.3.1.1 Boolean ( value ), https://tc39.es/ecma262/#sec-boolean-constructor-boolean-value
|
||||
Value BooleanConstructor::construct(Function&)
|
||||
Value BooleanConstructor::construct(Function& new_target)
|
||||
{
|
||||
return BooleanObject::create(global_object(), vm().argument(0).to_boolean());
|
||||
auto& vm = this->vm();
|
||||
auto& global_object = this->global_object();
|
||||
|
||||
auto b = vm.argument(0).to_boolean();
|
||||
return ordinary_create_from_constructor<BooleanObject>(global_object, new_target, &GlobalObject::boolean_prototype, b);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue