1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-26 06:37:35 +00:00

LibJS: Add EnvironmentRecord::global_object()

Our environment records are currently weird in that they inherit from
Object, but don't have a connection to the global object.

I'd like to remove this inheritance, and the first step is giving them
their own pointer to the global object.
This commit is contained in:
Andreas Kling 2021-06-23 12:29:12 +02:00
parent 9d49a5478a
commit f1e1d9dd74
3 changed files with 15 additions and 0 deletions

View file

@ -19,6 +19,11 @@ class EnvironmentRecord : public Object {
JS_OBJECT(EnvironmentRecord, Object);
public:
GlobalObject& global_object() { return *m_global_object; }
GlobalObject const& global_object() const { return *m_global_object; }
virtual void initialize(GlobalObject&) override;
virtual Optional<Variable> get_from_environment_record(FlyString const&) const = 0;
virtual void put_into_environment_record(FlyString const&, Variable) = 0;
virtual bool delete_from_environment_record(FlyString const&) = 0;
@ -44,6 +49,9 @@ protected:
virtual void visit_edges(Visitor&) override;
private:
virtual bool is_environment_record() const final { return true; }
GlobalObject* m_global_object { nullptr };
EnvironmentRecord* m_outer_environment { nullptr };
};