From ce6fa08abb05b27cdbbf502744434e4869fba08c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 19 Nov 2025 21:34:13 -0500 Subject: [PATCH] xo-interpreter: ObjectConverter + VirtualSchmatikaMachineFlyweight --- include/xo/reflect/TypeDrivenMap.hpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/include/xo/reflect/TypeDrivenMap.hpp b/include/xo/reflect/TypeDrivenMap.hpp index 3eb4266..d972780 100644 --- a/include/xo/reflect/TypeDrivenMap.hpp +++ b/include/xo/reflect/TypeDrivenMap.hpp @@ -14,21 +14,24 @@ namespace xo { template class TypeDrivenMap { public: - Value const * lookup(TypeId id) const { return this->lookup_slot(id); } + TypeDrivenMap() = default; + + const Value * lookup(TypeId id) const { return this->lookup_slot(id); } + const Value * lookup(TypeDescr td) { return this->lookup_slot(td->id()); } Value * require(TypeId id) { return this->require_slot(id); } Value * require(TypeDescr td) { return this->require_slot(td->id()); } private: - Value const * lookup_slot(TypeId id) const { - if (this->contents_v_.size() <= id.id()) + const Value * lookup_slot(TypeId id) const { + if (contents_v_.size() <= id.id()) return nullptr; return &(this->contents_v_[id.id()]); } /*lookup_slot*/ Value * require_slot(TypeId id) { - if (this->contents_v_.size() <= id.id()) + if (contents_v_.size() <= id.id()) this->contents_v_.resize(id.id() + 1); return &(this->contents_v_[id.id()]);