From 82c82ea33244661d34e75ffb69202f8c8263452c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 8 Feb 2026 01:01:03 -0500 Subject: [PATCH] xo-interpreter2 stack: work on VSM for apply -> closure action [WIP] --- CMakeLists.txt | 42 +++++++++++- idl/IGCObject_DClosure.json5 | 15 +++++ idl/IGCObject_DLocalEnv.json5 | 15 +++++ idl/IPrintable_DClosure.json5 | 13 ++++ include/xo/interpreter2/Closure.hpp | 2 + include/xo/interpreter2/DClosure.hpp | 5 ++ include/xo/interpreter2/DGlobalEnv.hpp | 6 +- include/xo/interpreter2/DLocalEnv.hpp | 11 ++- include/xo/interpreter2/LocalEnv.hpp | 2 +- .../interpreter2/VirtualSchematikaMachine.hpp | 4 ++ .../detail/IGCObject_DClosure.hpp | 67 +++++++++++++++++++ .../detail/IGCObject_DLocalEnv.hpp | 67 +++++++++++++++++++ .../detail/IPrintable_DClosure.hpp | 62 +++++++++++++++++ src/interpreter2/CMakeLists.txt | 7 +- src/interpreter2/DClosure.cpp | 36 +++++++++- src/interpreter2/DLocalEnv.cpp | 37 +++++++++- src/interpreter2/IGCObject_DClosure.cpp | 39 +++++++++++ src/interpreter2/IGCObject_DLocalEnv.cpp | 39 +++++++++++ src/interpreter2/IPrintable_DClosure.cpp | 28 ++++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 21 +++++- .../interpreter2_register_facets.cpp | 4 +- 21 files changed, 508 insertions(+), 14 deletions(-) create mode 100644 idl/IGCObject_DClosure.json5 create mode 100644 idl/IGCObject_DLocalEnv.json5 create mode 100644 idl/IPrintable_DClosure.json5 create mode 100644 include/xo/interpreter2/detail/IGCObject_DClosure.hpp create mode 100644 include/xo/interpreter2/detail/IGCObject_DLocalEnv.hpp create mode 100644 include/xo/interpreter2/detail/IPrintable_DClosure.hpp create mode 100644 src/interpreter2/IGCObject_DClosure.cpp create mode 100644 src/interpreter2/IGCObject_DLocalEnv.cpp create mode 100644 src/interpreter2/IPrintable_DClosure.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 25d8cd0d..b0b3c63a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/idl/IGCObject_DClosure.json5 b/idl/IGCObject_DClosure.json5 new file mode 100644 index 00000000..ec9f32fd --- /dev/null +++ b/idl/IGCObject_DClosure.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + 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" ], +} diff --git a/idl/IGCObject_DLocalEnv.json5 b/idl/IGCObject_DLocalEnv.json5 new file mode 100644 index 00000000..3c747621 --- /dev/null +++ b/idl/IGCObject_DLocalEnv.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + 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" ], +} diff --git a/idl/IPrintable_DClosure.json5 b/idl/IPrintable_DClosure.json5 new file mode 100644 index 00000000..d4b16a69 --- /dev/null +++ b/idl/IPrintable_DClosure.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + 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" ], +} diff --git a/include/xo/interpreter2/Closure.hpp b/include/xo/interpreter2/Closure.hpp index f352e7f0..5bbeb9b8 100644 --- a/include/xo/interpreter2/Closure.hpp +++ b/include/xo/interpreter2/Closure.hpp @@ -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 */ diff --git a/include/xo/interpreter2/DClosure.hpp b/include/xo/interpreter2/DClosure.hpp index bcf85c97..26ff2703 100644 --- a/include/xo/interpreter2/DClosure.hpp +++ b/include/xo/interpreter2/DClosure.hpp @@ -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 mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + ///@} /** @defgroup scm-closure-printable-facet **/ ///@{ diff --git a/include/xo/interpreter2/DGlobalEnv.hpp b/include/xo/interpreter2/DGlobalEnv.hpp index d0ab0827..e9f1a9c8 100644 --- a/include/xo/interpreter2/DGlobalEnv.hpp +++ b/include/xo/interpreter2/DGlobalEnv.hpp @@ -7,6 +7,7 @@ #include #include +#include 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. diff --git a/include/xo/interpreter2/DLocalEnv.hpp b/include/xo/interpreter2/DLocalEnv.hpp index 0291c748..5563fb3a 100644 --- a/include/xo/interpreter2/DLocalEnv.hpp +++ b/include/xo/interpreter2/DLocalEnv.hpp @@ -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 x); ///@} + /** @defgroup scm-localenv-gcobject-facet **/ + ///@{ + + std::size_t shallow_size() const noexcept; + DLocalEnv * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj 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*/ diff --git a/include/xo/interpreter2/LocalEnv.hpp b/include/xo/interpreter2/LocalEnv.hpp index 8976452f..a709e006 100644 --- a/include/xo/interpreter2/LocalEnv.hpp +++ b/include/xo/interpreter2/LocalEnv.hpp @@ -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 */ diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 7a209bf1..1aebed2c 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -8,6 +8,8 @@ #include "VsmConfig.hpp" #include "VsmInstr.hpp" #include "VsmFrame.hpp" +#include "DLocalEnv.hpp" +#include "DGlobalEnv.hpp" #include #include #include @@ -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 fn_; /** evaluated argument list **/ diff --git a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp new file mode 100644 index 00000000..fb863205 --- /dev/null +++ b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -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 +#include +#include "DClosure.hpp" + +namespace xo { namespace scm { class IGCObject_DClosure; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +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 mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DClosure & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/detail/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/detail/IGCObject_DLocalEnv.hpp new file mode 100644 index 00000000..d318bb61 --- /dev/null +++ b/include/xo/interpreter2/detail/IGCObject_DLocalEnv.hpp @@ -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 +#include +#include "DLocalEnv.hpp" + +namespace xo { namespace scm { class IGCObject_DLocalEnv; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +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 mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DLocalEnv & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/detail/IPrintable_DClosure.hpp b/include/xo/interpreter2/detail/IPrintable_DClosure.hpp new file mode 100644 index 00000000..6cc91cf1 --- /dev/null +++ b/include/xo/interpreter2/detail/IPrintable_DClosure.hpp @@ -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 +#include +#include "DClosure.hpp" + +namespace xo { namespace scm { class IPrintable_DClosure; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +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 */ \ No newline at end of file diff --git a/src/interpreter2/CMakeLists.txt b/src/interpreter2/CMakeLists.txt index b47ea31d..e7493775 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -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 ) diff --git a/src/interpreter2/DClosure.cpp b/src/interpreter2/DClosure.cpp index 1057a25d..b1868950 100644 --- a/src/interpreter2/DClosure.cpp +++ b/src/interpreter2/DClosure.cpp @@ -3,7 +3,10 @@ * @author Roland Conybeare, Feb 2026 **/ -#include "DClosure.hpp" +#include "Closure.hpp" +#include "LambdaExpr.hpp" +#include "LocalEnv.hpp" +#include 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 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 gc) noexcept + { + { + auto iface = xo::facet::impl_for(); + gc.forward_inplace(&iface, (void **)(&lambda_)); + + } + { + auto iface = xo::facet::impl_for(); + gc.forward_inplace(&iface, (void **)(&env_)); + } + + return shallow_size(); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/DLocalEnv.cpp b/src/interpreter2/DLocalEnv.cpp index 3aba3aa8..9ba65085 100644 --- a/src/interpreter2/DLocalEnv.cpp +++ b/src/interpreter2/DLocalEnv.cpp @@ -3,7 +3,8 @@ * @author Roland Conybeare, Feb 2026 **/ -#include "DLocalEnv.hpp" +#include "LocalEnv.hpp" +#include #include 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 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 gc) noexcept + { + { + auto iface = xo::facet::impl_for(); + gc.forward_inplace(&iface, (void **)(&parent_)); + } + { + auto iface = xo::facet::impl_for(); + gc.forward_inplace(&iface, (void **)(&symtab_)); + } + { + auto iface = xo::facet::impl_for(); + gc.forward_inplace(&iface, (void **)(&args_)); + } + + return shallow_size(); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/IGCObject_DClosure.cpp b/src/interpreter2/IGCObject_DClosure.cpp new file mode 100644 index 00000000..28dd3277 --- /dev/null +++ b/src/interpreter2/IGCObject_DClosure.cpp @@ -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 mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DClosure::forward_children(DClosure & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DClosure.cpp */ diff --git a/src/interpreter2/IGCObject_DLocalEnv.cpp b/src/interpreter2/IGCObject_DLocalEnv.cpp new file mode 100644 index 00000000..3ee3b7c7 --- /dev/null +++ b/src/interpreter2/IGCObject_DLocalEnv.cpp @@ -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 mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DLocalEnv::forward_children(DLocalEnv & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DLocalEnv.cpp */ diff --git a/src/interpreter2/IPrintable_DClosure.cpp b/src/interpreter2/IPrintable_DClosure.cpp new file mode 100644 index 00000000..e9c599fb --- /dev/null +++ b/src/interpreter2/IPrintable_DClosure.cpp @@ -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 */ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 767ef784..bfd5e09f 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -6,7 +6,9 @@ #include "VirtualSchematikaMachine.hpp" #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" +#include "Closure.hpp" #include +#include #include #include #include @@ -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::from(expr_); + + DClosure * closure = DClosure::make(mm_.to_op(), + lambda.data(), + local_env_); + + this->value_ = obj(obj(closure)); // not implemented assert(false); diff --git a/src/interpreter2/interpreter2_register_facets.cpp b/src/interpreter2/interpreter2_register_facets.cpp index 820dac2c..1953bf1d 100644 --- a/src/interpreter2/interpreter2_register_facets.cpp +++ b/src/interpreter2/interpreter2_register_facets.cpp @@ -7,7 +7,6 @@ #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" - #include "Closure.hpp" #include @@ -38,6 +37,9 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + // Procedure // +- Primitive_gco_2_gco_gco // \- Closure