diff options
author | Linus Groh <mail@linusgroh.de> | 2021-09-25 09:43:34 +0200 |
---|---|---|
committer | Linus Groh <mail@linusgroh.de> | 2021-09-25 17:51:30 +0200 |
commit | e14f420a44075aecf5c212ae61705e04f821cf38 (patch) | |
tree | 582bd7b2c3d0d364e23b149e0eca8bde3f309c6b /Userland/Libraries/LibJS/Runtime | |
parent | 2dba0481469b56db97a923eef9db4d87950ca47c (diff) | |
download | serenity-e14f420a44075aecf5c212ae61705e04f821cf38.zip |
LibJS: Add const Value::as_function()
Diffstat (limited to 'Userland/Libraries/LibJS/Runtime')
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Value.cpp | 6 | ||||
-rw-r--r-- | Userland/Libraries/LibJS/Runtime/Value.h | 1 |
2 files changed, 7 insertions, 0 deletions
diff --git a/Userland/Libraries/LibJS/Runtime/Value.cpp b/Userland/Libraries/LibJS/Runtime/Value.cpp index a32565fa55..9e9d099e87 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.cpp +++ b/Userland/Libraries/LibJS/Runtime/Value.cpp @@ -228,6 +228,12 @@ FunctionObject& Value::as_function() return static_cast<FunctionObject&>(as_object()); } +FunctionObject const& Value::as_function() const +{ + VERIFY(is_function()); + return static_cast<FunctionObject const&>(as_object()); +} + // 7.2.4 IsConstructor ( argument ), https://tc39.es/ecma262/#sec-isconstructor bool Value::is_constructor() const { diff --git a/Userland/Libraries/LibJS/Runtime/Value.h b/Userland/Libraries/LibJS/Runtime/Value.h index 626500d4e0..feef1475c2 100644 --- a/Userland/Libraries/LibJS/Runtime/Value.h +++ b/Userland/Libraries/LibJS/Runtime/Value.h @@ -240,6 +240,7 @@ public: Array& as_array(); FunctionObject& as_function(); + FunctionObject const& as_function() const; i32 as_i32() const; u32 as_u32() const; |