1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 10:37:45 +00:00

LibJS: Start implementing spec-compliant variable bindings

This patch adds the concept of variable bindings to the various
environment record classes. The bindings are not yet hooked up to
anything, this is just fleshing out all the operations.

Most of this is following the spec exactly, but in a few cases we are
missing the requisite abstract operations to do the exact right thing.
I've added FIXME's in those cases where I noticed it.
This commit is contained in:
Andreas Kling 2021-06-23 12:26:37 +02:00
parent 2822da8c8f
commit 9d49a5478a
8 changed files with 360 additions and 4 deletions

View file

@ -26,6 +26,14 @@ public:
virtual bool has_this_binding() const { return false; }
virtual Value get_this_binding(GlobalObject&) const { return {}; }
virtual bool has_binding([[maybe_unused]] FlyString const& name) const { return false; }
virtual void create_mutable_binding(GlobalObject&, [[maybe_unused]] FlyString const& name, [[maybe_unused]] bool can_be_deleted) { }
virtual void create_immutable_binding(GlobalObject&, [[maybe_unused]] FlyString const& name, [[maybe_unused]] bool strict) { }
virtual void initialize_binding(GlobalObject&, [[maybe_unused]] FlyString const& name, Value) { }
virtual void set_mutable_binding(GlobalObject&, [[maybe_unused]] FlyString const& name, Value, [[maybe_unused]] bool strict) { }
virtual Value get_binding_value(GlobalObject&, [[maybe_unused]] FlyString const& name, [[maybe_unused]] bool strict) { return {}; }
virtual bool delete_binding(GlobalObject&, [[maybe_unused]] FlyString const& name) { return false; }
// [[OuterEnv]]
EnvironmentRecord* outer_environment() { return m_outer_environment; }
EnvironmentRecord const* outer_environment() const { return m_outer_environment; }