xo-interpreter2 stack: work on VSM for apply -> closure action [WIP]

This commit is contained in:
Roland Conybeare 2026-02-08 01:01:03 -05:00
commit 82c82ea332
21 changed files with 508 additions and 14 deletions

View file

@ -16,12 +16,15 @@ set(SELF_SRCS
IGCObject_DVsmApplyFrame.cpp
IPrintable_DVsmApplyFrame.cpp
DClosure.cpp
IGCObject_DClosure.cpp
IProcedure_DClosure.cpp
IGCObject_DLocalEnv.cpp
DLocalEnv.cpp
VsmInstr.cpp
DClosure.cpp
DLocalEnv.cpp
#IExpression_Any.cpp
)

View file

@ -3,7 +3,10 @@
* @author Roland Conybeare, Feb 2026
**/
#include "DClosure.hpp"
#include "Closure.hpp"
#include "LambdaExpr.hpp"
#include "LocalEnv.hpp"
#include <cstddef>
namespace xo {
using xo::mm::AGCObject;
@ -35,6 +38,37 @@ namespace xo {
assert(false);
}
size_t
DClosure::shallow_size() const noexcept {
return sizeof(DClosure);
}
DClosure *
DClosure::shallow_copy(obj<AAllocator> mm) const noexcept {
DClosure * copy = (DClosure *)mm.alloc_copy((std::byte *)this);
if (copy)
*copy = *this;
return copy;
}
std::size_t
DClosure::forward_children(obj<ACollector> gc) noexcept
{
{
auto iface = xo::facet::impl_for<AGCObject,DLambdaExpr>();
gc.forward_inplace(&iface, (void **)(&lambda_));
}
{
auto iface = xo::facet::impl_for<AGCObject,DLocalEnv>();
gc.forward_inplace(&iface, (void **)(&env_));
}
return shallow_size();
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -3,7 +3,8 @@
* @author Roland Conybeare, Feb 2026
**/
#include "DLocalEnv.hpp"
#include "LocalEnv.hpp"
#include <xo/object2/Array.hpp>
#include <xo/reflectutil/typeseq.hpp>
namespace xo {
@ -86,6 +87,40 @@ namespace xo {
/* something terribly wrong if control here */
}
std::size_t
DLocalEnv::shallow_size() const noexcept {
return sizeof(DLocalEnv);
}
DLocalEnv *
DLocalEnv::shallow_copy(obj<AAllocator> mm) const noexcept {
DLocalEnv * copy = (DLocalEnv *)mm.alloc_copy((std::byte *)this);
if (copy)
*copy = *this;
return copy;
}
std::size_t
DLocalEnv::forward_children(obj<ACollector> gc) noexcept
{
{
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_));
}
{
auto iface = xo::facet::impl_for<AGCObject,DArray>();
gc.forward_inplace(&iface, (void **)(&args_));
}
return shallow_size();
}
} /*namespace scm*/
} /*namespace xo*/

View file

@ -0,0 +1,39 @@
/** @file IGCObject_DClosure.cpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IGCObject_DClosure.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_any.hpp.j2]
* 3. idl for facet methods
* [idl/IGCObject_DClosure.json5]
**/
#include "detail/IGCObject_DClosure.hpp"
namespace xo {
namespace scm {
auto
IGCObject_DClosure::shallow_size(const DClosure & self) noexcept -> size_type
{
return self.shallow_size();
}
auto
IGCObject_DClosure::shallow_copy(const DClosure & self, obj<AAllocator> mm) noexcept -> Opaque
{
return self.shallow_copy(mm);
}
auto
IGCObject_DClosure::forward_children(DClosure & self, obj<ACollector> gc) noexcept -> size_type
{
return self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/
/* end IGCObject_DClosure.cpp */

View file

@ -0,0 +1,39 @@
/** @file IGCObject_DLocalEnv.cpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IGCObject_DLocalEnv.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_any.hpp.j2]
* 3. idl for facet methods
* [idl/IGCObject_DLocalEnv.json5]
**/
#include "detail/IGCObject_DLocalEnv.hpp"
namespace xo {
namespace scm {
auto
IGCObject_DLocalEnv::shallow_size(const DLocalEnv & self) noexcept -> size_type
{
return self.shallow_size();
}
auto
IGCObject_DLocalEnv::shallow_copy(const DLocalEnv & self, obj<AAllocator> mm) noexcept -> Opaque
{
return self.shallow_copy(mm);
}
auto
IGCObject_DLocalEnv::forward_children(DLocalEnv & self, obj<ACollector> gc) noexcept -> size_type
{
return self.forward_children(gc);
}
} /*namespace scm*/
} /*namespace xo*/
/* end IGCObject_DLocalEnv.cpp */

View file

@ -0,0 +1,28 @@
/** @file IPrintable_DClosure.cpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IPrintable_DClosure.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_any.hpp.j2]
* 3. idl for facet methods
* [idl/IPrintable_DClosure.json5]
**/
#include "detail/IPrintable_DClosure.hpp"
namespace xo {
namespace scm {
auto
IPrintable_DClosure::pretty(const DClosure & self, const ppindentinfo & ppii) -> bool
{
return self.pretty(ppii);
}
} /*namespace scm*/
} /*namespace xo*/
/* end IPrintable_DClosure.cpp */

View file

@ -6,7 +6,9 @@
#include "VirtualSchematikaMachine.hpp"
#include "VsmApplyFrame.hpp"
#include "VsmEvalArgsFrame.hpp"
#include "Closure.hpp"
#include <xo/expression2/ApplyExpr.hpp>
#include <xo/expression2/LambdaExpr.hpp>
#include <xo/expression2/Constant.hpp>
#include <xo/procedure2/RuntimeContext.hpp>
#include <xo/procedure2/SimpleRcx.hpp>
@ -21,7 +23,7 @@ namespace xo {
using xo::print::ppconfig;
using xo::print::ppstate_standalone;
using xo::mm::AGCObject;
using xo::mm::MemorySizeInfo;
//using xo::mm::MemorySizeInfo; // not used yet
using xo::mm::DX1Collector;
using xo::facet::FacetRegistry;
using std::cout;
@ -217,7 +219,7 @@ namespace xo {
// <--------------------------------------/ | |
// | |
// v v
// DLocalSymtab DLambdaExpr
// DLocalSymtab DLambdaExpr
//
// DClosure runtime procedure (created below)
// DArray bound non-local variables (established by VSM)
@ -225,8 +227,21 @@ namespace xo {
// h alloc header
// DLocalSymtab local symbol table (created by parser)
// DLambdaExpr lambda expression (created by parser)
//
DArray * args =
// will create DClosure with local_env_
// local_env_
// global_env_
auto lambda
= obj<AExpression,DLambdaExpr>::from(expr_);
DClosure * closure = DClosure::make(mm_.to_op(),
lambda.data(),
local_env_);
this->value_ = obj<AGCObject>(obj<AGCObject,DClosure>(closure));
// not implemented
assert(false);

View file

@ -7,7 +7,6 @@
#include "VsmApplyFrame.hpp"
#include "VsmEvalArgsFrame.hpp"
#include "Closure.hpp"
#include <xo/printable2/detail/APrintable.hpp>
@ -38,6 +37,9 @@ namespace xo {
FacetRegistry::register_impl<AGCObject, DVsmEvalArgsFrame>();
FacetRegistry::register_impl<APrintable, DVsmEvalArgsFrame>();
FacetRegistry::register_impl<AGCObject, DClosure>();
FacetRegistry::register_impl<APrintable, DClosure>();
// Procedure
// +- Primitive_gco_2_gco_gco
// \- Closure