xo-interpreter2: scaffold repl + alloc measurement frameowkr

This commit is contained in:
Roland Conybeare 2026-02-02 21:55:34 -05:00
commit 438e92d51b
2 changed files with 23 additions and 0 deletions

View file

@ -21,6 +21,7 @@ namespace xo {
class StringTable {
public:
using DArena = xo::mm::DArena;
using MemorySizeInfo = xo::mm::MemorySizeInfo;
using StringMap = xo::map::DArenaHashMap<std::string_view,
DUniqueString*>;
using size_type = StringMap::size_type;
@ -45,6 +46,9 @@ namespace xo {
**/
bool verify_ok(verify_policy p = verify_policy::throw_only()) const;
std::size_t _n_store() const noexcept;
MemorySizeInfo _store_info(std::size_t i) const noexcept;
private:
/** allocate string storage in this arena; use DString to represent each string.
* Can't use DArenaVector b/c DString has variable size

View file

@ -10,6 +10,7 @@
namespace xo {
using xo::mm::ArenaConfig;
using xo::mm::AAllocator;
using xo::mm::MemorySizeInfo;
using xo::facet::with_facet;
using xo::facet::obj;
@ -159,6 +160,24 @@ namespace xo {
return true;
}
std::size_t
StringTable::_n_store() const noexcept
{
return 1 + map_._n_store();
}
MemorySizeInfo
StringTable::_store_info(std::size_t i) const noexcept
{
if (i == 0)
return strings_._store_info();
if (i+1 < map_._n_store())
return map_._store_info(i-1);
return MemorySizeInfo::sentinel();
}
} /*namespace scm*/
} /*namespace xo*/