mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:47:45 +00:00
LibJS+LibWeb: Function calls should always go through Interpreter
This ensures that we set up a call frame with |this| and arguments.
This commit is contained in:
parent
30440134cb
commit
62d5f79388
2 changed files with 5 additions and 5 deletions
|
@ -88,7 +88,7 @@ public:
|
||||||
void enter_scope(const ScopeNode&, Vector<Argument>, ScopeType);
|
void enter_scope(const ScopeNode&, Vector<Argument>, ScopeType);
|
||||||
void exit_scope(const ScopeNode&);
|
void exit_scope(const ScopeNode&);
|
||||||
|
|
||||||
Value call(Function*, Value this_value, const Vector<Value>& arguments);
|
Value call(Function*, Value this_value = {}, const Vector<Value>& arguments = {});
|
||||||
|
|
||||||
CallFrame& push_call_frame()
|
CallFrame& push_call_frame()
|
||||||
{
|
{
|
||||||
|
|
|
@ -357,8 +357,8 @@ JS::Interpreter& Document::interpreter()
|
||||||
// FIXME: This timer should not be leaked! It should also be removable with clearInterval()!
|
// FIXME: This timer should not be leaked! It should also be removable with clearInterval()!
|
||||||
(void)Core::Timer::construct(
|
(void)Core::Timer::construct(
|
||||||
arguments[1].to_i32(), [this, callback] {
|
arguments[1].to_i32(), [this, callback] {
|
||||||
// FIXME: Perform the call through Interpreter so it can set up a call frame!
|
auto* function = const_cast<JS::Function*>(static_cast<const JS::Function*>(callback.cell()));
|
||||||
const_cast<JS::Function*>(static_cast<const JS::Function*>(callback.cell()))->call(*m_interpreter);
|
m_interpreter->call(function);
|
||||||
})
|
})
|
||||||
.leak_ref();
|
.leak_ref();
|
||||||
|
|
||||||
|
@ -374,8 +374,8 @@ JS::Interpreter& Document::interpreter()
|
||||||
auto callback = make_handle(const_cast<JS::Object*>(arguments[0].as_object()));
|
auto callback = make_handle(const_cast<JS::Object*>(arguments[0].as_object()));
|
||||||
// FIXME: Don't hand out raw DisplayLink ID's to JavaScript!
|
// FIXME: Don't hand out raw DisplayLink ID's to JavaScript!
|
||||||
i32 link_id = GUI::DisplayLink::register_callback([this, callback](i32 link_id) {
|
i32 link_id = GUI::DisplayLink::register_callback([this, callback](i32 link_id) {
|
||||||
// FIXME: Perform the call through Interpreter so it can set up a call frame!
|
auto* function = const_cast<JS::Function*>(static_cast<const JS::Function*>(callback.cell()));
|
||||||
const_cast<JS::Function*>(static_cast<const JS::Function*>(callback.cell()))->call(*m_interpreter);
|
m_interpreter->call(function);
|
||||||
GUI::DisplayLink::unregister_callback(link_id);
|
GUI::DisplayLink::unregister_callback(link_id);
|
||||||
});
|
});
|
||||||
return JS::Value(link_id);
|
return JS::Value(link_id);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue