1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-16 15:54:58 +00:00
serenity/Userland/Libraries/LibJS/Runtime/EnvironmentRecord.h
Andreas Kling 5edd259b0a LibJS: Rename EnvironmentRecord::parent() => outer_environment()
This name matches the spec (corresponds to the [[OuterEnv]] slot.)
2021-06-21 23:49:50 +02:00

42 lines
1.1 KiB
C++

/*
* Copyright (c) 2020-2021, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Runtime/Object.h>
namespace JS {
struct Variable {
Value value;
DeclarationKind declaration_kind;
};
class EnvironmentRecord : public Object {
JS_OBJECT(EnvironmentRecord, Object);
public:
virtual Optional<Variable> get_from_scope(FlyString const&) const = 0;
virtual void put_to_scope(FlyString const&, Variable) = 0;
virtual bool delete_from_scope(FlyString const&) = 0;
virtual bool has_this_binding() const = 0;
virtual Value get_this_binding(GlobalObject&) const = 0;
// [[OuterEnv]]
EnvironmentRecord* outer_environment() { return m_outer_environment; }
EnvironmentRecord const* outer_environment() const { return m_outer_environment; }
protected:
explicit EnvironmentRecord(EnvironmentRecord* parent);
explicit EnvironmentRecord(GlobalObjectTag);
virtual void visit_edges(Visitor&) override;
private:
EnvironmentRecord* m_outer_environment { nullptr };
};
}