xo-reader2: utest with variable reference. Works !

This commit is contained in:
Roland Conybeare 2026-02-16 23:25:34 -05:00
commit 57f6f9073e
5 changed files with 125 additions and 47 deletions

View file

@ -27,7 +27,7 @@ namespace xo {
Binding::print(std::ostream & os) const
{
if (i_link_ == c_link_global) {
os << "{path:global}";
os << "{path:global:" << j_slot_ << "}";
} else if (i_link_ == c_link_sentinel) {
os << "{path}";
} else {

View file

@ -69,6 +69,8 @@ namespace xo {
DGlobalSymtab::upsert_variable(obj<AAllocator> mm,
DVariable * var)
{
scope log(XO_DEBUG(true), std::string_view(*var->name()));
// It's possible there's already a global variable
// with the same name.
//
@ -78,6 +80,8 @@ namespace xo {
DVariable * existing = this->lookup_variable(var->name());
if (existing) {
log && log("variable with this symbol already exists");
if (existing == var) {
// impossible, but.. noop, right?
return;
@ -91,6 +95,8 @@ namespace xo {
//
(*vars_)[existing->path().j_slot()] = obj<AGCObject,DVariable>(var);
} else {
log && log("variable is new");
DArray::size_type n = vars_->size();
// NOTE: expansion of var_ array here is moot at present (Feb 2026),
@ -146,8 +152,7 @@ namespace xo {
{
assert(sym);
scope log(XO_DEBUG(true), "stub");
log && log(xtag("sym", std::string_view(*sym)));
scope log(XO_DEBUG(true), std::string_view(*sym));
auto ix = map_->find(sym);