1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-31 11:18:11 +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:
Andreas Kling 2020-10-04 13:54:44 +02:00
parent f41b5a4535
commit a007b3c379
15 changed files with 49 additions and 37 deletions

View file

@ -50,7 +50,6 @@ struct ScopeFrame {
ScopeType type;
NonnullRefPtr<ScopeNode> scope_node;
bool pushed_environment { false };
bool is_strict_mode { false };
};
struct CallFrame {
@ -58,6 +57,7 @@ struct CallFrame {
Value this_value;
Vector<Value> arguments;
LexicalEnvironment* environment { nullptr };
bool is_strict_mode { false };
};
struct Argument {
@ -108,9 +108,9 @@ public:
PrimitiveString& empty_string() { return *m_empty_string; }
CallFrame& push_call_frame()
CallFrame& push_call_frame(bool strict_mode = false)
{
m_call_stack.append({ {}, js_undefined(), {}, nullptr });
m_call_stack.append({ {}, js_undefined(), {}, nullptr, strict_mode });
return m_call_stack.last();
}
void pop_call_frame() { m_call_stack.take_last(); }