From 038a931fa5f66b467269c3f339dea2021d4db59a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 28 Feb 2026 13:26:10 +1100 Subject: [PATCH] xo-interpreter2 stack: + RuntimeContext.visit_pools() method --- include/xo/interpreter2/DVsmRcx.hpp | 6 ++++-- include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp | 3 +++ src/interpreter2/DVsmRcx.cpp | 6 ++++++ src/interpreter2/IRuntimeContext_DVsmRcx.cpp | 6 ++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/xo/interpreter2/DVsmRcx.hpp b/include/xo/interpreter2/DVsmRcx.hpp index eeeb7289..3323f7d7 100644 --- a/include/xo/interpreter2/DVsmRcx.hpp +++ b/include/xo/interpreter2/DVsmRcx.hpp @@ -6,11 +6,12 @@ #pragma once #include +#include namespace xo { namespace scm { // see xo-interpreter/ VirtualSchematikaMachine.hpp - class VirtualSchematikaMachine; + class VirtualSchematikaMachine; /** @brief Runtime context for schematika interpreter * @@ -19,12 +20,14 @@ namespace xo { class DVsmRcx { public: using AAllocator = xo::mm::AAllocator; + using MemorySizeVisitor = xo::mm::MemorySizeVisitor; public: DVsmRcx(VirtualSchematikaMachine * vsm); obj allocator() const noexcept; obj error_allocator() const noexcept; + void visit_pools(const MemorySizeVisitor & visitor) const; private: /** schematika interpreter **/ @@ -34,4 +37,3 @@ namespace xo { } /*namespace xo*/ /* end DVsmRcx.hpp */ - diff --git a/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp b/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp index ecb81f1f..0305e3e5 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 MemorySizeVisitor = xo::scm::ARuntimeContext::MemorySizeVisitor; using Copaque = xo::scm::ARuntimeContext::Copaque; using Opaque = xo::scm::ARuntimeContext::Opaque; ///@} @@ -48,6 +49,8 @@ namespace xo { // const methods /** default allocator to use for objects **/ static obj allocator(const DVsmRcx & self) noexcept; + /** invoke visitor for each distinct memory pool **/ + static void visit_pools(const DVsmRcx & self, MemorySizeVisitor visitor); // non-const methods ///@} diff --git a/src/interpreter2/DVsmRcx.cpp b/src/interpreter2/DVsmRcx.cpp index 71916771..fa81b9c8 100644 --- a/src/interpreter2/DVsmRcx.cpp +++ b/src/interpreter2/DVsmRcx.cpp @@ -25,6 +25,12 @@ namespace xo { return vsm_->error_allocator(); } + void + DVsmRcx::visit_pools(const MemorySizeVisitor & visitor) const + { + vsm_->visit_pools(visitor); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/IRuntimeContext_DVsmRcx.cpp b/src/interpreter2/IRuntimeContext_DVsmRcx.cpp index 3fd3730d..d201051a 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::visit_pools(const DVsmRcx & self, MemorySizeVisitor visitor) -> void + { + self.visit_pools(visitor); + } + } /*namespace scm*/ } /*namespace xo*/