1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:17:36 +00:00

LibJS: Strict mode is now handled by Functions and Programs, not Blocks

Since blocks can't be strict by themselves, it makes no sense for them
to store whether or not they are strict. Strict-ness is now stored in
the Program and FunctionNode ASTNodes. Fixes issue #3641
This commit is contained in:
Matthew Olsson 2020-10-03 17:02:43 -07:00 committed by Andreas Kling
parent 1b3f9c170c
commit 6eb6752c4c
10 changed files with 92 additions and 37 deletions

View file

@ -88,10 +88,9 @@ public:
bool in_strict_mode() const
{
// FIXME: This implementation is bogus; strict mode is per-file or per-function, not per-block!
if (m_scope_stack.is_empty())
return true;
return m_scope_stack.last().scope_node->in_strict_mode();
return false;
return m_scope_stack.last().is_strict_mode;
}
size_t argument_count() const { return vm().argument_count(); }
@ -100,10 +99,10 @@ public:
LexicalEnvironment* current_environment() { return vm().current_environment(); }
const CallFrame& call_frame() { return vm().call_frame(); }
void enter_scope(const ScopeNode&, ArgumentVector, ScopeType, GlobalObject&);
void enter_scope(const ScopeNode&, ArgumentVector, ScopeType, GlobalObject&, bool is_strict = false);
void exit_scope(const ScopeNode&);
Value execute_statement(GlobalObject&, const Statement&, ArgumentVector = {}, ScopeType = ScopeType::Block);
Value execute_statement(GlobalObject&, const Statement&, ArgumentVector = {}, ScopeType = ScopeType::Block, bool is_strict = false);
private:
explicit Interpreter(VM&);
@ -113,11 +112,13 @@ private:
return vm().call(function, this_value, move(arguments));
}
void push_scope(ScopeFrame frame);
Vector<ScopeFrame> m_scope_stack;
NonnullRefPtr<VM> m_vm;
Handle<Object> m_global_object;
Vector<ScopeFrame> m_scope_stack;
};
template<>