LibJS: Make Interpreter::in_strict_mode() work outside of scope

This one is a little weird. I don't know why it's okay for this
function to assume that there is a current scope on the scope stack
when it can be called during global object initialization etc.

For now, just make it say "we are in strict mode" when there is no
currently active scope.
This commit is contained in:
Andreas Kling 2020-09-20 19:16:34 +02:00
parent 893df28e80
commit 668e73df8a
Notes: sideshowbarker 2024-07-19 02:19:31 +09:00

View file

@ -152,7 +152,12 @@ public:
const LexicalEnvironment* current_environment() const { return m_call_stack.last().environment; }
LexicalEnvironment* current_environment() { return m_call_stack.last().environment; }
bool in_strict_mode() const { return m_scope_stack.last().scope_node->in_strict_mode(); }
bool in_strict_mode() const
{
if (m_scope_stack.is_empty())
return true;
return m_scope_stack.last().scope_node->in_strict_mode();
}
template<typename Callback>
void for_each_argument(Callback callback)