mirror of
https://github.com/fergalmoran/ladybird.git
synced 2025-12-25 19:04:58 +00:00
LibJS: Move "strict mode" state to the call stack
Each call frame now knows whether it's executing in strict mode. It's no longer necessary to access the scope stack to find this mode.
This commit is contained in:
@@ -187,7 +187,7 @@ Reference VM::get_reference(const FlyString& name)
|
||||
|
||||
Value VM::construct(Function& function, Function& new_target, Optional<MarkedValueList> arguments, GlobalObject& global_object)
|
||||
{
|
||||
auto& call_frame = push_call_frame();
|
||||
auto& call_frame = push_call_frame(function.is_strict_mode());
|
||||
|
||||
ArmedScopeGuard call_frame_popper = [&] {
|
||||
pop_call_frame();
|
||||
@@ -304,7 +304,7 @@ Value VM::call_internal(Function& function, Value this_value, Optional<MarkedVal
|
||||
{
|
||||
ASSERT(!exception());
|
||||
|
||||
auto& call_frame = push_call_frame();
|
||||
auto& call_frame = push_call_frame(function.is_strict_mode());
|
||||
call_frame.function_name = function.name();
|
||||
call_frame.this_value = function.bound_this().value_or(this_value);
|
||||
call_frame.arguments = function.bound_arguments();
|
||||
@@ -320,4 +320,11 @@ Value VM::call_internal(Function& function, Value this_value, Optional<MarkedVal
|
||||
return result;
|
||||
}
|
||||
|
||||
bool VM::in_strict_mode() const
|
||||
{
|
||||
if (call_stack().is_empty())
|
||||
return false;
|
||||
return call_frame().is_strict_mode;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user