diff --git a/include/xo/expression2/DApplyExpr.hpp b/include/xo/expression2/DApplyExpr.hpp index b4119def..0042d561 100644 --- a/include/xo/expression2/DApplyExpr.hpp +++ b/include/xo/expression2/DApplyExpr.hpp @@ -8,6 +8,7 @@ #include "Expression.hpp" #include "TypeRef.hpp" #include "exprtype.hpp" +#include #include #include #include @@ -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 gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-applyexpr-printable-facet **/ diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp index e78440ad..2c878ea9 100644 --- a/include/xo/expression2/DConstant.hpp +++ b/include/xo/expression2/DConstant.hpp @@ -10,6 +10,7 @@ #include "exprtype.hpp" #include #include +#include #include 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 gc) noexcept; - size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-constant-printable-facet **/ diff --git a/include/xo/expression2/DDefineExpr.hpp b/include/xo/expression2/DDefineExpr.hpp index 1e20c530..f1528531 100644 --- a/include/xo/expression2/DDefineExpr.hpp +++ b/include/xo/expression2/DDefineExpr.hpp @@ -8,6 +8,7 @@ #include "Expression.hpp" #include "DVariable.hpp" #include +#include #include 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 gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-defineexpr-printable-facet **/ diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index 782e48f7..a24c0bdc 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -9,6 +9,7 @@ #include "DVariable.hpp" #include "DTypename.hpp" #include +#include #include #include @@ -30,8 +31,9 @@ namespace xo { using ArenaHashMapConfig = xo::map::ArenaHashMapConfig; using repr_type = xo::map::DArenaHashMap; 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 gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-globalsymtab-printable-facet printable facet **/ diff --git a/include/xo/expression2/DIfElseExpr.hpp b/include/xo/expression2/DIfElseExpr.hpp index 8ffee429..b27c9ade 100644 --- a/include/xo/expression2/DIfElseExpr.hpp +++ b/include/xo/expression2/DIfElseExpr.hpp @@ -9,10 +9,9 @@ #include "TypeRef.hpp" #include "exprtype.hpp" #include +#include #include -//#include #include -//#include 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 gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DLambdaExpr.hpp b/include/xo/expression2/DLambdaExpr.hpp index 0d8d2391..2a507497 100644 --- a/include/xo/expression2/DLambdaExpr.hpp +++ b/include/xo/expression2/DLambdaExpr.hpp @@ -10,6 +10,7 @@ #include "exprtype.hpp" #include "DLocalSymtab.hpp" #include "DString.hpp" +#include #include 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 gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-lambdaexpr-printable-facet **/ diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index b2843cb9..f389c3ea 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -9,6 +9,7 @@ #include "DVariable.hpp" #include "DUniqueString.hpp" #include +#include 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 gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup xo-localsymtab-printable-facet printable facet **/ diff --git a/include/xo/expression2/DSequenceExpr.hpp b/include/xo/expression2/DSequenceExpr.hpp index f876cfac..76a8bec0 100644 --- a/include/xo/expression2/DSequenceExpr.hpp +++ b/include/xo/expression2/DSequenceExpr.hpp @@ -8,6 +8,7 @@ #include "Expression.hpp" #include "TypeRef.hpp" #include +#include 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 gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DTypename.hpp b/include/xo/expression2/DTypename.hpp index 7bd30931..2e35c9e3 100644 --- a/include/xo/expression2/DTypename.hpp +++ b/include/xo/expression2/DTypename.hpp @@ -7,6 +7,7 @@ #include "DUniqueString.hpp" #include +#include #include #include @@ -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 gc) noexcept; - size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-typename-printable-facet **/ diff --git a/include/xo/expression2/DVarRef.hpp b/include/xo/expression2/DVarRef.hpp index 65abddb2..db85d558 100644 --- a/include/xo/expression2/DVarRef.hpp +++ b/include/xo/expression2/DVarRef.hpp @@ -6,6 +6,7 @@ #pragma once #include "Variable.hpp" +#include 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 gc) noexcept; - size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-variable-printable-facet **/ diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp index 12abae94..2e74fbcc 100644 --- a/include/xo/expression2/DVariable.hpp +++ b/include/xo/expression2/DVariable.hpp @@ -9,6 +9,7 @@ #include "Binding.hpp" #include "TypeRef.hpp" #include "exprtype.hpp" +#include #include #include @@ -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 gc) noexcept; - size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-variable-printable-facet **/ diff --git a/include/xo/expression2/TypeRef.hpp b/include/xo/expression2/TypeRef.hpp index 1342b4df..f56028ba 100644 --- a/include/xo/expression2/TypeRef.hpp +++ b/include/xo/expression2/TypeRef.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -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 gc) noexcept; + void visit_gco_children(obj gc) noexcept; private: TypeRef(const type_var & id, TypeDescr td); diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp index c0e774c8..adb18480 100644 --- a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -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 gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DDefineExpr & self, obj 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 fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp index 477a9b77..86047bd7 100644 --- a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -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 gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DApplyExpr & self, obj 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 fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp index 6d631c74..823d0de9 100644 --- a/include/xo/expression2/detail/IGCObject_DConstant.hpp +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -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 gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DConstant & self, obj 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 fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp index c4917774..13d0e3e4 100644 --- a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -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 gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DIfElseExpr & self, obj 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 fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp index 6a484b28..077b0e3a 100644 --- a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -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 gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DLambdaExpr & self, obj 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 fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index 0bcf1f90..8d86241b 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -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 gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DSequenceExpr & self, obj 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 fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp index 91c1888c..71489ef4 100644 --- a/include/xo/expression2/detail/IGCObject_DVarRef.hpp +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -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 gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DVarRef & self, obj 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 fn) noexcept; ///@} }; diff --git a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp index 692be2fc..48cf1d7c 100644 --- a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -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 gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DGlobalSymtab & self, obj 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 fn) noexcept; ///@} }; diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp index 42de5a79..82717f96 100644 --- a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -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 gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DLocalSymtab & self, obj 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 fn) noexcept; ///@} }; diff --git a/include/xo/expression2/typename/IGCObject_DTypename.hpp b/include/xo/expression2/typename/IGCObject_DTypename.hpp index 3ed445aa..8c72100b 100644 --- a/include/xo/expression2/typename/IGCObject_DTypename.hpp +++ b/include/xo/expression2/typename/IGCObject_DTypename.hpp @@ -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 gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DTypename & self, obj 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 fn) noexcept; ///@} }; diff --git a/include/xo/expression2/variable/IGCObject_DVariable.hpp b/include/xo/expression2/variable/IGCObject_DVariable.hpp index 84c224cd..d04f3588 100644 --- a/include/xo/expression2/variable/IGCObject_DVariable.hpp +++ b/include/xo/expression2/variable/IGCObject_DVariable.hpp @@ -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 gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DVariable & self, obj 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 fn) noexcept; ///@} }; diff --git a/src/expression2/DApplyExpr.cpp b/src/expression2/DApplyExpr.cpp index 9683d459..18b9b60a 100644 --- a/src/expression2/DApplyExpr.cpp +++ b/src/expression2/DApplyExpr.cpp @@ -129,27 +129,25 @@ namespace xo { return copy; } - std::size_t - DApplyExpr::forward_children(obj gc) noexcept + void + DApplyExpr::visit_gco_children(obj gc) noexcept { - typeref_.forward_children(gc); + typeref_.visit_gco_children(gc); { - obj fn_gco = fn_.to_facet(); - gc.forward_inplace(fn_gco.iface(), (void **)&fn_.data_); + gc.visit_poly_child(&fn_); + //obj fn_gco = fn_.to_facet(); + //gc.forward_inplace(fn_gco.iface(), (void **)&fn_.data_); } for (size_type i = 0; i < n_args_; ++i) { obj & arg = args_[i]; // runtime poly here - obj arg_gco = arg.to_facet(); - - // need the data address within *this - gc.forward_inplace(arg_gco.iface(), (void **)(&arg.data_)); + gc.visit_poly_child(&arg); + //obj arg_gco = arg.to_facet(); + //gc.forward_inplace(arg_gco.iface(), (void **)(&arg.data_)); } - - return shallow_size(); } // ----- printable facet ----- diff --git a/src/expression2/DConstant.cpp b/src/expression2/DConstant.cpp index 46d4cbe9..bbf86183 100644 --- a/src/expression2/DConstant.cpp +++ b/src/expression2/DConstant.cpp @@ -83,15 +83,12 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DConstant::forward_children(obj gc) noexcept + void + DConstant::visit_gco_children(obj 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 diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index b25a655d..69ce84e0 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -90,14 +90,12 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DDefineExpr::forward_children(obj gc) noexcept + void + DDefineExpr::visit_gco_children(obj 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 diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index c125fb98..10f65ea2 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -262,30 +262,22 @@ namespace xo { // ----- gcobject facet ----- - std::size_t - DGlobalSymtab::shallow_size() const noexcept - { - return sizeof(DGlobalSymtab); - } - DGlobalSymtab * DGlobalSymtab::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - std::size_t - DGlobalSymtab::forward_children(obj gc) noexcept + void + DGlobalSymtab::visit_gco_children(obj 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 ----- diff --git a/src/expression2/DIfElseExpr.cpp b/src/expression2/DIfElseExpr.cpp index 81efee1e..c44a7ebd 100644 --- a/src/expression2/DIfElseExpr.cpp +++ b/src/expression2/DIfElseExpr.cpp @@ -94,26 +94,27 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DIfElseExpr::forward_children(obj gc) noexcept + void + DIfElseExpr::visit_gco_children(obj 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(); - gc.forward_inplace(gco.iface(), (void **)&(test_.data_)); + gc.visit_poly_child(&test_); + //auto gco = test_.to_facet(); + //gc.forward_inplace(gco.iface(), (void **)&(test_.data_)); } { - auto gco = when_true_.to_facet(); - gc.forward_inplace(gco.iface(), (void **)&(when_true_.data_)); + gc.visit_poly_child(&when_true_); + //auto gco = when_true_.to_facet(); + //gc.forward_inplace(gco.iface(), (void **)&(when_true_.data_)); } { - auto gco = when_false_.to_facet(); - gc.forward_inplace(gco.iface(), (void **)&(when_false_.data_)); + gc.visit_poly_child(&when_false_); + //auto gco = when_false_.to_facet(); + //gc.forward_inplace(gco.iface(), (void **)&(when_false_.data_)); } - - return shallow_size(); } // ----- printable facet ----- diff --git a/src/expression2/DLambdaExpr.cpp b/src/expression2/DLambdaExpr.cpp index 8069cd3c..349ccd99 100644 --- a/src/expression2/DLambdaExpr.cpp +++ b/src/expression2/DLambdaExpr.cpp @@ -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 gc) noexcept { - typeref_.forward_children(gc); + void + DLambdaExpr::visit_gco_children(obj gc) noexcept { + typeref_.visit_gco_children(gc); - { - //gc.forward_inplace(&name_); // doesn't compile for const ptr - auto iface = xo::facet::impl_for(); - gc.forward_inplace(&iface, (void **)(&name_)); - } + gc.visit_child(&name_); + //{ + // auto iface = xo::facet::impl_for(); + // gc.forward_inplace(&iface, (void **)(&name_)); + //} // type_name_str_ { - gc.forward_inplace(&local_symtab_); - //auto iface = xo::facet::impl_for(); - //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().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 diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index 60cdd2e2..017fb1d7 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -112,26 +112,18 @@ namespace xo { // ----- gcobject facet ----- - std::size_t - DLocalSymtab::shallow_size() const noexcept - { - return sizeof(DLocalSymtab); - } - DLocalSymtab * DLocalSymtab::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - std::size_t - DLocalSymtab::forward_children(obj gc) noexcept + void + DLocalSymtab::visit_gco_children(obj 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 ----- diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index ed03affc..2dc153f0 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -125,14 +125,12 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DSequenceExpr::forward_children(obj gc) noexcept + void + DSequenceExpr::visit_gco_children(obj 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*/ diff --git a/src/expression2/DTypename.cpp b/src/expression2/DTypename.cpp index c9f56cf1..15e7dbdb 100644 --- a/src/expression2/DTypename.cpp +++ b/src/expression2/DTypename.cpp @@ -52,16 +52,16 @@ namespace xo { return gc.std_move_for(this); } - size_t - DTypename::forward_children(obj gc) noexcept + void + DTypename::visit_gco_children(obj gc) noexcept { - gc.forward_inplace(const_cast(&name_)); + gc.visit_child(&name_); + //gc.forward_inplace(const_cast(&name_)); { - auto e = type_.to_facet(); - gc.forward_inplace(e.iface(), (void **)&(type_.data_)); + gc.visit_poly_child(&type_); + //auto e = type_.to_facet(); + //gc.forward_inplace(e.iface(), (void **)&(type_.data_)); } - - return shallow_size(); } bool diff --git a/src/expression2/DVarRef.cpp b/src/expression2/DVarRef.cpp index 3b9b2638..6cdea4e5 100644 --- a/src/expression2/DVarRef.cpp +++ b/src/expression2/DVarRef.cpp @@ -70,16 +70,14 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DVarRef::forward_children(obj gc) noexcept + void + DVarRef::visit_gco_children(obj gc) noexcept { - gc.forward_inplace(&vardef_); + gc.visit_child(&vardef_); //auto iface = xo::facet::impl_for(); //gc.forward_inplace(&iface, (void **)vardef_.data_); // TODO: concept to indicate that no gc pointers in Binding - - return shallow_size(); } // printable facet diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index 68a87f67..9ab2f8bd 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -50,12 +50,10 @@ namespace xo { return gc.std_move_for(this); } - size_t - DVariable::forward_children(obj gc) noexcept + void + DVariable::visit_gco_children(obj gc) noexcept { - typeref_.forward_children(gc); - - return shallow_size(); + typeref_.visit_gco_children(gc); } bool diff --git a/src/expression2/IGCObject_DApplyExpr.cpp b/src/expression2/IGCObject_DApplyExpr.cpp index 56fdda92..9b5fc735 100644 --- a/src/expression2/IGCObject_DApplyExpr.cpp +++ b/src/expression2/IGCObject_DApplyExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DApplyExpr::forward_children(DApplyExpr & self, obj gc) noexcept -> void + IGCObject_DApplyExpr::visit_gco_children(DApplyExpr & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DConstant.cpp b/src/expression2/IGCObject_DConstant.cpp index 62bf0fd7..3e350102 100644 --- a/src/expression2/IGCObject_DConstant.cpp +++ b/src/expression2/IGCObject_DConstant.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DConstant::forward_children(DConstant & self, obj gc) noexcept -> void + IGCObject_DConstant::visit_gco_children(DConstant & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DDefineExpr.cpp b/src/expression2/IGCObject_DDefineExpr.cpp index 91c83d67..34c59e93 100644 --- a/src/expression2/IGCObject_DDefineExpr.cpp +++ b/src/expression2/IGCObject_DDefineExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DDefineExpr::forward_children(DDefineExpr & self, obj gc) noexcept -> void + IGCObject_DDefineExpr::visit_gco_children(DDefineExpr & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DGlobalSymtab.cpp b/src/expression2/IGCObject_DGlobalSymtab.cpp index 9f9549ae..1e78de47 100644 --- a/src/expression2/IGCObject_DGlobalSymtab.cpp +++ b/src/expression2/IGCObject_DGlobalSymtab.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DGlobalSymtab::forward_children(DGlobalSymtab & self, obj gc) noexcept -> void + IGCObject_DGlobalSymtab::visit_gco_children(DGlobalSymtab & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DIfElseExpr.cpp b/src/expression2/IGCObject_DIfElseExpr.cpp index 532cad21..0db6f160 100644 --- a/src/expression2/IGCObject_DIfElseExpr.cpp +++ b/src/expression2/IGCObject_DIfElseExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DIfElseExpr::forward_children(DIfElseExpr & self, obj gc) noexcept -> void + IGCObject_DIfElseExpr::visit_gco_children(DIfElseExpr & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DLambdaExpr.cpp b/src/expression2/IGCObject_DLambdaExpr.cpp index b6045e90..a9ad37aa 100644 --- a/src/expression2/IGCObject_DLambdaExpr.cpp +++ b/src/expression2/IGCObject_DLambdaExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DLambdaExpr::forward_children(DLambdaExpr & self, obj gc) noexcept -> void + IGCObject_DLambdaExpr::visit_gco_children(DLambdaExpr & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DLocalSymtab.cpp b/src/expression2/IGCObject_DLocalSymtab.cpp index df9bc0b7..7384e17a 100644 --- a/src/expression2/IGCObject_DLocalSymtab.cpp +++ b/src/expression2/IGCObject_DLocalSymtab.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DLocalSymtab::forward_children(DLocalSymtab & self, obj gc) noexcept -> void + IGCObject_DLocalSymtab::visit_gco_children(DLocalSymtab & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DSequenceExpr.cpp b/src/expression2/IGCObject_DSequenceExpr.cpp index 36efcbfe..8660f506 100644 --- a/src/expression2/IGCObject_DSequenceExpr.cpp +++ b/src/expression2/IGCObject_DSequenceExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DSequenceExpr::forward_children(DSequenceExpr & self, obj gc) noexcept -> void + IGCObject_DSequenceExpr::visit_gco_children(DSequenceExpr & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DTypename.cpp b/src/expression2/IGCObject_DTypename.cpp index 246b7bd5..478b2005 100644 --- a/src/expression2/IGCObject_DTypename.cpp +++ b/src/expression2/IGCObject_DTypename.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DTypename::forward_children(DTypename & self, obj gc) noexcept -> void + IGCObject_DTypename::visit_gco_children(DTypename & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DVarRef.cpp b/src/expression2/IGCObject_DVarRef.cpp index fc0934fd..7035db1e 100644 --- a/src/expression2/IGCObject_DVarRef.cpp +++ b/src/expression2/IGCObject_DVarRef.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVarRef::forward_children(DVarRef & self, obj gc) noexcept -> void + IGCObject_DVarRef::visit_gco_children(DVarRef & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/TypeRef.cpp b/src/expression2/TypeRef.cpp index b5baa88d..961ae148 100644 --- a/src/expression2/TypeRef.cpp +++ b/src/expression2/TypeRef.cpp @@ -102,11 +102,11 @@ namespace xo { } void - TypeRef::forward_children(obj gc) noexcept + TypeRef::visit_gco_children(obj 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 diff --git a/src/expression2/facet/IGCObject_DVariable.cpp b/src/expression2/facet/IGCObject_DVariable.cpp index 7b2103d6..a6370f56 100644 --- a/src/expression2/facet/IGCObject_DVariable.cpp +++ b/src/expression2/facet/IGCObject_DVariable.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVariable::forward_children(DVariable & self, obj gc) noexcept -> void + IGCObject_DVariable::visit_gco_children(DVariable & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/