From 3220cb1b5982ff27d8edf3336c4b869b586fab62 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Mar 2026 21:59:59 -0400 Subject: [PATCH] xo-reader2 stack: + ARuntimeContext.collector() access Collector API (if present) from runtime context --- include/xo/interpreter2/DVsmRcx.hpp | 2 ++ .../xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp | 3 +++ src/interpreter2/DVsmRcx.cpp | 8 ++++++++ src/interpreter2/IRuntimeContext_DVsmRcx.cpp | 6 ++++++ 4 files changed, 19 insertions(+) diff --git a/include/xo/interpreter2/DVsmRcx.hpp b/include/xo/interpreter2/DVsmRcx.hpp index 1f3a8f57..1ab7e773 100644 --- a/include/xo/interpreter2/DVsmRcx.hpp +++ b/include/xo/interpreter2/DVsmRcx.hpp @@ -22,12 +22,14 @@ namespace xo { public: using StringTable = xo::scm::StringTable; using AAllocator = xo::mm::AAllocator; + using ACollector = xo::mm::ACollector; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; public: DVsmRcx(VirtualSchematikaMachine * vsm); obj allocator() const noexcept; + obj collector() const noexcept; StringTable * stringtable() const noexcept; obj error_allocator() const noexcept; void visit_pools(const MemorySizeVisitor & visitor) const; diff --git a/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp b/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp index 1b4c1567..1eddf28c 100644 --- a/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp +++ b/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp @@ -40,6 +40,7 @@ namespace xo { /** @defgroup scm-runtimecontext-dvsmrcx-type-traits **/ ///@{ using AAllocator = xo::scm::ARuntimeContext::AAllocator; + using ACollector = xo::scm::ARuntimeContext::ACollector; using MemorySizeVisitor = xo::scm::ARuntimeContext::MemorySizeVisitor; using Copaque = xo::scm::ARuntimeContext::Copaque; using Opaque = xo::scm::ARuntimeContext::Opaque; @@ -49,6 +50,8 @@ namespace xo { // const methods /** default allocator to use for objects **/ static obj allocator(const DVsmRcx & self) noexcept; + /** collector facet for allocator. If non-null, same data pointer as allocator **/ + static obj collector(const DVsmRcx & self) noexcept; /** stringtable for unique symbols **/ static StringTable * stringtable(const DVsmRcx & self) noexcept; /** invoke visitor for each distinct memory pool **/ diff --git a/src/interpreter2/DVsmRcx.cpp b/src/interpreter2/DVsmRcx.cpp index b7ea4112..856f38e4 100644 --- a/src/interpreter2/DVsmRcx.cpp +++ b/src/interpreter2/DVsmRcx.cpp @@ -5,9 +5,11 @@ #include "DVsmRcx.hpp" #include "VirtualSchematikaMachine.hpp" +#include namespace xo { using xo::mm::AAllocator; + using xo::mm::ACollector; namespace scm { @@ -19,6 +21,12 @@ namespace xo { return vsm_->allocator(); } + obj + DVsmRcx::collector() const noexcept + { + return vsm_->allocator().try_to_facet(); + } + obj DVsmRcx::error_allocator() const noexcept { diff --git a/src/interpreter2/IRuntimeContext_DVsmRcx.cpp b/src/interpreter2/IRuntimeContext_DVsmRcx.cpp index e879d4ed..9b1a73d0 100644 --- a/src/interpreter2/IRuntimeContext_DVsmRcx.cpp +++ b/src/interpreter2/IRuntimeContext_DVsmRcx.cpp @@ -21,6 +21,12 @@ namespace xo { return self.allocator(); } + auto + IRuntimeContext_DVsmRcx::collector(const DVsmRcx & self) noexcept -> obj + { + return self.collector(); + } + auto IRuntimeContext_DVsmRcx::stringtable(const DVsmRcx & self) noexcept -> StringTable * {