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 9a4a6b7188
42 changed files with 835 additions and 22 deletions

View file

@ -34,6 +34,7 @@ xo_add_genfacet(
# ----------------------------------------------------------------
# note: manual target; generated code committed to git
xo_add_genfacetimpl(
TARGET xo-expression2-facetimpl-symboltable-localsymtab
FACET_PKG xo_expression2
@ -45,6 +46,19 @@ xo_add_genfacetimpl(
OUTPUT_CPP_DIR src/expression2
)
# note: manual target; generated code committed to git
xo_add_genfacetimpl(
TARGET xo-expression2-facetimpl-gcobject-localsymtab
FACET_PKG xo_gc
FACET GCObject
REPR LocalSymtab
INPUT idl/IGCObject_DLocalSymtab.json5
OUTPUT_HPP_DIR include/xo/expression2
OUTPUT_IMPL_SUBDIR symtab
OUTPUT_CPP_DIR src/expression2
)
# note: manual target; generated code committed to git
xo_add_genfacetimpl(
TARGET xo-expression2-facetimpl-printable-localsymtab
FACET_PKG xo_printable2
@ -260,6 +274,18 @@ xo_add_genfacetimpl(
OUTPUT_CPP_DIR src/expression2
)
# note: manual target; generated code committed to git
xo_add_genfacetimpl(
TARGET xo-expression2-facetimpl-gcobject-lambdaexpr
FACET_PKG xo_gc
FACET GCObject
REPR LambdaExpr
INPUT idl/IGCObject_DLambdaExpr.json5
OUTPUT_HPP_DIR include/xo/expression2
OUTPUT_IMPL_SUBDIR detail
OUTPUT_CPP_DIR src/expression2
)
# note: manual target; generated code committed to git
xo_add_genfacetimpl(
TARGET xo-expression2-facetimpl-printable-lambdaexpr

View file

@ -0,0 +1,15 @@
{
mode: "implementation",
includes: [
"<xo/gc/GCObject.hpp>",
"<xo/alloc2/Allocator.hpp>"
],
local_types: [ ],
namespace1: "xo",
namespace2: "scm",
facet_idl: "idl/GCObject.json5",
brief: "provide AGCObject interface for DLambdaExpr",
using_doxygen: true,
repr: "DLambdaExpr",
doc: [ "implement AGCObject for DLambdaExpr" ],
}

View file

@ -0,0 +1,15 @@
{
mode: "implementation",
includes: [
"<xo/gc/GCObject.hpp>",
"<xo/alloc2/Allocator.hpp>"
],
local_types: [ ],
namespace1: "xo",
namespace2: "scm",
facet_idl: "idl/GCObject.json5",
brief: "provide AGCObject interface for DLocalSymtab",
using_doxygen: true,
repr: "DLocalSymtab",
doc: [ "implement AGCObject for DLocalSymtab" ],
}

View file

@ -56,4 +56,5 @@
// // Variable gives both {name, type}
// void upsert_local(DVariable * target) = 0;
],
router_facet_explicit_content: [ ],
}

View file

@ -25,6 +25,7 @@ namespace xo {
// using typeseq = xo::reflect::typeseq;
using ppindentinfo = xo::print::ppindentinfo;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
/* note: uint16_t would be fine too */
using size_type = std::uint32_t;
@ -90,6 +91,14 @@ namespace xo {
/** lookup binding for variable @p sym **/
Binding lookup_binding(const DUniqueString * sym) const noexcept;
///@}
/** @defgroup xo-localsymtab-gcobject-facet gcobject facet **/
///@{
std::size_t shallow_size() const noexcept;
DLocalSymtab * shallow_copy(obj<AAllocator> mm) const noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
///@}
/** @defgroup xo-localsymtab-printable-facet printable facet **/
///@{

View file

@ -7,7 +7,7 @@
#include "DLambdaExpr.hpp"
#include "detail/IExpression_DLambdaExpr.hpp"
//#include "detail/IGCObject_DLambdaExpr.hpp"
#include "detail/IGCObject_DLambdaExpr.hpp"
#include "detail/IPrintable_DLambdaExpr.hpp"
/* end LambdaExpr.hpp */

View file

@ -7,6 +7,7 @@
#include "DLocalSymtab.hpp"
#include "symtab/ISymbolTable_DLocalSymtab.hpp"
#include "symtab/IGCObject_DLocalSymtab.hpp"
#include "symtab/IPrintable_DLocalSymtab.hpp"
/* end LocalSymtab.hpp */

View file

@ -50,6 +50,8 @@ public:
// const methods
/** RTTI: unique id# for actual runtime data representation **/
virtual typeseq _typeseq() const noexcept = 0;
/** destroy instance @p d; calls c++ dtor only for actual runtime type; does not recover memory **/
virtual void _drop(Opaque d) const noexcept = 0;
/** expression type (constant | apply | ..) **/
virtual exprtype extype(Copaque data) const noexcept = 0;
/** placeholder for type giving possible values for this expression **/

View file

@ -54,8 +54,11 @@ namespace scm {
// from AExpression
// const methods
// builtin methods
typeseq _typeseq() const noexcept override { return s_typeseq; }
[[noreturn]] void _drop(Opaque) const noexcept override { _fatal(); }
// const methods
[[noreturn]] exprtype extype(Copaque) const noexcept override { _fatal(); }
[[noreturn]] TypeRef typeref(Copaque) const noexcept override { _fatal(); }
[[noreturn]] TypeDescr valuetype(Copaque) const noexcept override { _fatal(); }

View file

@ -41,8 +41,11 @@ namespace scm {
// from AExpression
// const methods
// builtin methods
typeseq _typeseq() const noexcept override { return s_typeseq; }
void _drop(Opaque d) const noexcept override { _dcast(d).~DRepr(); }
// const methods
exprtype extype(Copaque data) const noexcept override {
return I::extype(_dcast(data));
}

View file

@ -0,0 +1,67 @@
/** @file IGCObject_DLambdaExpr.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IGCObject_DLambdaExpr.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_repr.hpp.j2]
* 3. idl for facet methods
* [idl/IGCObject_DLambdaExpr.json5]
**/
#pragma once
#include "GCObject.hpp"
#include <xo/gc/GCObject.hpp>
#include <xo/alloc2/Allocator.hpp>
#include "DLambdaExpr.hpp"
namespace xo { namespace scm { class IGCObject_DLambdaExpr; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::mm::AGCObject,
xo::scm::DLambdaExpr>
{
using ImplType = xo::mm::IGCObject_Xfer
<xo::scm::DLambdaExpr,
xo::scm::IGCObject_DLambdaExpr>;
};
}
}
namespace xo {
namespace scm {
/** @class IGCObject_DLambdaExpr
**/
class IGCObject_DLambdaExpr {
public:
/** @defgroup scm-gcobject-dlambdaexpr-type-traits **/
///@{
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
/** @defgroup scm-gcobject-dlambdaexpr-methods **/
///@{
// const methods
/** memory consumption for this instance **/
static size_type shallow_size(const DLambdaExpr & self) noexcept;
/** copy instance using allocator **/
static Opaque shallow_copy(const DLambdaExpr & self, obj<AAllocator> mm) noexcept;
// non-const methods
/** during GC: forward immdiate children **/
static size_type forward_children(DLambdaExpr & self, obj<ACollector> gc) noexcept;
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */

View file

@ -46,8 +46,13 @@ public:
/** @defgroup scm-expression-router-methods **/
///@{
// const methods
// explicit injected content
// builtin methods
typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); }
void _drop() const noexcept { O::iface()->_drop(O::data()); }
// const methods
exprtype extype() const noexcept {
return O::iface()->extype(O::data());
}

View file

@ -47,6 +47,8 @@ public:
// const methods
/** RTTI: unique id# for actual runtime data representation **/
virtual typeseq _typeseq() const noexcept = 0;
/** destroy instance @p d; calls c++ dtor only for actual runtime type; does not recover memory **/
virtual void _drop(Opaque d) const noexcept = 0;
/** true iff this is toplevel (global) symbol table. **/
virtual bool is_global_symtab(Copaque data) const noexcept = 0;
/** report ingredients needed to address variable at runtime. **/

View file

@ -0,0 +1,67 @@
/** @file IGCObject_DLocalSymtab.hpp
*
* Generated automagically from ingredients:
* 1. code generator:
* [xo-facet/codegen/genfacet]
* arguments:
* --input [idl/IGCObject_DLocalSymtab.json5]
* 2. jinja2 template for abstract facet .hpp file:
* [iface_facet_repr.hpp.j2]
* 3. idl for facet methods
* [idl/IGCObject_DLocalSymtab.json5]
**/
#pragma once
#include "GCObject.hpp"
#include <xo/gc/GCObject.hpp>
#include <xo/alloc2/Allocator.hpp>
#include "DLocalSymtab.hpp"
namespace xo { namespace scm { class IGCObject_DLocalSymtab; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::mm::AGCObject,
xo::scm::DLocalSymtab>
{
using ImplType = xo::mm::IGCObject_Xfer
<xo::scm::DLocalSymtab,
xo::scm::IGCObject_DLocalSymtab>;
};
}
}
namespace xo {
namespace scm {
/** @class IGCObject_DLocalSymtab
**/
class IGCObject_DLocalSymtab {
public:
/** @defgroup scm-gcobject-dlocalsymtab-type-traits **/
///@{
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
/** @defgroup scm-gcobject-dlocalsymtab-methods **/
///@{
// const methods
/** memory consumption for this instance **/
static size_type shallow_size(const DLocalSymtab & self) noexcept;
/** copy instance using allocator **/
static Opaque shallow_copy(const DLocalSymtab & self, obj<AAllocator> mm) noexcept;
// non-const methods
/** during GC: forward immdiate children **/
static size_type forward_children(DLocalSymtab & self, obj<ACollector> gc) noexcept;
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */

View file

@ -53,8 +53,11 @@ namespace scm {
// from ASymbolTable
// const methods
// builtin methods
typeseq _typeseq() const noexcept override { return s_typeseq; }
[[noreturn]] void _drop(Opaque) const noexcept override { _fatal(); }
// const methods
[[noreturn]] bool is_global_symtab(Copaque) const noexcept override { _fatal(); }
[[noreturn]] Binding lookup_binding(Copaque, const DUniqueString *) const noexcept override { _fatal(); }

View file

@ -39,8 +39,11 @@ namespace scm {
// from ASymbolTable
// const methods
// builtin methods
typeseq _typeseq() const noexcept override { return s_typeseq; }
void _drop(Opaque d) const noexcept override { _dcast(d).~DRepr(); }
// const methods
bool is_global_symtab(Copaque data) const noexcept override {
return I::is_global_symtab(_dcast(data));
}

View file

@ -45,8 +45,13 @@ public:
/** @defgroup scm-symboltable-router-methods **/
///@{
// const methods
// explicit injected content
// builtin methods
typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); }
void _drop() const noexcept { O::iface()->_drop(O::data()); }
// const methods
bool is_global_symtab() const noexcept {
return O::iface()->is_global_symtab(O::data());
}

View file

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

View file

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

View file

@ -85,4 +85,4 @@ namespace xo { namespace facet {
};
} }
/* end RGCObject.hpp */
/* end RGCObject.hpp */

View file

@ -81,14 +81,52 @@ xo_add_genfacetimpl(
xo_add_genfacetimpl(
TARGET xo-interpreter2-facetimpl-procedure-closure
FACET_PKG xo_procedure2
FACET Printable
REPR DClosure
FACET Procedure
REPR Closure
INPUT idl/IProcedure_DClosure.json5
OUTPUT_HPP_DIR include/xo/interpreter2
OUTPUT_IMPL_SUBDIR detail
OUTPUT_CPP_DIR src/interpreter2
)
# note: manual target; generated code committed to git
xo_add_genfacetimpl(
TARGET xo-interpreter2-facetimpl-gcobject-closure
FACET_PKG xo_gc
FACET GCObject
REPR Closure
INPUT idl/IGCObject_DClosure.json5
OUTPUT_HPP_DIR include/xo/interpreter2
OUTPUT_IMPL_SUBDIR detail
OUTPUT_CPP_DIR src/interpreter2
)
# note: manual target; generated code committed to git
xo_add_genfacetimpl(
TARGET xo-interpreter2-facetimpl-printable-closure
FACET_PKG xo_printable2
FACET Printable
REPR Closure
INPUT idl/IPrintable_DClosure.json5
OUTPUT_HPP_DIR include/xo/interpreter2
OUTPUT_IMPL_SUBDIR detail
OUTPUT_CPP_DIR src/interpreter2
)
# ----------------------------------------------------------------
# note: manual target; generated code committed to git
xo_add_genfacetimpl(
TARGET xo-interpreter2-facetimpl-gcobject-localenv
FACET_PKG xo_gc
FACET GCObject
REPR LocalEnv
INPUT idl/IGCObject_DLocalEnv.json5
OUTPUT_HPP_DIR include/xo/interpreter2
OUTPUT_IMPL_SUBDIR detail
OUTPUT_CPP_DIR src/interpreter2
)
# ----------------------------------------------------------------
xo_add_genfacet_all(xo-interpreter2-genfacet-all)

View file

@ -0,0 +1,15 @@
{
mode: "implementation",
includes: [
"<xo/gc/GCObject.hpp>",
"<xo/alloc2/Allocator.hpp>"
],
local_types: [ ],
namespace1: "xo",
namespace2: "scm",
facet_idl: "idl/GCObject.json5",
brief: "provide AGCObject interface for Closure",
using_doxygen: true,
repr: "DClosure",
doc: [ "implement AGCObject for DClosure" ],
}

View file

@ -0,0 +1,15 @@
{
mode: "implementation",
includes: [
"<xo/gc/GCObject.hpp>",
"<xo/alloc2/Allocator.hpp>"
],
local_types: [ ],
namespace1: "xo",
namespace2: "scm",
facet_idl: "idl/GCObject.json5",
brief: "provide AGCObject interface for LocalEnv",
using_doxygen: true,
repr: "DLocalEnv",
doc: [ "implement AGCObject for DLocalEnv" ],
}

View file

@ -0,0 +1,13 @@
{
mode: "implementation",
includes: [ "<xo/printable2/Printable.hpp>",
"<xo/printable2/detail/IPrintable_Xfer.hpp>" ],
local_types: [ ],
namespace1: "xo",
namespace2: "scm",
facet_idl: "idl/Printable.json5",
brief: "provide APrintable interface for DClosure",
using_doxygen: true,
repr: "DClosure",
doc: [ "implement APrintable for DClosure" ],
}

View file

@ -7,5 +7,7 @@
#include "DClosure.hpp"
#include "detail/IProcedure_DClosure.hpp"
#include "detail/IGCObject_DClosure.hpp"
#include "detail/IPrintable_DClosure.hpp"
/* end Closure.hpp */

View file

@ -19,6 +19,7 @@ namespace xo {
class DClosure {
public:
using ARuntimeContext = xo::scm::ARuntimeContext;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using AGCObject = xo::mm::AGCObject;
using ppindentinfo = xo::print::ppindentinfo;
@ -56,6 +57,10 @@ namespace xo {
/** @defgroup scm-closure-gcobject-facet **/
///@{
std::size_t shallow_size() const noexcept;
DClosure * shallow_copy(obj<AAllocator> mm) const noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
///@}
/** @defgroup scm-closure-printable-facet **/
///@{

View file

@ -7,6 +7,7 @@
#include <xo/expression2/DGlobalSymtab.hpp>
#include <xo/object2/DList.hpp>
#include <xo/object2/DArray.hpp>
namespace xo {
namespace scm {
@ -16,9 +17,10 @@ namespace xo {
**/
class DGlobalEnv {
public:
DGLobalEnv() = default;
DGlobalEnv() = default;
protected: // temporary, to appease compiler
private:
// absurd O(n) implementation for now
// replace with gc-aware hashtable, when available.

View file

@ -16,6 +16,7 @@ namespace xo {
class DLocalEnv {
public:
using DArray = xo::scm::DArray;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using AGCObject = xo::mm::AGCObject;
using ppindentinfo = xo::print::ppindentinfo;
@ -49,6 +50,14 @@ namespace xo {
void assign_value(Binding ix, obj<AGCObject> x);
///@}
/** @defgroup scm-localenv-gcobject-facet **/
///@{
std::size_t shallow_size() const noexcept;
DLocalEnv * shallow_copy(obj<AAllocator> mm) const noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
///@}
private:
/** parent environment (from closure) **/
@ -58,7 +67,7 @@ namespace xo {
/** bindings.
* (*args)[i] associates a value with symtab->slots_[i]
**/
DArray * args_ = nullptr;;
DArray * args_ = nullptr;
};
} /*namespace scm*/

View file

@ -6,7 +6,7 @@
#pragma once
#include "DLocalEnv.hpp"
//#include "detail/IGCObject_DLocalEnv.hpp"
#include "detail/IGCObject_DLocalEnv.hpp"
//#include "detail/IPrintable_DLocalEnv.hpp"
/* end LocalEnv.hpp */

View file

@ -8,6 +8,8 @@
#include "VsmConfig.hpp"
#include "VsmInstr.hpp"
#include "VsmFrame.hpp"
#include "DLocalEnv.hpp"
#include "DGlobalEnv.hpp"
#include <xo/reader2/SchematikaReader.hpp>
#include <xo/expression2/Expression.hpp>
#include <xo/gc/GCObject.hpp>
@ -214,11 +216,13 @@ namespace xo {
* in execution
**/
DLocalEnv * local_env_ = nullptr;
protected: // temporarily, to appease compiler
/** environment pointer. Maintains bindings
* for global variables.
**/
DGlobalEnv * global_env_ = nullptr;
private:
/** function to call **/
obj<AProcedure> fn_;
/** evaluated argument list **/

View file

@ -0,0 +1,67 @@
/** @file IGCObject_DClosure.hpp
*
* 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_repr.hpp.j2]
* 3. idl for facet methods
* [idl/IGCObject_DClosure.json5]
**/
#pragma once
#include "GCObject.hpp"
#include <xo/gc/GCObject.hpp>
#include <xo/alloc2/Allocator.hpp>
#include "DClosure.hpp"
namespace xo { namespace scm { class IGCObject_DClosure; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::mm::AGCObject,
xo::scm::DClosure>
{
using ImplType = xo::mm::IGCObject_Xfer
<xo::scm::DClosure,
xo::scm::IGCObject_DClosure>;
};
}
}
namespace xo {
namespace scm {
/** @class IGCObject_DClosure
**/
class IGCObject_DClosure {
public:
/** @defgroup scm-gcobject-dclosure-type-traits **/
///@{
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
/** @defgroup scm-gcobject-dclosure-methods **/
///@{
// const methods
/** memory consumption for this instance **/
static size_type shallow_size(const DClosure & self) noexcept;
/** copy instance using allocator **/
static Opaque shallow_copy(const DClosure & self, obj<AAllocator> mm) noexcept;
// non-const methods
/** during GC: forward immdiate children **/
static size_type forward_children(DClosure & self, obj<ACollector> gc) noexcept;
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */

View file

@ -0,0 +1,67 @@
/** @file IGCObject_DLocalEnv.hpp
*
* 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_repr.hpp.j2]
* 3. idl for facet methods
* [idl/IGCObject_DLocalEnv.json5]
**/
#pragma once
#include "GCObject.hpp"
#include <xo/gc/GCObject.hpp>
#include <xo/alloc2/Allocator.hpp>
#include "DLocalEnv.hpp"
namespace xo { namespace scm { class IGCObject_DLocalEnv; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::mm::AGCObject,
xo::scm::DLocalEnv>
{
using ImplType = xo::mm::IGCObject_Xfer
<xo::scm::DLocalEnv,
xo::scm::IGCObject_DLocalEnv>;
};
}
}
namespace xo {
namespace scm {
/** @class IGCObject_DLocalEnv
**/
class IGCObject_DLocalEnv {
public:
/** @defgroup scm-gcobject-dlocalenv-type-traits **/
///@{
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
/** @defgroup scm-gcobject-dlocalenv-methods **/
///@{
// const methods
/** memory consumption for this instance **/
static size_type shallow_size(const DLocalEnv & self) noexcept;
/** copy instance using allocator **/
static Opaque shallow_copy(const DLocalEnv & self, obj<AAllocator> mm) noexcept;
// non-const methods
/** during GC: forward immdiate children **/
static size_type forward_children(DLocalEnv & self, obj<ACollector> gc) noexcept;
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */

View file

@ -0,0 +1,62 @@
/** @file IPrintable_DClosure.hpp
*
* 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_repr.hpp.j2]
* 3. idl for facet methods
* [idl/IPrintable_DClosure.json5]
**/
#pragma once
#include "Printable.hpp"
#include <xo/printable2/Printable.hpp>
#include <xo/printable2/detail/IPrintable_Xfer.hpp>
#include "DClosure.hpp"
namespace xo { namespace scm { class IPrintable_DClosure; } }
namespace xo {
namespace facet {
template <>
struct FacetImplementation<xo::print::APrintable,
xo::scm::DClosure>
{
using ImplType = xo::print::IPrintable_Xfer
<xo::scm::DClosure,
xo::scm::IPrintable_DClosure>;
};
}
}
namespace xo {
namespace scm {
/** @class IPrintable_DClosure
**/
class IPrintable_DClosure {
public:
/** @defgroup scm-printable-dclosure-type-traits **/
///@{
using ppindentinfo = xo::print::APrintable::ppindentinfo;
using Copaque = xo::print::APrintable::Copaque;
using Opaque = xo::print::APrintable::Opaque;
///@}
/** @defgroup scm-printable-dclosure-methods **/
///@{
// const methods
/** Pretty-printing support for this object.
See [xo-indentlog/xo/indentlog/pretty.hpp] **/
static bool pretty(const DClosure & self, const ppindentinfo & ppii);
// non-const methods
///@}
};
} /*namespace scm*/
} /*namespace xo*/
/* end */

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

View file

@ -0,0 +1,14 @@
/** @file Array.hpp
*
* @author Roland Conybeare, Feb 2026
**/
#pragma once
#include "DArray.hpp"
#include "array/ISequence_DArray.hpp"
#include "array/IGCObject_DArray.hpp"
#include "array/IPrintable_DArray.hpp"
/* end Array.hpp */