1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 02:47:35 +00:00

LibJS: Begin implementing GlobalEnvironmentRecord

These represent the outermost scope in the environment record
hierarchy. The spec says they should be a "composite" of two things:

- An ObjectEnvironmentRecord wrapping the global object
- A DeclarativeEnvironmentRecord for other declarations

It's not yet clear to me how this should work, so this patch only
implements the first part, an object record wrapping the global object.
This commit is contained in:
Andreas Kling 2021-06-22 17:16:08 +02:00
parent 1d20380859
commit 1f8b6ac3c3
13 changed files with 130 additions and 43 deletions

View file

@ -12,8 +12,8 @@
namespace JS {
class GlobalObject : public EnvironmentRecord {
JS_OBJECT(GlobalObject, EnvironmentRecord);
class GlobalObject : public Object {
JS_OBJECT(GlobalObject, Object);
public:
explicit GlobalObject();
@ -21,11 +21,7 @@ public:
virtual ~GlobalObject() override;
virtual Optional<Variable> get_from_environment_record(FlyString const&) const override;
virtual void put_into_environment_record(FlyString const&, Variable) override;
virtual bool delete_from_environment_record(FlyString const&) override;
virtual bool has_this_binding() const final { return true; }
virtual Value get_this_binding(GlobalObject&) const final { return this; }
GlobalEnvironmentRecord& environment_record() { return *m_environment_record; }
Console& console() { return *m_console; }
@ -87,6 +83,8 @@ private:
// Not included in JS_ENUMERATE_NATIVE_OBJECTS due to missing distinct constructor
GeneratorObjectPrototype* m_generator_object_prototype { nullptr };
GlobalEnvironmentRecord* m_environment_record { nullptr };
#define __JS_ENUMERATE(ClassName, snake_name, PrototypeName, ConstructorName, ArrayType) \
ConstructorName* m_##snake_name##_constructor { nullptr }; \
Object* m_##snake_name##_prototype { nullptr };