/* * Copyright (c) 2023, Andreas Kling * * SPDX-License-Identifier: BSD-2-Clause */ #pragma once #include #include #include namespace GC { template class Function final : public Cell { GC_CELL(Function, Cell); public: static Ref create(Heap& heap, AK::Function function) { return heap.allocate(move(function)); } virtual ~Function() override = default; [[nodiscard]] AK::Function const& function() const { return m_function; } private: Function(AK::Function function) : m_function(move(function)) { } virtual void visit_edges(Visitor& visitor) override { Base::visit_edges(visitor); visitor.visit_possible_values(m_function.raw_capture_range()); } AK::Function m_function; }; template> static Ref> create_function(Heap& heap, Callable&& function) { return Function::create(heap, AK::Function { forward(function) }); } }