2020-05-21 11:14:23 -07:00
|
|
|
/*
|
2021-04-22 16:53:07 -07:00
|
|
|
* Copyright (c) 2020, Matthew Olsson <mattco@serenityos.org>
|
2021-04-22 22:51:19 +02:00
|
|
|
* Copyright (c) 2020, Linus Groh <linusg@serenityos.org>
|
2020-05-21 11:14:23 -07:00
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-05-21 11:14:23 -07:00
|
|
|
*/
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2022-03-16 18:26:49 -06:00
|
|
|
#include <AK/StringView.h>
|
2021-06-27 21:48:34 +02:00
|
|
|
#include <LibJS/Runtime/FunctionObject.h>
|
2020-09-27 19:59:33 +02:00
|
|
|
#include <LibJS/Runtime/VM.h>
|
2020-05-21 11:14:23 -07:00
|
|
|
|
|
|
|
namespace JS {
|
|
|
|
|
|
|
|
class Accessor final : public Cell {
|
2022-08-28 22:11:20 +02:00
|
|
|
JS_CELL(Accessor, Cell);
|
2023-11-19 09:45:05 +01:00
|
|
|
JS_DECLARE_ALLOCATOR(Accessor);
|
2022-08-28 22:11:20 +02:00
|
|
|
|
2020-05-21 11:14:23 -07:00
|
|
|
public:
|
2022-12-13 20:49:49 +00:00
|
|
|
static NonnullGCPtr<Accessor> create(VM& vm, FunctionObject* getter, FunctionObject* setter)
|
2020-05-21 11:14:23 -07:00
|
|
|
{
|
2022-12-14 17:40:33 +00:00
|
|
|
return vm.heap().allocate_without_realm<Accessor>(getter, setter);
|
2020-05-21 11:14:23 -07:00
|
|
|
}
|
|
|
|
|
2021-06-27 21:48:34 +02:00
|
|
|
FunctionObject* getter() const { return m_getter; }
|
|
|
|
void set_getter(FunctionObject* getter) { m_getter = getter; }
|
2020-05-21 11:14:23 -07:00
|
|
|
|
2021-06-27 21:48:34 +02:00
|
|
|
FunctionObject* setter() const { return m_setter; }
|
|
|
|
void set_setter(FunctionObject* setter) { m_setter = setter; }
|
2020-05-23 23:27:10 +01:00
|
|
|
|
2020-11-28 14:33:36 +01:00
|
|
|
void visit_edges(Cell::Visitor& visitor) override
|
2020-05-21 11:14:23 -07:00
|
|
|
{
|
2023-03-20 13:37:11 -07:00
|
|
|
Base::visit_edges(visitor);
|
2020-05-21 11:14:23 -07:00
|
|
|
visitor.visit(m_getter);
|
|
|
|
visitor.visit(m_setter);
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2022-08-28 23:51:28 +02:00
|
|
|
Accessor(FunctionObject* getter, FunctionObject* setter)
|
|
|
|
: m_getter(getter)
|
|
|
|
, m_setter(setter)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2023-02-26 16:09:02 -07:00
|
|
|
GCPtr<FunctionObject> m_getter;
|
|
|
|
GCPtr<FunctionObject> m_setter;
|
2020-05-21 11:14:23 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|