xo-interpreter2 stack: + reason arg to visit_gco_children()

Helps streamline DX1Collector in xo-gc/.
Want both forward and verify entry points for the same
representation.
This commit is contained in:
Roland Conybeare 2026-04-10 01:10:03 -04:00
commit 4fdaa64085
28 changed files with 58 additions and 61 deletions

View file

@ -38,6 +38,8 @@ namespace xo {
using AGCObject = xo::mm::AGCObject;
/** gc-centric object visitor **/
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
/** hint for object visitor **/
using VisitReason = xo::mm::VisitReason;
/** pretty-printer state for APrintable **/
using ppindentinfo = xo::print::ppindentinfo;
@ -150,7 +152,7 @@ namespace xo {
/** move to new address, mandated by @p gc **/
DArray * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
/** forward elements to @p gc to-space; replace originals with forarding pointers **/
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(VisitReason reason, obj<AGCObjectVisitor> gc) noexcept;
///@}
private:

View file

@ -19,6 +19,7 @@ namespace xo {
//using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AGCObject = xo::mm::AGCObject;
using VisitReason = xo::mm::VisitReason;
using ppindentinfo = xo::print::ppindentinfo;
using value_type = long;
@ -40,7 +41,7 @@ namespace xo {
// GCObject facet
DBoolean * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(VisitReason reason, obj<AGCObjectVisitor> gc) noexcept;
private:
/** boxed boolean value **/

View file

@ -40,6 +40,8 @@ namespace xo {
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
/** gc-aware object facet **/
using AGCObject = xo::mm::AGCObject;
/** color for gco visitor **/
using VisitReason = xo::mm::VisitReason;
/** pretty-printer state for APrintable **/
using ppindentinfo = xo::print::ppindentinfo;
/** canonical type representing a key-value pair **/
@ -206,7 +208,7 @@ namespace xo {
/** return shallow copy of this array, using memory from @p mm **/
DDictionary * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
/** forward elements to @p gc to-space; replace originals with forwarding pointers **/
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(VisitReason reason, obj<AGCObjectVisitor> gc) noexcept;
///@}
private:

View file

@ -6,7 +6,6 @@
#pragma once
#include <xo/alloc2/Allocator.hpp>
//#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/facet/obj.hpp>
#include <xo/indentlog/print/ppindentinfo.hpp>
@ -15,8 +14,8 @@ namespace xo {
namespace scm {
struct DFloat {
using AAllocator = xo::mm::AAllocator;
//using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using VisitReason = xo::mm::VisitReason;
using ppindentinfo = xo::print::ppindentinfo;
using value_type = double;
@ -37,7 +36,7 @@ namespace xo {
// GCObject facet
DFloat * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(VisitReason reason, obj<AGCObjectVisitor> gc) noexcept;
private:

View file

@ -19,6 +19,7 @@ namespace xo {
//using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AGCObject = xo::mm::AGCObject;
using VisitReason = xo::mm::VisitReason;
using ppindentinfo = xo::print::ppindentinfo;
using value_type = long;
@ -42,7 +43,7 @@ namespace xo {
// GCObject facet
DInteger * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(VisitReason reason, obj<AGCObjectVisitor> gc) noexcept;
private:
/** boxed integer value **/

View file

@ -22,6 +22,7 @@ namespace xo {
using AAllocator = xo::mm::AAllocator;
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using VisitReason = xo::mm::VisitReason;
using ppindentinfo = xo::print::ppindentinfo;
public:
@ -75,7 +76,7 @@ namespace xo {
/** @defgroup xo-scm-list-gcobject-facet gcobject facet **/
///@{
DList * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(VisitReason reason, obj<AGCObjectVisitor> gc) noexcept;
///@}
/** first member of list **/

View file

@ -19,6 +19,7 @@ namespace xo {
using AGCObject = xo::mm::AGCObject;
//using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using VisitReason = xo::mm::VisitReason;
using AAllocator = xo::mm::AAllocator;
using ppindentinfo = xo::print::ppindentinfo;
@ -51,7 +52,7 @@ namespace xo {
///@{
DRuntimeError * gco_shallow_move(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
void visit_gco_children(VisitReason reason, obj<AGCObjectVisitor> gc) noexcept;
///@}

View file

@ -43,6 +43,7 @@ namespace xo {
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using VisitReason = xo::mm::AGCObject::VisitReason;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -57,7 +58,7 @@ Arguably abusing the word 'visitor' here **/
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DArray & self, obj<AGCObjectVisitor> fn) noexcept;
static void visit_gco_children(DArray & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -43,6 +43,7 @@ namespace xo {
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using VisitReason = xo::mm::AGCObject::VisitReason;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -57,7 +58,7 @@ Arguably abusing the word 'visitor' here **/
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DBoolean & self, obj<AGCObjectVisitor> fn) noexcept;
static void visit_gco_children(DBoolean & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -43,6 +43,7 @@ namespace xo {
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using VisitReason = xo::mm::AGCObject::VisitReason;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -57,7 +58,7 @@ Arguably abusing the word 'visitor' here **/
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DDictionary & self, obj<AGCObjectVisitor> fn) noexcept;
static void visit_gco_children(DDictionary & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -43,6 +43,7 @@ namespace xo {
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using VisitReason = xo::mm::AGCObject::VisitReason;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -57,7 +58,7 @@ Arguably abusing the word 'visitor' here **/
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DRuntimeError & self, obj<AGCObjectVisitor> fn) noexcept;
static void visit_gco_children(DRuntimeError & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -43,6 +43,7 @@ namespace xo {
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using VisitReason = xo::mm::AGCObject::VisitReason;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -57,7 +58,7 @@ Arguably abusing the word 'visitor' here **/
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DList & self, obj<AGCObjectVisitor> fn) noexcept;
static void visit_gco_children(DList & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using VisitReason = xo::mm::AGCObject::VisitReason;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -58,7 +59,7 @@ Arguably abusing the word 'visitor' here **/
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DFloat & self, obj<AGCObjectVisitor> fn) noexcept;
static void visit_gco_children(DFloat & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -43,6 +43,7 @@ namespace xo {
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using VisitReason = xo::mm::AGCObject::VisitReason;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -57,7 +58,7 @@ Arguably abusing the word 'visitor' here **/
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DInteger & self, obj<AGCObjectVisitor> fn) noexcept;
static void visit_gco_children(DInteger & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -198,16 +198,12 @@ namespace xo {
}
void
DArray::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
DArray::visit_gco_children(VisitReason reason, obj<AGCObjectVisitor> gc) noexcept
{
scope log(XO_DEBUG(false));
for (size_type i = 0; i < size_; ++i) {
log && log("DArray::visit_gco_children (loop)", xtag("i", i), xtag("z", size_));
obj<AGCObject> & elt = elts_[i];
gc.visit_child(&elt);
gc.visit_child(reason, &elt);
}
}

View file

@ -36,7 +36,7 @@ namespace xo {
}
void
DBoolean::visit_gco_children(obj<AGCObjectVisitor>) noexcept
DBoolean::visit_gco_children(VisitReason, obj<AGCObjectVisitor>) noexcept
{
// no-op. childless
}

View file

@ -274,10 +274,10 @@ namespace xo {
}
void
DDictionary::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
DDictionary::visit_gco_children(VisitReason reason, obj<AGCObjectVisitor> gc) noexcept
{
gc.visit_child(&keys_);
gc.visit_child(&values_);
gc.visit_child(reason, &keys_);
gc.visit_child(reason, &values_);
}
} /*namespace scm*/

View file

@ -34,7 +34,7 @@ namespace xo {
}
void
DFloat::visit_gco_children(obj<AGCObjectVisitor>) noexcept
DFloat::visit_gco_children(VisitReason, obj<AGCObjectVisitor>) noexcept
{
// noop -- childless!
}

View file

@ -34,7 +34,7 @@ namespace xo {
}
void
DInteger::visit_gco_children(obj<AGCObjectVisitor>) noexcept
DInteger::visit_gco_children(VisitReason, obj<AGCObjectVisitor>) noexcept
{
// no-op. childless
}

View file

@ -185,12 +185,10 @@ namespace xo {
}
void
DList::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
DList::visit_gco_children(VisitReason reason, obj<AGCObjectVisitor> gc) noexcept
{
//scope log(XO_DEBUG(true));
gc.visit_child(&head_);
gc.visit_child(&rest_);
gc.visit_child(reason, &head_);
gc.visit_child(reason, &rest_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -59,21 +59,10 @@ namespace xo {
}
void
DRuntimeError::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
DRuntimeError::visit_gco_children(VisitReason reason, obj<AGCObjectVisitor> gc) noexcept
{
{
gc.visit_child(&src_function_);
//auto iface = xo::facet::impl_for<AGCObject,DString>();
//gc.forward_inplace(&iface, (void **)(&src_function_));
}
{
gc.visit_child(&error_descr_);
//auto iface = xo::facet::impl_for<AGCObject,DString>();
//gc.forward_inplace(&iface, (void **)(&error_descr_));
}
gc.visit_child(reason, &src_function_);
gc.visit_child(reason, &error_descr_);
}
// ----- Printable facet -----

View file

@ -21,9 +21,9 @@ namespace xo {
return self.gco_shallow_move(gc);
}
auto
IGCObject_DArray::visit_gco_children(DArray & self, obj<AGCObjectVisitor> fn) noexcept -> void
IGCObject_DArray::visit_gco_children(DArray & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.visit_gco_children(fn);
self.visit_gco_children(reason, fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.gco_shallow_move(gc);
}
auto
IGCObject_DBoolean::visit_gco_children(DBoolean & self, obj<AGCObjectVisitor> fn) noexcept -> void
IGCObject_DBoolean::visit_gco_children(DBoolean & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.visit_gco_children(fn);
self.visit_gco_children(reason, fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.gco_shallow_move(gc);
}
auto
IGCObject_DDictionary::visit_gco_children(DDictionary & self, obj<AGCObjectVisitor> fn) noexcept -> void
IGCObject_DDictionary::visit_gco_children(DDictionary & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.visit_gco_children(fn);
self.visit_gco_children(reason, fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.gco_shallow_move(gc);
}
auto
IGCObject_DFloat::visit_gco_children(DFloat & self, obj<AGCObjectVisitor> fn) noexcept -> void
IGCObject_DFloat::visit_gco_children(DFloat & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.visit_gco_children(fn);
self.visit_gco_children(reason, fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.gco_shallow_move(gc);
}
auto
IGCObject_DInteger::visit_gco_children(DInteger & self, obj<AGCObjectVisitor> fn) noexcept -> void
IGCObject_DInteger::visit_gco_children(DInteger & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.visit_gco_children(fn);
self.visit_gco_children(reason, fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.gco_shallow_move(gc);
}
auto
IGCObject_DList::visit_gco_children(DList & self, obj<AGCObjectVisitor> fn) noexcept -> void
IGCObject_DList::visit_gco_children(DList & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.visit_gco_children(fn);
self.visit_gco_children(reason, fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.gco_shallow_move(gc);
}
auto
IGCObject_DRuntimeError::visit_gco_children(DRuntimeError & self, obj<AGCObjectVisitor> fn) noexcept -> void
IGCObject_DRuntimeError::visit_gco_children(DRuntimeError & self, VisitReason reason, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.visit_gco_children(fn);
self.visit_gco_children(reason, fn);
}
} /*namespace scm*/