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

@ -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 */