mirror of
https://github.com/RGBCube/serenity
synced 2025-05-28 19:15:09 +00:00

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.
39 lines
1.4 KiB
C++
39 lines
1.4 KiB
C++
/*
|
|
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <LibJS/Runtime/EnvironmentRecord.h>
|
|
|
|
namespace JS {
|
|
|
|
class ObjectEnvironmentRecord : public EnvironmentRecord {
|
|
JS_OBJECT(ObjectEnvironmentRecord, EnvironmentRecord);
|
|
|
|
public:
|
|
ObjectEnvironmentRecord(Object&, EnvironmentRecord* parent_scope);
|
|
|
|
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_binding(FlyString const& name) const override;
|
|
virtual void create_mutable_binding(GlobalObject&, FlyString const& name, bool can_be_deleted) override;
|
|
virtual void create_immutable_binding(GlobalObject&, FlyString const& name, bool strict) override;
|
|
virtual void initialize_binding(GlobalObject&, FlyString const& name, Value) override;
|
|
virtual void set_mutable_binding(GlobalObject&, FlyString const& name, Value, bool strict) override;
|
|
virtual Value get_binding_value(GlobalObject&, FlyString const& name, bool strict) override;
|
|
virtual bool delete_binding(GlobalObject&, FlyString const& name) override;
|
|
|
|
Object& object() { return m_object; }
|
|
|
|
private:
|
|
virtual void visit_edges(Visitor&) override;
|
|
|
|
Object& m_object;
|
|
};
|
|
|
|
}
|