1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-14 08:34:57 +00:00

LibJS: Add DisposableStack{, Prototype, Constructor}

Since the async parts of the spec are not stage 3 at this point we don't
add AsyncDisposableStack.
This commit is contained in:
davidot 2022-12-21 11:48:14 +01:00 committed by Linus Groh
parent bff038411a
commit 6255ca4a42
22 changed files with 868 additions and 0 deletions

View file

@ -0,0 +1,26 @@
/*
* Copyright (c) 2022, David Tuin <davidot@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibJS/Runtime/DisposableStack.h>
namespace JS {
DisposableStack::DisposableStack(Vector<DisposableResource> stack, Object& prototype)
: Object(ConstructWithPrototypeTag::Tag, prototype)
, m_disposable_resource_stack(move(stack))
{
}
void DisposableStack::visit_edges(Cell::Visitor& visitor)
{
Base::visit_edges(visitor);
for (auto& resource : m_disposable_resource_stack) {
visitor.visit(resource.resource_value);
visitor.visit(resource.dispose_method);
}
}
}