diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 5165c9a8..5aecbc55 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -61,14 +61,14 @@ namespace xo { using Stack = void *; using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; - using MemorySizeInfo = xo::mm::MemorySizeInfo; + using MemorySizeVisitor = xo::mm::MemorySizeVisitor; using span_type = xo::mm::span; public: VirtualSchematikaMachine(const VsmConfig & config); - size_t _n_store() const noexcept; - MemorySizeInfo _store_info(std::size_t i) const noexcept; + /** visit vsm-owned memory pools; call visitor(info) for each **/ + void visit_pools(const MemorySizeVisitor & visitor) const; /** begin interactive session. **/ void begin_interactive_session(); diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index d40b85c6..7c4873fb 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -30,20 +30,11 @@ namespace xo { reader_{config.rdr_config_, mm_.to_op()} {} - std::size_t - VirtualSchematikaMachine::_n_store() const noexcept + void + VirtualSchematikaMachine::visit_pools(const MemorySizeVisitor & visitor) const { - // oops. need something that goes through AAllocator api - - return reader_._n_store(); - } - - MemorySizeInfo - VirtualSchematikaMachine::_store_info(std::size_t i) const noexcept - { - // oops. need something poly that goes through AAllocator api - - return reader_._store_info(i); + mm_.visit_pools(visitor); + reader_.visit_pools(visitor); } void diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index a0554f87..2ad7122d 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -28,6 +28,7 @@ namespace xo { using xo::scm::VsmResultExt; using xo::scm::DFloat; using xo::mm::AGCObject; + using xo::mm::MemorySizeInfo; using span_type = xo::scm::VirtualSchematikaMachine::span_type; using Catch::Matchers::WithinAbs; @@ -55,6 +56,8 @@ namespace xo { namespace ut { TEST_CASE("VirtualSchematikaMachine-ctor", "[interpreter2][VSM]") { + scope log(XO_DEBUG(true)); + VsmConfig cfg; VirtualSchematikaMachine vsm(cfg); @@ -73,6 +76,15 @@ namespace xo { REQUIRE(res.remaining_.size() == 1); REQUIRE(*res.remaining_.lo() == '\n'); + + auto visitor = [&log](const MemorySizeInfo & info) { + log && log(xtag("resource", info.resource_name_), + xtag("alloc", info.allocated_), + xtag("commit", info.committed_), + xtag("resv", info.reserved_)); + }; + + vsm.visit_pools(visitor); } } /*namespace ut*/