mirror of
https://github.com/RGBCube/serenity
synced 2025-07-10 08:57:35 +00:00
LibJS: Implement constructor/non-constructor function calls
This adds Function::construct() for constructor function calls via `new` keyword. NativeFunction doesn't have constructor behaviour by default, ScriptFunction simply calls call() in construct()
This commit is contained in:
parent
a27884e4be
commit
849e2c77e4
11 changed files with 66 additions and 1 deletions
|
@ -46,6 +46,14 @@ DateConstructor::~DateConstructor()
|
|||
}
|
||||
|
||||
Value DateConstructor::call(Interpreter& interpreter)
|
||||
{
|
||||
auto* date = static_cast<Date*>(construct(interpreter).as_object());
|
||||
if (!date)
|
||||
return {};
|
||||
return js_string(interpreter.heap(), date->string());
|
||||
}
|
||||
|
||||
Value DateConstructor::construct(Interpreter& interpreter)
|
||||
{
|
||||
// TODO: Support args
|
||||
struct timeval tv;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue