blob: 77b846f559545342f9f03f29e72f2b1393eba9b2 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
|
/*
* Copyright (c) 2022, David Tuin <davidot@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibJS/Runtime/AbstractOperations.h>
#include <LibJS/Runtime/Object.h>
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<DisposableResource> const& disposable_resource_stack() const { return m_disposable_resource_stack; }
[[nodiscard]] Vector<DisposableResource>& disposable_resource_stack() { return m_disposable_resource_stack; }
void set_disposed() { m_state = DisposableState::Disposed; }
private:
DisposableStack(Vector<DisposableResource> stack, Object& prototype);
virtual void visit_edges(Visitor& visitor) override;
Vector<DisposableResource> m_disposable_resource_stack;
DisposableState m_state { DisposableState::Pending };
};
}
|