mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-01 06:07:59 +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:
committed by
Andreas Kling
parent
a27884e4be
commit
849e2c77e4
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user