refactor: + narrower interface for gc pointer forwarding

add AGCObjectVisitor, instead of requiring ACollector.
This commit is contained in:
Roland Conybeare 2026-04-05 23:53:02 -04:00
commit fdc3054c7c
46 changed files with 187 additions and 165 deletions

View file

@ -8,6 +8,7 @@
#include "Expression.hpp"
#include "TypeRef.hpp"
#include "exprtype.hpp"
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/object2/DArray.hpp>
#include <xo/reflect/TypeDescr.hpp>
#include <xo/indentlog/print/pretty.hpp>
@ -21,6 +22,7 @@ namespace xo {
class DApplyExpr {
public:
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
using ppindentinfo = xo::print::ppindentinfo;
@ -84,7 +86,7 @@ namespace xo {
std::size_t shallow_size() const noexcept;
DApplyExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-applyexpr-printable-facet **/

View file

@ -10,6 +10,7 @@
#include "exprtype.hpp"
#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/reflect/TaggedPtr.hpp>
namespace xo {
@ -22,8 +23,9 @@ namespace xo {
using TaggedPtr = xo::reflect::TaggedPtr;
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using AGCObject = xo::mm::AGCObject;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using typeseq = xo::reflect::typeseq;
using ppindentinfo = xo::print::ppindentinfo;
@ -64,7 +66,7 @@ namespace xo {
size_t shallow_size() const noexcept;
DConstant * shallow_move(obj<ACollector> gc) noexcept;
size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-constant-printable-facet **/

View file

@ -8,6 +8,7 @@
#include "Expression.hpp"
#include "DVariable.hpp"
#include <xo/alloc2/Allocator.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/indentlog/print/pretty.hpp>
namespace xo {
@ -24,6 +25,7 @@ namespace xo {
public:
using ppindentinfo = xo::print::ppindentinfo;
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
@ -74,7 +76,7 @@ namespace xo {
std::size_t shallow_size() const noexcept;
DDefineExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-defineexpr-printable-facet **/

View file

@ -9,6 +9,7 @@
#include "DVariable.hpp"
#include "DTypename.hpp"
#include <xo/object2/DArray.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/alloc2/dp.hpp>
#include <xo/arena/DArenaHashMap.hpp>
@ -30,8 +31,9 @@ namespace xo {
using ArenaHashMapConfig = xo::map::ArenaHashMapConfig;
using repr_type = xo::map::DArenaHashMap<key_type, Binding::slot_type>;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using AGCObject = xo::mm::AGCObject;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using MemorySizeVisitor = xo::mm::MemorySizeVisitor;
using ppindentinfo = xo::print::ppindentinfo;
using size_type = std::uint32_t;
@ -113,9 +115,8 @@ namespace xo {
/** @defgroup scm-globalsymtab-gcobject-facet gcobject facet **/
///@{
std::size_t shallow_size() const noexcept;
DGlobalSymtab * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-globalsymtab-printable-facet printable facet **/

View file

@ -9,10 +9,9 @@
#include "TypeRef.hpp"
#include "exprtype.hpp"
#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/alloc2/Allocator.hpp>
//#include <vector>
#include <string>
//#include <cstdint>
namespace xo {
namespace scm {
@ -23,6 +22,7 @@ namespace xo {
class DIfElseExpr {
public:
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
using ppindentinfo = xo::print::ppindentinfo;
@ -100,7 +100,7 @@ namespace xo {
std::size_t shallow_size() const noexcept;
DIfElseExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}

View file

@ -10,6 +10,7 @@
#include "exprtype.hpp"
#include "DLocalSymtab.hpp"
#include "DString.hpp"
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/facet/obj.hpp>
namespace xo {
@ -21,6 +22,7 @@ namespace xo {
class DLambdaExpr {
public:
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
using ppindentinfo = xo::print::ppindentinfo;
@ -86,7 +88,7 @@ namespace xo {
std::size_t shallow_size() const noexcept;
DLambdaExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-lambdaexpr-printable-facet **/

View file

@ -9,6 +9,7 @@
#include "DVariable.hpp"
#include "DUniqueString.hpp"
#include <xo/object2/DArray.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
namespace xo {
namespace scm {
@ -20,8 +21,9 @@ namespace xo {
using DArray = xo::scm::DArray;
using ppindentinfo = xo::print::ppindentinfo;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using AGCObject = xo::mm::AGCObject;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
/* note: uint16_t would be fine too */
using size_type = std::uint32_t;
@ -97,9 +99,8 @@ namespace xo {
/** @defgroup xo-localsymtab-gcobject-facet gcobject facet **/
///@{
std::size_t shallow_size() const noexcept;
DLocalSymtab * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup xo-localsymtab-printable-facet printable facet **/

View file

@ -8,6 +8,7 @@
#include "Expression.hpp"
#include "TypeRef.hpp"
#include <xo/object2/DArray.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
namespace xo {
namespace scm {
@ -23,6 +24,7 @@ namespace xo {
class DSequenceExpr {
public:
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
using size_type = DArray::size_type;
@ -74,7 +76,7 @@ namespace xo {
std::size_t shallow_size() const noexcept;
DSequenceExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}

View file

@ -7,6 +7,7 @@
#include "DUniqueString.hpp"
#include <xo/type/Type.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/printable2/Printable.hpp>
#include <xo/indentlog/print/pretty.hpp>
@ -24,8 +25,9 @@ namespace xo {
public:
using ppindentinfo = xo::print::ppindentinfo;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AGCObject = xo::mm::AGCObject;
using AAllocator = xo::mm::AAllocator;
public:
DTypename(const DUniqueString * name,
@ -55,7 +57,7 @@ namespace xo {
size_t shallow_size() const noexcept;
DTypename * shallow_move(obj<ACollector> gc) noexcept;
size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-typename-printable-facet **/

View file

@ -6,6 +6,7 @@
#pragma once
#include "Variable.hpp"
#include <xo/alloc2/GCObjectVisitor.hpp>
namespace xo {
namespace scm {
@ -21,6 +22,7 @@ namespace xo {
public:
using ppindentinfo = xo::print::ppindentinfo;
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
@ -56,7 +58,7 @@ namespace xo {
size_t shallow_size() const noexcept;
DVarRef * shallow_move(obj<ACollector> gc) noexcept;
size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-variable-printable-facet **/

View file

@ -9,6 +9,7 @@
#include "Binding.hpp"
#include "TypeRef.hpp"
#include "exprtype.hpp"
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/reflect/TypeDescr.hpp>
#include <xo/indentlog/print/pretty.hpp>
@ -22,6 +23,7 @@ namespace xo {
public:
using ppindentinfo = xo::print::ppindentinfo;
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
@ -64,7 +66,7 @@ namespace xo {
size_t shallow_size() const noexcept;
DVariable * shallow_move(obj<ACollector> gc) noexcept;
size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-variable-printable-facet **/

View file

@ -8,6 +8,7 @@
#include <xo/type/Type.hpp>
#include <xo/reflect/TypeDescr.hpp>
#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/flatstring/flatstring.hpp>
#include <xo/indentlog/print/pretty.hpp>
@ -26,6 +27,7 @@ namespace xo {
using type_var = flatstring<20>;
using prefix_type = flatstring<8>;
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using ppindentinfo = xo::print::ppindentinfo;
public:
@ -73,7 +75,7 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
/** gc support **/
void forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
private:
TypeRef(const type_var & id, TypeDescr td);

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DDefineExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DDefineExpr & self, obj<ACollector> gc) noexcept;
/** 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(DDefineExpr & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DApplyExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DApplyExpr & self, obj<ACollector> gc) noexcept;
/** 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(DApplyExpr & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DConstant & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DConstant & self, obj<ACollector> gc) noexcept;
/** 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(DConstant & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DIfElseExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DIfElseExpr & self, obj<ACollector> gc) noexcept;
/** 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(DIfElseExpr & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DLambdaExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DLambdaExpr & self, obj<ACollector> gc) noexcept;
/** 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(DLambdaExpr & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DSequenceExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DSequenceExpr & self, obj<ACollector> gc) noexcept;
/** 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(DSequenceExpr & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DVarRef & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DVarRef & self, obj<ACollector> gc) noexcept;
/** 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(DVarRef & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DGlobalSymtab & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DGlobalSymtab & self, obj<ACollector> gc) noexcept;
/** 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(DGlobalSymtab & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DLocalSymtab & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DLocalSymtab & self, obj<ACollector> gc) noexcept;
/** 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(DLocalSymtab & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -42,6 +42,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -52,8 +53,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DTypename & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DTypename & self, obj<ACollector> gc) noexcept;
/** 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(DTypename & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DVariable & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DVariable & self, obj<ACollector> gc) noexcept;
/** 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(DVariable & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -129,27 +129,25 @@ namespace xo {
return copy;
}
std::size_t
DApplyExpr::forward_children(obj<ACollector> gc) noexcept
void
DApplyExpr::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
typeref_.forward_children(gc);
typeref_.visit_gco_children(gc);
{
obj<AGCObject> fn_gco = fn_.to_facet<AGCObject>();
gc.forward_inplace(fn_gco.iface(), (void **)&fn_.data_);
gc.visit_poly_child(&fn_);
//obj<AGCObject> fn_gco = fn_.to_facet<AGCObject>();
//gc.forward_inplace(fn_gco.iface(), (void **)&fn_.data_);
}
for (size_type i = 0; i < n_args_; ++i) {
obj<AExpression> & arg = args_[i];
// runtime poly here
obj<AGCObject> arg_gco = arg.to_facet<AGCObject>();
// need the data address within *this
gc.forward_inplace(arg_gco.iface(), (void **)(&arg.data_));
gc.visit_poly_child(&arg);
//obj<AGCObject> arg_gco = arg.to_facet<AGCObject>();
//gc.forward_inplace(arg_gco.iface(), (void **)(&arg.data_));
}
return shallow_size();
}
// ----- printable facet -----

View file

@ -83,15 +83,12 @@ namespace xo {
return gc.std_move_for(this);
}
std::size_t
DConstant::forward_children(obj<ACollector> gc) noexcept
void
DConstant::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
typeref_.forward_children(gc);
typeref_.visit_gco_children(gc);
gc.forward_inplace(&value_);
//gc.forward_inplace(value_.iface(), (void **)&(value_.data_));
return shallow_size();
gc.visit_child(&value_);
}
bool

View file

@ -90,14 +90,12 @@ namespace xo {
return gc.std_move_for(this);
}
std::size_t
DDefineExpr::forward_children(obj<ACollector> gc) noexcept
void
DDefineExpr::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_inplace(&lhs_var_);
gc.visit_child(&lhs_var_);
//gc.forward_inplace(&rhs_); // complicated - need to access via GCObject facet
poly_forward_inplace(gc, &rhs_);
return this->shallow_size();
gc.visit_poly_child(&rhs_);
}
bool

View file

@ -262,30 +262,22 @@ namespace xo {
// ----- gcobject facet -----
std::size_t
DGlobalSymtab::shallow_size() const noexcept
{
return sizeof(DGlobalSymtab);
}
DGlobalSymtab *
DGlobalSymtab::shallow_move(obj<ACollector> gc) noexcept
{
return gc.std_move_for(this);
}
std::size_t
DGlobalSymtab::forward_children(obj<ACollector> gc) noexcept
void
DGlobalSymtab::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
// map_ doesn't contain any gc-owned data, can skip
static_assert(var_map_.is_gc_eligible() == false);
static_assert(type_map_.is_gc_eligible() == false);
gc.forward_inplace(&vars_);
gc.forward_inplace(&types_);
return this->shallow_size();
gc.visit_child(&vars_);
gc.visit_child(&types_);
}
// ----- printable facet -----

View file

@ -94,26 +94,27 @@ namespace xo {
return gc.std_move_for(this);
}
std::size_t
DIfElseExpr::forward_children(obj<ACollector> gc) noexcept
void
DIfElseExpr::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
typeref_.forward_children(gc);
typeref_.visit_gco_children(gc);
// GC needs to locate AGCObject iface for each member.
{
auto gco = test_.to_facet<AGCObject>();
gc.forward_inplace(gco.iface(), (void **)&(test_.data_));
gc.visit_poly_child(&test_);
//auto gco = test_.to_facet<AGCObject>();
//gc.forward_inplace(gco.iface(), (void **)&(test_.data_));
}
{
auto gco = when_true_.to_facet<AGCObject>();
gc.forward_inplace(gco.iface(), (void **)&(when_true_.data_));
gc.visit_poly_child(&when_true_);
//auto gco = when_true_.to_facet<AGCObject>();
//gc.forward_inplace(gco.iface(), (void **)&(when_true_.data_));
}
{
auto gco = when_false_.to_facet<AGCObject>();
gc.forward_inplace(gco.iface(), (void **)&(when_false_.data_));
gc.visit_poly_child(&when_false_);
//auto gco = when_false_.to_facet<AGCObject>();
//gc.forward_inplace(gco.iface(), (void **)&(when_false_.data_));
}
return shallow_size();
}
// ----- printable facet -----

View file

@ -13,6 +13,7 @@
namespace xo {
using xo::mm::AGCObject;
using xo::mm::AGCObjectVisitor;
using xo::print::APrintable;
using xo::facet::FacetRegistry;
using xo::reflect::TypeDescr;
@ -144,36 +145,32 @@ namespace xo {
return gc.std_move_for(this);
}
std::size_t
DLambdaExpr::forward_children(obj<ACollector> gc) noexcept {
typeref_.forward_children(gc);
void
DLambdaExpr::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept {
typeref_.visit_gco_children(gc);
{
//gc.forward_inplace(&name_); // doesn't compile for const ptr
auto iface = xo::facet::impl_for<AGCObject,DUniqueString>();
gc.forward_inplace(&iface, (void **)(&name_));
}
gc.visit_child(&name_);
//{
// auto iface = xo::facet::impl_for<AGCObject,DUniqueString>();
// gc.forward_inplace(&iface, (void **)(&name_));
//}
// type_name_str_
{
gc.forward_inplace(&local_symtab_);
//auto iface = xo::facet::impl_for<AGCObject,DLocalSymtab>();
//gc.forward_inplace(&iface, (void **)(&local_symtab_));
gc.visit_child(&local_symtab_);
//gc.forward_inplace(&local_symtab_);
}
{
gc.forward_pivot_inplace(&body_expr_);
//auto iface = body_expr_.to_facet<AGCObject>().iface();
//gc.forward_inplace(iface, (void **)&(body_expr_.data_));
gc.visit_poly_child(&body_expr_);
//gc.forward_pivot_inplace(&body_expr_);
}
// xxx free_var_set
// xxx captured_var_set
// xxx layer_var_map
// xxx nested_lambda_map
return shallow_size();
}
bool

View file

@ -112,26 +112,18 @@ namespace xo {
// ----- gcobject facet -----
std::size_t
DLocalSymtab::shallow_size() const noexcept
{
return sizeof(DLocalSymtab);
}
DLocalSymtab *
DLocalSymtab::shallow_move(obj<ACollector> gc) noexcept
{
return gc.std_move_for(this);
}
std::size_t
DLocalSymtab::forward_children(obj<ACollector> gc) noexcept
void
DLocalSymtab::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_inplace(&parent_);
gc.forward_inplace(&vars_);
gc.forward_inplace(&types_);
return shallow_size();
gc.visit_child(&parent_);
gc.visit_child(&vars_);
gc.visit_child(&types_);
}
// ----- printable facet -----

View file

@ -125,14 +125,12 @@ namespace xo {
return gc.std_move_for(this);
}
std::size_t
DSequenceExpr::forward_children(obj<ACollector> gc) noexcept
void
DSequenceExpr::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
typeref_.forward_children(gc);
typeref_.visit_gco_children(gc);
gc.forward_inplace(&expr_v_);
return this->shallow_size();
gc.visit_child(&expr_v_);
}
} /*namespace scm*/

View file

@ -52,16 +52,16 @@ namespace xo {
return gc.std_move_for(this);
}
size_t
DTypename::forward_children(obj<ACollector> gc) noexcept
void
DTypename::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_inplace(const_cast<DUniqueString**>(&name_));
gc.visit_child(&name_);
//gc.forward_inplace(const_cast<DUniqueString**>(&name_));
{
auto e = type_.to_facet<AGCObject>();
gc.forward_inplace(e.iface(), (void **)&(type_.data_));
gc.visit_poly_child(&type_);
//auto e = type_.to_facet<AGCObject>();
//gc.forward_inplace(e.iface(), (void **)&(type_.data_));
}
return shallow_size();
}
bool

View file

@ -70,16 +70,14 @@ namespace xo {
return gc.std_move_for(this);
}
std::size_t
DVarRef::forward_children(obj<ACollector> gc) noexcept
void
DVarRef::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_inplace(&vardef_);
gc.visit_child(&vardef_);
//auto iface = xo::facet::impl_for<AGCObject,DVariable>();
//gc.forward_inplace(&iface, (void **)vardef_.data_);
// TODO: concept to indicate that no gc pointers in Binding
return shallow_size();
}
// printable facet

View file

@ -50,12 +50,10 @@ namespace xo {
return gc.std_move_for(this);
}
size_t
DVariable::forward_children(obj<ACollector> gc) noexcept
void
DVariable::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
typeref_.forward_children(gc);
return shallow_size();
typeref_.visit_gco_children(gc);
}
bool

View file

@ -21,9 +21,9 @@ namespace xo {
return self.shallow_move(gc);
}
auto
IGCObject_DApplyExpr::forward_children(DApplyExpr & self, obj<ACollector> gc) noexcept -> void
IGCObject_DApplyExpr::visit_gco_children(DApplyExpr & self, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.forward_children(gc);
self.visit_gco_children(fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.shallow_move(gc);
}
auto
IGCObject_DConstant::forward_children(DConstant & self, obj<ACollector> gc) noexcept -> void
IGCObject_DConstant::visit_gco_children(DConstant & self, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.forward_children(gc);
self.visit_gco_children(fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.shallow_move(gc);
}
auto
IGCObject_DDefineExpr::forward_children(DDefineExpr & self, obj<ACollector> gc) noexcept -> void
IGCObject_DDefineExpr::visit_gco_children(DDefineExpr & self, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.forward_children(gc);
self.visit_gco_children(fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.shallow_move(gc);
}
auto
IGCObject_DGlobalSymtab::forward_children(DGlobalSymtab & self, obj<ACollector> gc) noexcept -> void
IGCObject_DGlobalSymtab::visit_gco_children(DGlobalSymtab & self, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.forward_children(gc);
self.visit_gco_children(fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.shallow_move(gc);
}
auto
IGCObject_DIfElseExpr::forward_children(DIfElseExpr & self, obj<ACollector> gc) noexcept -> void
IGCObject_DIfElseExpr::visit_gco_children(DIfElseExpr & self, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.forward_children(gc);
self.visit_gco_children(fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.shallow_move(gc);
}
auto
IGCObject_DLambdaExpr::forward_children(DLambdaExpr & self, obj<ACollector> gc) noexcept -> void
IGCObject_DLambdaExpr::visit_gco_children(DLambdaExpr & self, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.forward_children(gc);
self.visit_gco_children(fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.shallow_move(gc);
}
auto
IGCObject_DLocalSymtab::forward_children(DLocalSymtab & self, obj<ACollector> gc) noexcept -> void
IGCObject_DLocalSymtab::visit_gco_children(DLocalSymtab & self, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.forward_children(gc);
self.visit_gco_children(fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.shallow_move(gc);
}
auto
IGCObject_DSequenceExpr::forward_children(DSequenceExpr & self, obj<ACollector> gc) noexcept -> void
IGCObject_DSequenceExpr::visit_gco_children(DSequenceExpr & self, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.forward_children(gc);
self.visit_gco_children(fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.shallow_move(gc);
}
auto
IGCObject_DTypename::forward_children(DTypename & self, obj<ACollector> gc) noexcept -> void
IGCObject_DTypename::visit_gco_children(DTypename & self, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.forward_children(gc);
self.visit_gco_children(fn);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.shallow_move(gc);
}
auto
IGCObject_DVarRef::forward_children(DVarRef & self, obj<ACollector> gc) noexcept -> void
IGCObject_DVarRef::visit_gco_children(DVarRef & self, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.forward_children(gc);
self.visit_gco_children(fn);
}
} /*namespace scm*/

View file

@ -102,11 +102,11 @@ namespace xo {
}
void
TypeRef::forward_children(obj<ACollector> gc) noexcept
TypeRef::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
//scope log(XO_DEBUG(true), xtag("type", type_.data()), xtag("type.tseq", type_._typeseq()));
gc.forward_pivot_inplace(&type_);
gc.visit_poly_child(&type_);
}
bool

View file

@ -21,9 +21,9 @@ namespace xo {
return self.shallow_move(gc);
}
auto
IGCObject_DVariable::forward_children(DVariable & self, obj<ACollector> gc) noexcept -> void
IGCObject_DVariable::visit_gco_children(DVariable & self, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.forward_children(gc);
self.visit_gco_children(fn);
}
} /*namespace scm*/