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 d740c94406
105 changed files with 260 additions and 416 deletions

View file

@ -397,10 +397,10 @@ namespace xo {
}
void
DApplySsm::forward_children(obj<ACollector> gc) noexcept
DApplySsm::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_pivot_inplace(&fn_expr_);
gc.forward_inplace(&args_expr_v_);
gc.visit_poly_child(&fn_expr_);
gc.visit_child(&args_expr_v_);
}
} /*namespace scm*/

View file

@ -692,9 +692,9 @@ namespace xo {
// ----- gc support -----
void
DDefineSsm::forward_children(obj<ACollector> gc)
DDefineSsm::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_inplace(&def_expr_.data_);
gc.visit_child(&def_expr_.data_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -271,7 +271,7 @@ namespace xo {
refrtag("expect", this->get_expect_str()));
}
void
DDeftypeSsm::forward_children(obj<ACollector> /*gc*/) noexcept
DDeftypeSsm::visit_gco_children(obj<AGCObjectVisitor>) noexcept
{
static_assert(!DUniqueString::is_gc_eligible());
}

View file

@ -625,7 +625,7 @@ namespace xo {
#endif
void
DExpectExprSsm::forward_children(obj<ACollector> /*gc*/) noexcept
DExpectExprSsm::visit_gco_children(obj<AGCObjectVisitor>) noexcept
{
// all members POD, skip
}

View file

@ -265,7 +265,7 @@ namespace xo {
}
void
DExpectFormalArgSsm::forward_children(obj<ACollector> /*gc*/) noexcept
DExpectFormalArgSsm::visit_gco_children(obj<AGCObjectVisitor>) noexcept
{
static_assert(!DUniqueString::is_gc_eligible());
}

View file

@ -358,9 +358,9 @@ namespace xo {
}
void
DExpectFormalArglistSsm::forward_children(obj<ACollector> gc) noexcept
DExpectFormalArglistSsm::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_inplace(&argl_);
gc.visit_child(&argl_);
}
} /*namespace scm*/

View file

@ -204,9 +204,9 @@ namespace xo {
}
void
DExpectListTypeSsm::forward_children(obj<ACollector> gc) noexcept
DExpectListTypeSsm::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_pivot_inplace(&elt_type_);
gc.visit_poly_child(&elt_type_);
}
} /*namespace scm*/

View file

@ -220,9 +220,9 @@ namespace xo {
refrtag("array", array_pr));
}
void
DExpectQArraySsm::forward_children(obj<ACollector> gc) noexcept
DExpectQArraySsm::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_inplace(&array_);
gc.visit_child(&array_);
}
}

View file

@ -267,10 +267,10 @@ namespace xo {
void
DExpectQDictSsm::forward_children(obj<ACollector> gc) noexcept
DExpectQDictSsm::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_inplace(const_cast<DString **>(&key_));
gc.forward_inplace(&dict_);
gc.visit_child(&key_);
gc.visit_child(&dict_);
}
} /*namespace scm*/

View file

@ -215,10 +215,10 @@ namespace xo {
refrtag("list", list_pr));
}
void
DExpectQListSsm::forward_children(obj<ACollector> gc) noexcept
DExpectQListSsm::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_inplace(&start_);
gc.forward_inplace(&end_);
gc.visit_child(&start_);
gc.visit_child(&end_);
}
}

View file

@ -256,7 +256,7 @@ namespace xo {
refrtag("expect", this->get_expect_str()));
}
void
DExpectQLiteralSsm::forward_children(obj<ACollector> /*gc*/) noexcept
DExpectQLiteralSsm::visit_gco_children(obj<AGCObjectVisitor>) noexcept
{
// cxl_on_rightparen_, cxl_on_rightbracket_: POD, skip
}

View file

@ -146,7 +146,7 @@ namespace xo {
);
}
void
DExpectSymbolSsm::forward_children(obj<ACollector> /*gc*/) noexcept
DExpectSymbolSsm::visit_gco_children(obj<AGCObjectVisitor>) noexcept
{
// no gc-aware members
}

View file

@ -198,7 +198,7 @@ namespace xo {
}
void
DExpectTypeSsm::forward_children(obj<ACollector> /*gc*/) noexcept
DExpectTypeSsm::visit_gco_children(obj<AGCObjectVisitor>) noexcept
{
// corrected_: POD, skip
}

View file

@ -107,25 +107,17 @@ namespace xo {
// ----- AGCObject facet -----
std::size_t
DGlobalEnv::shallow_size() const noexcept
{
return sizeof(*this);
}
DGlobalEnv *
DGlobalEnv::shallow_move(obj<ACollector> gc) noexcept
{
return gc.std_move_for<DGlobalEnv>(this);
}
std::size_t
DGlobalEnv::forward_children(obj<ACollector> gc) noexcept
void
DGlobalEnv::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_inplace(&symtab_);
gc.forward_inplace(&values_);
return this->shallow_size();
gc.visit_child(&symtab_);
gc.visit_child(&values_);
}
// ----- APrintable facet -----

View file

@ -510,9 +510,9 @@ namespace xo {
}
void
DIfElseSsm::forward_children(obj<ACollector> gc) noexcept
DIfElseSsm::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_pivot_inplace(&if_expr_);
gc.visit_poly_child(&if_expr_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -4,16 +4,13 @@
**/
#include "LambdaSsm.hpp"
//#include "ssm/ISyntaxStateMachine_DLambdaSsm.hpp"
#include "ExpectFormalArglistSsm.hpp"
//#include "ssm/ISyntaxStateMachine_DExpectFormalArglistSsm.hpp"
#include "DExpectTypeSsm.hpp"
#include "DExpectExprSsm.hpp"
#include "ParserStateMachine.hpp"
#include "syntaxstatetype.hpp"
#include <xo/expression2/detail/IExpression_DLambdaExpr.hpp>
#include <xo/expression2/Variable.hpp>
//#include <xo/expression2/detail/IExpression_DVariable.hpp>
//#include <xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp>
#include <xo/printable2/Printable.hpp>
#include <xo/alloc2/GCObject.hpp>
@ -474,15 +471,15 @@ namespace xo {
}
void
DLambdaSsm::forward_children(obj<ACollector> gc) noexcept
DLambdaSsm::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_inplace(&local_symtab_);
gc.visit_child(&local_symtab_);
// explicit_return_td not gcobject
// lambda_td not gcobject
gc.forward_pivot_inplace(&body_);
gc.forward_pivot_inplace(&parent_symtab_);
gc.visit_poly_child(&body_);
gc.visit_poly_child(&parent_symtab_);
}
} /*namespace scm*/

View file

@ -459,9 +459,9 @@ namespace xo {
}
void
DParenSsm::forward_children(obj<ACollector> gc) noexcept
DParenSsm::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_pivot_inplace(&expr_);
gc.visit_poly_child(&expr_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -1244,10 +1244,10 @@ case optype::op_assign:
}
void
DProgressSsm::forward_children(obj<ACollector> gc) noexcept
DProgressSsm::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_pivot_inplace(&lhs_);
gc.forward_pivot_inplace(&rhs_);
gc.visit_poly_child(&lhs_);
gc.visit_poly_child(&rhs_);
}
} /*namespace scm*/

View file

@ -212,9 +212,9 @@ namespace xo {
}
void
DQuoteSsm::forward_children(obj<ACollector> gc) noexcept
DQuoteSsm::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_pivot_inplace(&expr_);
gc.visit_poly_child(&expr_);
}
} /*namespace scm*/

View file

@ -184,12 +184,6 @@ namespace xo {
);
}
std::size_t
DSchematikaParser::shallow_size() const noexcept
{
return sizeof(DSchematikaParser);
}
DSchematikaParser *
DSchematikaParser::shallow_move(obj<ACollector> gc) noexcept
{
@ -202,12 +196,10 @@ namespace xo {
return nullptr;
}
std::size_t
DSchematikaParser::forward_children(obj<ACollector> gc) noexcept
void
DSchematikaParser::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
psm_.forward_children(gc);
return this->shallow_size();
psm_.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -258,9 +258,9 @@ namespace xo {
}
void
DSequenceSsm::forward_children(obj<ACollector> gc) noexcept
DSequenceSsm::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_inplace(&seq_expr_);
gc.visit_child(&seq_expr_);
}
} /*namespace scm*/

View file

@ -518,7 +518,7 @@ namespace xo {
refrtag("seqtype", seqtype_));
}
void
DToplevelSeqSsm::forward_children(obj<ACollector> /*gc*/) noexcept
DToplevelSeqSsm::visit_gco_children(obj<AGCObjectVisitor>) noexcept
{
// seqtype_: POD, skip
}

View file

@ -96,7 +96,7 @@ ISyntaxStateMachine_Any::on_quoted_literal(Opaque, obj<AGCObject>, ParserStateMa
}
auto
ISyntaxStateMachine_Any::forward_children(Opaque, obj<ACollector>) -> void
ISyntaxStateMachine_Any::visit_gco_children(Opaque, obj<AGCObjectVisitor>) -> void
{
_fatal();
}

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectExprSsm::forward_children(DExpectExprSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DExpectExprSsm::visit_gco_children(DExpectExprSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectFormalArglistSsm::forward_children(DExpectFormalArglistSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DExpectFormalArglistSsm::visit_gco_children(DExpectFormalArglistSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectQArraySsm::forward_children(DExpectQArraySsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DExpectQArraySsm::visit_gco_children(DExpectQArraySsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectQListSsm::forward_children(DExpectQListSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DExpectQListSsm::visit_gco_children(DExpectQListSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectQLiteralSsm::forward_children(DExpectQLiteralSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DExpectQLiteralSsm::visit_gco_children(DExpectQLiteralSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectSymbolSsm::forward_children(DExpectSymbolSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DExpectSymbolSsm::visit_gco_children(DExpectSymbolSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectTypeSsm::forward_children(DExpectTypeSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DExpectTypeSsm::visit_gco_children(DExpectTypeSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DParenSsm::forward_children(DParenSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DParenSsm::visit_gco_children(DParenSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DProgressSsm::forward_children(DProgressSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DProgressSsm::visit_gco_children(DProgressSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DSequenceSsm::forward_children(DSequenceSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DSequenceSsm::visit_gco_children(DSequenceSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DToplevelSeqSsm::forward_children(DToplevelSeqSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DToplevelSeqSsm::visit_gco_children(DToplevelSeqSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -106,12 +106,12 @@ namespace xo {
}
void
ParserResult::forward_children(obj<ACollector> gc) noexcept
ParserResult::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
// {result_type_, error_src_fn_}: pod, ignore
gc.forward_pivot_inplace(&result_expr_);
gc.forward_inplace(const_cast<DString **>(&error_description_));
gc.visit_poly_child(&result_expr_);
gc.visit_child(&error_description_);
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -90,14 +90,14 @@ namespace xo {
}
void
ParserStack::forward_children(obj<ACollector> gc) noexcept
ParserStack::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
for (ParserStack * target = this; target; target = target->parent_) {
// ParserStack::ckp: skip, POD
if (target->ssm_)
target->ssm_.forward_children(gc);
target->ssm_.visit_gco_children(gc);
}
}

View file

@ -907,7 +907,7 @@ namespace xo {
#endif
void
ParserStateMachine::forward_children(obj<ACollector> gc) noexcept
ParserStateMachine::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
//scope log(XO_DEBUG(true));
@ -916,23 +916,23 @@ namespace xo {
//log && log("forward stack_", xtag("addr", stack_));
if (stack_) {
stack_->forward_children(gc);
stack_->visit_gco_children(gc);
}
// static_assert(!expr_alloc_.is_gc_eligible());
// static_assert(!aux_alloc_.is_gc_eligible());
//log && log("global_symtab_", xtag("addr", global_symtab_.data()));
gc.forward_inplace(&global_symtab_);
gc.visit_child(&global_symtab_);
//log && log("local_symtab_", xtag("addr", local_symtab_.data()));
gc.forward_inplace(&local_symtab_);
gc.visit_child(&local_symtab_);
//log && log("global_env_", xtag("addr", global_env_.data()));
gc.forward_inplace(&global_env_);
gc.visit_child(&global_env_);
//log && log("result_");
result_.forward_children(gc);
result_.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -10,9 +10,9 @@ namespace xo {
namespace scm {
void
ReaderResult::forward_children(obj<ACollector> gc) noexcept
ReaderResult::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
gc.forward_pivot_inplace(&expr_);
gc.visit_poly_child(&expr_);
}
// ----- SchematikaReader -----
@ -208,12 +208,12 @@ namespace xo {
}
void
SchematikaReader::forward_children(obj<ACollector> gc) noexcept
SchematikaReader::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
{
// tokenizer doesn't contain any gc-aware pointers.
parser_.forward_children(gc);
result_.forward_children(gc);
parser_.visit_gco_children(gc);
result_.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -21,9 +21,9 @@ namespace xo {
return self.shallow_move(gc);
}
auto
IGCObject_DGlobalEnv::forward_children(DGlobalEnv & self, obj<ACollector> gc) noexcept -> void
IGCObject_DGlobalEnv::visit_gco_children(DGlobalEnv & 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_DSchematikaParser::forward_children(DSchematikaParser & self, obj<ACollector> gc) noexcept -> void
IGCObject_DSchematikaParser::visit_gco_children(DSchematikaParser & self, obj<AGCObjectVisitor> fn) noexcept -> void
{
self.forward_children(gc);
self.visit_gco_children(fn);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DApplySsm::forward_children(DApplySsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DApplySsm::visit_gco_children(DApplySsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DDefineSsm::forward_children(DDefineSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DDefineSsm::visit_gco_children(DDefineSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DDeftypeSsm::forward_children(DDeftypeSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DDeftypeSsm::visit_gco_children(DDeftypeSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectFormalArgSsm::forward_children(DExpectFormalArgSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DExpectFormalArgSsm::visit_gco_children(DExpectFormalArgSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectListTypeSsm::forward_children(DExpectListTypeSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DExpectListTypeSsm::visit_gco_children(DExpectListTypeSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DExpectQDictSsm::forward_children(DExpectQDictSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DExpectQDictSsm::visit_gco_children(DExpectQDictSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DIfElseSsm::forward_children(DIfElseSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DIfElseSsm::visit_gco_children(DIfElseSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DLambdaSsm::forward_children(DLambdaSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DLambdaSsm::visit_gco_children(DLambdaSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/

View file

@ -78,9 +78,9 @@ namespace xo {
self.on_quoted_literal(lit, p_psm);
}
auto
ISyntaxStateMachine_DQuoteSsm::forward_children(DQuoteSsm & self, obj<ACollector> gc) -> void
ISyntaxStateMachine_DQuoteSsm::visit_gco_children(DQuoteSsm & self, obj<AGCObjectVisitor> gc) -> void
{
self.forward_children(gc);
self.visit_gco_children(gc);
}
} /*namespace scm*/