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

LibJS: Add a scope object abstraction

Both GlobalObject and LexicalEnvironment now inherit from ScopeObject,
and the VM's call frames point to a ScopeObject chain rather than just
a LexicalEnvironment chain.

This gives us much more flexibility to implement things like "with",
and also unifies some of the code paths that previously required
special handling of the global object.

There's a bunch of more cleanup that can be done in the wake of this
change, and there might be some oversights in the handling of the
"super" keyword, but this generally seems like a good architectural
improvement. :^)
This commit is contained in:
Andreas Kling 2020-11-28 16:02:27 +01:00
parent e1bbc7c075
commit c3fe9b4df8
16 changed files with 241 additions and 92 deletions

View file

@ -71,7 +71,8 @@ public:
Heap& heap() { return vm().heap(); }
Exception* exception() { return vm().exception(); }
LexicalEnvironment* current_environment() { return vm().current_environment(); }
ScopeObject* current_scope() { return vm().current_scope(); }
LexicalEnvironment* current_environment();
void enter_scope(const ScopeNode&, ArgumentVector, ScopeType, GlobalObject&);
void exit_scope(const ScopeNode&);