mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 04:07:45 +00:00
LibJS: Add [[GlobalThisValue]] internal slot to GlobalEnvironment
Instead of hardcoding the environment's global object as the return value of GlobalEnvironment::global_this_value(), it now stores an Object reference which is passed to the constructor for this purpose. From the spec (https://tc39.es/ecma262/#sec-global-environment-records): [[GlobalThisValue]] | Object | The value returned by this in global scope. Hosts may provide any ECMAScript Object value.
This commit is contained in:
parent
2b8d5696ab
commit
1e79934acf
4 changed files with 13 additions and 18 deletions
|
@ -14,7 +14,7 @@ class GlobalEnvironment final : public Environment {
|
|||
JS_ENVIRONMENT(GlobalEnvironment, Environment);
|
||||
|
||||
public:
|
||||
explicit GlobalEnvironment(GlobalObject&);
|
||||
GlobalEnvironment(GlobalObject&, Object& this_value);
|
||||
|
||||
virtual Optional<Variable> get_from_environment(FlyString const&) const override;
|
||||
virtual bool put_into_environment(FlyString const&, Variable) override;
|
||||
|
@ -30,12 +30,8 @@ public:
|
|||
virtual Value get_binding_value(GlobalObject&, FlyString const& name, bool strict) override;
|
||||
virtual bool delete_binding(GlobalObject&, FlyString const& name) override;
|
||||
|
||||
Value global_this_value() const;
|
||||
|
||||
// [[ObjectRecord]]
|
||||
ObjectEnvironment& object_record() { return *m_object_record; }
|
||||
|
||||
// [[DeclarativeRecord]]
|
||||
Object& global_this_value() { return *m_global_this_value; }
|
||||
DeclarativeEnvironment& declarative_record() { return *m_declarative_record; }
|
||||
|
||||
bool has_var_declaration(FlyString const& name) const;
|
||||
|
@ -50,12 +46,13 @@ private:
|
|||
virtual bool is_global_environment() const override { return true; }
|
||||
virtual void visit_edges(Visitor&) override;
|
||||
|
||||
ObjectEnvironment* m_object_record { nullptr };
|
||||
DeclarativeEnvironment* m_declarative_record { nullptr };
|
||||
|
||||
Vector<FlyString> m_var_names;
|
||||
ObjectEnvironment* m_object_record { nullptr }; // [[ObjectRecord]]
|
||||
Object* m_global_this_value { nullptr }; // [[GlobalThisValue]]
|
||||
DeclarativeEnvironment* m_declarative_record { nullptr }; // [[DeclarativeRecord]]
|
||||
Vector<FlyString> m_var_names; // [[VarNames]]
|
||||
};
|
||||
|
||||
template<>
|
||||
inline bool Environment::fast_is<GlobalEnvironment>() const { return is_global_environment(); }
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue