mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 11:47:45 +00:00
LibJS: Add arguments.callee to our hack arguments object
arguments.callee refers to the currently executing function.
This commit is contained in:
parent
093331df06
commit
8062fc711c
3 changed files with 5 additions and 0 deletions
|
@ -75,6 +75,7 @@ namespace JS {
|
||||||
P(bind) \
|
P(bind) \
|
||||||
P(byteLength) \
|
P(byteLength) \
|
||||||
P(call) \
|
P(call) \
|
||||||
|
P(callee) \
|
||||||
P(cbrt) \
|
P(cbrt) \
|
||||||
P(ceil) \
|
P(ceil) \
|
||||||
P(charAt) \
|
P(charAt) \
|
||||||
|
|
|
@ -175,6 +175,7 @@ Value VM::get_variable(const FlyString& name, GlobalObject& global_object)
|
||||||
return possible_match.value().value;
|
return possible_match.value().value;
|
||||||
if (!call_frame().arguments_object) {
|
if (!call_frame().arguments_object) {
|
||||||
call_frame().arguments_object = Array::create(global_object);
|
call_frame().arguments_object = Array::create(global_object);
|
||||||
|
call_frame().arguments_object->put(names.callee, call_frame().callee);
|
||||||
for (auto argument : call_frame().arguments) {
|
for (auto argument : call_frame().arguments) {
|
||||||
call_frame().arguments_object->indexed_properties().append(argument);
|
call_frame().arguments_object->indexed_properties().append(argument);
|
||||||
}
|
}
|
||||||
|
@ -211,6 +212,7 @@ Reference VM::get_reference(const FlyString& name)
|
||||||
Value VM::construct(Function& function, Function& new_target, Optional<MarkedValueList> arguments, GlobalObject& global_object)
|
Value VM::construct(Function& function, Function& new_target, Optional<MarkedValueList> arguments, GlobalObject& global_object)
|
||||||
{
|
{
|
||||||
CallFrame call_frame;
|
CallFrame call_frame;
|
||||||
|
call_frame.callee = &function;
|
||||||
call_frame.current_node = current_node();
|
call_frame.current_node = current_node();
|
||||||
call_frame.is_strict_mode = function.is_strict_mode();
|
call_frame.is_strict_mode = function.is_strict_mode();
|
||||||
|
|
||||||
|
@ -335,6 +337,7 @@ Value VM::call_internal(Function& function, Value this_value, Optional<MarkedVal
|
||||||
VERIFY(!exception());
|
VERIFY(!exception());
|
||||||
|
|
||||||
CallFrame call_frame;
|
CallFrame call_frame;
|
||||||
|
call_frame.callee = &function;
|
||||||
call_frame.current_node = current_node();
|
call_frame.current_node = current_node();
|
||||||
call_frame.is_strict_mode = function.is_strict_mode();
|
call_frame.is_strict_mode = function.is_strict_mode();
|
||||||
call_frame.function_name = function.name();
|
call_frame.function_name = function.name();
|
||||||
|
|
|
@ -58,6 +58,7 @@ struct ScopeFrame {
|
||||||
struct CallFrame {
|
struct CallFrame {
|
||||||
const ASTNode* current_node;
|
const ASTNode* current_node;
|
||||||
FlyString function_name;
|
FlyString function_name;
|
||||||
|
Value callee;
|
||||||
Value this_value;
|
Value this_value;
|
||||||
Vector<Value> arguments;
|
Vector<Value> arguments;
|
||||||
Array* arguments_object { nullptr };
|
Array* arguments_object { nullptr };
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue