/* * Copyright (c) 2022, David Tuin * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include namespace JS { class DisposableStack final : public Object { JS_OBJECT(DisposableStack, Object); public: virtual ~DisposableStack() override = default; enum class DisposableState { Pending, Disposed }; [[nodiscard]] DisposableState disposable_state() const { return m_state; } [[nodiscard]] Vector const& disposable_resource_stack() const { return m_disposable_resource_stack; } [[nodiscard]] Vector& disposable_resource_stack() { return m_disposable_resource_stack; } void set_disposed() { m_state = DisposableState::Disposed; } private: DisposableStack(Vector stack, Object& prototype); virtual void visit_edges(Visitor& visitor) override; Vector m_disposable_resource_stack; DisposableState m_state { DisposableState::Pending }; }; }