refactor: rename shallow_copy -> shallow_move + streamline

Use RCollector.std_copy_for where appropriate
This commit is contained in:
Roland Conybeare 2026-04-04 16:33:35 -04:00
commit d16f2a0484
44 changed files with 72 additions and 114 deletions

View file

@ -83,7 +83,7 @@ namespace xo {
///@{
std::size_t shallow_size() const noexcept;
DApplyExpr * shallow_move(obj<AAllocator> mm) const noexcept;
DApplyExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
///@}

View file

@ -63,7 +63,7 @@ namespace xo {
///@{
size_t shallow_size() const noexcept;
DConstant * shallow_move(obj<AAllocator> mm) const noexcept;
DConstant * shallow_move(obj<ACollector> gc) noexcept;
size_t forward_children(obj<ACollector> gc) noexcept;
///@}

View file

@ -73,7 +73,7 @@ namespace xo {
///@{
std::size_t shallow_size() const noexcept;
DDefineExpr * shallow_move(obj<AAllocator> mm) noexcept;
DDefineExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
///@}

View file

@ -43,6 +43,9 @@ namespace xo {
DGlobalSymtab(dp<repr_type> var_map, DArray * vars,
dp<repr_type> type_map, DArray * types);
/** move constructor (needed because dp<> deletes copy ctor) **/
DGlobalSymtab(DGlobalSymtab && other) = default;
/** create instance.
* Use memory from @p fixed_mm for @ref map_.
* Use memory from @p mm for DGlobalSymtab instance.
@ -111,7 +114,7 @@ namespace xo {
///@{
std::size_t shallow_size() const noexcept;
DGlobalSymtab * shallow_move(obj<AAllocator> mm) const noexcept;
DGlobalSymtab * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
///@}

View file

@ -99,7 +99,7 @@ namespace xo {
///@{
std::size_t shallow_size() const noexcept;
DIfElseExpr * shallow_move(obj<AAllocator> mm) const noexcept;
DIfElseExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
///@}

View file

@ -85,7 +85,7 @@ namespace xo {
///@{
std::size_t shallow_size() const noexcept;
DLambdaExpr * shallow_move(obj<AAllocator> mm) const noexcept;
DLambdaExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
///@}

View file

@ -98,7 +98,7 @@ namespace xo {
///@{
std::size_t shallow_size() const noexcept;
DLocalSymtab * shallow_move(obj<AAllocator> mm) noexcept;
DLocalSymtab * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
///@}

View file

@ -73,7 +73,7 @@ namespace xo {
///@{
std::size_t shallow_size() const noexcept;
DSequenceExpr * shallow_move(obj<AAllocator> mm) const noexcept;
DSequenceExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
///@}

View file

@ -54,7 +54,7 @@ namespace xo {
///@{
size_t shallow_size() const noexcept;
DTypename * shallow_move(obj<AAllocator> mm) noexcept;
DTypename * shallow_move(obj<ACollector> gc) noexcept;
size_t forward_children(obj<ACollector> gc) noexcept;
///@}

View file

@ -55,7 +55,7 @@ namespace xo {
///@{
size_t shallow_size() const noexcept;
DVarRef * shallow_move(obj<AAllocator> mm) const noexcept;
DVarRef * shallow_move(obj<ACollector> gc) noexcept;
size_t forward_children(obj<ACollector> gc) noexcept;
///@}

View file

@ -63,7 +63,7 @@ namespace xo {
///@{
size_t shallow_size() const noexcept;
DVariable * shallow_move(obj<AAllocator> mm) const noexcept;
DVariable * shallow_move(obj<ACollector> gc) noexcept;
size_t forward_children(obj<ACollector> gc) noexcept;
///@}

View file

@ -55,7 +55,7 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DDefineExpr & self, obj<AAllocator> mm) noexcept;
static Opaque shallow_move(DDefineExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DDefineExpr & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -55,7 +55,7 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DApplyExpr & self, obj<AAllocator> mm) noexcept;
static Opaque shallow_move(DApplyExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DApplyExpr & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -55,7 +55,7 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DConstant & self, obj<AAllocator> mm) noexcept;
static Opaque shallow_move(DConstant & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DConstant & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -55,7 +55,7 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DIfElseExpr & self, obj<AAllocator> mm) noexcept;
static Opaque shallow_move(DIfElseExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DIfElseExpr & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -55,7 +55,7 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DLambdaExpr & self, obj<AAllocator> mm) noexcept;
static Opaque shallow_move(DLambdaExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DLambdaExpr & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -55,7 +55,7 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DSequenceExpr & self, obj<AAllocator> mm) noexcept;
static Opaque shallow_move(DSequenceExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DSequenceExpr & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -55,7 +55,7 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DVarRef & self, obj<AAllocator> mm) noexcept;
static Opaque shallow_move(DVarRef & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DVarRef & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -55,7 +55,7 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DGlobalSymtab & self, obj<AAllocator> mm) noexcept;
static Opaque shallow_move(DGlobalSymtab & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DGlobalSymtab & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -55,7 +55,7 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DLocalSymtab & self, obj<AAllocator> mm) noexcept;
static Opaque shallow_move(DLocalSymtab & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DLocalSymtab & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -53,7 +53,7 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DTypename & self, obj<AAllocator> mm) noexcept;
static Opaque shallow_move(DTypename & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DTypename & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -55,7 +55,7 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DVariable & self, obj<AAllocator> mm) noexcept;
static Opaque shallow_move(DVariable & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static size_type forward_children(DVariable & self, obj<ACollector> gc) noexcept;
///@}

View file

@ -110,8 +110,11 @@ namespace xo {
}
DApplyExpr *
DApplyExpr::shallow_move(obj<AAllocator> mm) const noexcept {
DApplyExpr * copy = (DApplyExpr *)mm.alloc_copy((std::byte *)this);
DApplyExpr::shallow_move(obj<ACollector> gc) noexcept {
// note: not using ACollector.std_copy_for() here,
// flexible array -> not move-constructible
DApplyExpr * copy = (DApplyExpr *)gc.alloc_copy_for(this);
if (copy) {
copy->typeref_ = typeref_;

View file

@ -78,14 +78,9 @@ namespace xo {
}
DConstant *
DConstant::shallow_move(obj<AAllocator> mm) const noexcept
DConstant::shallow_move(obj<ACollector> gc) noexcept
{
DConstant * copy = (DConstant *)mm.alloc_copy((std::byte *)this);
if (copy)
*copy = *this;
return copy;
return gc.std_copy_for(this);
}
std::size_t

View file

@ -85,9 +85,9 @@ namespace xo {
}
DDefineExpr *
DDefineExpr::shallow_move(obj<AAllocator> mm) noexcept
DDefineExpr::shallow_move(obj<ACollector> gc) noexcept
{
return mm.std_copy_for(this);
return gc.std_copy_for(this);
}
std::size_t

View file

@ -261,25 +261,9 @@ namespace xo {
}
DGlobalSymtab *
DGlobalSymtab::shallow_move(obj<AAllocator> mm) const noexcept
DGlobalSymtab::shallow_move(obj<ACollector> gc) noexcept
{
/** can't use std_copy_for because of non-copyable dp<repr_type>
*
* TODO: rename to shallow_move() throughout, and have std_copy_for()
* -> std_move_for()
*
**/
void * copy_mem = mm.alloc_copy_for(this);
if (copy_mem) {
DGlobalSymtab * self = const_cast<DGlobalSymtab*>(this);
return new (copy_mem) DGlobalSymtab(std::move(self->var_map_), vars_,
std::move(self->type_map_), types_);
}
return nullptr;
return gc.std_copy_for(this);
}
std::size_t

View file

@ -89,14 +89,9 @@ namespace xo {
}
DIfElseExpr *
DIfElseExpr::shallow_move(obj<AAllocator> mm) const noexcept
DIfElseExpr::shallow_move(obj<ACollector> gc) noexcept
{
DIfElseExpr * copy = (DIfElseExpr *)mm.alloc_copy((std::byte *)this);
if (copy)
*copy = *this;
return copy;
return gc.std_copy_for(this);
}
std::size_t

View file

@ -140,14 +140,8 @@ namespace xo {
}
DLambdaExpr *
DLambdaExpr::shallow_move(obj<AAllocator> mm) const noexcept {
DLambdaExpr * copy = (DLambdaExpr *)mm.alloc_copy((std::byte *)this);
if (copy) {
*copy = *this;
}
return copy;
DLambdaExpr::shallow_move(obj<ACollector> gc) noexcept {
return gc.std_copy_for(this);
}
std::size_t

View file

@ -119,9 +119,9 @@ namespace xo {
}
DLocalSymtab *
DLocalSymtab::shallow_move(obj<AAllocator> mm) noexcept
DLocalSymtab::shallow_move(obj<ACollector> gc) noexcept
{
return mm.std_copy_for(this);
return gc.std_copy_for(this);
}
std::size_t

View file

@ -120,14 +120,9 @@ namespace xo {
}
DSequenceExpr *
DSequenceExpr::shallow_move(obj<AAllocator> mm) const noexcept
DSequenceExpr::shallow_move(obj<ACollector> gc) noexcept
{
DSequenceExpr * copy = (DSequenceExpr *)mm.alloc_copy((std::byte *)this);
if (copy)
*copy = *this;
return copy;
return gc.std_copy_for(this);
}
std::size_t

View file

@ -47,9 +47,9 @@ namespace xo {
}
DTypename *
DTypename::shallow_move(obj<AAllocator> mm) noexcept
DTypename::shallow_move(obj<ACollector> gc) noexcept
{
return mm.std_copy_for(this);
return gc.std_copy_for(this);
}
size_t

View file

@ -65,14 +65,9 @@ namespace xo {
}
DVarRef *
DVarRef::shallow_move(obj<AAllocator> mm) const noexcept
DVarRef::shallow_move(obj<ACollector> gc) noexcept
{
DVarRef * copy = (DVarRef *)mm.alloc_copy((std::byte *)this);
if (copy)
*copy = *this;
return copy;
return gc.std_copy_for(this);
}
std::size_t

View file

@ -45,15 +45,9 @@ namespace xo {
}
DVariable *
DVariable::shallow_move(obj<AAllocator> mm) const noexcept
DVariable::shallow_move(obj<ACollector> gc) noexcept
{
DVariable * copy = (DVariable *)mm.alloc_copy((std::byte *)this);
if (copy) {
*copy = *this;
}
return copy;
return gc.std_copy_for(this);
}
size_t

View file

@ -22,9 +22,9 @@ namespace xo {
}
auto
IGCObject_DApplyExpr::shallow_move(DApplyExpr & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DApplyExpr::shallow_move(DApplyExpr & self, obj<ACollector> gc) noexcept -> Opaque
{
return self.shallow_move(mm);
return self.shallow_move(gc);
}
auto
IGCObject_DApplyExpr::forward_children(DApplyExpr & self, obj<ACollector> gc) noexcept -> size_type

View file

@ -22,9 +22,9 @@ namespace xo {
}
auto
IGCObject_DConstant::shallow_move(DConstant & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DConstant::shallow_move(DConstant & self, obj<ACollector> gc) noexcept -> Opaque
{
return self.shallow_move(mm);
return self.shallow_move(gc);
}
auto
IGCObject_DConstant::forward_children(DConstant & self, obj<ACollector> gc) noexcept -> size_type

View file

@ -22,9 +22,9 @@ namespace xo {
}
auto
IGCObject_DDefineExpr::shallow_move(DDefineExpr & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DDefineExpr::shallow_move(DDefineExpr & self, obj<ACollector> gc) noexcept -> Opaque
{
return self.shallow_move(mm);
return self.shallow_move(gc);
}
auto
IGCObject_DDefineExpr::forward_children(DDefineExpr & self, obj<ACollector> gc) noexcept -> size_type

View file

@ -22,9 +22,9 @@ namespace xo {
}
auto
IGCObject_DGlobalSymtab::shallow_move(DGlobalSymtab & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DGlobalSymtab::shallow_move(DGlobalSymtab & self, obj<ACollector> gc) noexcept -> Opaque
{
return self.shallow_move(mm);
return self.shallow_move(gc);
}
auto
IGCObject_DGlobalSymtab::forward_children(DGlobalSymtab & self, obj<ACollector> gc) noexcept -> size_type

View file

@ -22,9 +22,9 @@ namespace xo {
}
auto
IGCObject_DIfElseExpr::shallow_move(DIfElseExpr & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DIfElseExpr::shallow_move(DIfElseExpr & self, obj<ACollector> gc) noexcept -> Opaque
{
return self.shallow_move(mm);
return self.shallow_move(gc);
}
auto
IGCObject_DIfElseExpr::forward_children(DIfElseExpr & self, obj<ACollector> gc) noexcept -> size_type

View file

@ -22,9 +22,9 @@ namespace xo {
}
auto
IGCObject_DLambdaExpr::shallow_move(DLambdaExpr & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DLambdaExpr::shallow_move(DLambdaExpr & self, obj<ACollector> gc) noexcept -> Opaque
{
return self.shallow_move(mm);
return self.shallow_move(gc);
}
auto
IGCObject_DLambdaExpr::forward_children(DLambdaExpr & self, obj<ACollector> gc) noexcept -> size_type

View file

@ -22,9 +22,9 @@ namespace xo {
}
auto
IGCObject_DLocalSymtab::shallow_move(DLocalSymtab & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DLocalSymtab::shallow_move(DLocalSymtab & self, obj<ACollector> gc) noexcept -> Opaque
{
return self.shallow_move(mm);
return self.shallow_move(gc);
}
auto
IGCObject_DLocalSymtab::forward_children(DLocalSymtab & self, obj<ACollector> gc) noexcept -> size_type

View file

@ -22,9 +22,9 @@ namespace xo {
}
auto
IGCObject_DSequenceExpr::shallow_move(DSequenceExpr & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DSequenceExpr::shallow_move(DSequenceExpr & self, obj<ACollector> gc) noexcept -> Opaque
{
return self.shallow_move(mm);
return self.shallow_move(gc);
}
auto
IGCObject_DSequenceExpr::forward_children(DSequenceExpr & self, obj<ACollector> gc) noexcept -> size_type

View file

@ -22,9 +22,9 @@ namespace xo {
}
auto
IGCObject_DTypename::shallow_move(DTypename & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DTypename::shallow_move(DTypename & self, obj<ACollector> gc) noexcept -> Opaque
{
return self.shallow_move(mm);
return self.shallow_move(gc);
}
auto
IGCObject_DTypename::forward_children(DTypename & self, obj<ACollector> gc) noexcept -> size_type

View file

@ -22,9 +22,9 @@ namespace xo {
}
auto
IGCObject_DVarRef::shallow_move(DVarRef & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DVarRef::shallow_move(DVarRef & self, obj<ACollector> gc) noexcept -> Opaque
{
return self.shallow_move(mm);
return self.shallow_move(gc);
}
auto
IGCObject_DVarRef::forward_children(DVarRef & self, obj<ACollector> gc) noexcept -> size_type

View file

@ -22,9 +22,9 @@ namespace xo {
}
auto
IGCObject_DVariable::shallow_move(DVariable & self, obj<AAllocator> mm) noexcept -> Opaque
IGCObject_DVariable::shallow_move(DVariable & self, obj<ACollector> gc) noexcept -> Opaque
{
return self.shallow_move(mm);
return self.shallow_move(gc);
}
auto
IGCObject_DVariable::forward_children(DVariable & self, obj<ACollector> gc) noexcept -> size_type