mirror of
https://github.com/RGBCube/serenity
synced 2025-05-30 22:28:12 +00:00
LibJS: Add Value::{is, as}_function()
This commit is contained in:
parent
419bce6915
commit
eea62dd365
6 changed files with 26 additions and 15 deletions
|
@ -31,6 +31,7 @@
|
|||
#include <LibJS/Runtime/Array.h>
|
||||
#include <LibJS/Runtime/BooleanObject.h>
|
||||
#include <LibJS/Runtime/Error.h>
|
||||
#include <LibJS/Runtime/Function.h>
|
||||
#include <LibJS/Runtime/NumberObject.h>
|
||||
#include <LibJS/Runtime/Object.h>
|
||||
#include <LibJS/Runtime/PrimitiveString.h>
|
||||
|
@ -48,6 +49,17 @@ bool Value::is_array() const
|
|||
return is_object() && as_object().is_array();
|
||||
}
|
||||
|
||||
bool Value::is_function() const
|
||||
{
|
||||
return is_object() && as_object().is_function();
|
||||
}
|
||||
|
||||
Function& Value::as_function()
|
||||
{
|
||||
ASSERT(is_function());
|
||||
return static_cast<Function&>(as_object());
|
||||
}
|
||||
|
||||
String Value::to_string() const
|
||||
{
|
||||
if (is_boolean())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue