mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 08:35:09 +00:00
LibJS: Add Boolean constructor object
This commit is contained in:
parent
57bd194e5a
commit
edae926cb0
16 changed files with 400 additions and 0 deletions
|
@ -29,6 +29,7 @@
|
|||
#include <LibJS/Heap/Heap.h>
|
||||
#include <LibJS/Interpreter.h>
|
||||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/BooleanObject.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/NumberObject.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
|
@ -110,6 +111,9 @@ Object* Value::to_object(Heap& heap) const
|
|||
if (is_number())
|
||||
return heap.allocate<NumberObject>(m_value.as_double);
|
||||
|
||||
if (is_boolean())
|
||||
return heap.allocate<BooleanObject>(m_value.as_bool);
|
||||
|
||||
if (is_null() || is_undefined()) {
|
||||
heap.interpreter().throw_exception<Error>("TypeError", "ToObject on null or undefined.");
|
||||
return nullptr;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue