refactor: + narrower interface for gc pointer forwarding
add AGCObjectVisitor, instead of requiring ACollector.
This commit is contained in:
parent
bc83df3f08
commit
7e583b1337
36 changed files with 138 additions and 179 deletions
|
|
@ -64,32 +64,16 @@ namespace xo {
|
|||
return err;
|
||||
}
|
||||
|
||||
size_t
|
||||
DClosure::shallow_size() const noexcept {
|
||||
return sizeof(DClosure);
|
||||
}
|
||||
|
||||
DClosure *
|
||||
DClosure::shallow_move(obj<ACollector> gc) noexcept {
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DClosure::forward_children(obj<ACollector> gc) noexcept
|
||||
void
|
||||
DClosure::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
{
|
||||
gc.forward_inplace(&lambda_);
|
||||
//auto iface = xo::facet::impl_for<AGCObject,DLambdaExpr>();
|
||||
//gc.forward_inplace(&iface, (void **)(&lambda_));
|
||||
|
||||
}
|
||||
{
|
||||
gc.forward_inplace(&env_);
|
||||
//auto iface = xo::facet::impl_for<AGCObject,DLocalEnv>();
|
||||
//gc.forward_inplace(&iface, (void **)(&env_));
|
||||
}
|
||||
|
||||
return this->shallow_size();
|
||||
gc.visit_child(&lambda_);
|
||||
gc.visit_child(&env_);
|
||||
}
|
||||
|
||||
// ----- printable facet -----
|
||||
|
|
|
|||
|
|
@ -91,33 +91,29 @@ namespace xo {
|
|||
/* something terribly wrong if control here */
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DLocalEnv::shallow_size() const noexcept {
|
||||
return sizeof(DLocalEnv);
|
||||
}
|
||||
|
||||
DLocalEnv *
|
||||
DLocalEnv::shallow_move(obj<ACollector> gc) noexcept {
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DLocalEnv::forward_children(obj<ACollector> gc) noexcept
|
||||
void
|
||||
DLocalEnv::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
{
|
||||
auto iface = xo::facet::impl_for<AGCObject,DLocalEnv>();
|
||||
gc.forward_inplace(&iface, (void **)(&parent_));
|
||||
gc.visit_child(&parent_);
|
||||
//auto iface = xo::facet::impl_for<AGCObject,DLocalEnv>();
|
||||
//gc.forward_inplace(&iface, (void **)(&parent_));
|
||||
}
|
||||
{
|
||||
auto iface = xo::facet::impl_for<AGCObject,DLocalSymtab>();
|
||||
gc.forward_inplace(&iface, (void **)(&symtab_));
|
||||
gc.visit_child(&symtab_);
|
||||
//auto iface = xo::facet::impl_for<AGCObject,DLocalSymtab>();
|
||||
//gc.forward_inplace(&iface, (void **)(&symtab_));
|
||||
}
|
||||
{
|
||||
auto iface = xo::facet::impl_for<AGCObject,DArray>();
|
||||
gc.forward_inplace(&iface, (void **)(&args_));
|
||||
gc.visit_child(&args_);
|
||||
//auto iface = xo::facet::impl_for<AGCObject,DArray>();
|
||||
//gc.forward_inplace(&iface, (void **)(&args_));
|
||||
}
|
||||
|
||||
return shallow_size();
|
||||
}
|
||||
|
||||
// ----- printable facet -----
|
||||
|
|
|
|||
|
|
@ -968,22 +968,20 @@ namespace xo {
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DVirtualSchematikaMachine::forward_children(obj<ACollector> gc) noexcept
|
||||
void
|
||||
DVirtualSchematikaMachine::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
reader_.forward_children(gc);
|
||||
reader_.visit_gco_children(gc);
|
||||
|
||||
gc.forward_inplace(&stack_);
|
||||
gc.forward_pivot_inplace(&expr_);
|
||||
gc.forward_inplace(&global_env_);
|
||||
gc.forward_inplace(&local_env_);
|
||||
gc.forward_inplace(&fn_);
|
||||
gc.forward_inplace(&args_);
|
||||
gc.visit_child(&stack_);
|
||||
gc.visit_poly_child(&expr_);
|
||||
gc.visit_child(&global_env_);
|
||||
gc.visit_child(&local_env_);
|
||||
gc.visit_child(&fn_);
|
||||
gc.visit_child(&args_);
|
||||
if (value_.is_value()) {
|
||||
gc.forward_inplace(const_cast<obj<AGCObject> *>(&value_.value_ref()));
|
||||
gc.visit_child(const_cast<obj<AGCObject> *>(&value_.value_ref()));
|
||||
}
|
||||
|
||||
return this->shallow_size();
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -32,25 +32,17 @@ namespace xo {
|
|||
return new (mem) DVsmApplyClosureFrame(stack, cont, local_env);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DVsmApplyClosureFrame::shallow_size() const noexcept
|
||||
{
|
||||
return sizeof(DVsmApplyClosureFrame);
|
||||
}
|
||||
|
||||
DVsmApplyClosureFrame *
|
||||
DVsmApplyClosureFrame::shallow_move(obj<ACollector> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DVsmApplyClosureFrame::forward_children(obj<ACollector> gc) noexcept
|
||||
void
|
||||
DVsmApplyClosureFrame::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
gc.forward_inplace(&stack_);
|
||||
gc.forward_inplace(&local_env_);
|
||||
|
||||
return this->shallow_size();
|
||||
gc.visit_child(&stack_);
|
||||
gc.visit_child(&local_env_);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -40,26 +40,18 @@ namespace xo {
|
|||
return result;
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DVsmApplyFrame::shallow_size() const noexcept
|
||||
{
|
||||
return sizeof(DVsmApplyFrame);
|
||||
}
|
||||
|
||||
DVsmApplyFrame *
|
||||
DVsmApplyFrame::shallow_move(obj<ACollector> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DVsmApplyFrame::forward_children(obj<ACollector> gc) noexcept
|
||||
void
|
||||
DVsmApplyFrame::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
gc.forward_inplace(&parent_);
|
||||
gc.forward_inplace(&fn_);
|
||||
gc.forward_inplace(&args_);
|
||||
|
||||
return this->shallow_size();
|
||||
gc.visit_child(&parent_);
|
||||
gc.visit_child(&fn_);
|
||||
gc.visit_child(&args_);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -31,25 +31,17 @@ namespace xo {
|
|||
|
||||
// gcobject facet
|
||||
|
||||
std::size_t
|
||||
DVsmDefContFrame::shallow_size() const noexcept
|
||||
{
|
||||
return sizeof(*this);
|
||||
}
|
||||
|
||||
DVsmDefContFrame *
|
||||
DVsmDefContFrame::shallow_move(obj<ACollector> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for<DVsmDefContFrame>(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DVsmDefContFrame::forward_children(obj<ACollector> gc) noexcept
|
||||
void
|
||||
DVsmDefContFrame::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
gc.forward_inplace(&parent_);
|
||||
gc.forward_inplace(&def_expr_);
|
||||
|
||||
return this->shallow_size();
|
||||
gc.visit_child(&parent_);
|
||||
gc.visit_child(&def_expr_);
|
||||
}
|
||||
|
||||
// printable facet
|
||||
|
|
|
|||
|
|
@ -41,25 +41,17 @@ namespace xo {
|
|||
return result;
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DVsmEvalArgsFrame::shallow_size() const noexcept
|
||||
{
|
||||
return sizeof(DVsmEvalArgsFrame);
|
||||
}
|
||||
|
||||
DVsmEvalArgsFrame *
|
||||
DVsmEvalArgsFrame::shallow_move(obj<ACollector> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DVsmEvalArgsFrame::forward_children(obj<ACollector> gc) noexcept
|
||||
void
|
||||
DVsmEvalArgsFrame::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
gc.forward_inplace(&parent_);
|
||||
gc.forward_inplace(&apply_expr_);
|
||||
|
||||
return this->shallow_size();
|
||||
gc.visit_child(&parent_);
|
||||
gc.visit_child(&apply_expr_);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
|
|||
|
|
@ -29,25 +29,17 @@ namespace xo {
|
|||
|
||||
// gcobject facet
|
||||
|
||||
std::size_t
|
||||
DVsmIfElseContFrame::shallow_size() const noexcept
|
||||
{
|
||||
return sizeof(*this);
|
||||
}
|
||||
|
||||
DVsmIfElseContFrame *
|
||||
DVsmIfElseContFrame::shallow_move(obj<ACollector> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for<DVsmIfElseContFrame>(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DVsmIfElseContFrame::forward_children(obj<ACollector> gc) noexcept
|
||||
void
|
||||
DVsmIfElseContFrame::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
gc.forward_inplace(&parent_);
|
||||
gc.forward_inplace(&ifelse_expr_);
|
||||
|
||||
return this->shallow_size();
|
||||
gc.visit_child(&parent_);
|
||||
gc.visit_child(&ifelse_expr_);
|
||||
}
|
||||
|
||||
// printable facet
|
||||
|
|
|
|||
|
|
@ -32,25 +32,17 @@ namespace xo {
|
|||
|
||||
// gcobject facet
|
||||
|
||||
std::size_t
|
||||
DVsmSeqContFrame::shallow_size() const noexcept
|
||||
{
|
||||
return sizeof(*this);
|
||||
}
|
||||
|
||||
DVsmSeqContFrame *
|
||||
DVsmSeqContFrame::shallow_move(obj<ACollector> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for<DVsmSeqContFrame>(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DVsmSeqContFrame::forward_children(obj<ACollector> gc) noexcept
|
||||
void
|
||||
DVsmSeqContFrame::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
gc.forward_inplace(&parent_);
|
||||
gc.forward_inplace(&seq_expr_);
|
||||
|
||||
return this->shallow_size();
|
||||
gc.visit_child(&parent_);
|
||||
gc.visit_child(&seq_expr_);
|
||||
}
|
||||
|
||||
// printable facet
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace xo {
|
|||
return self.shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DClosure::forward_children(DClosure & self, obj<ACollector> gc) noexcept -> void
|
||||
IGCObject_DClosure::visit_gco_children(DClosure & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.forward_children(gc);
|
||||
self.visit_gco_children(fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace xo {
|
|||
return self.shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DVsmApplyClosureFrame::forward_children(DVsmApplyClosureFrame & self, obj<ACollector> gc) noexcept -> void
|
||||
IGCObject_DVsmApplyClosureFrame::visit_gco_children(DVsmApplyClosureFrame & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.forward_children(gc);
|
||||
self.visit_gco_children(fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace xo {
|
|||
return self.shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DVsmApplyFrame::forward_children(DVsmApplyFrame & self, obj<ACollector> gc) noexcept -> void
|
||||
IGCObject_DVsmApplyFrame::visit_gco_children(DVsmApplyFrame & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.forward_children(gc);
|
||||
self.visit_gco_children(fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace xo {
|
|||
return self.shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DVsmDefContFrame::forward_children(DVsmDefContFrame & self, obj<ACollector> gc) noexcept -> void
|
||||
IGCObject_DVsmDefContFrame::visit_gco_children(DVsmDefContFrame & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.forward_children(gc);
|
||||
self.visit_gco_children(fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace xo {
|
|||
return self.shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DVsmEvalArgsFrame::forward_children(DVsmEvalArgsFrame & self, obj<ACollector> gc) noexcept -> void
|
||||
IGCObject_DVsmEvalArgsFrame::visit_gco_children(DVsmEvalArgsFrame & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.forward_children(gc);
|
||||
self.visit_gco_children(fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace xo {
|
|||
return self.shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DVsmIfElseContFrame::forward_children(DVsmIfElseContFrame & self, obj<ACollector> gc) noexcept -> void
|
||||
IGCObject_DVsmIfElseContFrame::visit_gco_children(DVsmIfElseContFrame & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.forward_children(gc);
|
||||
self.visit_gco_children(fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace xo {
|
|||
return self.shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DVsmSeqContFrame::forward_children(DVsmSeqContFrame & self, obj<ACollector> gc) noexcept -> void
|
||||
IGCObject_DVsmSeqContFrame::visit_gco_children(DVsmSeqContFrame & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.forward_children(gc);
|
||||
self.visit_gco_children(fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace xo {
|
|||
return self.shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DLocalEnv::forward_children(DLocalEnv & self, obj<ACollector> gc) noexcept -> void
|
||||
IGCObject_DLocalEnv::visit_gco_children(DLocalEnv & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.forward_children(gc);
|
||||
self.visit_gco_children(fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace xo {
|
|||
return self.shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DVirtualSchematikaMachine::forward_children(DVirtualSchematikaMachine & self, obj<ACollector> gc) noexcept -> void
|
||||
IGCObject_DVirtualSchematikaMachine::visit_gco_children(DVirtualSchematikaMachine & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.forward_children(gc);
|
||||
self.visit_gco_children(fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue