From 5be6650bd17659cca1173d993284646c4ceec24c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 10 Jan 2026 12:39:09 -0500 Subject: [PATCH 001/131] + xo-tokenizer2 xo-reader2 xo-expression2 xo-interpreter2 2nd gen schematika interpreter using fomo --- CMakeLists.txt | 41 ++++++++++++++++++++++++++++ cmake/xo-bootstrap-macros.cmake | 33 ++++++++++++++++++++++ cmake/xo_interpreter2Config.cmake.in | 12 ++++++++ include/xo/interpreter2/.gitkeep | 0 4 files changed, 86 insertions(+) create mode 100644 CMakeLists.txt create mode 100644 cmake/xo-bootstrap-macros.cmake create mode 100644 cmake/xo_interpreter2Config.cmake.in create mode 100644 include/xo/interpreter2/.gitkeep diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..aa9c09e6 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,41 @@ +# xo-interpreter2/CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) + +project(xo_interpreter2 VERSION 1.0) +enable_language(CXX) + +include(GNUInstallDirs) +include(cmake/xo-bootstrap-macros.cmake) + +xo_cxx_toplevel_options3() + +# ---------------------------------------------------------------- +# c++ settings + +# one-time project-specific c++ flags. usually empty +set(PROJECT_CXX_FLAGS "") +add_definitions(${PROJECT_CXX_FLAGS}) + +# ---------------------------------------------------------------- +# output targets + +#add_subdirectory(utest) + +# ---------------------------------------------------------------- +# header-only library + +set(SELF_LIB xo_interpreter2) +xo_add_headeronly_library(${SELF_LIB}) +xo_install_library4(${SELF_LIB} ${PROJECT_NAME}Targets) +xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) + +# ---------------------------------------------------------------- +# input dependencies +# +# NOTE: dependency set here must be kept consistent with +# xo-interpreter2/cmake/xo_interpreter2Config.cmake.in + +#xo_headeronly_dependency(${SELF_LIB} xo_flatstring) + +# end CMakeLists.txt diff --git a/cmake/xo-bootstrap-macros.cmake b/cmake/xo-bootstrap-macros.cmake new file mode 100644 index 00000000..2cf387e5 --- /dev/null +++ b/cmake/xo-bootstrap-macros.cmake @@ -0,0 +1,33 @@ +# ---------------------------------------------------------------- +# for example: +# $ PREFIX=/usr/local # for example +# $ cmake -DCMAKE_MODULE_PATH=prefix -DCMAKE_INSTALL_PREFIX=$PREFIX -B .build +# +# will get +# CMAKE_MODULE_PATH +# from xo-cmake-config --cmake-module-path +# +# and expect .cmake macros in +# CMAKE_MODULE_PATH/xo_macros/xo_cxx.cmake +# ---------------------------------------------------------------- + +find_program(XO_CMAKE_CONFIG_EXECUTABLE NAMES xo-cmake-config REQUIRED) + +if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "prefix")) + message(FATAL "could not find xo-cmake-config executable") +endif() + +if (NOT XO_SUBMODULE_BUILD) + if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix)) + # default to typical install location for xo-project-macros + execute_process(COMMAND ${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH) + message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + endif() +endif() + +# needs to have been installed somewhere on CMAKE_MODULE_PATH, +# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) +# +include(xo_macros/xo_cxx) + +xo_cxx_bootstrap_message() diff --git a/cmake/xo_interpreter2Config.cmake.in b/cmake/xo_interpreter2Config.cmake.in new file mode 100644 index 00000000..b5c3cd5c --- /dev/null +++ b/cmake/xo_interpreter2Config.cmake.in @@ -0,0 +1,12 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +# note: changes to find_dependency() calls here +# must coordinate with xo_dependency() calls +# in CMakeLists.txt +# +#find_dependency(xo_flatstring) + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/include/xo/interpreter2/.gitkeep b/include/xo/interpreter2/.gitkeep new file mode 100644 index 00000000..e69de29b From 2521751f0a2f7929889f1d7c7e3bcd7f9048613e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 13 Jan 2026 01:40:48 -0500 Subject: [PATCH 002/131] + xo-interpreter2 scaffold for constant expression [WIP] --- CMakeLists.txt | 7 +- cmake/xo_interpreter2Config.cmake.in | 3 +- .../interpreter2/VirtualSchematikaMachine.hpp | 78 +++++++++++++++++++ include/xo/interpreter2/VsmInstr.hpp | 27 +++++++ include/xo/interpreter2/VsmOpcode.hpp | 29 +++++++ src/interpreter2/CMakeLists.txt | 17 ++++ src/interpreter2/VirtualSchematikaMachine.cpp | 63 +++++++++++++++ 7 files changed, 217 insertions(+), 7 deletions(-) create mode 100644 include/xo/interpreter2/VirtualSchematikaMachine.hpp create mode 100644 include/xo/interpreter2/VsmInstr.hpp create mode 100644 include/xo/interpreter2/VsmOpcode.hpp create mode 100644 src/interpreter2/CMakeLists.txt create mode 100644 src/interpreter2/VirtualSchematikaMachine.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index aa9c09e6..ac944a36 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,14 +20,9 @@ add_definitions(${PROJECT_CXX_FLAGS}) # ---------------------------------------------------------------- # output targets +add_subdirectory(src/interpreter2) #add_subdirectory(utest) -# ---------------------------------------------------------------- -# header-only library - -set(SELF_LIB xo_interpreter2) -xo_add_headeronly_library(${SELF_LIB}) -xo_install_library4(${SELF_LIB} ${PROJECT_NAME}Targets) xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) # ---------------------------------------------------------------- diff --git a/cmake/xo_interpreter2Config.cmake.in b/cmake/xo_interpreter2Config.cmake.in index b5c3cd5c..bea8e9cc 100644 --- a/cmake/xo_interpreter2Config.cmake.in +++ b/cmake/xo_interpreter2Config.cmake.in @@ -6,7 +6,8 @@ include(CMakeFindDependencyMacro) # must coordinate with xo_dependency() calls # in CMakeLists.txt # -#find_dependency(xo_flatstring) +find_dependency(xo_expression2) +find_dependency(xo_gc) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") check_required_components("@PROJECT_NAME@") diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp new file mode 100644 index 00000000..6facb3fb --- /dev/null +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -0,0 +1,78 @@ +/** @file VirtualSchematikaMachine.hpp + * + * @author Roland Conybare, Jan 2026 + **/ + +#pragma once + +#include "VsmInstr.hpp" +#include +#include + +namespace xo { + namespace scm { + /** @class VirtualSchematikaMachine + * @brief virtual machine for schematika + **/ + class VirtualSchematikaMachine { + public: + // will be DArenaVector> probably + using Stack = void *; + using AGCObject = xo::mm::AGCObject; + + public: + VirtualSchematikaMachine(); + + /** borrow calling thread to run indefinitely, + * until halt instruction + **/ + void run(); + + /** execute vsm instruction in @ref pc_. + * @retval instruction count. 1 unless pc_ is halt. + **/ + bool execute_one(); + + private: + /** Require: + * - expression in @ref expr_ + **/ + void _do_eval_op(); + + /** evaluate a constant expression + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_constant_op(); + + private: + /* + * Some registers are preserved by evaluation: + * stack_ + * cont_ + * + * Other registers are not preserved + * pc_ + * expr_ + * value_ + */ + + /** program counter **/ + VsmInstr pc_ = VsmInstr::halt(); + + /** stack pointer **/ + Stack stack_; + + /** expression register **/ + obj expr_; + + /** result register **/ + obj value_; + + /** continuation register **/ + VsmInstr cont_ = VsmInstr::halt(); + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VirtualSchematikaMachine.hpp */ diff --git a/include/xo/interpreter2/VsmInstr.hpp b/include/xo/interpreter2/VsmInstr.hpp new file mode 100644 index 00000000..ca74bc4c --- /dev/null +++ b/include/xo/interpreter2/VsmInstr.hpp @@ -0,0 +1,27 @@ +/** @file VsmInstr.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "VsmOpcode.hpp" + +namespace xo { + namespace scm { + class VsmInstr { + public: + explicit VsmInstr(vsm_opcode oc) : opcode_{oc} {} + + static VsmInstr halt() { return VsmInstr{vsm_opcode::halt}; } + static VsmInstr eval() { return VsmInstr{vsm_opcode::eval}; } + + vsm_opcode opcode() const noexcept { return opcode_; } + + private: + vsm_opcode opcode_; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VsmInstr.hpp */ diff --git a/include/xo/interpreter2/VsmOpcode.hpp b/include/xo/interpreter2/VsmOpcode.hpp new file mode 100644 index 00000000..3638fa29 --- /dev/null +++ b/include/xo/interpreter2/VsmOpcode.hpp @@ -0,0 +1,29 @@ +/** @file VsmOpcode.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + /** Opcode for a virtual schematika expression; + * exeucted by VirtualSchematikaMachine + **/ + enum class vsm_opcode { + /** Immediately halt virtual schematika machine. **/ + halt, + /** Evaluate expression in expr register **/ + eval, + + /** sentinel, counts number of opcodes **/ + N, + }; + + static constexpr uint32_t n_opcode = static_cast(vsm_opcode::N); + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VsmOpcode.hpp */ diff --git a/src/interpreter2/CMakeLists.txt b/src/interpreter2/CMakeLists.txt new file mode 100644 index 00000000..15d06fdf --- /dev/null +++ b/src/interpreter2/CMakeLists.txt @@ -0,0 +1,17 @@ +# interpreter2/CMakeLists.txt + +set(SELF_LIB xo_interpreter2) +set(SELF_SRCS + VirtualSchematikaMachine.cpp + #IExpression_Any.cpp + #interpreter2_register_facets.cpp + ) + +xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) +# note: deps here must also appear in cmake/xo_interpreter2Config.cmake.in +xo_dependency(${SELF_LIB} xo_expression2) +xo_dependency(${SELF_LIB} xo_gc) +#xo_dependency(${SELF_LIB} reflect) +#xo_dependency(${SELF_LIB} xo_printable2) +#xo_dependency(${SELF_LIB} xo_flatstring) +#xo_dependency(${SELF_LIB} indentlog) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp new file mode 100644 index 00000000..5882dc89 --- /dev/null +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -0,0 +1,63 @@ +/** @file VirtualSchematikaMachine.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "VirtualSchematikaMachine.hpp" +#include +#include + +namespace xo { + namespace scm { + + VirtualSchematikaMachine::VirtualSchematikaMachine() + {} + + void + VirtualSchematikaMachine::run() + { + while (this->execute_one()) + ; + } + + bool + VirtualSchematikaMachine::execute_one() + { + switch (pc_.opcode()) { + case vsm_opcode::halt: + case vsm_opcode::N: + return false; + case vsm_opcode::eval: + _do_eval_op(); + } + + return true; + } + + void + VirtualSchematikaMachine::_do_eval_op() + { + switch(expr_.extype()) { + case exprtype::invalid: + case exprtype::N: + break; + case exprtype::constant: + _do_eval_constant_op(); + break; + } + } + + void + VirtualSchematikaMachine::_do_eval_constant_op() + { + auto expr + = obj::from(expr_); + + this->value_ = expr.data()->value(); + this->pc_ = this->cont_; + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VirtualSchematikaMachine.hpp */ From 56e9b5750827fc0bfec9bf612950a469aa4c3857 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 14 Jan 2026 00:09:45 -0500 Subject: [PATCH 003/131] xo-expression2: + IExpression_DConstant --- src/interpreter2/VirtualSchematikaMachine.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 5882dc89..012b16f6 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -4,6 +4,7 @@ **/ #include "VirtualSchematikaMachine.hpp" +#include #include #include From fd0eb9466132b5da3193316fe3b5f1cd946103cd Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 17 Jan 2026 01:11:50 -0500 Subject: [PATCH 004/131] xo-expression2: scaffold variable eval in VSM --- include/xo/interpreter2/VirtualSchematikaMachine.hpp | 8 ++++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 9 +++++++++ 2 files changed, 17 insertions(+) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 6facb3fb..8bbe6bb4 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -45,6 +45,12 @@ namespace xo { **/ void _do_eval_constant_op(); + /** evaluate a variable expression + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_variable_op(); + private: /* * Some registers are preserved by evaluation: @@ -60,8 +66,10 @@ namespace xo { /** program counter **/ VsmInstr pc_ = VsmInstr::halt(); +#ifdef NOT_YET /** stack pointer **/ Stack stack_; +#endif /** expression register **/ obj expr_; diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 012b16f6..bd29e968 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -45,6 +45,9 @@ namespace xo { case exprtype::constant: _do_eval_constant_op(); break; + case exprtype::variable: + _do_eval_variable_op(); + break; } } @@ -58,6 +61,12 @@ namespace xo { this->pc_ = this->cont_; } + void + VirtualSchematikaMachine::_do_eval_variable_op() + { + // not implemented + assert(false); + } } /*namespace scm*/ } /*namespace xo*/ From 0bcd97685e124981ea4cfd92411cc57018307811 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 19 Jan 2026 21:25:30 -0500 Subject: [PATCH 005/131] xo-reader2 xo-expresion2: work on define-expressions [WIP] --- include/xo/interpreter2/VirtualSchematikaMachine.hpp | 6 ++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 8bbe6bb4..a149173e 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -45,6 +45,12 @@ namespace xo { **/ void _do_eval_constant_op(); + /** evaluate a define-expression + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_define_op(); + /** evaluate a variable expression * Require: * - expression in @ref expr_ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index bd29e968..f7131e0a 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -45,6 +45,9 @@ namespace xo { case exprtype::constant: _do_eval_constant_op(); break; + case exprtype::define: + _do_eval_define_op(); + break; case exprtype::variable: _do_eval_variable_op(); break; @@ -61,6 +64,13 @@ namespace xo { this->pc_ = this->cont_; } + void + VirtualSchematikaMachine::_do_eval_define_op() + { + // not implemented + assert(false); + } + void VirtualSchematikaMachine::_do_eval_variable_op() { From c1a88bb2cb92fee9fe8bfc92997481750f891077 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 22 Jan 2026 15:18:35 -0500 Subject: [PATCH 006/131] xo-reader2: + on_f64_token() + handle in DDefineSsm+DProgressSsm --- src/interpreter2/VirtualSchematikaMachine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index f7131e0a..4dccce34 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -4,7 +4,7 @@ **/ #include "VirtualSchematikaMachine.hpp" -#include +#include #include #include From 64f690c253d2942ffb59c8bc27bff7d20ae289da Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 25 Jan 2026 13:14:26 -0500 Subject: [PATCH 007/131] xo-expression2: + DApplyExpr [WIP]. Builds, not used or tested --- include/xo/interpreter2/VirtualSchematikaMachine.hpp | 6 ++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index a149173e..e8e58dbc 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -57,6 +57,12 @@ namespace xo { **/ void _do_eval_variable_op(); + /** evaluate an apply expression + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_apply_op(); + private: /* * Some registers are preserved by evaluation: diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 4dccce34..b2789c26 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -51,6 +51,9 @@ namespace xo { case exprtype::variable: _do_eval_variable_op(); break; + case exprtype::apply: + _do_eval_apply_op(); + break; } } @@ -77,6 +80,13 @@ namespace xo { // not implemented assert(false); } + + void + VirtualSchematikaMachine::_do_eval_apply_op() + { + // not implemented + assert(false); + } } /*namespace scm*/ } /*namespace xo*/ From 21310c20c0d52915a30272080609d52355d16d0e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 27 Jan 2026 10:09:26 -0500 Subject: [PATCH 008/131] xo-expression2: + DIfElseExpr + utest --- include/xo/interpreter2/VirtualSchematikaMachine.hpp | 6 ++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index e8e58dbc..066b7ffd 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -63,6 +63,12 @@ namespace xo { **/ void _do_eval_apply_op(); + /** evaluate an if-else expression + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_if_else_op(); + private: /* * Some registers are preserved by evaluation: diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index b2789c26..11a60c64 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -54,6 +54,9 @@ namespace xo { case exprtype::apply: _do_eval_apply_op(); break; + case exprtype::ifexpr: + _do_eval_if_else_op(); + break; } } @@ -87,6 +90,13 @@ namespace xo { // not implemented assert(false); } + + void + VirtualSchematikaMachine::_do_eval_if_else_op() + { + // not implemented + assert(false); + } } /*namespace scm*/ } /*namespace xo*/ From c68357a3bd6f936334f64df4413beda33fa9c0db Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 27 Jan 2026 22:35:22 -0500 Subject: [PATCH 009/131] xo-expression2: + LambdaExpr ++ LocalSymtab --- include/xo/interpreter2/VirtualSchematikaMachine.hpp | 6 ++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 066b7ffd..66a1c1e1 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -51,6 +51,12 @@ namespace xo { **/ void _do_eval_define_op(); + /** evaluate a lambda expression + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_lambda_op(); + /** evaluate a variable expression * Require: * - expression in @ref expr_ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 11a60c64..fe104f9a 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -48,6 +48,9 @@ namespace xo { case exprtype::define: _do_eval_define_op(); break; + case exprtype::lambda: + _do_eval_lambda_op(); + break; case exprtype::variable: _do_eval_variable_op(); break; @@ -77,6 +80,13 @@ namespace xo { assert(false); } + void + VirtualSchematikaMachine::_do_eval_lambda_op() + { + // not implemented + assert(false); + } + void VirtualSchematikaMachine::_do_eval_variable_op() { From b69098af0db1d58258ca4d07362df6fa9f56e944 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 31 Jan 2026 01:13:55 -0500 Subject: [PATCH 010/131] xo-interpreter2: + _do_eval_sequence_op() --- include/xo/interpreter2/VirtualSchematikaMachine.hpp | 6 ++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 10 ++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 66a1c1e1..0f58f2c4 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -75,6 +75,12 @@ namespace xo { **/ void _do_eval_if_else_op(); + /** evaluate a sequence expression + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_sequence_op(); + private: /* * Some registers are preserved by evaluation: diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index fe104f9a..02ed023a 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -60,6 +60,9 @@ namespace xo { case exprtype::ifexpr: _do_eval_if_else_op(); break; + case exprtype::sequence: + _do_eval_sequence_op(); + break; } } @@ -107,6 +110,13 @@ namespace xo { // not implemented assert(false); } + + void + VirtualSchematikaMachine::_do_eval_sequence_op() + { + // not implemented + assert(false); + } } /*namespace scm*/ } /*namespace xo*/ From a10c7dcab2412f205fa4d287a75eea83497e8dcf Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 1 Feb 2026 22:12:28 -0500 Subject: [PATCH 011/131] xo-interpreter2: work towards utest w/ vsm+reader [WIP] --- CMakeLists.txt | 2 +- .../interpreter2/VirtualSchematikaMachine.hpp | 14 ++++- include/xo/interpreter2/VsmConfig.hpp | 28 +++++++++ include/xo/interpreter2/init_interpreter2.hpp | 21 +++++++ src/interpreter2/CMakeLists.txt | 3 +- src/interpreter2/VirtualSchematikaMachine.cpp | 9 ++- src/interpreter2/init_interpreter2.cpp | 50 +++++++++++++++ utest/CMakeLists.txt | 11 ++++ utest/VirtualSchematikaMachine.test.cpp | 63 +++++++++++++++++++ utest/interpreter2_utest_main.cpp | 27 ++++++++ 10 files changed, 224 insertions(+), 4 deletions(-) create mode 100644 include/xo/interpreter2/VsmConfig.hpp create mode 100644 include/xo/interpreter2/init_interpreter2.hpp create mode 100644 src/interpreter2/init_interpreter2.cpp create mode 100644 utest/CMakeLists.txt create mode 100644 utest/VirtualSchematikaMachine.test.cpp create mode 100644 utest/interpreter2_utest_main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ac944a36..466e1a1c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,7 +21,7 @@ add_definitions(${PROJECT_CXX_FLAGS}) # output targets add_subdirectory(src/interpreter2) -#add_subdirectory(utest) +add_subdirectory(utest) xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 0f58f2c4..6e1595da 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -5,9 +5,12 @@ #pragma once +#include "VsmConfig.hpp" #include "VsmInstr.hpp" +#include #include #include +#include namespace xo { namespace scm { @@ -18,10 +21,11 @@ namespace xo { public: // will be DArenaVector> probably using Stack = void *; + using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; public: - VirtualSchematikaMachine(); + VirtualSchematikaMachine(const VsmConfig & config); /** borrow calling thread to run indefinitely, * until halt instruction @@ -93,6 +97,14 @@ namespace xo { * value_ */ + /** configuration **/ + VsmConfig config_; + + box mm_; + + /** reader: text -> expression **/ + SchematikaReader reader_; + /** program counter **/ VsmInstr pc_ = VsmInstr::halt(); diff --git a/include/xo/interpreter2/VsmConfig.hpp b/include/xo/interpreter2/VsmConfig.hpp new file mode 100644 index 00000000..5071c020 --- /dev/null +++ b/include/xo/interpreter2/VsmConfig.hpp @@ -0,0 +1,28 @@ +/** @file VsmConfig.hpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include +#include + +namespace xo { + namespace scm { + /** Configuration for virtual schematika machine + **/ + struct VsmConfig { + using X1CollectorConfig = xo::mm::X1CollectorConfig; + + /** reader configuration **/ + ReaderConfig rdr_config_; + /** Configuration for allocator/collector. + * TODO: may want to make CollectorConfig polymorphic + **/ + X1CollectorConfig x1_config_ = X1CollectorConfig().with_size(4*1024*1024); + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VsmConfig.hpp */ diff --git a/include/xo/interpreter2/init_interpreter2.hpp b/include/xo/interpreter2/init_interpreter2.hpp new file mode 100644 index 00000000..87e93438 --- /dev/null +++ b/include/xo/interpreter2/init_interpreter2.hpp @@ -0,0 +1,21 @@ +/** @file init_interpreter2.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include + +namespace xo { + /* tag to represent the xo-interpreter2/ subsystem within ordered initialization */ + enum S_interpreter2_tag {}; + + template <> + struct InitSubsys { + static void init(); + static InitEvidence require(); + }; +} /*namespace xo*/ + +/* end init_interpreter2.hpp */ diff --git a/src/interpreter2/CMakeLists.txt b/src/interpreter2/CMakeLists.txt index 15d06fdf..7d9cd250 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -2,6 +2,7 @@ set(SELF_LIB xo_interpreter2) set(SELF_SRCS + init_interpreter2.cpp VirtualSchematikaMachine.cpp #IExpression_Any.cpp #interpreter2_register_facets.cpp @@ -9,7 +10,7 @@ set(SELF_SRCS xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) # note: deps here must also appear in cmake/xo_interpreter2Config.cmake.in -xo_dependency(${SELF_LIB} xo_expression2) +xo_dependency(${SELF_LIB} xo_reader2) xo_dependency(${SELF_LIB} xo_gc) #xo_dependency(${SELF_LIB} reflect) #xo_dependency(${SELF_LIB} xo_printable2) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 02ed023a..f7e8259e 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -6,12 +6,19 @@ #include "VirtualSchematikaMachine.hpp" #include #include +#include +#include #include namespace xo { + using xo::mm::DX1Collector; + namespace scm { - VirtualSchematikaMachine::VirtualSchematikaMachine() + VirtualSchematikaMachine::VirtualSchematikaMachine(const VsmConfig & config) + : config_{config}, + mm_(box(new DX1Collector(config.x1_config_))), + reader_{config.rdr_config_, mm_.to_op()} {} void diff --git a/src/interpreter2/init_interpreter2.cpp b/src/interpreter2/init_interpreter2.cpp new file mode 100644 index 00000000..b0e8a71c --- /dev/null +++ b/src/interpreter2/init_interpreter2.cpp @@ -0,0 +1,50 @@ +/** @file init_interpreter2.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_interpreter2.hpp" + +#ifdef NOT_YET +#include "interpreter2_register_facets.hpp" +#include "interpreter2_register_types.hpp" +#endif + +#include +#ifdef NOT_YET +#include +#endif + +namespace xo { +#ifdef NOT_YET + using xo::scm::interpreter2_register_facets; + using xo::scm::interpreter2_register_types; + using xo::mm::CollectorTypeRegistry; +#endif + + void + InitSubsys::init() + { +#ifdef NOT_YET + interpreter2_register_facets(); + + CollectorTypeRegistry::instance().register_types(&interpreter2_register_types); +#endif + } + + InitEvidence + InitSubsys::require() + { + InitEvidence retval; + + /* direct subsystem deps for xo-interpreter2/ */ + retval ^= InitSubsys::require(); + + /* xo-interpreter2/'s own initialization code */ + retval ^= Subsystem::provide("interpreter2", &init); + + return retval; + } +} /*namespace xo*/ + +/* end init_interpreter2.cpp */ diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt new file mode 100644 index 00000000..e45cffaa --- /dev/null +++ b/utest/CMakeLists.txt @@ -0,0 +1,11 @@ +# build unittest xo-interpreter2/utest + +set(UTEST_EXE utest.interpreter2) +set(UTEST_SRCS + interpreter2_utest_main.cpp + VirtualSchematikaMachine.test.cpp +) + +xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) +xo_self_dependency(${UTEST_EXE} xo_interpreter2) +xo_external_target_dependency(${UTEST_EXE} Catch2 Catch2::Catch2) diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp new file mode 100644 index 00000000..29301b1f --- /dev/null +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -0,0 +1,63 @@ +/** @file VirtualSchematikaMachine.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include + +#ifdef NOT_YET +#include +#include +#include +#include +#include +#endif +#include +#ifdef NOT_YET +#include +#endif + +#include + +namespace xo { +#ifdef NOT_YET + using xo::scm::SchematikaParser; + using xo::scm::ASyntaxStateMachine; + using xo::scm::syntaxstatetype; +// using xo::scm::DDefineSsm; + using xo::scm::DExpectExprSsm; +// using xo::scm::defexprstatetype; + //using xo::scm::ParserResult; + //using xo::scm::parser_result_type; + using xo::scm::Token; + using xo::scm::DString; + using xo::mm::ArenaConfig; + using xo::mm::AAllocator; + using xo::mm::DArena; + using xo::facet::with_facet; +#endif + + static InitEvidence s_init = (InitSubsys::require()); + + namespace ut { + TEST_CASE("VirtualSchematikaMachine-ctor", "[interpreter2][VSM]") + { +#ifdef NOT_YET + ArenaConfig config; + config.name_ = "test-arena"; + config.size_ = 16 * 1024; + + DArena expr_arena = DArena::map(config); + obj expr_alloc = with_facet::mkobj(&expr_arena); + + SchematikaParser parser(config, 4096, expr_alloc, false /*debug_flag*/); + + REQUIRE(parser.debug_flag() == false); + REQUIRE(parser.is_at_toplevel() == true); +#endif + } + + } /*namespace ut*/ +} /*namespace xo*/ + +/* end SchematikaParser.test.cpp */ diff --git a/utest/interpreter2_utest_main.cpp b/utest/interpreter2_utest_main.cpp new file mode 100644 index 00000000..addc079a --- /dev/null +++ b/utest/interpreter2_utest_main.cpp @@ -0,0 +1,27 @@ +/** @file interpreter2_utest_main.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include + +#define CATCH_CONFIG_RUNNER +#include "catch2/catch.hpp" + +int +main(int argc, char* argv[]) +{ + using xo::Subsystem; + + // initialize subsystems + Subsystem::initialize_all(); + + // Run Catch2's test session + int result = Catch::Session().run(argc, argv); + + // cleanup here, if any + + return result; +} + +/* end interpreter2_utest_main.cpp */ From a71060bb75a7694c22546df08c33d1dd97efdebf Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 2 Feb 2026 10:53:28 -0500 Subject: [PATCH 012/131] xo-interpreter2: refactor to setup vsm utest + repl --- .../interpreter2/VirtualSchematikaMachine.hpp | 24 +++++++++ include/xo/interpreter2/VsmConfig.hpp | 4 +- src/interpreter2/VirtualSchematikaMachine.cpp | 54 +++++++++++++++++++ utest/VirtualSchematikaMachine.test.cpp | 5 ++ 4 files changed, 86 insertions(+), 1 deletion(-) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 6e1595da..c9dc0749 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -14,6 +14,23 @@ namespace xo { namespace scm { + /** similar to @ref xo::scm::ReaderResult **/ + struct VsmResult { + using AGCObject = xo::mm::AGCObject; + using span_type = xo::mm::span; + + bool is_tk_error() const { return tk_error_.is_error(); } + + /** result of evaluating first expression encountered in input **/ + obj value_; + + /** unconsumed portion of input span **/ + span_type remaining_input_; + + /** {src_function, error_description, input_state, error_pos} **/ + TokenizerError tk_error_; + }; + /** @class VirtualSchematikaMachine * @brief virtual machine for schematika **/ @@ -23,10 +40,17 @@ namespace xo { using Stack = void *; using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; + using span_type = xo::mm::span; public: VirtualSchematikaMachine(const VsmConfig & config); + /** consume input @p input_cstr **/ + VsmResult read_eval_print(span_type input_span, bool eof); + + /** evaluate expression @p expr **/ + std::pair, TokenizerError> eval(obj expr); + /** borrow calling thread to run indefinitely, * until halt instruction **/ diff --git a/include/xo/interpreter2/VsmConfig.hpp b/include/xo/interpreter2/VsmConfig.hpp index 5071c020..2957b297 100644 --- a/include/xo/interpreter2/VsmConfig.hpp +++ b/include/xo/interpreter2/VsmConfig.hpp @@ -10,11 +10,13 @@ namespace xo { namespace scm { - /** Configuration for virtual schematika machine + /** Configuration for virtual schematika machine **/ struct VsmConfig { using X1CollectorConfig = xo::mm::X1CollectorConfig; + VsmConfig() = default; + /** reader configuration **/ ReaderConfig rdr_config_; /** Configuration for allocator/collector. diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index f7e8259e..fabc5441 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -8,10 +8,18 @@ #include #include #include +#include +#include #include namespace xo { + using xo::print::APrintable; + using xo::print::ppconfig; + using xo::print::ppstate_standalone; + using xo::mm::AGCObject; using xo::mm::DX1Collector; + using xo::facet::FacetRegistry; + using std::cout; namespace scm { @@ -21,6 +29,52 @@ namespace xo { reader_{config.rdr_config_, mm_.to_op()} {} + VsmResult + VirtualSchematikaMachine::read_eval_print(span_type input, bool eof) + { + if (input.empty()) { + return VsmResult(); + } + + auto [expr, remaining, error1] + = reader_.read_expr(input, eof); + + if (!expr) { + return { + .remaining_input_ = remaining, + .tk_error_ = error1 + }; + } + + auto [value, error2] = this->eval(expr); + + if (!value) { + return { + .remaining_input_ = remaining, + .tk_error_ = error2 + }; + } + + obj value_pr + = FacetRegistry::instance().variant(value); + + // pretty_toplevel(value_pr, &cout, ppconfig()); + ppconfig ppc; + ppstate_standalone pps(&cout, 0, &ppc); + pps.prettyn(value_pr); + + return { .remaining_input_ = remaining }; + } + + std::pair, TokenizerError> + VirtualSchematikaMachine::eval(obj expr) + { + (void)expr; + + assert(false); + return std::make_pair(obj(), TokenizerError()); + } + void VirtualSchematikaMachine::run() { diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 29301b1f..8dacb437 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -20,6 +20,9 @@ #include namespace xo { + using xo::scm::VirtualSchematikaMachine; + using xo::scm::VsmConfig; + #ifdef NOT_YET using xo::scm::SchematikaParser; using xo::scm::ASyntaxStateMachine; @@ -42,6 +45,8 @@ namespace xo { namespace ut { TEST_CASE("VirtualSchematikaMachine-ctor", "[interpreter2][VSM]") { + VirtualSchematikaMachine vsm(VsmConfig); + #ifdef NOT_YET ArenaConfig config; config.name_ = "test-arena"; From 6db1ddc802984ca336e2ea0b33009ba7f2921aa7 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 2 Feb 2026 21:55:34 -0500 Subject: [PATCH 013/131] xo-interpreter2: scaffold repl + alloc measurement frameowkr --- .../interpreter2/VirtualSchematikaMachine.hpp | 63 ++++++++++++---- include/xo/interpreter2/VsmConfig.hpp | 3 + include/xo/interpreter2/VsmInstr.hpp | 4 +- src/interpreter2/CMakeLists.txt | 1 + src/interpreter2/VirtualSchematikaMachine.cpp | 73 ++++++++++++++----- src/interpreter2/VsmInstr.cpp | 18 +++++ utest/VirtualSchematikaMachine.test.cpp | 35 ++++++--- 7 files changed, 152 insertions(+), 45 deletions(-) create mode 100644 src/interpreter2/VsmInstr.cpp diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index c9dc0749..5165c9a8 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -14,21 +14,42 @@ namespace xo { namespace scm { + struct EvaluationError { + /** source location (in vsm implementation) at which error identified **/ + std::string_view src_function_; + /** error description (allocated from ErrorArena) **/ + std::string_view error_description_; + // TODO: info about location in schematika source + }; + /** similar to @ref xo::scm::ReaderResult **/ struct VsmResult { using AGCObject = xo::mm::AGCObject; using span_type = xo::mm::span; - bool is_tk_error() const { return tk_error_.is_error(); } + VsmResult() = default; + VsmResult(obj value) : result_{value} {} + VsmResult(TokenizerError err) : result_{err} {} + + bool is_value() const { return std::holds_alternative>(result_); } + bool is_tk_error() const { return std::holds_alternative(result_); } + bool is_eval_error() const { return std::holds_alternative(result_); } + + const obj * value() const { return std::get_if>(&result_); } /** result of evaluating first expression encountered in input **/ - obj value_; + std::variant, TokenizerError, EvaluationError> result_; + }; - /** unconsumed portion of input span **/ - span_type remaining_input_; + /** vsm result + reamining span **/ + struct VsmResultExt : public VsmResult { + using span_type = VsmResult::span_type; - /** {src_function, error_description, input_state, error_pos} **/ - TokenizerError tk_error_; + VsmResultExt() = default; + VsmResultExt(const VsmResult & result, span_type rem) : VsmResult{result}, remaining_{rem} {} + + /** unconsumed portion of input **/ + VsmResult::span_type remaining_; }; /** @class VirtualSchematikaMachine @@ -40,16 +61,29 @@ namespace xo { using Stack = void *; using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; + using MemorySizeInfo = xo::mm::MemorySizeInfo; using span_type = xo::mm::span; public: VirtualSchematikaMachine(const VsmConfig & config); - /** consume input @p input_cstr **/ - VsmResult read_eval_print(span_type input_span, bool eof); + size_t _n_store() const noexcept; + MemorySizeInfo _store_info(std::size_t i) const noexcept; - /** evaluate expression @p expr **/ - std::pair, TokenizerError> eval(obj expr); + /** begin interactive session. **/ + void begin_interactive_session(); + /** begin batch session **/ + void begin_batch_session(); + + /** consume input @p input_cstr. + * Require: must first start interactive/batch session + **/ + VsmResultExt read_eval_print(span_type input_span, bool eof); + + /** evaluate expression @p expr + * Require: must first start interactive/batch session + **/ + VsmResult start_eval(obj expr); /** borrow calling thread to run indefinitely, * until halt instruction @@ -124,13 +158,16 @@ namespace xo { /** configuration **/ VsmConfig config_; + /** allocator (likely collector) for + * expressions and values + **/ box mm_; /** reader: text -> expression **/ SchematikaReader reader_; /** program counter **/ - VsmInstr pc_ = VsmInstr::halt(); + VsmInstr pc_ = VsmInstr::c_halt; #ifdef NOT_YET /** stack pointer **/ @@ -141,10 +178,10 @@ namespace xo { obj expr_; /** result register **/ - obj value_; + VsmResult value_; /** continuation register **/ - VsmInstr cont_ = VsmInstr::halt(); + VsmInstr cont_ = VsmInstr::c_halt; }; } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/interpreter2/VsmConfig.hpp b/include/xo/interpreter2/VsmConfig.hpp index 2957b297..9d13ab8e 100644 --- a/include/xo/interpreter2/VsmConfig.hpp +++ b/include/xo/interpreter2/VsmConfig.hpp @@ -17,6 +17,9 @@ namespace xo { VsmConfig() = default; + /** true for interactive parser session; false for batch session **/ + bool interactive_flag_ = true; + /** reader configuration **/ ReaderConfig rdr_config_; /** Configuration for allocator/collector. diff --git a/include/xo/interpreter2/VsmInstr.hpp b/include/xo/interpreter2/VsmInstr.hpp index ca74bc4c..c956c607 100644 --- a/include/xo/interpreter2/VsmInstr.hpp +++ b/include/xo/interpreter2/VsmInstr.hpp @@ -13,8 +13,8 @@ namespace xo { public: explicit VsmInstr(vsm_opcode oc) : opcode_{oc} {} - static VsmInstr halt() { return VsmInstr{vsm_opcode::halt}; } - static VsmInstr eval() { return VsmInstr{vsm_opcode::eval}; } + static VsmInstr c_halt; + static VsmInstr c_eval; vsm_opcode opcode() const noexcept { return opcode_; } diff --git a/src/interpreter2/CMakeLists.txt b/src/interpreter2/CMakeLists.txt index 7d9cd250..93ecd47e 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -4,6 +4,7 @@ set(SELF_LIB xo_interpreter2) set(SELF_SRCS init_interpreter2.cpp VirtualSchematikaMachine.cpp + VsmInstr.cpp #IExpression_Any.cpp #interpreter2_register_facets.cpp ) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index fabc5441..d40b85c6 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -17,6 +17,7 @@ namespace xo { using xo::print::ppconfig; using xo::print::ppstate_standalone; using xo::mm::AGCObject; + using xo::mm::MemorySizeInfo; using xo::mm::DX1Collector; using xo::facet::FacetRegistry; using std::cout; @@ -29,50 +30,84 @@ namespace xo { reader_{config.rdr_config_, mm_.to_op()} {} - VsmResult + std::size_t + VirtualSchematikaMachine::_n_store() const noexcept + { + // oops. need something that goes through AAllocator api + + return reader_._n_store(); + } + + MemorySizeInfo + VirtualSchematikaMachine::_store_info(std::size_t i) const noexcept + { + // oops. need something poly that goes through AAllocator api + + return reader_._store_info(i); + } + + void + VirtualSchematikaMachine::begin_interactive_session() + { + reader_.begin_interactive_session(); + } + + void + VirtualSchematikaMachine::begin_batch_session() + { + reader_.begin_batch_session(); + } + + VsmResultExt VirtualSchematikaMachine::read_eval_print(span_type input, bool eof) { if (input.empty()) { - return VsmResult(); + return VsmResultExt(); } auto [expr, remaining, error1] = reader_.read_expr(input, eof); if (!expr) { - return { - .remaining_input_ = remaining, - .tk_error_ = error1 - }; + /* tokenizer error */ + + return VsmResultExt(VsmResult(error1), remaining); } - auto [value, error2] = this->eval(expr); + VsmResult evalresult = this->start_eval(expr); - if (!value) { - return { - .remaining_input_ = remaining, - .tk_error_ = error2 - }; + if (evalresult.is_eval_error() || evalresult.is_tk_error()) { + return VsmResultExt(evalresult, remaining); } + assert(evalresult.is_value()); + + obj * p_value = std::get_if>(&(evalresult.result_)); + + assert(p_value); + obj value_pr - = FacetRegistry::instance().variant(value); + = FacetRegistry::instance().variant(*p_value); // pretty_toplevel(value_pr, &cout, ppconfig()); ppconfig ppc; ppstate_standalone pps(&cout, 0, &ppc); pps.prettyn(value_pr); - return { .remaining_input_ = remaining }; + return VsmResultExt(VsmResult(*p_value), remaining); } - std::pair, TokenizerError> - VirtualSchematikaMachine::eval(obj expr) + VsmResult + VirtualSchematikaMachine::start_eval(obj expr) { - (void)expr; + this->pc_ = VsmInstr::c_eval; + this->expr_ = expr; + this->value_ = obj(); + this->cont_ = VsmInstr::c_halt; - assert(false); - return std::make_pair(obj(), TokenizerError()); + this->run(); + + return value_; } void diff --git a/src/interpreter2/VsmInstr.cpp b/src/interpreter2/VsmInstr.cpp new file mode 100644 index 00000000..95a0ef74 --- /dev/null +++ b/src/interpreter2/VsmInstr.cpp @@ -0,0 +1,18 @@ +/** @file VsmInstr.cpp +* + * @author Roland Conybeare, Feb 2026 + **/ + +#include "VsmInstr.hpp" + +namespace xo { + namespace scm { + VsmInstr + VsmInstr::c_halt = VsmInstr(vsm_opcode::halt); + + VsmInstr + VsmInstr::c_eval = VsmInstr(vsm_opcode::eval); + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VsmInstr.cpp */ diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 8dacb437..a0554f87 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -4,6 +4,8 @@ **/ #include +#include +#include #ifdef NOT_YET #include @@ -16,12 +18,18 @@ #ifdef NOT_YET #include #endif +#include #include namespace xo { using xo::scm::VirtualSchematikaMachine; using xo::scm::VsmConfig; + using xo::scm::VsmResultExt; + using xo::scm::DFloat; + using xo::mm::AGCObject; + using span_type = xo::scm::VirtualSchematikaMachine::span_type; + using Catch::Matchers::WithinAbs; #ifdef NOT_YET using xo::scm::SchematikaParser; @@ -39,27 +47,32 @@ namespace xo { using xo::mm::DArena; using xo::facet::with_facet; #endif + using std::cout; + using std::endl; static InitEvidence s_init = (InitSubsys::require()); namespace ut { TEST_CASE("VirtualSchematikaMachine-ctor", "[interpreter2][VSM]") { - VirtualSchematikaMachine vsm(VsmConfig); + VsmConfig cfg; + VirtualSchematikaMachine vsm(cfg); -#ifdef NOT_YET - ArenaConfig config; - config.name_ = "test-arena"; - config.size_ = 16 * 1024; + bool eof_flag = false; - DArena expr_arena = DArena::map(config); - obj expr_alloc = with_facet::mkobj(&expr_arena); + vsm.begin_interactive_session(); + VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("3.141592635;"), eof_flag); - SchematikaParser parser(config, 4096, expr_alloc, false /*debug_flag*/); + REQUIRE(res.is_value()); + REQUIRE(res.value()); - REQUIRE(parser.debug_flag() == false); - REQUIRE(parser.is_at_toplevel() == true); -#endif + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE_THAT(x.data()->value(), WithinAbs(3.141592635, 1e-6)); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); } } /*namespace ut*/ From bfc7a1d3797c0be43f9d4c62717ea8e49ed859bb Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Feb 2026 01:05:36 -0500 Subject: [PATCH 014/131] xo-interpreter2 .. xo-arena. memory pool introspection --- .../interpreter2/VirtualSchematikaMachine.hpp | 6 +++--- src/interpreter2/VirtualSchematikaMachine.cpp | 17 ++++------------- utest/VirtualSchematikaMachine.test.cpp | 12 ++++++++++++ 3 files changed, 19 insertions(+), 16 deletions(-) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 5165c9a8..5aecbc55 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -61,14 +61,14 @@ namespace xo { using Stack = void *; using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; - using MemorySizeInfo = xo::mm::MemorySizeInfo; + using MemorySizeVisitor = xo::mm::MemorySizeVisitor; using span_type = xo::mm::span; public: VirtualSchematikaMachine(const VsmConfig & config); - size_t _n_store() const noexcept; - MemorySizeInfo _store_info(std::size_t i) const noexcept; + /** visit vsm-owned memory pools; call visitor(info) for each **/ + void visit_pools(const MemorySizeVisitor & visitor) const; /** begin interactive session. **/ void begin_interactive_session(); diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index d40b85c6..7c4873fb 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -30,20 +30,11 @@ namespace xo { reader_{config.rdr_config_, mm_.to_op()} {} - std::size_t - VirtualSchematikaMachine::_n_store() const noexcept + void + VirtualSchematikaMachine::visit_pools(const MemorySizeVisitor & visitor) const { - // oops. need something that goes through AAllocator api - - return reader_._n_store(); - } - - MemorySizeInfo - VirtualSchematikaMachine::_store_info(std::size_t i) const noexcept - { - // oops. need something poly that goes through AAllocator api - - return reader_._store_info(i); + mm_.visit_pools(visitor); + reader_.visit_pools(visitor); } void diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index a0554f87..2ad7122d 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -28,6 +28,7 @@ namespace xo { using xo::scm::VsmResultExt; using xo::scm::DFloat; using xo::mm::AGCObject; + using xo::mm::MemorySizeInfo; using span_type = xo::scm::VirtualSchematikaMachine::span_type; using Catch::Matchers::WithinAbs; @@ -55,6 +56,8 @@ namespace xo { namespace ut { TEST_CASE("VirtualSchematikaMachine-ctor", "[interpreter2][VSM]") { + scope log(XO_DEBUG(true)); + VsmConfig cfg; VirtualSchematikaMachine vsm(cfg); @@ -73,6 +76,15 @@ namespace xo { REQUIRE(res.remaining_.size() == 1); REQUIRE(*res.remaining_.lo() == '\n'); + + auto visitor = [&log](const MemorySizeInfo & info) { + log && log(xtag("resource", info.resource_name_), + xtag("alloc", info.allocated_), + xtag("commit", info.committed_), + xtag("resv", info.reserved_)); + }; + + vsm.visit_pools(visitor); } } /*namespace ut*/ From d06f18f444a17cc9b92b661681f20266133a7ad5 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Feb 2026 11:55:50 -0500 Subject: [PATCH 015/131] xo-interpreter2 stack: cleanup memory reporting --- utest/VirtualSchematikaMachine.test.cpp | 2 ++ utest/interpreter2_utest_main.cpp | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 2ad7122d..a4970b72 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -29,6 +29,7 @@ namespace xo { using xo::scm::DFloat; using xo::mm::AGCObject; using xo::mm::MemorySizeInfo; + using xo::facet::FacetRegistry; using span_type = xo::scm::VirtualSchematikaMachine::span_type; using Catch::Matchers::WithinAbs; @@ -84,6 +85,7 @@ namespace xo { xtag("resv", info.reserved_)); }; + FacetRegistry::instance().visit_pools(visitor); vsm.visit_pools(visitor); } diff --git a/utest/interpreter2_utest_main.cpp b/utest/interpreter2_utest_main.cpp index addc079a..ca898beb 100644 --- a/utest/interpreter2_utest_main.cpp +++ b/utest/interpreter2_utest_main.cpp @@ -3,6 +3,7 @@ * @author Roland Conybeare, Jan 2026 **/ +#include #include #define CATCH_CONFIG_RUNNER @@ -11,8 +12,12 @@ int main(int argc, char* argv[]) { + using xo::facet::FacetRegistry; using xo::Subsystem; + // initialize facet registry + FacetRegistry::instance(1024); + // initialize subsystems Subsystem::initialize_all(); From 3b5d3571e323b587f5a4088571ee584eaf2167df Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Feb 2026 12:23:56 -0500 Subject: [PATCH 016/131] xo-interpreter2 stack: + MemorySizeInfo.used + pop for DArenaHashMap --- utest/VirtualSchematikaMachine.test.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index a4970b72..9c70f85c 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -80,6 +80,7 @@ namespace xo { auto visitor = [&log](const MemorySizeInfo & info) { log && log(xtag("resource", info.resource_name_), + xtag("used", info.used_), xtag("alloc", info.allocated_), xtag("commit", info.committed_), xtag("resv", info.reserved_)); From 6e8ae6926b9cee14ac217bc30c271ab8777e243b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Feb 2026 12:58:55 -0500 Subject: [PATCH 017/131] xo-interpreter2 stack: bugfix: top-level i64 token -> DInteger --- utest/VirtualSchematikaMachine.test.cpp | 59 +++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 9c70f85c..0a2ba92f 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -6,6 +6,8 @@ #include #include #include +#include +#include #ifdef NOT_YET #include @@ -27,6 +29,7 @@ namespace xo { using xo::scm::VsmConfig; using xo::scm::VsmResultExt; using xo::scm::DFloat; + using xo::scm::DInteger; using xo::mm::AGCObject; using xo::mm::MemorySizeInfo; using xo::facet::FacetRegistry; @@ -62,6 +65,25 @@ namespace xo { VsmConfig cfg; VirtualSchematikaMachine vsm(cfg); + auto visitor = [&log](const MemorySizeInfo & info) { + log && log(xtag("resource", info.resource_name_), + xtag("used", info.used_), + xtag("alloc", info.allocated_), + xtag("commit", info.committed_), + xtag("resv", info.reserved_)); + }; + + FacetRegistry::instance().visit_pools(visitor); + vsm.visit_pools(visitor); + } + + TEST_CASE("VirtualSchematikaMachine-const1", "[interpreter2][VSM]") + { + scope log(XO_DEBUG(true)); + + VsmConfig cfg; + VirtualSchematikaMachine vsm(cfg); + bool eof_flag = false; vsm.begin_interactive_session(); @@ -90,6 +112,43 @@ namespace xo { vsm.visit_pools(visitor); } + TEST_CASE("VirtualSchematikaMachine-const2", "[interpreter2][VSM]") + { + scope log(XO_DEBUG(true)); + + VsmConfig cfg; + VirtualSchematikaMachine vsm(cfg); + + bool eof_flag = false; + + vsm.begin_interactive_session(); + VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("1011;"), eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq())); + + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(x.data()->value() == 1011); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + + auto visitor = [&log](const MemorySizeInfo & info) { + log && log(xtag("resource", info.resource_name_), + xtag("used", info.used_), + xtag("alloc", info.allocated_), + xtag("commit", info.committed_), + xtag("resv", info.reserved_)); + }; + + FacetRegistry::instance().visit_pools(visitor); + vsm.visit_pools(visitor); + } + } /*namespace ut*/ } /*namespace xo*/ From dc88663271bb9fc5e5ab9e5c202468f6c0eefbb6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Feb 2026 21:44:40 -0500 Subject: [PATCH 018/131] xo-interpreter: + VSM work in progress --- include/xo/interpreter2/DApplyFrame.hpp | 20 +++++ .../interpreter2/VirtualSchematikaMachine.hpp | 15 +++- include/xo/interpreter2/VsmFrame.hpp | 86 +++++++++++++++++++ include/xo/interpreter2/VsmInstr.hpp | 3 + include/xo/interpreter2/VsmOpcode.hpp | 9 ++ src/interpreter2/CMakeLists.txt | 1 + src/interpreter2/VirtualSchematikaMachine.cpp | 69 ++++++++++++++- src/interpreter2/VsmFrame.cpp | 68 +++++++++++++++ src/interpreter2/VsmInstr.cpp | 6 ++ utest/VirtualSchematikaMachine.test.cpp | 37 ++++++++ 10 files changed, 307 insertions(+), 7 deletions(-) create mode 100644 include/xo/interpreter2/DApplyFrame.hpp create mode 100644 include/xo/interpreter2/VsmFrame.hpp create mode 100644 src/interpreter2/VsmFrame.cpp diff --git a/include/xo/interpreter2/DApplyFrame.hpp b/include/xo/interpreter2/DApplyFrame.hpp new file mode 100644 index 00000000..d1c81c2b --- /dev/null +++ b/include/xo/interpreter2/DApplyFrame.hpp @@ -0,0 +1,20 @@ +/** @file DApplyFrame.hpp + * + * @author Roland Conyberae, Feb 2026 + **/ + +#pragma once + +namespace xo { + namespace scm { + /** In virtual schematika machine (VSM): + * stack frame for interpreted apply expression + * (@ref DApplyExpr) + **/ + class DApplyFrame { + obj + }; + } +} + +/* end DApplyFrame.hpp */ diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 5aecbc55..26366d50 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -7,6 +7,7 @@ #include "VsmConfig.hpp" #include "VsmInstr.hpp" +#include "VsmFrame.hpp" #include #include #include @@ -143,6 +144,12 @@ namespace xo { **/ void _do_eval_sequence_op(); + /** apply a function to evaluated arguments **/ + void _do_apply_op(); + + /** evaluate arguments on behalf of a function call **/ + void _do_evalargs_op(); + private: /* * Some registers are preserved by evaluation: @@ -163,16 +170,18 @@ namespace xo { **/ box mm_; + // consider separate allocator (which _may_ turn out to be the same) + // for VM stack. Only works for code that doesn't rely on fancy + // lexical scoping + /** reader: text -> expression **/ SchematikaReader reader_; /** program counter **/ VsmInstr pc_ = VsmInstr::c_halt; -#ifdef NOT_YET /** stack pointer **/ - Stack stack_; -#endif + VsmFrame * stack_ = nullptr; /** expression register **/ obj expr_; diff --git a/include/xo/interpreter2/VsmFrame.hpp b/include/xo/interpreter2/VsmFrame.hpp new file mode 100644 index 00000000..09b542a8 --- /dev/null +++ b/include/xo/interpreter2/VsmFrame.hpp @@ -0,0 +1,86 @@ +/** @file VsmFrame.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "VsmInstr.hpp" +#include +#include + +namespace xo { + namespace scm { + class VsmFrame { + public: + VsmFrame(VsmFrame * parent, VsmInstr cont) : parent_{parent}, cont_{cont} {} + + VsmFrame * parent() const noexcept { return parent_; } + VsmInstr cont() const noexcept { return cont_; } + + protected: + /** saved VSM stack; restore when this frame consumed **/ + VsmFrame * parent_ = nullptr; + /** saved continuation; restore when this frame consumed **/ + VsmInstr cont_; + }; + + class VsmApplyFrame : public VsmFrame { + public: + using AProcedure = xo::scm::AProcedure; + using AAllocator = xo::mm::AAllocator; + + public: + VsmApplyFrame(VsmFrame * old_parent, + VsmInstr old_cont, + DArray * args); + + static VsmApplyFrame * make(obj mm, + VsmFrame * old_parent, + VsmInstr old_cont, + DArray * args); + + obj fn() const noexcept { return fn_; } + DArray * args() const noexcept { return args_; } + + private: + /** evaluated target procedure. + * + * note: when initially created, this will be unpopulated; + * don't know correct value until we evaluate + * expression in head position + **/ + obj fn_; + /** evaluated arguments (to target procedure) **/ + DArray * args_; + }; + + /** frame for executing an apply expression **/ + class VsmEvalArgsFrame : public VsmFrame { + public: + using AAllocator = xo::mm::AAllocator; + + public: + /** see picture in VirtualSchematikaMachine._do_eval_apply_op() + * + * old_parent = [apply frame] + * old_cont = [xfer to called function] + * + **/ + VsmEvalArgsFrame(VsmApplyFrame * old_parent, + VsmInstr old_cont); + + static VsmEvalArgsFrame * make(obj mm, + VsmApplyFrame * apply_frame, + VsmInstr old_cont); + + private: + /** next argument to be evaluated. -1 means function head **/ + int32_t i_arg_ = -1; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VsmFrame.hpp */ + diff --git a/include/xo/interpreter2/VsmInstr.hpp b/include/xo/interpreter2/VsmInstr.hpp index c956c607..a94ee625 100644 --- a/include/xo/interpreter2/VsmInstr.hpp +++ b/include/xo/interpreter2/VsmInstr.hpp @@ -16,6 +16,9 @@ namespace xo { static VsmInstr c_halt; static VsmInstr c_eval; + static VsmInstr c_apply; + static VsmInstr c_evalargs; + vsm_opcode opcode() const noexcept { return opcode_; } private: diff --git a/include/xo/interpreter2/VsmOpcode.hpp b/include/xo/interpreter2/VsmOpcode.hpp index 3638fa29..6e41c5c1 100644 --- a/include/xo/interpreter2/VsmOpcode.hpp +++ b/include/xo/interpreter2/VsmOpcode.hpp @@ -18,6 +18,15 @@ namespace xo { /** Evaluate expression in expr register **/ eval, + /** Apply function in stack frame + * See diagram in VirtualSchematikaMachine::_do_eval_apply_op + **/ + apply, + /** Eval arguments to function. + * See diagram in VirtualSchematikaMachine::_do_eval_apply_op + **/ + evalargs, + /** sentinel, counts number of opcodes **/ N, }; diff --git a/src/interpreter2/CMakeLists.txt b/src/interpreter2/CMakeLists.txt index 93ecd47e..8ce214ba 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -4,6 +4,7 @@ set(SELF_LIB xo_interpreter2) set(SELF_SRCS init_interpreter2.cpp VirtualSchematikaMachine.cpp + VsmFrame.cpp VsmInstr.cpp #IExpression_Any.cpp #interpreter2_register_facets.cpp diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 7c4873fb..dc876b44 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -4,8 +4,8 @@ **/ #include "VirtualSchematikaMachine.hpp" -#include -#include +#include +#include #include #include #include @@ -117,6 +117,13 @@ namespace xo { return false; case vsm_opcode::eval: _do_eval_op(); + break; + case vsm_opcode::apply: + _do_apply_op(); + break; + case vsm_opcode::evalargs: + _do_evalargs_op(); + break; } return true; @@ -187,8 +194,47 @@ namespace xo { void VirtualSchematikaMachine::_do_eval_apply_op() { - // not implemented - assert(false); + // ApplyExpr in expr_ register + + // assuming bump allocator: + // + // DArray VsmApplyFrame VsmEvalArgsFrame + // v v v + // +----------------------+-------+------+----+--------+-------+------+-------+ + // | argument expressions | par x | cont | fn | args x | par x | cont | i_arg | + // +----------------------+-----|-+------+----+------|-+-----|-+------+-------+ + // ^ ^ | | | + // | \----------------------------------/ + // \ | / + // \-----------------------------------------------/ + // / + // <---------------------------/ + // + // - VsmEvalArgsFrame: owned by VSM, state for evalargs loop + // - VsmApplyFrame: owned by VSM, state for transferring control to called function + // - DArray: contains evaluated args; owned by called primitive + + auto apply = obj::from(expr_); + + // evaluated arguments + DArray * args = DArray::empty(mm_.to_op(), + apply->n_args()); + + // TODO: check function signature + + VsmApplyFrame * apply_frame + = VsmApplyFrame::make(mm_.to_op(), stack_, cont_, args); + + VsmEvalArgsFrame * evalargs_frame + = VsmEvalArgsFrame::make(mm_.to_op(), apply_frame, VsmInstr::c_apply); + + this->stack_ = evalargs_frame; + + // Setup evaluation of first argument. No new stack for this. + + this->cont_ = VsmInstr::c_evalargs; + this->expr_ = apply->fn(); + this->pc_ = VsmInstr::c_eval; } void @@ -204,6 +250,21 @@ namespace xo { // not implemented assert(false); } + + void + VirtualSchematikaMachine::_do_apply_op() + { + // not implemented + assert(false); + } + + void + VirtualSchematikaMachine::_do_evalargs_op() + { + // not implemented + assert(false); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/VsmFrame.cpp b/src/interpreter2/VsmFrame.cpp new file mode 100644 index 00000000..2f262431 --- /dev/null +++ b/src/interpreter2/VsmFrame.cpp @@ -0,0 +1,68 @@ +/** @file VsmFrame.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "VsmFrame.hpp" + +namespace xo { + using xo::facet::typeseq; + + namespace scm { + + VsmApplyFrame::VsmApplyFrame(VsmFrame * old_parent, + VsmInstr old_cont, + DArray * args) + : VsmFrame(old_parent, old_cont), + args_{args} + {} + + VsmApplyFrame * + VsmApplyFrame::make(obj mm, + VsmFrame * old_parent, + VsmInstr old_cont, + DArray * args) + { + VsmApplyFrame * result = nullptr; + + void * mem = mm.alloc(typeseq::id(), + sizeof(VsmApplyFrame)); + + result = new (mem) VsmApplyFrame(old_parent, + old_cont, + args); + + assert(result); + + return result; + } + + // ----- VsmEvalArgsFrame ----- + + VsmEvalArgsFrame::VsmEvalArgsFrame(VsmApplyFrame * old_parent, + VsmInstr old_cont) + : VsmFrame(old_parent, old_cont) + {} + + VsmEvalArgsFrame * + VsmEvalArgsFrame::make(obj mm, + VsmApplyFrame * apply_frame, + VsmInstr cont) + { + VsmEvalArgsFrame * result = nullptr; + + void * mem = mm.alloc(typeseq::id(), + sizeof(VsmEvalArgsFrame)); + + result = new (mem) VsmEvalArgsFrame(apply_frame, cont); + + assert(result); + + return result; + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VsmFrame.cpp */ + diff --git a/src/interpreter2/VsmInstr.cpp b/src/interpreter2/VsmInstr.cpp index 95a0ef74..8d0907fc 100644 --- a/src/interpreter2/VsmInstr.cpp +++ b/src/interpreter2/VsmInstr.cpp @@ -12,6 +12,12 @@ namespace xo { VsmInstr VsmInstr::c_eval = VsmInstr(vsm_opcode::eval); + + VsmInstr + VsmInstr::c_apply = VsmInstr(vsm_opcode::apply); + + VsmInstr + VsmInstr::c_evalargs = VsmInstr(vsm_opcode::evalargs); } /*namespace scm*/ } /*namespace xo*/ diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 0a2ba92f..59104860 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -149,6 +149,43 @@ namespace xo { vsm.visit_pools(visitor); } + TEST_CASE("VirtualSchematikaMachine-arith1", "[interpreter2][VSM]") + { + scope log(XO_DEBUG(true)); + + VsmConfig cfg; + VirtualSchematikaMachine vsm(cfg); + + bool eof_flag = false; + + vsm.begin_interactive_session(); + VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("3.14159265 * 0.5;"), eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq())); + + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(x.data()->value() == 1011); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + + auto visitor = [&log](const MemorySizeInfo & info) { + log && log(xtag("resource", info.resource_name_), + xtag("used", info.used_), + xtag("alloc", info.allocated_), + xtag("commit", info.committed_), + xtag("resv", info.reserved_)); + }; + + FacetRegistry::instance().visit_pools(visitor); + vsm.visit_pools(visitor); + } + } /*namespace ut*/ } /*namespace xo*/ From 5292518eaffed53bfd04ae155a98c61bd360856e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Feb 2026 01:44:28 -0500 Subject: [PATCH 019/131] xo-interpreter2: vsm stack: facet + gcobject + printable + init --- CMakeLists.txt | 59 +++++++++++++ idl/IGCObject_DVsmApplyFrame.json5 | 15 ++++ idl/IGCObject_DVsmEvalArgsFrame.json5 | 15 ++++ idl/IPrintable_DVsmApplyFrame.json5 | 13 +++ idl/IPrintable_DVsmEvalArgsFrame.json5 | 13 +++ include/xo/interpreter2/DVsmApplyFrame.hpp | 53 ++++++++++++ include/xo/interpreter2/DVsmEvalArgsFrame.hpp | 48 +++++++++++ .../interpreter2/VirtualSchematikaMachine.hpp | 2 +- include/xo/interpreter2/VsmApplyFrame.hpp | 12 +++ include/xo/interpreter2/VsmEvalArgsFrame.hpp | 12 +++ include/xo/interpreter2/VsmFrame.hpp | 68 +++------------ include/xo/interpreter2/VsmInstr.hpp | 6 ++ include/xo/interpreter2/VsmOpcode.hpp | 11 +++ .../detail/IGCObject_DVsmApplyFrame.hpp | 67 +++++++++++++++ .../detail/IGCObject_DVsmEvalArgsFrame.hpp | 67 +++++++++++++++ .../detail/IPrintable_DVsmApplyFrame.hpp | 62 ++++++++++++++ .../detail/IPrintable_DVsmEvalArgsFrame.hpp | 62 ++++++++++++++ .../interpreter2_register_facets.hpp | 15 ++++ .../interpreter2_register_types.hpp | 17 ++++ src/interpreter2/CMakeLists.txt | 14 +++- src/interpreter2/DVsmApplyFrame.cpp | 82 +++++++++++++++++++ src/interpreter2/DVsmEvalArgsFrame.cpp | 77 +++++++++++++++++ src/interpreter2/IGCObject_DVsmApplyFrame.cpp | 39 +++++++++ .../IGCObject_DVsmEvalArgsFrame.cpp | 39 +++++++++ .../IPrintable_DVsmApplyFrame.cpp | 28 +++++++ .../IPrintable_DVsmEvalArgsFrame.cpp | 28 +++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 23 +++++- src/interpreter2/VsmApplyFrame.cpp | 0 src/interpreter2/VsmFrame.cpp | 68 --------------- src/interpreter2/VsmInstr.cpp | 15 ++++ src/interpreter2/init_interpreter2.cpp | 8 -- .../interpreter2_register_facets.cpp | 47 +++++++++++ .../interpreter2_register_types.cpp | 36 ++++++++ 33 files changed, 980 insertions(+), 141 deletions(-) create mode 100644 idl/IGCObject_DVsmApplyFrame.json5 create mode 100644 idl/IGCObject_DVsmEvalArgsFrame.json5 create mode 100644 idl/IPrintable_DVsmApplyFrame.json5 create mode 100644 idl/IPrintable_DVsmEvalArgsFrame.json5 create mode 100644 include/xo/interpreter2/DVsmApplyFrame.hpp create mode 100644 include/xo/interpreter2/DVsmEvalArgsFrame.hpp create mode 100644 include/xo/interpreter2/VsmApplyFrame.hpp create mode 100644 include/xo/interpreter2/VsmEvalArgsFrame.hpp create mode 100644 include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp create mode 100644 include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp create mode 100644 include/xo/interpreter2/detail/IPrintable_DVsmApplyFrame.hpp create mode 100644 include/xo/interpreter2/detail/IPrintable_DVsmEvalArgsFrame.hpp create mode 100644 include/xo/interpreter2/interpreter2_register_facets.hpp create mode 100644 include/xo/interpreter2/interpreter2_register_types.hpp create mode 100644 src/interpreter2/DVsmApplyFrame.cpp create mode 100644 src/interpreter2/DVsmEvalArgsFrame.cpp create mode 100644 src/interpreter2/IGCObject_DVsmApplyFrame.cpp create mode 100644 src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp create mode 100644 src/interpreter2/IPrintable_DVsmApplyFrame.cpp create mode 100644 src/interpreter2/IPrintable_DVsmEvalArgsFrame.cpp create mode 100644 src/interpreter2/VsmApplyFrame.cpp delete mode 100644 src/interpreter2/VsmFrame.cpp create mode 100644 src/interpreter2/interpreter2_register_facets.cpp create mode 100644 src/interpreter2/interpreter2_register_types.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 466e1a1c..259c3f03 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -23,6 +23,65 @@ add_definitions(${PROJECT_CXX_FLAGS}) add_subdirectory(src/interpreter2) add_subdirectory(utest) +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-gcobject-vsmapplyframe + FACET_PKG xo_gc + FACET GCObject + REPR VsmApplyFrame + INPUT idl/IGCObject_DVsmApplyFrame.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-vsmapplyframe + FACET_PKG xo_printable2 + FACET Printable + REPR VsmApplyFrame + INPUT idl/IPrintable_DVsmApplyFrame.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-vsmevalargsframe + FACET_PKG xo_gc + FACET GCObject + REPR VsmEvalArgsFrame + INPUT idl/IGCObject_DVsmEvalArgsFrame.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-vsmevalargsframe + FACET_PKG xo_printable2 + FACET Printable + REPR DVsmEvalArgsFrame + INPUT idl/IPrintable_DVsmEvalArgsFrame.json5 + OUTPUT_HPP_DIR include/xo/interpreter2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/interpreter2 +) + +# ---------------------------------------------------------------- + +xo_add_genfacet_all(xo-interpreter2-genfacet-all) + +# ---------------------------------------------------------------- +# cmake helper (for external xo-interpreter2 users) + xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) # ---------------------------------------------------------------- diff --git a/idl/IGCObject_DVsmApplyFrame.json5 b/idl/IGCObject_DVsmApplyFrame.json5 new file mode 100644 index 00000000..979c14bf --- /dev/null +++ b/idl/IGCObject_DVsmApplyFrame.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DVsmApplyFrame", + using_doxygen: true, + repr: "DVsmApplyFrame", + doc: [ "implement AGCObject for DVsmApplyFrame" ], +} diff --git a/idl/IGCObject_DVsmEvalArgsFrame.json5 b/idl/IGCObject_DVsmEvalArgsFrame.json5 new file mode 100644 index 00000000..8bebc6ec --- /dev/null +++ b/idl/IGCObject_DVsmEvalArgsFrame.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DVsmEvalArgsFrame", + using_doxygen: true, + repr: "DVsmEvalArgsFrame", + doc: [ "implement AGCObject for DVsmEvalArgsFrame" ], +} diff --git a/idl/IPrintable_DVsmApplyFrame.json5 b/idl/IPrintable_DVsmApplyFrame.json5 new file mode 100644 index 00000000..f5957d7e --- /dev/null +++ b/idl/IPrintable_DVsmApplyFrame.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DVsmApplyFrame", + using_doxygen: true, + repr: "DVsmApplyFrame", + doc: [ "implement APrintable for DVsmApplyFrame" ], +} diff --git a/idl/IPrintable_DVsmEvalArgsFrame.json5 b/idl/IPrintable_DVsmEvalArgsFrame.json5 new file mode 100644 index 00000000..24df6cbd --- /dev/null +++ b/idl/IPrintable_DVsmEvalArgsFrame.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DVsmEvalArgsFrame", + using_doxygen: true, + repr: "DVsmEvalArgsFrame", + doc: [ "implement APrintable for DVsmEvalArgsFrame" ], +} diff --git a/include/xo/interpreter2/DVsmApplyFrame.hpp b/include/xo/interpreter2/DVsmApplyFrame.hpp new file mode 100644 index 00000000..d947a8bc --- /dev/null +++ b/include/xo/interpreter2/DVsmApplyFrame.hpp @@ -0,0 +1,53 @@ +/** @file DVsmApplyFrame.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "VsmFrame.hpp" + +namespace xo { + namespace scm { + class DVsmApplyFrame : public VsmFrame { + public: + using AProcedure = xo::scm::AProcedure; + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + using ppindentinfo = xo::print::ppindentinfo; + + public: + DVsmApplyFrame(obj old_parent, + VsmInstr old_cont, + DArray * args); + + static DVsmApplyFrame * make(obj mm, + obj old_parent, + VsmInstr old_cont, + DArray * args); + + obj fn() const noexcept { return fn_; } + DArray * args() const noexcept { return args_; } + + std::size_t shallow_size() const noexcept; + DVsmApplyFrame * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + + /** pretty-printing support **/ + bool pretty(const ppindentinfo & ppii) const; + + private: + /** evaluated target procedure. + * + * note: when initially created, this will be unpopulated; + * don't know correct value until we evaluate + * expression in head position + **/ + obj fn_; + /** evaluated arguments (to target procedure) **/ + DArray * args_; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmApplyFrame.hpp */ diff --git a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp new file mode 100644 index 00000000..a8ef0226 --- /dev/null +++ b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp @@ -0,0 +1,48 @@ +/** @file DVsmEvalArgsFrame.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DVsmApplyFrame.hpp" + +namespace xo { + namespace scm { + + /** frame for executing an apply expression **/ + class DVsmEvalArgsFrame : public VsmFrame { + public: + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + using ppindentinfo = xo::print::ppindentinfo; + + public: + /** see picture in VirtualSchematikaMachine._do_eval_apply_op() + * + * old_parent = [apply frame] + * old_cont = [xfer to called function] + * + **/ + DVsmEvalArgsFrame(obj old_parent, + VsmInstr old_cont); + + static DVsmEvalArgsFrame * make(obj mm, + obj apply_frame, + VsmInstr old_cont); + + std::size_t shallow_size() const noexcept; + DVsmEvalArgsFrame * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + + bool pretty(const ppindentinfo & ppii) const; + + protected: + /** next argument to be evaluated. -1 means function head **/ + int32_t i_arg_ = -1; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmEvalArgsFrame.hpp */ diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 26366d50..78c2f3f7 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -181,7 +181,7 @@ namespace xo { VsmInstr pc_ = VsmInstr::c_halt; /** stack pointer **/ - VsmFrame * stack_ = nullptr; + obj stack_; /** expression register **/ obj expr_; diff --git a/include/xo/interpreter2/VsmApplyFrame.hpp b/include/xo/interpreter2/VsmApplyFrame.hpp new file mode 100644 index 00000000..5ed121ba --- /dev/null +++ b/include/xo/interpreter2/VsmApplyFrame.hpp @@ -0,0 +1,12 @@ +/** @file VsmApplyFrame.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DVsmApplyFrame.hpp" +#include "detail/IGCObject_DVsmApplyFrame.hpp" +#include "detail/IPrintable_DVsmApplyFrame.hpp" + +/* end VsmApplyFrame.hpp */ diff --git a/include/xo/interpreter2/VsmEvalArgsFrame.hpp b/include/xo/interpreter2/VsmEvalArgsFrame.hpp new file mode 100644 index 00000000..8c45b25e --- /dev/null +++ b/include/xo/interpreter2/VsmEvalArgsFrame.hpp @@ -0,0 +1,12 @@ +/** @file VsmEvalArgsFrame.hpp +* +* @author Roland Conybeare, Feb 2026 +**/ + +#pragma once + +#include "DVsmEvalArgsFrame.hpp" +#include "detail/IGCObject_DVsmEvalArgsFrame.hpp" +#include "detail/IPrintable_DVsmEvalArgsFrame.hpp" + +/* end VsmEvalArgsFrame.hpp */ diff --git a/include/xo/interpreter2/VsmFrame.hpp b/include/xo/interpreter2/VsmFrame.hpp index 09b542a8..f4cf5f1e 100644 --- a/include/xo/interpreter2/VsmFrame.hpp +++ b/include/xo/interpreter2/VsmFrame.hpp @@ -13,74 +13,26 @@ namespace xo { namespace scm { class VsmFrame { public: - VsmFrame(VsmFrame * parent, VsmInstr cont) : parent_{parent}, cont_{cont} {} + using AGCObject = xo::mm::AGCObject; - VsmFrame * parent() const noexcept { return parent_; } + public: + VsmFrame(obj parent, + VsmInstr cont) : parent_{parent}, cont_{cont} {} + + //obj parent() const noexcept { return parent_; } + VsmFrame * parent() const noexcept { + return reinterpret_cast(parent_.data()); + } VsmInstr cont() const noexcept { return cont_; } protected: /** saved VSM stack; restore when this frame consumed **/ - VsmFrame * parent_ = nullptr; + obj parent_; /** saved continuation; restore when this frame consumed **/ VsmInstr cont_; }; - class VsmApplyFrame : public VsmFrame { - public: - using AProcedure = xo::scm::AProcedure; - using AAllocator = xo::mm::AAllocator; - - public: - VsmApplyFrame(VsmFrame * old_parent, - VsmInstr old_cont, - DArray * args); - - static VsmApplyFrame * make(obj mm, - VsmFrame * old_parent, - VsmInstr old_cont, - DArray * args); - - obj fn() const noexcept { return fn_; } - DArray * args() const noexcept { return args_; } - - private: - /** evaluated target procedure. - * - * note: when initially created, this will be unpopulated; - * don't know correct value until we evaluate - * expression in head position - **/ - obj fn_; - /** evaluated arguments (to target procedure) **/ - DArray * args_; - }; - - /** frame for executing an apply expression **/ - class VsmEvalArgsFrame : public VsmFrame { - public: - using AAllocator = xo::mm::AAllocator; - - public: - /** see picture in VirtualSchematikaMachine._do_eval_apply_op() - * - * old_parent = [apply frame] - * old_cont = [xfer to called function] - * - **/ - VsmEvalArgsFrame(VsmApplyFrame * old_parent, - VsmInstr old_cont); - - static VsmEvalArgsFrame * make(obj mm, - VsmApplyFrame * apply_frame, - VsmInstr old_cont); - - private: - /** next argument to be evaluated. -1 means function head **/ - int32_t i_arg_ = -1; - }; - } /*namespace scm*/ } /*namespace xo*/ /* end VsmFrame.hpp */ - diff --git a/include/xo/interpreter2/VsmInstr.hpp b/include/xo/interpreter2/VsmInstr.hpp index a94ee625..ec836c4d 100644 --- a/include/xo/interpreter2/VsmInstr.hpp +++ b/include/xo/interpreter2/VsmInstr.hpp @@ -24,6 +24,12 @@ namespace xo { private: vsm_opcode opcode_; }; + + inline std::ostream & + operator<<(std::ostream & os, VsmInstr x) { + os << x.opcode(); + return os; + } } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/interpreter2/VsmOpcode.hpp b/include/xo/interpreter2/VsmOpcode.hpp index 6e41c5c1..2c58c04f 100644 --- a/include/xo/interpreter2/VsmOpcode.hpp +++ b/include/xo/interpreter2/VsmOpcode.hpp @@ -5,6 +5,7 @@ #pragma once +#include #include namespace xo { @@ -32,6 +33,16 @@ namespace xo { }; static constexpr uint32_t n_opcode = static_cast(vsm_opcode::N); + + /** stringified enum value **/ + const char * + vsm_opcode_descr(vsm_opcode x); + + inline std::ostream & + operator<<(std::ostream & os, vsm_opcode x) { + os << vsm_opcode_descr(x); + return os; + } } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp new file mode 100644 index 00000000..ca6d3b10 --- /dev/null +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DVsmApplyFrame.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVsmApplyFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVsmApplyFrame.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DVsmApplyFrame.hpp" + +namespace xo { namespace scm { class IGCObject_DVsmApplyFrame; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DVsmApplyFrame + **/ + class IGCObject_DVsmApplyFrame { + public: + /** @defgroup scm-gcobject-dvsmapplyframe-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-dvsmapplyframe-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DVsmApplyFrame & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DVsmApplyFrame & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DVsmApplyFrame & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp new file mode 100644 index 00000000..4a8ad18a --- /dev/null +++ b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DVsmEvalArgsFrame.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVsmEvalArgsFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVsmEvalArgsFrame.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DVsmEvalArgsFrame.hpp" + +namespace xo { namespace scm { class IGCObject_DVsmEvalArgsFrame; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DVsmEvalArgsFrame + **/ + class IGCObject_DVsmEvalArgsFrame { + public: + /** @defgroup scm-gcobject-dvsmevalargsframe-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-dvsmevalargsframe-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DVsmEvalArgsFrame & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DVsmEvalArgsFrame & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DVsmEvalArgsFrame & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/detail/IPrintable_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IPrintable_DVsmApplyFrame.hpp new file mode 100644 index 00000000..af1a4e02 --- /dev/null +++ b/include/xo/interpreter2/detail/IPrintable_DVsmApplyFrame.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DVsmApplyFrame.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVsmApplyFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVsmApplyFrame.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DVsmApplyFrame.hpp" + +namespace xo { namespace scm { class IPrintable_DVsmApplyFrame; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DVsmApplyFrame + **/ + class IPrintable_DVsmApplyFrame { + public: + /** @defgroup scm-printable-dvsmapplyframe-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dvsmapplyframe-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DVsmApplyFrame & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/detail/IPrintable_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IPrintable_DVsmEvalArgsFrame.hpp new file mode 100644 index 00000000..1c06f71e --- /dev/null +++ b/include/xo/interpreter2/detail/IPrintable_DVsmEvalArgsFrame.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DVsmEvalArgsFrame.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVsmEvalArgsFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVsmEvalArgsFrame.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DVsmEvalArgsFrame.hpp" + +namespace xo { namespace scm { class IPrintable_DVsmEvalArgsFrame; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DVsmEvalArgsFrame + **/ + class IPrintable_DVsmEvalArgsFrame { + public: + /** @defgroup scm-printable-dvsmevalargsframe-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dvsmevalargsframe-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DVsmEvalArgsFrame & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/interpreter2_register_facets.hpp b/include/xo/interpreter2/interpreter2_register_facets.hpp new file mode 100644 index 00000000..587f882b --- /dev/null +++ b/include/xo/interpreter2/interpreter2_register_facets.hpp @@ -0,0 +1,15 @@ +/** @file interpreter2_register_facets.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +namespace xo { + namespace scm { + /** Register interpreter2 (facet,impl) combinations with FacetRegistry **/ + bool interpreter2_register_facets(); + } +} + +/* end interpreter2_register_facets.hpp */ diff --git a/include/xo/interpreter2/interpreter2_register_types.hpp b/include/xo/interpreter2/interpreter2_register_types.hpp new file mode 100644 index 00000000..1409d13a --- /dev/null +++ b/include/xo/interpreter2/interpreter2_register_types.hpp @@ -0,0 +1,17 @@ +/** @file interpreter2_register_types.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + /** Register interpreter2 (facet,impl) combinations with FacetRegistry **/ + bool interpreter2_register_types(obj gc); + } +} + +/* end interpreter2_register_types.hpp */ diff --git a/src/interpreter2/CMakeLists.txt b/src/interpreter2/CMakeLists.txt index 8ce214ba..635ecff3 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -3,11 +3,21 @@ set(SELF_LIB xo_interpreter2) set(SELF_SRCS init_interpreter2.cpp + interpreter2_register_facets.cpp + interpreter2_register_types.cpp + VirtualSchematikaMachine.cpp - VsmFrame.cpp + + DVsmEvalArgsFrame.cpp + IGCObject_DVsmEvalArgsFrame.cpp + IPrintable_DVsmEvalArgsFrame.cpp + + DVsmApplyFrame.cpp + IGCObject_DVsmApplyFrame.cpp + IPrintable_DVsmApplyFrame.cpp + VsmInstr.cpp #IExpression_Any.cpp - #interpreter2_register_facets.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) diff --git a/src/interpreter2/DVsmApplyFrame.cpp b/src/interpreter2/DVsmApplyFrame.cpp new file mode 100644 index 00000000..75da5877 --- /dev/null +++ b/src/interpreter2/DVsmApplyFrame.cpp @@ -0,0 +1,82 @@ +/** @file DVsmApplyFrame.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DVsmApplyFrame.hpp" +#include + +namespace xo { + using xo::facet::typeseq; + + namespace scm { + + DVsmApplyFrame::DVsmApplyFrame(obj old_parent, + VsmInstr old_cont, + DArray * args) + : VsmFrame(old_parent, old_cont), + args_{args} + {} + + DVsmApplyFrame * + DVsmApplyFrame::make(obj mm, + obj old_parent, + VsmInstr old_cont, + DArray * args) + { + DVsmApplyFrame * result = nullptr; + + void * mem = mm.alloc(typeseq::id(), + sizeof(DVsmApplyFrame)); + + result = new (mem) DVsmApplyFrame(old_parent, + old_cont, + args); + + assert(result); + + return result; + } + + std::size_t + DVsmApplyFrame::shallow_size() const noexcept + { + return sizeof(DVsmApplyFrame); + } + + DVsmApplyFrame * + DVsmApplyFrame::shallow_copy(obj mm) const noexcept + { + DVsmApplyFrame * copy = (DVsmApplyFrame *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + std::size_t + DVsmApplyFrame::forward_children(obj gc) noexcept + { + // GC needs to locate AGCObject iface for each member + + (void)gc; + + return this->shallow_size(); + } + + bool + DVsmApplyFrame::pretty(const ppindentinfo & ppii) const + { + return ppii.pps()->pretty_struct + (ppii, + "DVsmApplyFrame", + refrtag("cont", cont_), + refrtag("n_args", args_->size()) + ); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmApplyFrame.cpp */ diff --git a/src/interpreter2/DVsmEvalArgsFrame.cpp b/src/interpreter2/DVsmEvalArgsFrame.cpp new file mode 100644 index 00000000..cb2b328e --- /dev/null +++ b/src/interpreter2/DVsmEvalArgsFrame.cpp @@ -0,0 +1,77 @@ +/** @file DVsmEvalArgsFrame.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DVsmEvalArgsFrame.hpp" +#include + +namespace xo { + using xo::facet::typeseq; + using xo::print::ppindentinfo; + + namespace scm { + + // ----- VsmEvalArgsFrame ----- + + DVsmEvalArgsFrame::DVsmEvalArgsFrame(obj old_parent, + VsmInstr old_cont) + : VsmFrame(old_parent, old_cont) + {} + + DVsmEvalArgsFrame * + DVsmEvalArgsFrame::make(obj mm, + obj apply_frame, + VsmInstr cont) + { + DVsmEvalArgsFrame * result = nullptr; + + void * mem = mm.alloc(typeseq::id(), + sizeof(DVsmEvalArgsFrame)); + + result = new (mem) DVsmEvalArgsFrame(apply_frame, cont); + + assert(result); + + return result; + } + + std::size_t + DVsmEvalArgsFrame::shallow_size() const noexcept + { + return sizeof(DVsmEvalArgsFrame); + } + + DVsmEvalArgsFrame * + DVsmEvalArgsFrame::shallow_copy(obj mm) const noexcept + { + DVsmEvalArgsFrame * copy = (DVsmEvalArgsFrame *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + std::size_t + DVsmEvalArgsFrame::forward_children(obj gc) noexcept + { + (void)gc; + + return this->shallow_size(); + } + + bool + DVsmEvalArgsFrame::pretty(const ppindentinfo & ppii) const + { + return ppii.pps()->pretty_struct + (ppii, + "DVsmEvalArgsFrame", + refrtag("cont", cont_), + refrtag("i_arg", i_arg_) + ); + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VsmEvalArgsFrame.cpp */ diff --git a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp new file mode 100644 index 00000000..1e794477 --- /dev/null +++ b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DVsmApplyFrame.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVsmApplyFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVsmApplyFrame.json5] +**/ + +#include "detail/IGCObject_DVsmApplyFrame.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DVsmApplyFrame::shallow_size(const DVsmApplyFrame & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DVsmApplyFrame::shallow_copy(const DVsmApplyFrame & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DVsmApplyFrame::forward_children(DVsmApplyFrame & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVsmApplyFrame.cpp */ diff --git a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp new file mode 100644 index 00000000..d64b47bd --- /dev/null +++ b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DVsmEvalArgsFrame.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVsmEvalArgsFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVsmEvalArgsFrame.json5] +**/ + +#include "detail/IGCObject_DVsmEvalArgsFrame.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DVsmEvalArgsFrame::shallow_size(const DVsmEvalArgsFrame & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DVsmEvalArgsFrame::shallow_copy(const DVsmEvalArgsFrame & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DVsmEvalArgsFrame::forward_children(DVsmEvalArgsFrame & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVsmEvalArgsFrame.cpp */ diff --git a/src/interpreter2/IPrintable_DVsmApplyFrame.cpp b/src/interpreter2/IPrintable_DVsmApplyFrame.cpp new file mode 100644 index 00000000..5faa360f --- /dev/null +++ b/src/interpreter2/IPrintable_DVsmApplyFrame.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DVsmApplyFrame.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVsmApplyFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVsmApplyFrame.json5] +**/ + +#include "detail/IPrintable_DVsmApplyFrame.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DVsmApplyFrame::pretty(const DVsmApplyFrame & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DVsmApplyFrame.cpp */ diff --git a/src/interpreter2/IPrintable_DVsmEvalArgsFrame.cpp b/src/interpreter2/IPrintable_DVsmEvalArgsFrame.cpp new file mode 100644 index 00000000..25d81800 --- /dev/null +++ b/src/interpreter2/IPrintable_DVsmEvalArgsFrame.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DVsmEvalArgsFrame.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVsmEvalArgsFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVsmEvalArgsFrame.json5] +**/ + +#include "detail/IPrintable_DVsmEvalArgsFrame.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DVsmEvalArgsFrame::pretty(const DVsmEvalArgsFrame & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DVsmEvalArgsFrame.cpp */ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index dc876b44..22f9ed12 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -4,6 +4,8 @@ **/ #include "VirtualSchematikaMachine.hpp" +#include "VsmApplyFrame.hpp" +#include "VsmEvalArgsFrame.hpp" #include #include #include @@ -111,6 +113,17 @@ namespace xo { bool VirtualSchematikaMachine::execute_one() { + scope log(XO_DEBUG(true)); + log && log(xtag("pc", pc_), + xtag("cont", cont_)); + + obj stack_pr + = (FacetRegistry::instance() + .try_variant(stack_)); + + if (stack_pr) + log && log(xtag("stack", stack_pr)); + switch (pc_.opcode()) { case vsm_opcode::halt: case vsm_opcode::N: @@ -222,11 +235,13 @@ namespace xo { // TODO: check function signature - VsmApplyFrame * apply_frame - = VsmApplyFrame::make(mm_.to_op(), stack_, cont_, args); + auto apply_frame + = obj + (DVsmApplyFrame::make(mm_.to_op(), stack_, cont_, args)); - VsmEvalArgsFrame * evalargs_frame - = VsmEvalArgsFrame::make(mm_.to_op(), apply_frame, VsmInstr::c_apply); + auto evalargs_frame + = obj + (DVsmEvalArgsFrame::make(mm_.to_op(), apply_frame, VsmInstr::c_apply)); this->stack_ = evalargs_frame; diff --git a/src/interpreter2/VsmApplyFrame.cpp b/src/interpreter2/VsmApplyFrame.cpp new file mode 100644 index 00000000..e69de29b diff --git a/src/interpreter2/VsmFrame.cpp b/src/interpreter2/VsmFrame.cpp deleted file mode 100644 index 2f262431..00000000 --- a/src/interpreter2/VsmFrame.cpp +++ /dev/null @@ -1,68 +0,0 @@ -/** @file VsmFrame.cpp - * - * @author Roland Conybeare, Feb 2026 - **/ - -#include "VsmFrame.hpp" - -namespace xo { - using xo::facet::typeseq; - - namespace scm { - - VsmApplyFrame::VsmApplyFrame(VsmFrame * old_parent, - VsmInstr old_cont, - DArray * args) - : VsmFrame(old_parent, old_cont), - args_{args} - {} - - VsmApplyFrame * - VsmApplyFrame::make(obj mm, - VsmFrame * old_parent, - VsmInstr old_cont, - DArray * args) - { - VsmApplyFrame * result = nullptr; - - void * mem = mm.alloc(typeseq::id(), - sizeof(VsmApplyFrame)); - - result = new (mem) VsmApplyFrame(old_parent, - old_cont, - args); - - assert(result); - - return result; - } - - // ----- VsmEvalArgsFrame ----- - - VsmEvalArgsFrame::VsmEvalArgsFrame(VsmApplyFrame * old_parent, - VsmInstr old_cont) - : VsmFrame(old_parent, old_cont) - {} - - VsmEvalArgsFrame * - VsmEvalArgsFrame::make(obj mm, - VsmApplyFrame * apply_frame, - VsmInstr cont) - { - VsmEvalArgsFrame * result = nullptr; - - void * mem = mm.alloc(typeseq::id(), - sizeof(VsmEvalArgsFrame)); - - result = new (mem) VsmEvalArgsFrame(apply_frame, cont); - - assert(result); - - return result; - } - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end VsmFrame.cpp */ - diff --git a/src/interpreter2/VsmInstr.cpp b/src/interpreter2/VsmInstr.cpp index 8d0907fc..ddcc8c20 100644 --- a/src/interpreter2/VsmInstr.cpp +++ b/src/interpreter2/VsmInstr.cpp @@ -7,6 +7,21 @@ namespace xo { namespace scm { + const char * + vsm_opcode_descr(vsm_opcode x) + { + switch (x) { + case vsm_opcode::halt: return "halt"; + case vsm_opcode::eval: return "eval"; + case vsm_opcode::apply: return "apply"; + case vsm_opcode::evalargs: return "evalargs"; + case vsm_opcode::N: + break; + } + + return "opcode?"; + } + VsmInstr VsmInstr::c_halt = VsmInstr(vsm_opcode::halt); diff --git a/src/interpreter2/init_interpreter2.cpp b/src/interpreter2/init_interpreter2.cpp index b0e8a71c..07308863 100644 --- a/src/interpreter2/init_interpreter2.cpp +++ b/src/interpreter2/init_interpreter2.cpp @@ -5,31 +5,23 @@ #include "init_interpreter2.hpp" -#ifdef NOT_YET #include "interpreter2_register_facets.hpp" #include "interpreter2_register_types.hpp" -#endif #include -#ifdef NOT_YET #include -#endif namespace xo { -#ifdef NOT_YET using xo::scm::interpreter2_register_facets; using xo::scm::interpreter2_register_types; using xo::mm::CollectorTypeRegistry; -#endif void InitSubsys::init() { -#ifdef NOT_YET interpreter2_register_facets(); CollectorTypeRegistry::instance().register_types(&interpreter2_register_types); -#endif } InitEvidence diff --git a/src/interpreter2/interpreter2_register_facets.cpp b/src/interpreter2/interpreter2_register_facets.cpp new file mode 100644 index 00000000..b16d33ef --- /dev/null +++ b/src/interpreter2/interpreter2_register_facets.cpp @@ -0,0 +1,47 @@ +/** @file interpreter2_register_facets.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "interpreter2_register_facets.hpp" + +#include "VsmApplyFrame.hpp" +#include "VsmEvalArgsFrame.hpp" + +#include +#include +#include +#include + +namespace xo { + using xo::mm::AGCObject; + using xo::print::APrintable; + using xo::facet::FacetRegistry; + using xo::reflect::typeseq; + using xo::xtag; + + namespace scm { + bool + interpreter2_register_facets() + { + scope log(XO_DEBUG(true)); + + // VsmStackFrame + // +- VsmApplyFrame + // \- VsmEvalArgsFrame + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + log && log(xtag("DVsmApplyFrame.tseq", typeseq::id())); + log && log(xtag("DVsmEvalArgsFrame.tseq", typeseq::id())); + + return true; + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end interpreter2_register_facets.cpp */ diff --git a/src/interpreter2/interpreter2_register_types.cpp b/src/interpreter2/interpreter2_register_types.cpp new file mode 100644 index 00000000..54351beb --- /dev/null +++ b/src/interpreter2/interpreter2_register_types.cpp @@ -0,0 +1,36 @@ +/** @file interpreter2_register_types.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "interpreter2_register_types.hpp" + +#include "VsmApplyFrame.hpp" +#include "VsmEvalArgsFrame.hpp" + +#include + +namespace xo { + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::facet::impl_for; + //using xo::facet::typeseq; + using xo::scope; + + namespace scm { + bool + interpreter2_register_types(obj gc) + { + scope log(XO_DEBUG(true)); + + bool ok = true; + + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + + return ok; + } + } +} /*namespace xo*/ + +/* end interpreter2_register_types.cpp */ From a63e4b1dae79870374f57399e7fe40bedaf539d8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Feb 2026 16:26:19 -0500 Subject: [PATCH 020/131] xo-interpreter2: apply sequence now working in interpreter --- include/xo/interpreter2/DVsmApplyFrame.hpp | 2 + include/xo/interpreter2/DVsmEvalArgsFrame.hpp | 31 +++- .../interpreter2/VirtualSchematikaMachine.hpp | 21 ++- include/xo/interpreter2/VsmFrame.hpp | 4 +- src/interpreter2/DVsmEvalArgsFrame.cpp | 16 +- src/interpreter2/VirtualSchematikaMachine.cpp | 156 ++++++++++++++++-- utest/VirtualSchematikaMachine.test.cpp | 4 +- 7 files changed, 201 insertions(+), 33 deletions(-) diff --git a/include/xo/interpreter2/DVsmApplyFrame.hpp b/include/xo/interpreter2/DVsmApplyFrame.hpp index d947a8bc..c898c602 100644 --- a/include/xo/interpreter2/DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyFrame.hpp @@ -29,6 +29,8 @@ namespace xo { obj fn() const noexcept { return fn_; } DArray * args() const noexcept { return args_; } + void assign_fn(obj x) { this->fn_ = x; } + std::size_t shallow_size() const noexcept; DVsmApplyFrame * shallow_copy(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; diff --git a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp index a8ef0226..7131a001 100644 --- a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp @@ -5,16 +5,18 @@ #pragma once -#include "DVsmApplyFrame.hpp" +#include "VsmApplyFrame.hpp" +#include namespace xo { namespace scm { /** frame for executing an apply expression **/ - class DVsmEvalArgsFrame : public VsmFrame { + class DVsmEvalArgsFrame { public: using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; using ppindentinfo = xo::print::ppindentinfo; public: @@ -24,12 +26,21 @@ namespace xo { * old_cont = [xfer to called function] * **/ - DVsmEvalArgsFrame(obj old_parent, - VsmInstr old_cont); + DVsmEvalArgsFrame(DVsmApplyFrame * parent, + VsmInstr cont, + const DApplyExpr * apply_expr); static DVsmEvalArgsFrame * make(obj mm, - obj apply_frame, - VsmInstr old_cont); + DVsmApplyFrame * apply_frame, + VsmInstr old_cont, + const DApplyExpr * apply_expr); + + DVsmApplyFrame * parent() const noexcept { return parent_; } + VsmInstr cont() const noexcept { return cont_; } + const DApplyExpr * apply_expr() const noexcept { return apply_expr_; } + int32_t i_arg() const noexcept { return i_arg_; } + + int32_t increment_arg() { return ++i_arg_; } std::size_t shallow_size() const noexcept; DVsmEvalArgsFrame * shallow_copy(obj mm) const noexcept; @@ -38,6 +49,14 @@ namespace xo { bool pretty(const ppindentinfo & ppii) const; protected: + /** parent stack frame **/ + DVsmApplyFrame * parent_ = nullptr; + /** continuation after eval args completed (always VsmInstr::c_apply) **/ + VsmInstr cont_; + + /** expression being evaluated **/ + const DApplyExpr * apply_expr_ = nullptr; + /** next argument to be evaluated. -1 means function head **/ int32_t i_arg_ = -1; }; diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 78c2f3f7..774659eb 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -147,7 +147,14 @@ namespace xo { /** apply a function to evaluated arguments **/ void _do_apply_op(); - /** evaluate arguments on behalf of a function call **/ + /** evaluate arguments on behalf of a function call + * Require: + * - expression value in @ref value_ + * - stack: + * [0] VsmEvalArgsFrame + * [1] VsmApplyFrame + * ... + **/ void _do_evalargs_op(); private: @@ -159,6 +166,8 @@ namespace xo { * Other registers are not preserved * pc_ * expr_ + * fn_ + * args_ * value_ */ @@ -170,6 +179,11 @@ namespace xo { **/ box mm_; + /** runtime context for this vsm. + * For example, provides allocator to primitives + **/ + box rcx_; + // consider separate allocator (which _may_ turn out to be the same) // for VM stack. Only works for code that doesn't rely on fancy // lexical scoping @@ -186,6 +200,11 @@ namespace xo { /** expression register **/ obj expr_; + /** function to call **/ + obj fn_; + /** evaluated argument list **/ + DArray * args_; + /** result register **/ VsmResult value_; diff --git a/include/xo/interpreter2/VsmFrame.hpp b/include/xo/interpreter2/VsmFrame.hpp index f4cf5f1e..52a30761 100644 --- a/include/xo/interpreter2/VsmFrame.hpp +++ b/include/xo/interpreter2/VsmFrame.hpp @@ -20,9 +20,7 @@ namespace xo { VsmInstr cont) : parent_{parent}, cont_{cont} {} //obj parent() const noexcept { return parent_; } - VsmFrame * parent() const noexcept { - return reinterpret_cast(parent_.data()); - } + obj parent() const noexcept { return parent_; } VsmInstr cont() const noexcept { return cont_; } protected: diff --git a/src/interpreter2/DVsmEvalArgsFrame.cpp b/src/interpreter2/DVsmEvalArgsFrame.cpp index cb2b328e..01391cf2 100644 --- a/src/interpreter2/DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/DVsmEvalArgsFrame.cpp @@ -14,22 +14,26 @@ namespace xo { // ----- VsmEvalArgsFrame ----- - DVsmEvalArgsFrame::DVsmEvalArgsFrame(obj old_parent, - VsmInstr old_cont) - : VsmFrame(old_parent, old_cont) + DVsmEvalArgsFrame::DVsmEvalArgsFrame(DVsmApplyFrame * parent, + VsmInstr cont, + const DApplyExpr * apply_expr) + : parent_{parent}, + cont_{cont}, + apply_expr_{apply_expr} {} DVsmEvalArgsFrame * DVsmEvalArgsFrame::make(obj mm, - obj apply_frame, - VsmInstr cont) + DVsmApplyFrame * apply_frame, + VsmInstr cont, + const DApplyExpr * apply_expr) { DVsmEvalArgsFrame * result = nullptr; void * mem = mm.alloc(typeseq::id(), sizeof(DVsmEvalArgsFrame)); - result = new (mem) DVsmEvalArgsFrame(apply_frame, cont); + result = new (mem) DVsmEvalArgsFrame(apply_frame, cont, apply_expr); assert(result); diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 22f9ed12..b32f6b24 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -8,6 +8,8 @@ #include "VsmEvalArgsFrame.hpp" #include #include +#include +#include #include #include #include @@ -26,9 +28,13 @@ namespace xo { namespace scm { + // NOTE: using heap for {DX1Collector, DSimpleRcx} instances + // (though allocation from explictly mmap'd memory) + // VirtualSchematikaMachine::VirtualSchematikaMachine(const VsmConfig & config) : config_{config}, mm_(box(new DX1Collector(config.x1_config_))), + rcx_(box(new DSimpleRcx(mm_.to_op()))), reader_{config.rdr_config_, mm_.to_op()} {} @@ -211,21 +217,23 @@ namespace xo { // assuming bump allocator: // - // DArray VsmApplyFrame VsmEvalArgsFrame - // v v v - // +----------------------+-------+------+----+--------+-------+------+-------+ - // | argument expressions | par x | cont | fn | args x | par x | cont | i_arg | - // +----------------------+-----|-+------+----+------|-+-----|-+------+-------+ - // ^ ^ | | | - // | \----------------------------------/ - // \ | / - // \-----------------------------------------------/ + // DArray VsmApplyFrame VsmEvalArgsFrame + // v v v + // +----------------------+-------+-------+----+--------+-------+-------+-------+ + // | argument expressions | par x | cont1 | fn | args x | par x | cont2 | i_arg | + // +----------------------+-----|-+-------+----+------|-+-----|-+-------+-------+ + // ^ ^ | | | + // | \-----------------------------------/ + // \ | / + // \------------------------------------------------/ // / // <---------------------------/ // // - VsmEvalArgsFrame: owned by VSM, state for evalargs loop // - VsmApplyFrame: owned by VSM, state for transferring control to called function // - DArray: contains evaluated args; owned by called primitive + // - cont2: always c_apply + // auto apply = obj::from(expr_); @@ -235,13 +243,13 @@ namespace xo { // TODO: check function signature - auto apply_frame - = obj - (DVsmApplyFrame::make(mm_.to_op(), stack_, cont_, args)); + DVsmApplyFrame * apply_frame + = DVsmApplyFrame::make(mm_.to_op(), stack_, cont_, args); auto evalargs_frame = obj - (DVsmEvalArgsFrame::make(mm_.to_op(), apply_frame, VsmInstr::c_apply)); + (DVsmEvalArgsFrame::make(mm_.to_op(), + apply_frame, VsmInstr::c_apply, apply.data())); this->stack_ = evalargs_frame; @@ -269,13 +277,131 @@ namespace xo { void VirtualSchematikaMachine::_do_apply_op() { - // not implemented - assert(false); + // rcx_ : runtime context + // fn_ : function to call + // args_ : array of arguments + + // TODO: check argument types + + this->value_ = fn_.apply_nocheck(rcx_.to_op(), args_); + this->pc_ = cont_; + + return; } void VirtualSchematikaMachine::_do_evalargs_op() { + scope log(XO_DEBUG(false)); + + if (!value_.is_value()) { + // error while evaluating function arg + + log.retroactively_enable(); + log && log("error in apply -> terminating app"); + + this->pc_ = VsmInstr::c_halt; + return; + } + + // here: nested evaluation succeeded + + // value of one of {fn, arg(i), ..} in fn(arg0 .. arg(n-1)) + // + obj value = *(value_.value()); + + // value_ in [i_arg] value_ + // . (if i_arg >= 0) . (if i_arg = -1) + // . . + // DArray . VsmApplyFrame . VsmEvalArgsFrame + // v v v v v + // +----------------------+-------+-------+----+--------+-------+-------+--------+-------+ + // | argument expressions | par o | cont1 | fn | args x | par o | cont2 | applyx | i_arg | + // +----------------------+-----|-+-------+----+------|-+-----|-+-------+--------+-------+ + // ^ ^ | | | + // | \-----------------------------------/ + // \ | / + // \------------------------------------------------/ + // / + // <---------------------------/ + // + // - VsmEvalArgsFrame: owned by VSM, state for evalargs loop + // - VsmApplyFrame: owned by VSM, state for transferring control to called function + // - DArray: contains evaluated args; owned by called primitive + + // - i_arg + // if -1: value_ register holds function + // if >=0: value_ register holds i'th function argument + // + + auto evalargs_frame + = obj::from(stack_); + + assert(evalargs_frame); + + int32_t i_arg = evalargs_frame->i_arg(); + + DVsmApplyFrame * apply_frame = evalargs_frame->parent(); + + const DApplyExpr * apply_expr + = evalargs_frame->apply_expr(); + + if (i_arg == -1) { + auto fn = value.to_facet(); + + if (fn) { + apply_frame->assign_fn(fn); + + i_arg = evalargs_frame->increment_arg(); + + // now i_arg is 0 -> evaluate that argument + + this->expr_ = apply_expr->arg(i_arg); + this->pc_ = VsmInstr::c_eval; + //this->cont_ = VsmInstra::c_evalargs; // redundant, since preserved + + return; + } else { + // error - function position must deliver something with AProcedure? + // or DClosure, but we'll get to that. + + log.retroactively_enable(); + log("expected procedure in function position -> terminate"); + + assert(false); + } + } else { + DArray * args = apply_frame->args(); + + log && log(xtag("i_arg", i_arg), xtag("n_arg", args->size()), xtag("cap", args->capacity())); + + args->push_back(value); + + i_arg = evalargs_frame->increment_arg(); + + if (i_arg == static_cast(apply_expr->n_args())) { + // all apply-arguments have been evaluated + // -> done with VsmEvalArgsFrame + // + + this->fn_ = apply_frame->fn(); + this->args_ = apply_frame->args(); + + this->stack_ = apply_frame->parent(); + this->pc_ = VsmInstr::c_apply; + this->cont_ = apply_frame->cont(); + + return; + + } else { + this->expr_ = apply_expr->arg(i_arg); + this->pc_ = VsmInstr::c_eval; + //this->cont_ = VsmInstra::c_evalargs; // redundant, since preserved + + return; + } + } + // not implemented assert(false); } diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 59104860..32cf7cab 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -166,10 +166,10 @@ namespace xo { log && log(xtag("res.tseq", res.value()->_typeseq())); - auto x = obj::from(*res.value()); + auto x = obj::from(*res.value()); REQUIRE(x); - REQUIRE(x.data()->value() == 1011); + REQUIRE(x.data()->value() == 1.570796325); REQUIRE(res.remaining_.size() == 1); REQUIRE(*res.remaining_.lo() == '\n'); From cbca2b7c6b8b64b783b5d0ce49377ea46b331a73 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Feb 2026 19:17:07 -0500 Subject: [PATCH 021/131] xo-interpreter2 stack: scaffold DClosure, DLocalEnv [WIP] --- include/xo/interpreter2/DClosure.hpp | 49 ++++++++++++ include/xo/interpreter2/DLocalEnv.hpp | 67 ++++++++++++++++ include/xo/interpreter2/DVsmApplyFrame.hpp | 1 + include/xo/interpreter2/LocalEnv.hpp | 12 +++ src/interpreter2/CMakeLists.txt | 4 + src/interpreter2/DClosure.cpp | 29 +++++++ src/interpreter2/DLocalEnv.cpp | 92 ++++++++++++++++++++++ 7 files changed, 254 insertions(+) create mode 100644 include/xo/interpreter2/DClosure.hpp create mode 100644 include/xo/interpreter2/DLocalEnv.hpp create mode 100644 include/xo/interpreter2/LocalEnv.hpp create mode 100644 src/interpreter2/DClosure.cpp create mode 100644 src/interpreter2/DLocalEnv.cpp diff --git a/include/xo/interpreter2/DClosure.hpp b/include/xo/interpreter2/DClosure.hpp new file mode 100644 index 00000000..09966038 --- /dev/null +++ b/include/xo/interpreter2/DClosure.hpp @@ -0,0 +1,49 @@ +/** @file DClosure.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "LocalEnv.hpp" +#include + +namespace xo { + namespace scm { + + /** @brief runtime representation for a procedure + * + * Maintains lambda + captured lexical context + **/ + class DClosure { + public: + using AAllocator = xo::mm::AAllocator; + using size_type = std::int32_t; + + public: + DClosure(const DLambdaExpr * lm, + const DLocalEnv * env); + + /** create instance using memory from @p mm + * for lambda @p lm with captured environment @p env. + **/ + static DClosure * make(obj mm, + const DLambdaExpr * lm, + const DLocalEnv * env); + + /** for now, support just fixed-arity procedures **/ + bool is_nary() const noexcept { return false; } + /** number of arguments expected by this procedure (-1 if nary) **/ + size_type n_args() const noexcept { return lambda_->n_args(); } + + private: + /** lambda expression **/ + const DLambdaExpr * lambda_ = nullptr; + /** bindings for captured variables + * (from lexical context where lambda evaluated) + **/ + const DLocalEnv * env_ = nullptr; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DClosure.hpp */ diff --git a/include/xo/interpreter2/DLocalEnv.hpp b/include/xo/interpreter2/DLocalEnv.hpp new file mode 100644 index 00000000..fec8148d --- /dev/null +++ b/include/xo/interpreter2/DLocalEnv.hpp @@ -0,0 +1,67 @@ +/** @file DLocalEnv.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include +#include + +namespace xo { + namespace scm { + + /** @brief bindings for arguments to a lambda + **/ + class DLocalEnv { + public: + using DArray = xo::scm::DArray; + using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; + using ppindentinfo = xo::print::ppindentinfo; + using size_type = std::uint32_t; + + public: + /** @defgroup scm-localenv-constructors constructors **/ + ///@{ + + /** empty instance with parent @p p for variables in @p symtab **/ + DLocalEnv(DLocalEnv * parent, + DLocalSymtab * symtab, + DArray * args); + + static DLocalEnv * _make_empty(obj mm, + DLocalEnv * parent, + DLocalSymtab * symtab, + DArray * args); + + ///@} + /** @defgroup scm-local-env-methods methods **/ + ///@{ + + DLocalEnv * parent() const noexcept { return parent_; } + size_type size() const noexcept { return symtab_->size(); } + + /** lookup current value associated with binding @p ix **/ + obj lookup_value(Binding ix) const noexcept; + + /** assign value associated with binding @p ix to @p x **/ + void assign_value(Binding ix, obj x); + + ///@} + + private: + /** parent environment (from closure) **/ + DLocalEnv * parent_ = nullptr; + /** bind values for variables in this symbol table **/ + DLocalSymtab * symtab_ = nullptr; + /** bindings. + * (*args)[i] associates a value with symtab->slots_[i] + **/ + DArray * args_ = nullptr;; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DLocalEnv.hpp */ diff --git a/include/xo/interpreter2/DVsmApplyFrame.hpp b/include/xo/interpreter2/DVsmApplyFrame.hpp index c898c602..72900eb2 100644 --- a/include/xo/interpreter2/DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyFrame.hpp @@ -21,6 +21,7 @@ namespace xo { VsmInstr old_cont, DArray * args); + /** create instance using memory from @p mm **/ static DVsmApplyFrame * make(obj mm, obj old_parent, VsmInstr old_cont, diff --git a/include/xo/interpreter2/LocalEnv.hpp b/include/xo/interpreter2/LocalEnv.hpp new file mode 100644 index 00000000..8976452f --- /dev/null +++ b/include/xo/interpreter2/LocalEnv.hpp @@ -0,0 +1,12 @@ +/** @file LocalEnv.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DLocalEnv.hpp" +//#include "detail/IGCObject_DLocalEnv.hpp" +//#include "detail/IPrintable_DLocalEnv.hpp" + +/* end LocalEnv.hpp */ diff --git a/src/interpreter2/CMakeLists.txt b/src/interpreter2/CMakeLists.txt index 635ecff3..e0903be8 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -17,6 +17,10 @@ set(SELF_SRCS IPrintable_DVsmApplyFrame.cpp VsmInstr.cpp + + DClosure.cpp + DLocalEnv.cpp + #IExpression_Any.cpp ) diff --git a/src/interpreter2/DClosure.cpp b/src/interpreter2/DClosure.cpp new file mode 100644 index 00000000..6d9bc446 --- /dev/null +++ b/src/interpreter2/DClosure.cpp @@ -0,0 +1,29 @@ +/** @file DClosure.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DClosure.hpp" + +namespace xo { + namespace scm { + + DClosure::DClosure(const DLambdaExpr * lm, + const DLocalEnv * env) + : lambda_{lm}, env_{env} + {} + + DClosure * + DClosure::make(obj mm, + const DLambdaExpr * lm, + const DLocalEnv * env) + { + void * mem = mm.alloc_for(); + + return new (mem) DClosure(lm, env); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DClosure.cpp */ diff --git a/src/interpreter2/DLocalEnv.cpp b/src/interpreter2/DLocalEnv.cpp new file mode 100644 index 00000000..3aba3aa8 --- /dev/null +++ b/src/interpreter2/DLocalEnv.cpp @@ -0,0 +1,92 @@ +/** @file DLocalEnv.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DLocalEnv.hpp" +#include + +namespace xo { + using xo::mm::AGCObject; + using xo::reflect::typeseq; + + namespace scm { + + DLocalEnv::DLocalEnv(DLocalEnv * parent, + DLocalSymtab * symtab, + DArray * args) + : parent_{parent}, + symtab_{symtab}, + args_{args} + {} + + DLocalEnv * + DLocalEnv::_make_empty(obj mm, + DLocalEnv * parent, + DLocalSymtab * symtab, + DArray * args) + { + assert(symtab); + + void * mem = mm.alloc_for(); + + return new (mem) DLocalEnv(parent, symtab, args); + } + + obj + DLocalEnv::lookup_value(Binding ix) const noexcept + { + assert(!ix.is_global()); + + const DLocalEnv * env = this; + + for (auto i = ix.i_link(); i > 0; --i) { + env = env->parent(); + } + + if (env) { + auto j = ix.j_slot(); + + if (j < static_cast(env->size())) { + return (*(env->args_))[j]; + } else { + assert(false); + } + } else { + assert(false); + } + + /* something terribly wrong if control here */ + return obj(); + } + + void + DLocalEnv::assign_value(Binding ix, obj x) + { + assert(!ix.is_global()); + + const DLocalEnv * env = this; + + for (auto i = ix.i_link(); i > 0; --i) { + env = env->parent(); + } + + if (env) { + auto j = ix.j_slot(); + + if (j < static_cast(env->size())) { + (*(env->args_))[j] = x; + } else { + assert(false); + } + } else { + assert(false); + } + + /* something terribly wrong if control here */ + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DLocalEnv.cpp */ From 73614c3ce4653c72acb6d1fcd8ba3ad8c5d8defd Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 5 Feb 2026 10:44:11 -0500 Subject: [PATCH 022/131] xo-interpreter2 stack: work on variable references [WIP] --- CMakeLists.txt | 14 ++++ idl/IProcedure_DClosure.json5 | 17 +++++ include/xo/interpreter2/Closure.hpp | 11 +++ include/xo/interpreter2/DClosure.hpp | 30 +++++++++ .../detail/IProcedure_DClosure.hpp | 67 +++++++++++++++++++ src/interpreter2/CMakeLists.txt | 2 + src/interpreter2/DClosure.cpp | 12 ++++ src/interpreter2/IProcedure_DClosure.cpp | 39 +++++++++++ .../interpreter2_register_facets.cpp | 9 +++ utest/VirtualSchematikaMachine.test.cpp | 37 ++++++++++ 10 files changed, 238 insertions(+) create mode 100644 idl/IProcedure_DClosure.json5 create mode 100644 include/xo/interpreter2/Closure.hpp create mode 100644 include/xo/interpreter2/detail/IProcedure_DClosure.hpp create mode 100644 src/interpreter2/IProcedure_DClosure.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 259c3f03..25d8cd0d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,20 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-procedure-closure + FACET_PKG xo_procedure2 + FACET Printable + REPR DClosure + INPUT idl/IProcedure_DClosure.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/IProcedure_DClosure.json5 b/idl/IProcedure_DClosure.json5 new file mode 100644 index 00000000..d503f5c6 --- /dev/null +++ b/idl/IProcedure_DClosure.json5 @@ -0,0 +1,17 @@ +{ + mode: "implementation", + includes: [ + "", + "", + "", + "", + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Procedure.json5", + brief: "provide AProcedure interface for DClosure", + using_doxygen: true, + repr: "DClosure", + doc: [ "implement AProcedure for DClosure" ], +} diff --git a/include/xo/interpreter2/Closure.hpp b/include/xo/interpreter2/Closure.hpp new file mode 100644 index 00000000..f352e7f0 --- /dev/null +++ b/include/xo/interpreter2/Closure.hpp @@ -0,0 +1,11 @@ +/** @file Closure.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DClosure.hpp" +#include "detail/IProcedure_DClosure.hpp" + +/* end Closure.hpp */ diff --git a/include/xo/interpreter2/DClosure.hpp b/include/xo/interpreter2/DClosure.hpp index 09966038..bcf85c97 100644 --- a/include/xo/interpreter2/DClosure.hpp +++ b/include/xo/interpreter2/DClosure.hpp @@ -3,8 +3,11 @@ * @author Roland Conybeare, Feb 2026 **/ +#pragma once + #include "LocalEnv.hpp" #include +#include namespace xo { namespace scm { @@ -15,7 +18,10 @@ namespace xo { **/ class DClosure { public: + using ARuntimeContext = xo::scm::ARuntimeContext; using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; + using ppindentinfo = xo::print::ppindentinfo; using size_type = std::int32_t; public: @@ -29,11 +35,35 @@ namespace xo { const DLambdaExpr * lm, const DLocalEnv * env); + /** @defgroup scm-closure-general-methods **/ + ///@{ + + const DLambdaExpr * lambda() const noexcept { return lambda_; } + const DLocalEnv * env() const noexcept { return env_; } + + ///@} + /** @defgroup scm-closure-procedure-facet **/ + ///@{ + /** for now, support just fixed-arity procedures **/ bool is_nary() const noexcept { return false; } /** number of arguments expected by this procedure (-1 if nary) **/ size_type n_args() const noexcept { return lambda_->n_args(); } + obj apply_nocheck(obj rcx, const DArray * args); + + ///@} + /** @defgroup scm-closure-gcobject-facet **/ + ///@{ + + ///@} + /** @defgroup scm-closure-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + private: /** lambda expression **/ const DLambdaExpr * lambda_ = nullptr; diff --git a/include/xo/interpreter2/detail/IProcedure_DClosure.hpp b/include/xo/interpreter2/detail/IProcedure_DClosure.hpp new file mode 100644 index 00000000..2c966a50 --- /dev/null +++ b/include/xo/interpreter2/detail/IProcedure_DClosure.hpp @@ -0,0 +1,67 @@ +/** @file IProcedure_DClosure.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IProcedure_DClosure.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IProcedure_DClosure.json5] + **/ + +#pragma once + +#include "Procedure.hpp" +#include +#include +#include +#include +#include "DClosure.hpp" + +namespace xo { namespace scm { class IProcedure_DClosure; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IProcedure_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IProcedure_DClosure + **/ + class IProcedure_DClosure { + public: + /** @defgroup scm-procedure-dclosure-type-traits **/ + ///@{ + using AGCObject = xo::scm::AProcedure::AGCObject; + using Copaque = xo::scm::AProcedure::Copaque; + using Opaque = xo::scm::AProcedure::Opaque; + ///@} + /** @defgroup scm-procedure-dclosure-methods **/ + ///@{ + // const methods + /** true iff procedure takes n arguments **/ + static bool is_nary(const DClosure & self) noexcept; + /** number of arguments. -1 for n-ary **/ + static std::int32_t n_args(const DClosure & self) noexcept; + + // non-const methods + /** invoke procedure; assume arguments satisfy type system **/ + static obj apply_nocheck(DClosure & self, obj rcx, const DArray * args); + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/interpreter2/CMakeLists.txt b/src/interpreter2/CMakeLists.txt index e0903be8..b47ea31d 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -16,6 +16,8 @@ set(SELF_SRCS IGCObject_DVsmApplyFrame.cpp IPrintable_DVsmApplyFrame.cpp + IProcedure_DClosure.cpp + VsmInstr.cpp DClosure.cpp diff --git a/src/interpreter2/DClosure.cpp b/src/interpreter2/DClosure.cpp index 6d9bc446..1057a25d 100644 --- a/src/interpreter2/DClosure.cpp +++ b/src/interpreter2/DClosure.cpp @@ -6,6 +6,8 @@ #include "DClosure.hpp" namespace xo { + using xo::mm::AGCObject; + namespace scm { DClosure::DClosure(const DLambdaExpr * lm, @@ -23,6 +25,16 @@ namespace xo { return new (mem) DClosure(lm, env); } + obj + DClosure::apply_nocheck(obj rcx, + const DArray * args) + { + (void)rcx; + (void)args; + + assert(false); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/IProcedure_DClosure.cpp b/src/interpreter2/IProcedure_DClosure.cpp new file mode 100644 index 00000000..b41c7be1 --- /dev/null +++ b/src/interpreter2/IProcedure_DClosure.cpp @@ -0,0 +1,39 @@ +/** @file IProcedure_DClosure.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IProcedure_DClosure.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IProcedure_DClosure.json5] +**/ + +#include "detail/IProcedure_DClosure.hpp" + +namespace xo { + namespace scm { + auto + IProcedure_DClosure::is_nary(const DClosure & self) noexcept -> bool + { + return self.is_nary(); + } + + auto + IProcedure_DClosure::n_args(const DClosure & self) noexcept -> std::int32_t + { + return self.n_args(); + } + + auto + IProcedure_DClosure::apply_nocheck(DClosure & self, obj rcx, const DArray * args) -> obj + { + return self.apply_nocheck(rcx, args); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IProcedure_DClosure.cpp */ diff --git a/src/interpreter2/interpreter2_register_facets.cpp b/src/interpreter2/interpreter2_register_facets.cpp index b16d33ef..820dac2c 100644 --- a/src/interpreter2/interpreter2_register_facets.cpp +++ b/src/interpreter2/interpreter2_register_facets.cpp @@ -8,6 +8,8 @@ #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" +#include "Closure.hpp" + #include #include #include @@ -36,8 +38,15 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + // Procedure + // +- Primitive_gco_2_gco_gco + // \- Closure + + FacetRegistry::register_impl(); + log && log(xtag("DVsmApplyFrame.tseq", typeseq::id())); log && log(xtag("DVsmEvalArgsFrame.tseq", typeseq::id())); + log && log(xtag("DClosure.tseq", typeseq::id())); return true; } diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 32cf7cab..90805af7 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -186,6 +186,43 @@ namespace xo { vsm.visit_pools(visitor); } + TEST_CASE("VirtualSchematikaMachine-lambda1", "[interpreter2][VSM]") + { + scope log(XO_DEBUG(true)); + + VsmConfig cfg; + VirtualSchematikaMachine vsm(cfg); + + bool eof_flag = false; + + vsm.begin_interactive_session(); + VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("lambda (x : i64) -> i64 { x * x; };"), eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq())); + + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(x.data()->value() == 1.570796325); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + + auto visitor = [&log](const MemorySizeInfo & info) { + log && log(xtag("resource", info.resource_name_), + xtag("used", info.used_), + xtag("alloc", info.allocated_), + xtag("commit", info.committed_), + xtag("resv", info.reserved_)); + }; + + FacetRegistry::instance().visit_pools(visitor); + vsm.visit_pools(visitor); + } + } /*namespace ut*/ } /*namespace xo*/ From dbf251be6fd344a9ae5d62910bd2b3b4833def0d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 5 Feb 2026 15:45:40 -0500 Subject: [PATCH 023/131] xo-reader2 stack: top-level lambda w/ apply parses --- include/xo/interpreter2/VirtualSchematikaMachine.hpp | 8 +++++++- src/interpreter2/VirtualSchematikaMachine.cpp | 10 ++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 774659eb..d06deb26 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -120,12 +120,18 @@ namespace xo { **/ void _do_eval_lambda_op(); - /** evaluate a variable expression + /** evaluate variable expression (definition) * Require: * - expression in @ref expr_ **/ void _do_eval_variable_op(); + /** evaluate a variable reference (use after definition) + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_varref_op(); + /** evaluate an apply expression * Require: * - expression in @ref expr_ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index b32f6b24..1395209a 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -167,6 +167,9 @@ namespace xo { case exprtype::variable: _do_eval_variable_op(); break; + case exprtype::varref: + _do_eval_varref_op(); + break; case exprtype::apply: _do_eval_apply_op(); break; @@ -210,6 +213,13 @@ namespace xo { assert(false); } + void + VirtualSchematikaMachine::_do_eval_varref_op() + { + // not implemented + assert(false); + } + void VirtualSchematikaMachine::_do_eval_apply_op() { From 3221eef2f8f45224bb90428590637924d948657d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 7 Feb 2026 23:14:48 -0500 Subject: [PATCH 024/131] xo-interpreter: vsm work on environments [WIP] --- include/xo/interpreter2/DGlobalEnv.hpp | 29 +++++++++++++++++++ include/xo/interpreter2/DLocalEnv.hpp | 2 +- include/xo/interpreter2/DVsmRcx.hpp | 2 ++ .../interpreter2/VirtualSchematikaMachine.hpp | 13 +++++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 28 +++++++++++++++++- 5 files changed, 72 insertions(+), 2 deletions(-) create mode 100644 include/xo/interpreter2/DGlobalEnv.hpp create mode 100644 include/xo/interpreter2/DVsmRcx.hpp diff --git a/include/xo/interpreter2/DGlobalEnv.hpp b/include/xo/interpreter2/DGlobalEnv.hpp new file mode 100644 index 00000000..d0ab0827 --- /dev/null +++ b/include/xo/interpreter2/DGlobalEnv.hpp @@ -0,0 +1,29 @@ +/** @file DGlobalEnv.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include +#include + +namespace xo { + namespace scm { + + + /** @brief runtime bindings for global variabels + **/ + class DGlobalEnv { + public: + DGLobalEnv() = default; + + private: + // absurd O(n) implementation for now + // replace with gc-aware hashtable, when available. + + /** globals. Slots in @ref global_v_ are numbered in DLocalSymtab **/ + DArray * global_v_ = nullptr; + }; + } +} diff --git a/include/xo/interpreter2/DLocalEnv.hpp b/include/xo/interpreter2/DLocalEnv.hpp index fec8148d..0291c748 100644 --- a/include/xo/interpreter2/DLocalEnv.hpp +++ b/include/xo/interpreter2/DLocalEnv.hpp @@ -11,7 +11,7 @@ namespace xo { namespace scm { - /** @brief bindings for arguments to a lambda + /** @brief runtime bindings for arguments to a lambda **/ class DLocalEnv { public: diff --git a/include/xo/interpreter2/DVsmRcx.hpp b/include/xo/interpreter2/DVsmRcx.hpp new file mode 100644 index 00000000..3506206e --- /dev/null +++ b/include/xo/interpreter2/DVsmRcx.hpp @@ -0,0 +1,2 @@ +/** @file DVsmRcx.hpp +n* diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index d06deb26..7a209bf1 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -194,6 +194,9 @@ namespace xo { // for VM stack. Only works for code that doesn't rely on fancy // lexical scoping + // consider separate allocator for reader (i.e. program code) + // and data (program execution) + /** reader: text -> expression **/ SchematikaReader reader_; @@ -206,6 +209,16 @@ namespace xo { /** expression register **/ obj expr_; + /** environment pointer. Provides bindings + * for surrounding lexical scope at this point + * in execution + **/ + DLocalEnv * local_env_ = nullptr; + /** environment pointer. Maintains bindings + * for global variables. + **/ + DGlobalEnv * global_env_ = nullptr; + /** function to call **/ obj fn_; /** evaluated argument list **/ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 1395209a..767ef784 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -36,7 +36,9 @@ namespace xo { mm_(box(new DX1Collector(config.x1_config_))), rcx_(box(new DSimpleRcx(mm_.to_op()))), reader_{config.rdr_config_, mm_.to_op()} - {} + { + // TODO: allocate global_env + } void VirtualSchematikaMachine::visit_pools(const MemorySizeVisitor & visitor) const @@ -202,6 +204,30 @@ namespace xo { void VirtualSchematikaMachine::_do_eval_lambda_op() { + // assuming bump allocator + // + // +----------- DArray---------+ +-------------DLocalEnv-----------+ +-----DClosure-------+ + // | .cap |.size | .elts_[]... |h| .parent x | .symtab x | .args x |h| .lambda x | .env x | + // +------+------+-------------+ +---------|-+---------|-+-------|-+ +---------|-+------|-+ + // ^ ^ | | | | | + // \-----------------------------|---------|-----------|---------/ | | + // | | | | | + // \---------|-----------|-----------------------|--------/ + // | | | + // <--------------------------------------/ | | + // | | + // v v + // DLocalSymtab DLambdaExpr + // + // DClosure runtime procedure (created below) + // DArray bound non-local variables (established by VSM) + // DLocalEnv local environment (copy ref from VSM state) + // h alloc header + // DLocalSymtab local symbol table (created by parser) + // DLambdaExpr lambda expression (created by parser) + + DArray * args = + // not implemented assert(false); } From 82c82ea33244661d34e75ffb69202f8c8263452c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 8 Feb 2026 01:01:03 -0500 Subject: [PATCH 025/131] 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 From e219ea0db3e73f5126ee3192cb71eaace4481b8c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 8 Feb 2026 23:32:20 -0500 Subject: [PATCH 026/131] xo-interpreter2 stack: lambda expr -> closure runs in VSM utest --- CMakeLists.txt | 12 ++++ idl/IPrintable_DLocalEnv.json5 | 13 ++++ include/xo/interpreter2/DLocalEnv.hpp | 6 ++ include/xo/interpreter2/LocalEnv.hpp | 2 +- .../interpreter2/VirtualSchematikaMachine.hpp | 1 + .../detail/IPrintable_DLocalEnv.hpp | 62 +++++++++++++++++++ src/interpreter2/CMakeLists.txt | 4 +- src/interpreter2/DClosure.cpp | 19 ++++++ src/interpreter2/DLocalEnv.cpp | 16 +++++ src/interpreter2/IPrintable_DLocalEnv.cpp | 28 +++++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 7 +-- .../interpreter2_register_facets.cpp | 6 ++ utest/VirtualSchematikaMachine.test.cpp | 16 ++--- 13 files changed, 179 insertions(+), 13 deletions(-) create mode 100644 idl/IPrintable_DLocalEnv.json5 create mode 100644 include/xo/interpreter2/detail/IPrintable_DLocalEnv.hpp create mode 100644 src/interpreter2/IPrintable_DLocalEnv.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index b0b3c63a..7bda6388 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,6 +127,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/interpreter2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-printable-localenv + FACET_PKG xo_printable2 + FACET Printable + REPR LocalEnv + INPUT idl/IPrintable_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/IPrintable_DLocalEnv.json5 b/idl/IPrintable_DLocalEnv.json5 new file mode 100644 index 00000000..0302834d --- /dev/null +++ b/idl/IPrintable_DLocalEnv.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DLocalEnv", + using_doxygen: true, + repr: "DLocalEnv", + doc: [ "implement APrintable for DLocalEnv" ], +} diff --git a/include/xo/interpreter2/DLocalEnv.hpp b/include/xo/interpreter2/DLocalEnv.hpp index 5563fb3a..234db71f 100644 --- a/include/xo/interpreter2/DLocalEnv.hpp +++ b/include/xo/interpreter2/DLocalEnv.hpp @@ -58,6 +58,12 @@ namespace xo { std::size_t forward_children(obj gc) noexcept; ///@} + /** @defgroup scm-localenv-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const noexcept; + + ///@} private: /** parent environment (from closure) **/ diff --git a/include/xo/interpreter2/LocalEnv.hpp b/include/xo/interpreter2/LocalEnv.hpp index a709e006..8955e35d 100644 --- a/include/xo/interpreter2/LocalEnv.hpp +++ b/include/xo/interpreter2/LocalEnv.hpp @@ -7,6 +7,6 @@ #include "DLocalEnv.hpp" #include "detail/IGCObject_DLocalEnv.hpp" -//#include "detail/IPrintable_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 1aebed2c..f28c5bef 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -216,6 +216,7 @@ namespace xo { * in execution **/ DLocalEnv * local_env_ = nullptr; + protected: // temporarily, to appease compiler /** environment pointer. Maintains bindings * for global variables. diff --git a/include/xo/interpreter2/detail/IPrintable_DLocalEnv.hpp b/include/xo/interpreter2/detail/IPrintable_DLocalEnv.hpp new file mode 100644 index 00000000..c0ddb7f8 --- /dev/null +++ b/include/xo/interpreter2/detail/IPrintable_DLocalEnv.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DLocalEnv.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DLocalEnv.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DLocalEnv.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DLocalEnv.hpp" + +namespace xo { namespace scm { class IPrintable_DLocalEnv; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DLocalEnv + **/ + class IPrintable_DLocalEnv { + public: + /** @defgroup scm-printable-dlocalenv-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dlocalenv-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DLocalEnv & 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 e7493775..373f6138 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -17,10 +17,12 @@ set(SELF_SRCS IPrintable_DVsmApplyFrame.cpp DClosure.cpp - IGCObject_DClosure.cpp IProcedure_DClosure.cpp + IGCObject_DClosure.cpp + IPrintable_DClosure.cpp IGCObject_DLocalEnv.cpp + IPrintable_DLocalEnv.cpp DLocalEnv.cpp VsmInstr.cpp diff --git a/src/interpreter2/DClosure.cpp b/src/interpreter2/DClosure.cpp index b1868950..d1baa172 100644 --- a/src/interpreter2/DClosure.cpp +++ b/src/interpreter2/DClosure.cpp @@ -10,6 +10,7 @@ namespace xo { using xo::mm::AGCObject; + using xo::print::APrintable; namespace scm { @@ -69,6 +70,24 @@ namespace xo { return shallow_size(); } + // ----- printable facet ----- + + bool + DClosure::pretty(const ppindentinfo & ppii) const + { + obj lambda_pr(const_cast(lambda_)); + obj env_pr(const_cast(env_)); + + bool lambda_present = lambda_pr; + bool env_present = env_pr; + + return ppii.pps()->pretty_struct + (ppii, + "DClosure", + refrtag("lambda", lambda_pr, lambda_present), + refrtag("env", env_pr, env_present)); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/DLocalEnv.cpp b/src/interpreter2/DLocalEnv.cpp index 9ba65085..9ee0911a 100644 --- a/src/interpreter2/DLocalEnv.cpp +++ b/src/interpreter2/DLocalEnv.cpp @@ -121,6 +121,22 @@ namespace xo { return shallow_size(); } + // ----- printable facet ----- + + bool + DLocalEnv::pretty(const ppindentinfo & ppii) const noexcept + { + // print local bindings, perhaps + // symtab_ + // args_ + + return ppii.pps()->pretty_struct + (ppii, + "DLocalEnv", + refrtag("n_args", args_->size()) + ); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/IPrintable_DLocalEnv.cpp b/src/interpreter2/IPrintable_DLocalEnv.cpp new file mode 100644 index 00000000..bf701cb6 --- /dev/null +++ b/src/interpreter2/IPrintable_DLocalEnv.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DLocalEnv.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DLocalEnv.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DLocalEnv.json5] +**/ + +#include "detail/IPrintable_DLocalEnv.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DLocalEnv::pretty(const DLocalEnv & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DLocalEnv.cpp */ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index bfd5e09f..c62a723f 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -241,10 +241,9 @@ namespace xo { lambda.data(), local_env_); - this->value_ = obj(obj(closure)); - - // not implemented - assert(false); + this->value_ + = obj(obj(closure)); + this->pc_ = this->cont_; } void diff --git a/src/interpreter2/interpreter2_register_facets.cpp b/src/interpreter2/interpreter2_register_facets.cpp index 1953bf1d..22757a48 100644 --- a/src/interpreter2/interpreter2_register_facets.cpp +++ b/src/interpreter2/interpreter2_register_facets.cpp @@ -8,6 +8,7 @@ #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" #include "Closure.hpp" +#include "LocalEnv.hpp" #include #include @@ -37,9 +38,13 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + // Procedure // +- Primitive_gco_2_gco_gco // \- Closure @@ -49,6 +54,7 @@ namespace xo { log && log(xtag("DVsmApplyFrame.tseq", typeseq::id())); log && log(xtag("DVsmEvalArgsFrame.tseq", typeseq::id())); log && log(xtag("DClosure.tseq", typeseq::id())); + log && log(xtag("DLocalEnv.tseq", typeseq::id())); return true; } diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 90805af7..ee4ca351 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -4,10 +4,11 @@ **/ #include -#include -#include -#include -#include +#include +#include +//#include +#include +//#include #ifdef NOT_YET #include @@ -28,6 +29,7 @@ namespace xo { using xo::scm::VirtualSchematikaMachine; using xo::scm::VsmConfig; using xo::scm::VsmResultExt; + using xo::scm::DClosure; using xo::scm::DFloat; using xo::scm::DInteger; using xo::mm::AGCObject; @@ -196,17 +198,17 @@ namespace xo { bool eof_flag = false; vsm.begin_interactive_session(); - VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("lambda (x : i64) -> i64 { x * x; };"), eof_flag); + VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("lambda (x : i64) -> i64 { x * x; }"), eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); log && log(xtag("res.tseq", res.value()->_typeseq())); - auto x = obj::from(*res.value()); + auto x = obj::from(*res.value()); REQUIRE(x); - REQUIRE(x.data()->value() == 1.570796325); + //REQUIRE(x.data()->value() == 1.570796325); REQUIRE(res.remaining_.size() == 1); REQUIRE(*res.remaining_.lo() == '\n'); From 5e1eef3fc761352d2cadb3dd8aba3567197bdbeb Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 12 Feb 2026 16:05:22 -0500 Subject: [PATCH 027/131] xo-interpreter2: + DVsmRcx. runtime context for vsm --- include/xo/interpreter2/DVsmRcx.hpp | 36 +++++++++++++++- .../interpreter2/VirtualSchematikaMachine.hpp | 3 ++ src/interpreter2/CMakeLists.txt | 5 +-- src/interpreter2/DVsmRcx.cpp | 25 +++++++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 7 ++++ utest/VirtualSchematikaMachine.test.cpp | 41 +++++++++++++++++++ 6 files changed, 113 insertions(+), 4 deletions(-) create mode 100644 src/interpreter2/DVsmRcx.cpp diff --git a/include/xo/interpreter2/DVsmRcx.hpp b/include/xo/interpreter2/DVsmRcx.hpp index 3506206e..3d6632a3 100644 --- a/include/xo/interpreter2/DVsmRcx.hpp +++ b/include/xo/interpreter2/DVsmRcx.hpp @@ -1,2 +1,36 @@ /** @file DVsmRcx.hpp -n* + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + // see xo-interpreter/ VirtualSchematikaMachine.hpp + class VirtualSchematikaMachine; + + /** @brief Runtime context for schematika interpreter + * + * Provides allocator + **/ + class DVsmRcx { + public: + using AAllocator = xo::mm::AAllocator; + + public: + DVsmRcx(VirtualSchematikaMachine * vsm); + + obj allocator() const noexcept; + + private: + /** schematika interpreter **/ + VirtualSchematikaMachine * vsm_ = nullptr;; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmRcx.hpp */ + diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index f28c5bef..af551d04 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -70,6 +70,9 @@ namespace xo { public: VirtualSchematikaMachine(const VsmConfig & config); + /** allocator for schematika data **/ + obj allocator() const noexcept; + /** visit vsm-owned memory pools; call visitor(info) for each **/ void visit_pools(const MemorySizeVisitor & visitor) const; diff --git a/src/interpreter2/CMakeLists.txt b/src/interpreter2/CMakeLists.txt index 373f6138..b02a4a7a 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -25,10 +25,9 @@ set(SELF_SRCS IPrintable_DLocalEnv.cpp DLocalEnv.cpp + DVsmRcx.cpp + VsmInstr.cpp - - - #IExpression_Any.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) diff --git a/src/interpreter2/DVsmRcx.cpp b/src/interpreter2/DVsmRcx.cpp new file mode 100644 index 00000000..92e153bc --- /dev/null +++ b/src/interpreter2/DVsmRcx.cpp @@ -0,0 +1,25 @@ +/** @file DVsmRcx.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DVsmRcx.hpp" +#include "VirtualSchematikaMachine.hpp" + +namespace xo { + using xo::mm::AAllocator; + + namespace scm { + + DVsmRcx::DVsmRcx(VirtualSchematikaMachine * vsm) : vsm_{vsm} {} + + obj + DVsmRcx::allocator() const noexcept + { + return vsm_->allocator(); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmRcx.cpp */ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index c62a723f..2b07791f 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -24,6 +24,7 @@ namespace xo { using xo::print::ppstate_standalone; using xo::mm::AGCObject; //using xo::mm::MemorySizeInfo; // not used yet + using xo::mm::AAllocator; using xo::mm::DX1Collector; using xo::facet::FacetRegistry; using std::cout; @@ -42,6 +43,12 @@ namespace xo { // TODO: allocate global_env } + obj + VirtualSchematikaMachine::allocator() const noexcept + { + return mm_.to_op(); + } + void VirtualSchematikaMachine::visit_pools(const MemorySizeVisitor & visitor) const { diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index ee4ca351..4213764b 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -225,6 +225,47 @@ namespace xo { vsm.visit_pools(visitor); } +#ifdef NOT_YET + TEST_CASE("VirtualSchematikaMachine-apply2", "[interpreter2][VSM]") + { + scope log(XO_DEBUG(true)); + + VsmConfig cfg; + VirtualSchematikaMachine vsm(cfg); + + bool eof_flag = false; + + vsm.begin_interactive_session(); + VsmResultExt res + = vsm.read_eval_print(span_type::from_cstr + ("(lambda (x : i64, y : i64) { x * y; })(13, 15);"), + eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq())); + + auto x = obj::from(*res.value()); + + REQUIRE(x); + //REQUIRE(x.data()->value() == 1.570796325); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + + auto visitor = [&log](const MemorySizeInfo & info) { + log && log(xtag("resource", info.resource_name_), + xtag("used", info.used_), + xtag("alloc", info.allocated_), + xtag("commit", info.committed_), + xtag("resv", info.reserved_)); + }; + + FacetRegistry::instance().visit_pools(visitor); + vsm.visit_pools(visitor); + } +#endif } /*namespace ut*/ } /*namespace xo*/ From 01df73b3714641749d486808bcf08a5ef28ac3b2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 12 Feb 2026 16:16:49 -0500 Subject: [PATCH 028/131] xo-interpreter2: vsm uses VsmRcx for runtime context --- CMakeLists.txt | 13 ++++ idl/IRuntimeContext_DVsmRcx.json5 | 15 +++++ include/xo/interpreter2/VsmRcx.hpp | 11 ++++ .../detail/IRuntimeContext_DVsmRcx.hpp | 59 +++++++++++++++++++ src/interpreter2/CMakeLists.txt | 1 + src/interpreter2/IRuntimeContext_DVsmRcx.cpp | 28 +++++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 9 +-- .../interpreter2_register_facets.cpp | 7 +++ 8 files changed, 139 insertions(+), 4 deletions(-) create mode 100644 idl/IRuntimeContext_DVsmRcx.json5 create mode 100644 include/xo/interpreter2/VsmRcx.hpp create mode 100644 include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp create mode 100644 src/interpreter2/IRuntimeContext_DVsmRcx.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7bda6388..6f3b14bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -141,6 +141,19 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-runtimecontext-vsmrcx + FACET_PKG xo_procedure2 + FACET RuntimeContext + REPR DVsmRcx + INPUT idl/IRuntimeContext_DVsmRcx.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/IRuntimeContext_DVsmRcx.json5 b/idl/IRuntimeContext_DVsmRcx.json5 new file mode 100644 index 00000000..8659eb66 --- /dev/null +++ b/idl/IRuntimeContext_DVsmRcx.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + //"", + //"", + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/RuntimeContext.json5", + brief: "provide ARuntimeContext interface for DVsmRcx", + using_doxygen: true, + repr: "DVsmRcx", + doc: [ "implement ARuntimeContext for DVsmRcx" ], +} diff --git a/include/xo/interpreter2/VsmRcx.hpp b/include/xo/interpreter2/VsmRcx.hpp new file mode 100644 index 00000000..c0f015eb --- /dev/null +++ b/include/xo/interpreter2/VsmRcx.hpp @@ -0,0 +1,11 @@ +/** @file VsmRcx.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DVsmRcx.hpp" +#include "detail/IRuntimeContext_DVsmRcx.hpp" + +/* end VsmRcx.hpp */ diff --git a/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp b/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp new file mode 100644 index 00000000..ecb81f1f --- /dev/null +++ b/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp @@ -0,0 +1,59 @@ +/** @file IRuntimeContext_DVsmRcx.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IRuntimeContext_DVsmRcx.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IRuntimeContext_DVsmRcx.json5] + **/ + +#pragma once + +#include "RuntimeContext.hpp" +#include "DVsmRcx.hpp" + +namespace xo { namespace scm { class IRuntimeContext_DVsmRcx; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IRuntimeContext_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IRuntimeContext_DVsmRcx + **/ + class IRuntimeContext_DVsmRcx { + public: + /** @defgroup scm-runtimecontext-dvsmrcx-type-traits **/ + ///@{ + using AAllocator = xo::scm::ARuntimeContext::AAllocator; + using Copaque = xo::scm::ARuntimeContext::Copaque; + using Opaque = xo::scm::ARuntimeContext::Opaque; + ///@} + /** @defgroup scm-runtimecontext-dvsmrcx-methods **/ + ///@{ + // const methods + /** default allocator to use for objects **/ + static obj allocator(const DVsmRcx & self) noexcept; + + // 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 b02a4a7a..f6fbd10b 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -26,6 +26,7 @@ set(SELF_SRCS DLocalEnv.cpp DVsmRcx.cpp + IRuntimeContext_DVsmRcx.cpp VsmInstr.cpp ) diff --git a/src/interpreter2/IRuntimeContext_DVsmRcx.cpp b/src/interpreter2/IRuntimeContext_DVsmRcx.cpp new file mode 100644 index 00000000..3fd3730d --- /dev/null +++ b/src/interpreter2/IRuntimeContext_DVsmRcx.cpp @@ -0,0 +1,28 @@ +/** @file IRuntimeContext_DVsmRcx.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IRuntimeContext_DVsmRcx.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IRuntimeContext_DVsmRcx.json5] +**/ + +#include "detail/IRuntimeContext_DVsmRcx.hpp" + +namespace xo { + namespace scm { + auto + IRuntimeContext_DVsmRcx::allocator(const DVsmRcx & self) noexcept -> obj + { + return self.allocator(); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IRuntimeContext_DVsmRcx.cpp */ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 2b07791f..1569ccc0 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -6,12 +6,13 @@ #include "VirtualSchematikaMachine.hpp" #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" +#include "VsmRcx.hpp" #include "Closure.hpp" #include #include #include #include -#include +//#include #include #include #include @@ -31,13 +32,13 @@ namespace xo { namespace scm { - // NOTE: using heap for {DX1Collector, DSimpleRcx} instances - // (though allocation from explictly mmap'd memory) + // NOTE: using heap here for {DX1Collector, DVsmRcx} instances + // (though DX1Collector allocations will be from explictly mmap'd memory) // VirtualSchematikaMachine::VirtualSchematikaMachine(const VsmConfig & config) : config_{config}, mm_(box(new DX1Collector(config.x1_config_))), - rcx_(box(new DSimpleRcx(mm_.to_op()))), + rcx_(box(new DVsmRcx(this))), reader_{config.rdr_config_, mm_.to_op()} { // TODO: allocate global_env diff --git a/src/interpreter2/interpreter2_register_facets.cpp b/src/interpreter2/interpreter2_register_facets.cpp index 22757a48..5d1467e5 100644 --- a/src/interpreter2/interpreter2_register_facets.cpp +++ b/src/interpreter2/interpreter2_register_facets.cpp @@ -9,6 +9,7 @@ #include "VsmEvalArgsFrame.hpp" #include "Closure.hpp" #include "LocalEnv.hpp" +#include "VsmRcx.hpp" #include #include @@ -51,10 +52,16 @@ namespace xo { FacetRegistry::register_impl(); + // RuntimeContext + // \- VsmRcx + + FacetRegistry::register_impl(); + log && log(xtag("DVsmApplyFrame.tseq", typeseq::id())); log && log(xtag("DVsmEvalArgsFrame.tseq", typeseq::id())); log && log(xtag("DClosure.tseq", typeseq::id())); log && log(xtag("DLocalEnv.tseq", typeseq::id())); + log && log(xtag("DVsmRcx.tseq", typeseq::id())); return true; } From 497dc8a626f46f21d05ab0f3ac79ca5e7a2b924e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 12 Feb 2026 18:46:43 -0500 Subject: [PATCH 029/131] xo-interpreter2 stack: work on runtime error representation [WIP] --- .../interpreter2/VirtualSchematikaMachine.hpp | 26 ++++++++++--- include/xo/interpreter2/VsmConfig.hpp | 6 +++ src/interpreter2/DClosure.cpp | 27 ++++++++++++- src/interpreter2/VirtualSchematikaMachine.cpp | 38 ++++++++++++++++--- utest/VirtualSchematikaMachine.test.cpp | 2 - 5 files changed, 86 insertions(+), 13 deletions(-) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index af551d04..39421981 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -10,6 +10,7 @@ #include "VsmFrame.hpp" #include "DLocalEnv.hpp" #include "DGlobalEnv.hpp" +#include #include #include #include @@ -17,6 +18,10 @@ namespace xo { namespace scm { +#ifdef OBSOLETE // see DVsmError + // TODO: move error to collected space? + // or special arena? + // struct EvaluationError { /** source location (in vsm implementation) at which error identified **/ std::string_view src_function_; @@ -24,6 +29,7 @@ namespace xo { std::string_view error_description_; // TODO: info about location in schematika source }; +#endif /** similar to @ref xo::scm::ReaderResult **/ struct VsmResult { @@ -31,17 +37,17 @@ namespace xo { using span_type = xo::mm::span; VsmResult() = default; - VsmResult(obj value) : result_{value} {} - VsmResult(TokenizerError err) : result_{err} {} + explicit VsmResult(obj value) : result_{value} {} + explicit VsmResult(TokenizerError err) : result_{err} {} bool is_value() const { return std::holds_alternative>(result_); } bool is_tk_error() const { return std::holds_alternative(result_); } - bool is_eval_error() const { return std::holds_alternative(result_); } + bool is_eval_error() const; const obj * value() const { return std::get_if>(&result_); } /** result of evaluating first expression encountered in input **/ - std::variant, TokenizerError, EvaluationError> result_; + std::variant, TokenizerError> result_; }; /** vsm result + reamining span **/ @@ -72,6 +78,8 @@ namespace xo { /** allocator for schematika data **/ obj allocator() const noexcept; + /** allocator for runtime errors **/ + obj error_allocator() const noexcept; /** visit vsm-owned memory pools; call visitor(info) for each **/ void visit_pools(const MemorySizeVisitor & visitor) const; @@ -185,11 +193,19 @@ namespace xo { /** configuration **/ VsmConfig config_; - /** allocator (likely collector) for + /** allocator (likely DX1Collector or similar) for * expressions and values **/ box mm_; + /** Sidecar allocator for error reporting. + * Separate to mitigate interference with @ref mm_ + * (separate memory so we can for example report + * an out-of-memory error). + * Likely DArena or similar + **/ + box error_mm_; + /** runtime context for this vsm. * For example, provides allocator to primitives **/ diff --git a/include/xo/interpreter2/VsmConfig.hpp b/include/xo/interpreter2/VsmConfig.hpp index 9d13ab8e..63c4b365 100644 --- a/include/xo/interpreter2/VsmConfig.hpp +++ b/include/xo/interpreter2/VsmConfig.hpp @@ -7,6 +7,7 @@ #include #include +#include namespace xo { namespace scm { @@ -14,6 +15,7 @@ namespace xo { **/ struct VsmConfig { using X1CollectorConfig = xo::mm::X1CollectorConfig; + using ArenaConfig = xo::mm::ArenaConfig; VsmConfig() = default; @@ -26,6 +28,10 @@ namespace xo { * TODO: may want to make CollectorConfig polymorphic **/ X1CollectorConfig x1_config_ = X1CollectorConfig().with_size(4*1024*1024); + /** Configuration for error allocator + * TODO: may want to make ArenaConfig polymorphic + **/ + ArenaConfig error_config_ = ArenaConfig().with_size(64*1024); }; } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/DClosure.cpp b/src/interpreter2/DClosure.cpp index d1baa172..7fa3698c 100644 --- a/src/interpreter2/DClosure.cpp +++ b/src/interpreter2/DClosure.cpp @@ -6,6 +6,8 @@ #include "Closure.hpp" #include "LambdaExpr.hpp" #include "LocalEnv.hpp" +#include "VsmRcx.hpp" +#include #include namespace xo { @@ -33,7 +35,30 @@ namespace xo { DClosure::apply_nocheck(obj rcx, const DArray * args) { - (void)rcx; + scope log(XO_DEBUG(true)); + + auto vsm_rcx + = obj::from(rcx); + + log && log(xtag("vsm_rcx.data", (void*)vsm_rcx.data())); + + // let's try a not-implemented error + + // don't want to clutter Procedure facet, since it's + // lower-level than xo-interpreter2 + +#ifdef NOT_YET + // TODO: verify arguments against type signature. + // unless we have evidence that program is type correct + + int32_t n_args = this->n_args(); + + if (n_args != args->size()) { + // + } +#endif + + (void)args; assert(false); diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 1569ccc0..abdfb168 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -15,6 +15,7 @@ //#include #include #include +#include #include #include #include @@ -27,12 +28,25 @@ namespace xo { //using xo::mm::MemorySizeInfo; // not used yet using xo::mm::AAllocator; using xo::mm::DX1Collector; + using xo::mm::DArena; using xo::facet::FacetRegistry; using std::cout; namespace scm { - // NOTE: using heap here for {DX1Collector, DVsmRcx} instances + bool + VsmResult::is_eval_error() const + { + if (std::holds_alternative>(result_)) { + auto err = obj::from(*(this->value())); + + return err; + } else { + return false; + } + } + + // NOTE: using heap here for {DX1Collector, DArena, DVsmRcx} instances // (though DX1Collector allocations will be from explictly mmap'd memory) // VirtualSchematikaMachine::VirtualSchematikaMachine(const VsmConfig & config) @@ -41,6 +55,14 @@ namespace xo { rcx_(box(new DVsmRcx(this))), reader_{config.rdr_config_, mm_.to_op()} { + { + DArena * arena = new DArena(); + assert(arena); + *arena = DArena::map(config_.error_config_); + + error_mm_.adopt(obj(arena)); + } + // TODO: allocate global_env } @@ -50,6 +72,12 @@ namespace xo { return mm_.to_op(); } + obj + VirtualSchematikaMachine::error_allocator() const noexcept + { + return error_mm_.to_op(); + } + void VirtualSchematikaMachine::visit_pools(const MemorySizeVisitor & visitor) const { @@ -113,7 +141,7 @@ namespace xo { { this->pc_ = VsmInstr::c_eval; this->expr_ = expr; - this->value_ = obj(); + this->value_ = VsmResult(obj()); this->cont_ = VsmInstr::c_halt; this->run(); @@ -200,7 +228,7 @@ namespace xo { auto expr = obj::from(expr_); - this->value_ = expr.data()->value(); + this->value_ = VsmResult(expr.data()->value()); this->pc_ = this->cont_; } @@ -250,7 +278,7 @@ namespace xo { local_env_); this->value_ - = obj(obj(closure)); + = VsmResult(obj(obj(closure))); this->pc_ = this->cont_; } @@ -341,7 +369,7 @@ namespace xo { // TODO: check argument types - this->value_ = fn_.apply_nocheck(rcx_.to_op(), args_); + this->value_ = VsmResult(fn_.apply_nocheck(rcx_.to_op(), args_)); this->pc_ = cont_; return; diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 4213764b..5ccef226 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -225,7 +225,6 @@ namespace xo { vsm.visit_pools(visitor); } -#ifdef NOT_YET TEST_CASE("VirtualSchematikaMachine-apply2", "[interpreter2][VSM]") { scope log(XO_DEBUG(true)); @@ -265,7 +264,6 @@ namespace xo { FacetRegistry::instance().visit_pools(visitor); vsm.visit_pools(visitor); } -#endif } /*namespace ut*/ } /*namespace xo*/ From fd0e5613dd60978061a8a52e43a14dbd1bd4dd7d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 12 Feb 2026 20:09:22 -0500 Subject: [PATCH 030/131] xo-interpreter2 stack: work on apply for closures [WIP] --- include/xo/interpreter2/DLocalEnv.hpp | 10 +++--- include/xo/interpreter2/DVsmRcx.hpp | 1 + include/xo/interpreter2/VsmConfig.hpp | 2 +- src/interpreter2/DClosure.cpp | 36 +++++++++++-------- src/interpreter2/DLocalEnv.cpp | 8 ++--- src/interpreter2/DVsmRcx.cpp | 6 ++++ src/interpreter2/VirtualSchematikaMachine.cpp | 1 + utest/VirtualSchematikaMachine.test.cpp | 10 ++++-- 8 files changed, 47 insertions(+), 27 deletions(-) diff --git a/include/xo/interpreter2/DLocalEnv.hpp b/include/xo/interpreter2/DLocalEnv.hpp index 234db71f..c99aaad1 100644 --- a/include/xo/interpreter2/DLocalEnv.hpp +++ b/include/xo/interpreter2/DLocalEnv.hpp @@ -26,15 +26,15 @@ namespace xo { /** @defgroup scm-localenv-constructors constructors **/ ///@{ - /** empty instance with parent @p p for variables in @p symtab **/ + /** create instance with parent @p p for variables in @p symtab **/ DLocalEnv(DLocalEnv * parent, DLocalSymtab * symtab, DArray * args); - static DLocalEnv * _make_empty(obj mm, - DLocalEnv * parent, - DLocalSymtab * symtab, - DArray * args); + static DLocalEnv * _make(obj mm, + DLocalEnv * parent, + DLocalSymtab * symtab, + DArray * args); ///@} /** @defgroup scm-local-env-methods methods **/ diff --git a/include/xo/interpreter2/DVsmRcx.hpp b/include/xo/interpreter2/DVsmRcx.hpp index 3d6632a3..eeeb7289 100644 --- a/include/xo/interpreter2/DVsmRcx.hpp +++ b/include/xo/interpreter2/DVsmRcx.hpp @@ -24,6 +24,7 @@ namespace xo { DVsmRcx(VirtualSchematikaMachine * vsm); obj allocator() const noexcept; + obj error_allocator() const noexcept; private: /** schematika interpreter **/ diff --git a/include/xo/interpreter2/VsmConfig.hpp b/include/xo/interpreter2/VsmConfig.hpp index 63c4b365..f05ac449 100644 --- a/include/xo/interpreter2/VsmConfig.hpp +++ b/include/xo/interpreter2/VsmConfig.hpp @@ -31,7 +31,7 @@ namespace xo { /** Configuration for error allocator * TODO: may want to make ArenaConfig polymorphic **/ - ArenaConfig error_config_ = ArenaConfig().with_size(64*1024); + ArenaConfig error_config_ = ArenaConfig().with_name("error-reserve").with_size(64*1024); }; } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/DClosure.cpp b/src/interpreter2/DClosure.cpp index 7fa3698c..8aa7997b 100644 --- a/src/interpreter2/DClosure.cpp +++ b/src/interpreter2/DClosure.cpp @@ -7,6 +7,7 @@ #include "LambdaExpr.hpp" #include "LocalEnv.hpp" #include "VsmRcx.hpp" +#include #include #include @@ -35,6 +36,8 @@ namespace xo { DClosure::apply_nocheck(obj rcx, const DArray * args) { + (void)args; + scope log(XO_DEBUG(true)); auto vsm_rcx @@ -42,26 +45,31 @@ namespace xo { log && log(xtag("vsm_rcx.data", (void*)vsm_rcx.data())); - // let's try a not-implemented error - - // don't want to clutter Procedure facet, since it's - // lower-level than xo-interpreter2 + // we already checked this stuff before calling apply_nocheck() + // assert (n_args == args->size()); #ifdef NOT_YET - // TODO: verify arguments against type signature. - // unless we have evidence that program is type correct - - int32_t n_args = this->n_args(); - - if (n_args != args->size()) { - // - } + auto local_env + = DLocalEnv::_make(vsm_rcx->allocator(), + env_, + lambda_->local_symtab(), + args); #endif + // plan: + // 1. push current local environment to vsm stack_ + // 2. set expr_ to lambda body + // 2. set pc_ to eval + // 3. set cont_ to restore local_env_ - (void)args; + auto err_mm + = vsm_rcx->error_allocator(); - assert(false); + auto err + = DRuntimeError::make(err_mm, + "DClosure::apply_nocheck", + "not implemented"); + return err; } size_t diff --git a/src/interpreter2/DLocalEnv.cpp b/src/interpreter2/DLocalEnv.cpp index 9ee0911a..6866fda7 100644 --- a/src/interpreter2/DLocalEnv.cpp +++ b/src/interpreter2/DLocalEnv.cpp @@ -22,10 +22,10 @@ namespace xo { {} DLocalEnv * - DLocalEnv::_make_empty(obj mm, - DLocalEnv * parent, - DLocalSymtab * symtab, - DArray * args) + DLocalEnv::_make(obj mm, + DLocalEnv * parent, + DLocalSymtab * symtab, + DArray * args) { assert(symtab); diff --git a/src/interpreter2/DVsmRcx.cpp b/src/interpreter2/DVsmRcx.cpp index 92e153bc..71916771 100644 --- a/src/interpreter2/DVsmRcx.cpp +++ b/src/interpreter2/DVsmRcx.cpp @@ -19,6 +19,12 @@ namespace xo { return vsm_->allocator(); } + obj + DVsmRcx::error_allocator() const noexcept + { + return vsm_->error_allocator(); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index abdfb168..641723f9 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -82,6 +82,7 @@ namespace xo { VirtualSchematikaMachine::visit_pools(const MemorySizeVisitor & visitor) const { mm_.visit_pools(visitor); + error_mm_.visit_pools(visitor); reader_.visit_pools(visitor); } diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 5ccef226..22b50194 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -6,9 +6,8 @@ #include #include #include -//#include #include -//#include +#include #ifdef NOT_YET #include @@ -32,6 +31,7 @@ namespace xo { using xo::scm::DClosure; using xo::scm::DFloat; using xo::scm::DInteger; + using xo::scm::DRuntimeError; using xo::mm::AGCObject; using xo::mm::MemorySizeInfo; using xo::facet::FacetRegistry; @@ -245,9 +245,13 @@ namespace xo { log && log(xtag("res.tseq", res.value()->_typeseq())); - auto x = obj::from(*res.value()); + // currently get not-implemented error + auto x = obj::from(*res.value()); REQUIRE(x); + + log && log("runtime-error", xtag("ex.src", x->src_function()), xtag("ex.descr", x->error_descr())); + //REQUIRE(x.data()->value() == 1.570796325); REQUIRE(res.remaining_.size() == 1); From eecc70d6eb8033b5bb9d5df9c5669c97ccd82caf Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 13 Feb 2026 00:09:43 -0500 Subject: [PATCH 031/131] xo-interpreter2: + VsmApplyClosureFrame [WIP, not used] --- CMakeLists.txt | 26 +++++++ idl/IGCObject_DVsmApplyClosureFrame.json5 | 15 +++++ idl/IPrintable_DVsmApplyClosureFrame.json5 | 13 ++++ .../xo/interpreter2/DVsmApplyClosureFrame.hpp | 52 ++++++++++++++ include/xo/interpreter2/DVsmApplyFrame.hpp | 9 ++- .../interpreter2/VirtualSchematikaMachine.hpp | 7 +- .../xo/interpreter2/VsmApplyClosureFrame.hpp | 12 ++++ .../IGCObject_DVsmApplyClosureFrame.hpp | 67 +++++++++++++++++++ .../IPrintable_DVsmApplyClosureFrame.hpp | 62 +++++++++++++++++ src/interpreter2/CMakeLists.txt | 4 ++ src/interpreter2/DVsmApplyClosureFrame.cpp | 59 ++++++++++++++++ src/interpreter2/DVsmApplyFrame.cpp | 5 +- src/interpreter2/DVsmEvalArgsFrame.cpp | 3 +- .../IGCObject_DVsmApplyClosureFrame.cpp | 39 +++++++++++ .../IPrintable_DVsmApplyClosureFrame.cpp | 28 ++++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 2 +- .../interpreter2_register_facets.cpp | 19 ++++-- 17 files changed, 410 insertions(+), 12 deletions(-) create mode 100644 idl/IGCObject_DVsmApplyClosureFrame.json5 create mode 100644 idl/IPrintable_DVsmApplyClosureFrame.json5 create mode 100644 include/xo/interpreter2/DVsmApplyClosureFrame.hpp create mode 100644 include/xo/interpreter2/VsmApplyClosureFrame.hpp create mode 100644 include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp create mode 100644 include/xo/interpreter2/detail/IPrintable_DVsmApplyClosureFrame.hpp create mode 100644 src/interpreter2/DVsmApplyClosureFrame.cpp create mode 100644 src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp create mode 100644 src/interpreter2/IPrintable_DVsmApplyClosureFrame.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f3b14bc..ae8893a6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,6 +77,32 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-gcobject-vsmapplyclosureframe + FACET_PKG xo_gc + FACET GCObject + REPR VsmApplyClosureFrame + INPUT idl/IGCObject_DVsmApplyClosureFrame.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-vsmapplyclosureframe + FACET_PKG xo_printable2 + FACET Printable + REPR DVsmApplyClosureFrame + INPUT idl/IPrintable_DVsmApplyClosureFrame.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-procedure-closure diff --git a/idl/IGCObject_DVsmApplyClosureFrame.json5 b/idl/IGCObject_DVsmApplyClosureFrame.json5 new file mode 100644 index 00000000..398d53e9 --- /dev/null +++ b/idl/IGCObject_DVsmApplyClosureFrame.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DVsmApplyClosureFrame", + using_doxygen: true, + repr: "DVsmApplyClosureFrame", + doc: [ "implement AGCObject for DVsmApplyClosureFrame" ], +} diff --git a/idl/IPrintable_DVsmApplyClosureFrame.json5 b/idl/IPrintable_DVsmApplyClosureFrame.json5 new file mode 100644 index 00000000..717aa85f --- /dev/null +++ b/idl/IPrintable_DVsmApplyClosureFrame.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DVsmApplyClosureFrame", + using_doxygen: true, + repr: "DVsmApplyClosureFrame", + doc: [ "implement APrintable for DVsmApplyClosureFrame" ], +} diff --git a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp new file mode 100644 index 00000000..185b818f --- /dev/null +++ b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp @@ -0,0 +1,52 @@ +/** @file DVsmApplyClosureFrame.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "VsmInstr.hpp" +#include "DLocalEnv.hpp" +#include + +namespace xo { + namespace scm { + + /** Frame to preserve VSM registers: + * (stack_, parent_, cont_) + * while applying a closure. + **/ + class DVsmApplyClosureFrame { + public: + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; + using ppindentinfo = xo::print::ppindentinfo; + + public: + DVsmApplyClosureFrame(obj stack, + VsmInstr cont, + DLocalEnv * env); + + /** gcobject facet **/ + std::size_t shallow_size() const noexcept; + DVsmApplyClosureFrame * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + + /** pretty-printing support **/ + bool pretty(const ppindentinfo & ppii) const; + + protected: + /** saved VSM stack_ register **/ + obj stack_; + /** saved VSM cont_ register **/ + VsmInstr cont_; + /** saved VSM local_env_ register **/ + DLocalEnv * local_env_ = nullptr; + }; + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmApplyClosureFrame.hpp */ diff --git a/include/xo/interpreter2/DVsmApplyFrame.hpp b/include/xo/interpreter2/DVsmApplyFrame.hpp index 72900eb2..b4b46de2 100644 --- a/include/xo/interpreter2/DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyFrame.hpp @@ -9,11 +9,12 @@ namespace xo { namespace scm { - class DVsmApplyFrame : public VsmFrame { + class DVsmApplyFrame { public: using AProcedure = xo::scm::AProcedure; using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; using ppindentinfo = xo::print::ppindentinfo; public: @@ -27,6 +28,8 @@ namespace xo { VsmInstr old_cont, DArray * args); + obj parent() const noexcept { return parent_; } + VsmInstr cont() const noexcept { return cont_; } obj fn() const noexcept { return fn_; } DArray * args() const noexcept { return args_; } @@ -40,6 +43,10 @@ namespace xo { bool pretty(const ppindentinfo & ppii) const; private: + /** saved VSM stack; restore when this frame consumed **/ + obj parent_; + /** saved continuation; restore when this frame consumed **/ + VsmInstr cont_; /** evaluated target procedure. * * note: when initially created, this will be unpopulated; diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 39421981..67307700 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -21,7 +21,7 @@ namespace xo { #ifdef OBSOLETE // see DVsmError // TODO: move error to collected space? // or special arena? - // + // struct EvaluationError { /** source location (in vsm implementation) at which error identified **/ std::string_view src_function_; @@ -182,9 +182,10 @@ namespace xo { * stack_ * cont_ * - * Other registers are not preserved + * Other registers not preserved * pc_ * expr_ + * local_env_ * fn_ * args_ * value_ @@ -200,7 +201,7 @@ namespace xo { /** Sidecar allocator for error reporting. * Separate to mitigate interference with @ref mm_ - * (separate memory so we can for example report + * (separate memory so we can for example report * an out-of-memory error). * Likely DArena or similar **/ diff --git a/include/xo/interpreter2/VsmApplyClosureFrame.hpp b/include/xo/interpreter2/VsmApplyClosureFrame.hpp new file mode 100644 index 00000000..09b68d09 --- /dev/null +++ b/include/xo/interpreter2/VsmApplyClosureFrame.hpp @@ -0,0 +1,12 @@ +/** @file VsmApplyClosureFrame.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DVsmApplyClosureFrame.hpp" +#include "detail/IGCObject_DVsmApplyClosureFrame.hpp" +#include "detail/IPrintable_DVsmApplyClosureFrame.hpp" + +/* end VsmApplyClosureFrame.hpp */ diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp new file mode 100644 index 00000000..2baacd05 --- /dev/null +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DVsmApplyClosureFrame.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVsmApplyClosureFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVsmApplyClosureFrame.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DVsmApplyClosureFrame.hpp" + +namespace xo { namespace scm { class IGCObject_DVsmApplyClosureFrame; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DVsmApplyClosureFrame + **/ + class IGCObject_DVsmApplyClosureFrame { + public: + /** @defgroup scm-gcobject-dvsmapplyclosureframe-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-dvsmapplyclosureframe-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DVsmApplyClosureFrame & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DVsmApplyClosureFrame & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DVsmApplyClosureFrame & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/detail/IPrintable_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IPrintable_DVsmApplyClosureFrame.hpp new file mode 100644 index 00000000..f2e5a072 --- /dev/null +++ b/include/xo/interpreter2/detail/IPrintable_DVsmApplyClosureFrame.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DVsmApplyClosureFrame.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVsmApplyClosureFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVsmApplyClosureFrame.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DVsmApplyClosureFrame.hpp" + +namespace xo { namespace scm { class IPrintable_DVsmApplyClosureFrame; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DVsmApplyClosureFrame + **/ + class IPrintable_DVsmApplyClosureFrame { + public: + /** @defgroup scm-printable-dvsmapplyclosureframe-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dvsmapplyclosureframe-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DVsmApplyClosureFrame & 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 f6fbd10b..4a477874 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -16,6 +16,10 @@ set(SELF_SRCS IGCObject_DVsmApplyFrame.cpp IPrintable_DVsmApplyFrame.cpp + DVsmApplyClosureFrame.cpp + IGCObject_DVsmApplyClosureFrame.cpp + IPrintable_DVsmApplyClosureFrame.cpp + DClosure.cpp IProcedure_DClosure.cpp IGCObject_DClosure.cpp diff --git a/src/interpreter2/DVsmApplyClosureFrame.cpp b/src/interpreter2/DVsmApplyClosureFrame.cpp new file mode 100644 index 00000000..b7962ebd --- /dev/null +++ b/src/interpreter2/DVsmApplyClosureFrame.cpp @@ -0,0 +1,59 @@ +/** @file DVsmApplyClosureFrame.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DVsmApplyClosureFrame.hpp" + +namespace xo { + using xo::mm::AGCObject; + + namespace scm { + + DVsmApplyClosureFrame::DVsmApplyClosureFrame(obj stack, + VsmInstr cont, + DLocalEnv * local_env) + : stack_{stack}, + cont_{cont}, + local_env_{local_env} + {} + + std::size_t + DVsmApplyClosureFrame::shallow_size() const noexcept + { + return sizeof(DVsmApplyClosureFrame); + } + + DVsmApplyClosureFrame * + DVsmApplyClosureFrame::shallow_copy(obj mm) const noexcept + { + DVsmApplyClosureFrame * copy + = (DVsmApplyClosureFrame *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + std::size_t + DVsmApplyClosureFrame::forward_children(obj gc) noexcept + { + (void)gc; + + return this->shallow_size(); + } + + bool + DVsmApplyClosureFrame::pretty(const ppindentinfo & ppii) const + { + return ppii.pps()->pretty_struct + (ppii, + "DVsmApplyClosureFrame", + refrtag("cont", cont_), + refrtag("env", local_env_)); + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmApplyClosureFrame.cpp */ diff --git a/src/interpreter2/DVsmApplyFrame.cpp b/src/interpreter2/DVsmApplyFrame.cpp index 75da5877..55d59b37 100644 --- a/src/interpreter2/DVsmApplyFrame.cpp +++ b/src/interpreter2/DVsmApplyFrame.cpp @@ -14,8 +14,9 @@ namespace xo { DVsmApplyFrame::DVsmApplyFrame(obj old_parent, VsmInstr old_cont, DArray * args) - : VsmFrame(old_parent, old_cont), - args_{args} + : parent_{old_parent}, + cont_{old_cont}, + args_{args} {} DVsmApplyFrame * diff --git a/src/interpreter2/DVsmEvalArgsFrame.cpp b/src/interpreter2/DVsmEvalArgsFrame.cpp index 01391cf2..1ca470e9 100644 --- a/src/interpreter2/DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/DVsmEvalArgsFrame.cpp @@ -49,7 +49,8 @@ namespace xo { DVsmEvalArgsFrame * DVsmEvalArgsFrame::shallow_copy(obj mm) const noexcept { - DVsmEvalArgsFrame * copy = (DVsmEvalArgsFrame *)mm.alloc_copy((std::byte *)this); + DVsmEvalArgsFrame * copy + = (DVsmEvalArgsFrame *)mm.alloc_copy((std::byte *)this); if (copy) *copy = *this; diff --git a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp new file mode 100644 index 00000000..7a05d47e --- /dev/null +++ b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DVsmApplyClosureFrame.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVsmApplyClosureFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVsmApplyClosureFrame.json5] +**/ + +#include "detail/IGCObject_DVsmApplyClosureFrame.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DVsmApplyClosureFrame::shallow_size(const DVsmApplyClosureFrame & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DVsmApplyClosureFrame::shallow_copy(const DVsmApplyClosureFrame & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DVsmApplyClosureFrame::forward_children(DVsmApplyClosureFrame & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVsmApplyClosureFrame.cpp */ diff --git a/src/interpreter2/IPrintable_DVsmApplyClosureFrame.cpp b/src/interpreter2/IPrintable_DVsmApplyClosureFrame.cpp new file mode 100644 index 00000000..36b89a10 --- /dev/null +++ b/src/interpreter2/IPrintable_DVsmApplyClosureFrame.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DVsmApplyClosureFrame.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVsmApplyClosureFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVsmApplyClosureFrame.json5] +**/ + +#include "detail/IPrintable_DVsmApplyClosureFrame.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DVsmApplyClosureFrame::pretty(const DVsmApplyClosureFrame & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DVsmApplyClosureFrame.cpp */ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 641723f9..1242375a 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -62,7 +62,7 @@ namespace xo { error_mm_.adopt(obj(arena)); } - + // TODO: allocate global_env } diff --git a/src/interpreter2/interpreter2_register_facets.cpp b/src/interpreter2/interpreter2_register_facets.cpp index 5d1467e5..f945956e 100644 --- a/src/interpreter2/interpreter2_register_facets.cpp +++ b/src/interpreter2/interpreter2_register_facets.cpp @@ -5,8 +5,11 @@ #include "interpreter2_register_facets.hpp" +#include "DPrimitive_gco_2_gco_gco.hpp" #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" +#include "VsmApplyClosureFrame.hpp" +#include "Primitive_gco_2_gco_gco.hpp" #include "Closure.hpp" #include "LocalEnv.hpp" #include "VsmRcx.hpp" @@ -31,7 +34,8 @@ namespace xo { // VsmStackFrame // +- VsmApplyFrame - // \- VsmEvalArgsFrame + // +- VsmEvalArgsFrame + // \- VsmApplyClosureFrame FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -39,9 +43,10 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); - FacetRegistry::register_impl(); - FacetRegistry::register_impl(); - FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + // LocalEnv FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -50,7 +55,13 @@ namespace xo { // +- Primitive_gco_2_gco_gco // \- Closure + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); // RuntimeContext // \- VsmRcx From cfa5692804832499580e63b6b9fed864a769a007 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 13 Feb 2026 02:05:47 -0500 Subject: [PATCH 032/131] xo-interpreter2 stack: invoke closures w/ tail-call opt [WIP] --- CMakeLists.txt | 21 ++-- include/xo/interpreter2/Closure.hpp | 2 +- .../xo/interpreter2/DVsmApplyClosureFrame.hpp | 10 ++ include/xo/interpreter2/DVsmApplyFrame.hpp | 12 ++- .../interpreter2/VirtualSchematikaMachine.hpp | 18 +++- include/xo/interpreter2/VsmInstr.hpp | 8 ++ include/xo/interpreter2/VsmOpcode.hpp | 5 + src/interpreter2/CMakeLists.txt | 1 - src/interpreter2/DClosure.cpp | 25 ++--- src/interpreter2/DVsmApplyClosureFrame.cpp | 13 +++ src/interpreter2/IProcedure_DClosure.cpp | 39 -------- src/interpreter2/VirtualSchematikaMachine.cpp | 97 +++++++++++++++++-- src/interpreter2/VsmInstr.cpp | 4 + .../interpreter2_register_facets.cpp | 6 +- 14 files changed, 174 insertions(+), 87 deletions(-) delete mode 100644 src/interpreter2/IProcedure_DClosure.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ae8893a6..8a1b1b3c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,16 +104,17 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- # note: manual target; generated code committed to git -xo_add_genfacetimpl( - TARGET xo-interpreter2-facetimpl-procedure-closure - FACET_PKG xo_procedure2 - FACET Procedure - REPR Closure - INPUT idl/IProcedure_DClosure.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/interpreter2 -) +# +#xo_add_genfacetimpl( +# TARGET xo-interpreter2-facetimpl-procedure-closure +# FACET_PKG xo_procedure2 +# 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( diff --git a/include/xo/interpreter2/Closure.hpp b/include/xo/interpreter2/Closure.hpp index 5bbeb9b8..dc9272fe 100644 --- a/include/xo/interpreter2/Closure.hpp +++ b/include/xo/interpreter2/Closure.hpp @@ -6,7 +6,7 @@ #pragma once #include "DClosure.hpp" -#include "detail/IProcedure_DClosure.hpp" +//#include "detail/IProcedure_DClosure.hpp" #include "detail/IGCObject_DClosure.hpp" #include "detail/IPrintable_DClosure.hpp" diff --git a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp index 185b818f..a98d5713 100644 --- a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp @@ -28,6 +28,16 @@ namespace xo { VsmInstr cont, DLocalEnv * env); + /** create instance, using memory from @p mm **/ + static DVsmApplyClosureFrame * make(obj mm, + obj stack, + VsmInstr cont, + DLocalEnv * env); + + obj stack() const { return stack_; } + VsmInstr cont() const { return cont_; } + DLocalEnv * local_env() const { return local_env_; } + /** gcobject facet **/ std::size_t shallow_size() const noexcept; DVsmApplyClosureFrame * shallow_copy(obj mm) const noexcept; diff --git a/include/xo/interpreter2/DVsmApplyFrame.hpp b/include/xo/interpreter2/DVsmApplyFrame.hpp index b4b46de2..a5df3504 100644 --- a/include/xo/interpreter2/DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyFrame.hpp @@ -30,10 +30,10 @@ namespace xo { obj parent() const noexcept { return parent_; } VsmInstr cont() const noexcept { return cont_; } - obj fn() const noexcept { return fn_; } + obj fn() const noexcept { return fn_; } DArray * args() const noexcept { return args_; } - void assign_fn(obj x) { this->fn_ = x; } + void assign_fn(obj x) { this->fn_ = x; } std::size_t shallow_size() const noexcept; DVsmApplyFrame * shallow_copy(obj mm) const noexcept; @@ -51,9 +51,13 @@ namespace xo { * * note: when initially created, this will be unpopulated; * don't know correct value until we evaluate - * expression in head position + * expression in head position. + * + * Must exhibit either: + * 1. AProcedure facet (runs natively) + * 2. AVsmProcedure facet (requires schematika runtime) **/ - obj fn_; + obj fn_; /** evaluated arguments (to target procedure) **/ DArray * args_; }; diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 67307700..569d9d48 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -176,16 +176,28 @@ namespace xo { **/ void _do_evalargs_op(); + /** call closure @ref fn_ with arguments @ref args_ **/ + void _do_call_closure_op(); + /** call primitive @ref fn_ with arguments @ref args_ **/ + void _do_call_primitive_op(); + + /** restore registers from stack frame + * (specifically: local_env_, stack_, cont_) + * after invoking a schematika closure + **/ + void _do_applycoda_op(); + + private: /* * Some registers are preserved by evaluation: * stack_ * cont_ + * local_env_ * * Other registers not preserved * pc_ * expr_ - * local_env_ * fn_ * args_ * value_ @@ -244,8 +256,8 @@ namespace xo { DGlobalEnv * global_env_ = nullptr; private: - /** function to call **/ - obj fn_; + /** evaluated function to call **/ + obj fn_; /** evaluated argument list **/ DArray * args_; diff --git a/include/xo/interpreter2/VsmInstr.hpp b/include/xo/interpreter2/VsmInstr.hpp index ec836c4d..bdde3ab7 100644 --- a/include/xo/interpreter2/VsmInstr.hpp +++ b/include/xo/interpreter2/VsmInstr.hpp @@ -19,12 +19,20 @@ namespace xo { static VsmInstr c_apply; static VsmInstr c_evalargs; + /** restore registers after calling a schematika closure **/ + static VsmInstr c_applycoda; + vsm_opcode opcode() const noexcept { return opcode_; } private: vsm_opcode opcode_; }; + inline bool + operator==(VsmInstr x, VsmInstr y) noexcept { + return x.opcode() == y.opcode(); + } + inline std::ostream & operator<<(std::ostream & os, VsmInstr x) { os << x.opcode(); diff --git a/include/xo/interpreter2/VsmOpcode.hpp b/include/xo/interpreter2/VsmOpcode.hpp index 2c58c04f..ec21b988 100644 --- a/include/xo/interpreter2/VsmOpcode.hpp +++ b/include/xo/interpreter2/VsmOpcode.hpp @@ -28,6 +28,11 @@ namespace xo { **/ evalargs, + /** Coda to restore vsm registers (local_env, stack, cont) + * after invoking a closure + **/ + applycoda, + /** sentinel, counts number of opcodes **/ N, }; diff --git a/src/interpreter2/CMakeLists.txt b/src/interpreter2/CMakeLists.txt index 4a477874..1ddb3207 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -21,7 +21,6 @@ set(SELF_SRCS IPrintable_DVsmApplyClosureFrame.cpp DClosure.cpp - IProcedure_DClosure.cpp IGCObject_DClosure.cpp IPrintable_DClosure.cpp diff --git a/src/interpreter2/DClosure.cpp b/src/interpreter2/DClosure.cpp index 8aa7997b..53015068 100644 --- a/src/interpreter2/DClosure.cpp +++ b/src/interpreter2/DClosure.cpp @@ -36,6 +36,14 @@ namespace xo { DClosure::apply_nocheck(obj rcx, const DArray * args) { + // control here only if you try to invoke a closure + // as a procedure. + // + // May support this later, but requires + // nesting VSM (because call consumes c++ stack) + // + // typically prefer trampoline built into VSM + (void)args; scope log(XO_DEBUG(true)); @@ -45,23 +53,6 @@ namespace xo { log && log(xtag("vsm_rcx.data", (void*)vsm_rcx.data())); - // we already checked this stuff before calling apply_nocheck() - // assert (n_args == args->size()); - -#ifdef NOT_YET - auto local_env - = DLocalEnv::_make(vsm_rcx->allocator(), - env_, - lambda_->local_symtab(), - args); -#endif - - // plan: - // 1. push current local environment to vsm stack_ - // 2. set expr_ to lambda body - // 2. set pc_ to eval - // 3. set cont_ to restore local_env_ - auto err_mm = vsm_rcx->error_allocator(); diff --git a/src/interpreter2/DVsmApplyClosureFrame.cpp b/src/interpreter2/DVsmApplyClosureFrame.cpp index b7962ebd..6a86ce27 100644 --- a/src/interpreter2/DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/DVsmApplyClosureFrame.cpp @@ -7,6 +7,7 @@ namespace xo { using xo::mm::AGCObject; + using xo::reflect::typeseq; namespace scm { @@ -18,6 +19,18 @@ namespace xo { local_env_{local_env} {} + DVsmApplyClosureFrame * + DVsmApplyClosureFrame::make(obj mm, + obj stack, + VsmInstr cont, + DLocalEnv * local_env) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DVsmApplyClosureFrame)); + + return new (mem) DVsmApplyClosureFrame(stack, cont, local_env); + } + std::size_t DVsmApplyClosureFrame::shallow_size() const noexcept { diff --git a/src/interpreter2/IProcedure_DClosure.cpp b/src/interpreter2/IProcedure_DClosure.cpp deleted file mode 100644 index b41c7be1..00000000 --- a/src/interpreter2/IProcedure_DClosure.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/** @file IProcedure_DClosure.cpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IProcedure_DClosure.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] - * 3. idl for facet methods - * [idl/IProcedure_DClosure.json5] -**/ - -#include "detail/IProcedure_DClosure.hpp" - -namespace xo { - namespace scm { - auto - IProcedure_DClosure::is_nary(const DClosure & self) noexcept -> bool - { - return self.is_nary(); - } - - auto - IProcedure_DClosure::n_args(const DClosure & self) noexcept -> std::int32_t - { - return self.n_args(); - } - - auto - IProcedure_DClosure::apply_nocheck(DClosure & self, obj rcx, const DArray * args) -> obj - { - return self.apply_nocheck(rcx, args); - } - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end IProcedure_DClosure.cpp */ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 1242375a..8ff78ae0 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -6,6 +6,7 @@ #include "VirtualSchematikaMachine.hpp" #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" +#include "VsmApplyClosureFrame.hpp" #include "VsmRcx.hpp" #include "Closure.hpp" #include @@ -164,9 +165,9 @@ namespace xo { log && log(xtag("pc", pc_), xtag("cont", cont_)); - obj stack_pr - = (FacetRegistry::instance() - .try_variant(stack_)); + obj stack_pr = stack_.to_facet(); +// = (FacetRegistry::instance() +// .try_variant(stack_)); if (stack_pr) log && log(xtag("stack", stack_pr)); @@ -184,6 +185,9 @@ namespace xo { case vsm_opcode::evalargs: _do_evalargs_op(); break; + case vsm_opcode::applycoda: + _do_applycoda_op(); + break; } return true; @@ -370,10 +374,68 @@ namespace xo { // TODO: check argument types - this->value_ = VsmResult(fn_.apply_nocheck(rcx_.to_op(), args_)); - this->pc_ = cont_; + auto closure = obj::from(fn_); - return; + if (closure) { + _do_call_closure_op(); + return; + } else { + _do_call_closure_op(); + return; + } + } + + void + VirtualSchematikaMachine::_do_call_closure_op() + { + // We need to preserve registers while evaluating + // lambda body + + auto closure = obj::from(fn_); + + // TODO: for tail recursion: + // check whether stack_ already refers to a + // DVsmApplyClosureFrame instance, in which case + // we can just refer to it instead of pushing a new one + + if (cont_ == VsmInstr::c_applycoda) { + // we are making a tail call. + // No need to preserve (stack, cont, local_env), + // since continuation will restore on top of them + // frame top stackframe anyway + } else { + obj frame( + DVsmApplyClosureFrame::make(mm_.to_op(), + stack_, + cont_, + local_env_)); + + // push frame w/ saved vsm registers + this->stack_ = frame; + this->cont_ = VsmInstr::c_applycoda; + } + + auto lambda = closure->lambda(); + + auto local_env + = DLocalEnv::_make(mm_.to_op(), + local_env_, + lambda->local_symtab(), + args_); + + this->local_env_ = local_env; + this->expr_ = lambda->body_expr(); + this->pc_ = VsmInstr::c_eval; + } + + void + VirtualSchematikaMachine::_do_call_primitive_op() + { + auto fn = fn_.to_facet(); + + this->value_ = VsmResult(fn.apply_nocheck(rcx_.to_op(), args_)); + this->pc_ = cont_; } void @@ -434,10 +496,11 @@ namespace xo { = evalargs_frame->apply_expr(); if (i_arg == -1) { - auto fn = value.to_facet(); + bool is_native_fn = value.to_facet(); + bool is_closure = obj::from(value); - if (fn) { - apply_frame->assign_fn(fn); + if (is_native_fn || is_closure) { + apply_frame->assign_fn(value); i_arg = evalargs_frame->increment_arg(); @@ -493,6 +556,22 @@ namespace xo { assert(false); } + void + VirtualSchematikaMachine::_do_applycoda_op() + { + // see DVsmApplyClosureFrame + + auto frame = obj::from(stack_); + + assert(frame); + + this->stack_ = frame->stack(); + this->local_env_ = frame->local_env(); + this->pc_ = frame->cont(); + + // not implemented + assert(false); + } } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/VsmInstr.cpp b/src/interpreter2/VsmInstr.cpp index ddcc8c20..02ac8325 100644 --- a/src/interpreter2/VsmInstr.cpp +++ b/src/interpreter2/VsmInstr.cpp @@ -15,6 +15,7 @@ namespace xo { case vsm_opcode::eval: return "eval"; case vsm_opcode::apply: return "apply"; case vsm_opcode::evalargs: return "evalargs"; + case vsm_opcode::applycoda: return "applycoda"; case vsm_opcode::N: break; } @@ -33,6 +34,9 @@ namespace xo { VsmInstr VsmInstr::c_evalargs = VsmInstr(vsm_opcode::evalargs); + + VsmInstr + VsmInstr::c_applycoda = VsmInstr(vsm_opcode::applycoda); } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/interpreter2_register_facets.cpp b/src/interpreter2/interpreter2_register_facets.cpp index f945956e..1548aeaf 100644 --- a/src/interpreter2/interpreter2_register_facets.cpp +++ b/src/interpreter2/interpreter2_register_facets.cpp @@ -59,9 +59,9 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); - FacetRegistry::register_impl(); - FacetRegistry::register_impl(); - FacetRegistry::register_impl(); +// FacetRegistry::register_impl(); +// FacetRegistry::register_impl(); +// FacetRegistry::register_impl(); // RuntimeContext // \- VsmRcx From caed95c54d8fb0a2abf117b2565cfe16d7de7c95 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 13 Feb 2026 15:16:05 -0500 Subject: [PATCH 033/131] xo-interpreter2 stack: handle SequenceExpr + gc for frames --- CMakeLists.txt | 26 ++++++ idl/IGCObject_DVsmSeqContFrame.json5 | 15 ++++ idl/IPrintable_DVsmSeqContFrame.json5 | 13 +++ include/xo/interpreter2/DVsmApplyFrame.hpp | 4 +- include/xo/interpreter2/DVsmEvalArgsFrame.hpp | 6 +- include/xo/interpreter2/DVsmSeqContFrame.hpp | 89 +++++++++++++++++++ .../interpreter2/VirtualSchematikaMachine.hpp | 2 + include/xo/interpreter2/VsmInstr.hpp | 4 +- include/xo/interpreter2/VsmOpcode.hpp | 3 + include/xo/interpreter2/VsmSeqContFrame.hpp | 12 +++ .../sequence/IGCObject_DVsmSeqContFrame.hpp | 67 ++++++++++++++ .../sequence/IPrintable_DVsmSeqContFrame.hpp | 62 +++++++++++++ src/interpreter2/CMakeLists.txt | 4 + src/interpreter2/DVsmApplyClosureFrame.cpp | 4 +- src/interpreter2/DVsmApplyFrame.cpp | 17 ++-- src/interpreter2/DVsmEvalArgsFrame.cpp | 18 ++-- src/interpreter2/DVsmSeqContFrame.cpp | 70 +++++++++++++++ .../IGCObject_DVsmSeqContFrame.cpp | 39 ++++++++ .../IPrintable_DVsmSeqContFrame.cpp | 28 ++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 84 +++++++++++++++-- src/interpreter2/VsmInstr.cpp | 4 + .../interpreter2_register_facets.cpp | 24 +++-- 22 files changed, 559 insertions(+), 36 deletions(-) create mode 100644 idl/IGCObject_DVsmSeqContFrame.json5 create mode 100644 idl/IPrintable_DVsmSeqContFrame.json5 create mode 100644 include/xo/interpreter2/DVsmSeqContFrame.hpp create mode 100644 include/xo/interpreter2/VsmSeqContFrame.hpp create mode 100644 include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp create mode 100644 include/xo/interpreter2/sequence/IPrintable_DVsmSeqContFrame.hpp create mode 100644 src/interpreter2/DVsmSeqContFrame.cpp create mode 100644 src/interpreter2/IGCObject_DVsmSeqContFrame.cpp create mode 100644 src/interpreter2/IPrintable_DVsmSeqContFrame.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a1b1b3c..26124a21 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,6 +103,32 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-gcobject-vsmseqcontframe + FACET_PKG xo_gc + FACET GCObject + REPR VsmSeqContFrame + INPUT idl/IGCObject_DVsmSeqContFrame.json5 + OUTPUT_HPP_DIR include/xo/interpreter2 + OUTPUT_IMPL_SUBDIR sequence + OUTPUT_CPP_DIR src/interpreter2 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-printable-vsmseqcontframe + FACET_PKG xo_printable2 + FACET Printable + REPR DVsmSeqContFrame + INPUT idl/IPrintable_DVsmSeqContFrame.json5 + OUTPUT_HPP_DIR include/xo/interpreter2 + OUTPUT_IMPL_SUBDIR sequence + OUTPUT_CPP_DIR src/interpreter2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git # #xo_add_genfacetimpl( diff --git a/idl/IGCObject_DVsmSeqContFrame.json5 b/idl/IGCObject_DVsmSeqContFrame.json5 new file mode 100644 index 00000000..cf7196c6 --- /dev/null +++ b/idl/IGCObject_DVsmSeqContFrame.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DVsmSeqContFrame", + using_doxygen: true, + repr: "DVsmSeqContFrame", + doc: [ "implement AGCObject for DVsmSeqContFrame" ], +} diff --git a/idl/IPrintable_DVsmSeqContFrame.json5 b/idl/IPrintable_DVsmSeqContFrame.json5 new file mode 100644 index 00000000..e9ec796e --- /dev/null +++ b/idl/IPrintable_DVsmSeqContFrame.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DVsmSeqContFrame", + using_doxygen: true, + repr: "DVsmSeqContFrame", + doc: [ "implement APrintable for DVsmSeqContFrame" ], +} diff --git a/include/xo/interpreter2/DVsmApplyFrame.hpp b/include/xo/interpreter2/DVsmApplyFrame.hpp index a5df3504..47735afe 100644 --- a/include/xo/interpreter2/DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyFrame.hpp @@ -5,7 +5,9 @@ #pragma once -#include "VsmFrame.hpp" +#include "VsmInstr.hpp" +#include +#include namespace xo { namespace scm { diff --git a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp index 7131a001..e3b8b2b5 100644 --- a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp @@ -28,12 +28,12 @@ namespace xo { **/ DVsmEvalArgsFrame(DVsmApplyFrame * parent, VsmInstr cont, - const DApplyExpr * apply_expr); + DApplyExpr * apply_expr); static DVsmEvalArgsFrame * make(obj mm, DVsmApplyFrame * apply_frame, VsmInstr old_cont, - const DApplyExpr * apply_expr); + DApplyExpr * apply_expr); DVsmApplyFrame * parent() const noexcept { return parent_; } VsmInstr cont() const noexcept { return cont_; } @@ -55,7 +55,7 @@ namespace xo { VsmInstr cont_; /** expression being evaluated **/ - const DApplyExpr * apply_expr_ = nullptr; + DApplyExpr * apply_expr_ = nullptr; /** next argument to be evaluated. -1 means function head **/ int32_t i_arg_ = -1; diff --git a/include/xo/interpreter2/DVsmSeqContFrame.hpp b/include/xo/interpreter2/DVsmSeqContFrame.hpp new file mode 100644 index 00000000..cb63f0d4 --- /dev/null +++ b/include/xo/interpreter2/DVsmSeqContFrame.hpp @@ -0,0 +1,89 @@ +/** @file DVsmSeqContFrame.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "VsmInstr.hpp" +#include +#include + +namespace xo { + namespace scm { + /** @brief saved VSM state during evaluation of a SequenceExpr + **/ + class DVsmSeqContFrame { + public: + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; + using ppindentinfo = xo::print::ppindentinfo; + + public: + /** @defgroup scm-vsmevalsequenceframe-ctors constructors **/ + ///@{ + + DVsmSeqContFrame(obj parent, + VsmInstr cont, + DSequenceExpr * seq_expr, + uint32_t i_seq); + + /** create instance using memory from allocator @p mm **/ + static DVsmSeqContFrame * make(obj mm, + obj parent, + VsmInstr cont, + DSequenceExpr * seq_expr, + uint32_t i_seq); + + ///@} + /** @defgroup scm-vsmevalsequenceframe-access-methods access methods **/ + ///@{ + + obj parent() const noexcept { return parent_; } + VsmInstr cont() const noexcept { return cont_; } + DSequenceExpr * seq_expr() const noexcept { return seq_expr_; } + uint32_t i_seq() const noexcept { return i_seq_; } + + ///@} + /** @defgroup scm-vsmevalsequenceframe-general-methods general methods **/ + ///@{ + + uint32_t incr_i_seq() noexcept { return ++(this->i_seq_); } + + ///@} + /** @defgroup scm-vsmevalsequenceframe-gcobject-facet gcobject facet **/ + ///@{ + + std::size_t shallow_size() const noexcept; + DVsmSeqContFrame * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + + ///@} + /** @defgrouop scm-vsmseqcontframe-printable-facet printable facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const noexcept; + + ///@} + + private: + /** @defgroup scm-vsmevalsequenceframe-members member variables **/ + ///@{ + + /** saved VSM stack; restore when this frame consumed **/ + obj parent_; + /** saved continuation; restore when this frame consumed **/ + VsmInstr cont_; + /** saved expr. evaluate elements of this sequence in order **/ + DSequenceExpr * seq_expr_ = nullptr; + /** current sequence element being evaluated **/ + uint32_t i_seq_ = 0; + + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmSeqContFrame.hpp */ diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 569d9d48..d7e1ec77 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -187,6 +187,8 @@ namespace xo { **/ void _do_applycoda_op(); + /** loop continuation after evaluating element of a SequenceExpr **/ + void _do_seq_cont_op(); private: /* diff --git a/include/xo/interpreter2/VsmInstr.hpp b/include/xo/interpreter2/VsmInstr.hpp index bdde3ab7..4b51361d 100644 --- a/include/xo/interpreter2/VsmInstr.hpp +++ b/include/xo/interpreter2/VsmInstr.hpp @@ -18,10 +18,12 @@ namespace xo { static VsmInstr c_apply; static VsmInstr c_evalargs; - /** restore registers after calling a schematika closure **/ static VsmInstr c_applycoda; + /** loop to evaluate members of a SequenceExpr **/ + static VsmInstr c_seq_cont; + vsm_opcode opcode() const noexcept { return opcode_; } private: diff --git a/include/xo/interpreter2/VsmOpcode.hpp b/include/xo/interpreter2/VsmOpcode.hpp index ec21b988..06b3d08b 100644 --- a/include/xo/interpreter2/VsmOpcode.hpp +++ b/include/xo/interpreter2/VsmOpcode.hpp @@ -33,6 +33,9 @@ namespace xo { **/ applycoda, + /** Loop over elements of a SequenceExpr **/ + seq_cont, + /** sentinel, counts number of opcodes **/ N, }; diff --git a/include/xo/interpreter2/VsmSeqContFrame.hpp b/include/xo/interpreter2/VsmSeqContFrame.hpp new file mode 100644 index 00000000..96e8d053 --- /dev/null +++ b/include/xo/interpreter2/VsmSeqContFrame.hpp @@ -0,0 +1,12 @@ +/** @file VsmSeqContFrame.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DVsmSeqContFrame.hpp" +#include "sequence/IGCObject_DVsmSeqContFrame.hpp" +#include "sequence/IPrintable_DVsmSeqContFrame.hpp" + +/* end VsmSeqContFrame.hpp */ diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp new file mode 100644 index 00000000..1bdbe2ab --- /dev/null +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DVsmSeqContFrame.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVsmSeqContFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVsmSeqContFrame.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DVsmSeqContFrame.hpp" + +namespace xo { namespace scm { class IGCObject_DVsmSeqContFrame; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DVsmSeqContFrame + **/ + class IGCObject_DVsmSeqContFrame { + public: + /** @defgroup scm-gcobject-dvsmseqcontframe-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-dvsmseqcontframe-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DVsmSeqContFrame & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DVsmSeqContFrame & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DVsmSeqContFrame & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/sequence/IPrintable_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IPrintable_DVsmSeqContFrame.hpp new file mode 100644 index 00000000..0fb46c45 --- /dev/null +++ b/include/xo/interpreter2/sequence/IPrintable_DVsmSeqContFrame.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DVsmSeqContFrame.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVsmSeqContFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVsmSeqContFrame.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DVsmSeqContFrame.hpp" + +namespace xo { namespace scm { class IPrintable_DVsmSeqContFrame; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DVsmSeqContFrame + **/ + class IPrintable_DVsmSeqContFrame { + public: + /** @defgroup scm-printable-dvsmseqcontframe-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dvsmseqcontframe-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DVsmSeqContFrame & 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 1ddb3207..64e7dfe8 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -20,6 +20,10 @@ set(SELF_SRCS IGCObject_DVsmApplyClosureFrame.cpp IPrintable_DVsmApplyClosureFrame.cpp + DVsmSeqContFrame.cpp + IGCObject_DVsmSeqContFrame.cpp + IPrintable_DVsmSeqContFrame.cpp + DClosure.cpp IGCObject_DClosure.cpp IPrintable_DClosure.cpp diff --git a/src/interpreter2/DVsmApplyClosureFrame.cpp b/src/interpreter2/DVsmApplyClosureFrame.cpp index 6a86ce27..26a215a4 100644 --- a/src/interpreter2/DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/DVsmApplyClosureFrame.cpp @@ -4,6 +4,7 @@ **/ #include "DVsmApplyClosureFrame.hpp" +#include "LocalEnv.hpp" namespace xo { using xo::mm::AGCObject; @@ -52,7 +53,8 @@ namespace xo { std::size_t DVsmApplyClosureFrame::forward_children(obj gc) noexcept { - (void)gc; + gc.forward_inplace(&stack_); + gc.forward_inplace(&local_env_); return this->shallow_size(); } diff --git a/src/interpreter2/DVsmApplyFrame.cpp b/src/interpreter2/DVsmApplyFrame.cpp index 55d59b37..72b81405 100644 --- a/src/interpreter2/DVsmApplyFrame.cpp +++ b/src/interpreter2/DVsmApplyFrame.cpp @@ -4,6 +4,7 @@ **/ #include "DVsmApplyFrame.hpp" +#include #include namespace xo { @@ -59,9 +60,9 @@ namespace xo { std::size_t DVsmApplyFrame::forward_children(obj gc) noexcept { - // GC needs to locate AGCObject iface for each member - - (void)gc; + gc.forward_inplace(&parent_); + gc.forward_inplace(&fn_); + gc.forward_inplace(&args_); return this->shallow_size(); } @@ -69,12 +70,10 @@ namespace xo { bool DVsmApplyFrame::pretty(const ppindentinfo & ppii) const { - return ppii.pps()->pretty_struct - (ppii, - "DVsmApplyFrame", - refrtag("cont", cont_), - refrtag("n_args", args_->size()) - ); + return ppii.pps()->pretty_struct(ppii, + "DVsmApplyFrame", + refrtag("cont", cont_), + refrtag("n_args", args_->size())); } } /*namespace scm*/ diff --git a/src/interpreter2/DVsmEvalArgsFrame.cpp b/src/interpreter2/DVsmEvalArgsFrame.cpp index 1ca470e9..09439f2e 100644 --- a/src/interpreter2/DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/DVsmEvalArgsFrame.cpp @@ -4,6 +4,7 @@ **/ #include "DVsmEvalArgsFrame.hpp" +#include #include namespace xo { @@ -16,7 +17,7 @@ namespace xo { DVsmEvalArgsFrame::DVsmEvalArgsFrame(DVsmApplyFrame * parent, VsmInstr cont, - const DApplyExpr * apply_expr) + DApplyExpr * apply_expr) : parent_{parent}, cont_{cont}, apply_expr_{apply_expr} @@ -26,7 +27,7 @@ namespace xo { DVsmEvalArgsFrame::make(obj mm, DVsmApplyFrame * apply_frame, VsmInstr cont, - const DApplyExpr * apply_expr) + DApplyExpr * apply_expr) { DVsmEvalArgsFrame * result = nullptr; @@ -61,7 +62,8 @@ namespace xo { std::size_t DVsmEvalArgsFrame::forward_children(obj gc) noexcept { - (void)gc; + gc.forward_inplace(&parent_); + gc.forward_inplace(&apply_expr_); return this->shallow_size(); } @@ -69,12 +71,10 @@ namespace xo { bool DVsmEvalArgsFrame::pretty(const ppindentinfo & ppii) const { - return ppii.pps()->pretty_struct - (ppii, - "DVsmEvalArgsFrame", - refrtag("cont", cont_), - refrtag("i_arg", i_arg_) - ); + return ppii.pps()->pretty_struct(ppii, + "DVsmEvalArgsFrame", + refrtag("cont", cont_), + refrtag("i_arg", i_arg_)); } } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/DVsmSeqContFrame.cpp b/src/interpreter2/DVsmSeqContFrame.cpp new file mode 100644 index 00000000..80c1665f --- /dev/null +++ b/src/interpreter2/DVsmSeqContFrame.cpp @@ -0,0 +1,70 @@ +/** @file DVsmSeqContFrame.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DVsmSeqContFrame.hpp" + +namespace xo { + namespace scm { + + DVsmSeqContFrame::DVsmSeqContFrame(obj parent, + VsmInstr cont, + DSequenceExpr * seq_expr, + uint32_t i_seq) + : parent_{parent}, + cont_{cont}, + seq_expr_{seq_expr}, + i_seq_{i_seq} + {} + + DVsmSeqContFrame * + DVsmSeqContFrame::make(obj mm, + obj parent, + VsmInstr cont, + DSequenceExpr * seq_expr, + uint32_t i_seq) + { + void * mem = mm.alloc_for(); + + return new (mem) DVsmSeqContFrame(parent, cont, seq_expr, i_seq); + } + + // gcobject facet + + std::size_t + DVsmSeqContFrame::shallow_size() const noexcept + { + return sizeof(*this); + } + + DVsmSeqContFrame * + DVsmSeqContFrame::shallow_copy(obj mm) const noexcept + { + return mm.std_copy_for(this); + } + + std::size_t + DVsmSeqContFrame::forward_children(obj gc) noexcept + { + gc.forward_inplace(&parent_); + gc.forward_inplace(&seq_expr_); + + return this->shallow_size(); + } + + // printable facet + + bool + DVsmSeqContFrame::pretty(const ppindentinfo & ppii) const noexcept + { + return ppii.pps()->pretty_struct(ppii, + "DVsmSeqContFrame", + refrtag("cont", cont_), + refrtag("i_seq", i_seq_)); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmSeqContFrame.cpp */ diff --git a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp new file mode 100644 index 00000000..eecdf291 --- /dev/null +++ b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DVsmSeqContFrame.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVsmSeqContFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVsmSeqContFrame.json5] +**/ + +#include "sequence/IGCObject_DVsmSeqContFrame.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DVsmSeqContFrame::shallow_size(const DVsmSeqContFrame & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DVsmSeqContFrame::shallow_copy(const DVsmSeqContFrame & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DVsmSeqContFrame::forward_children(DVsmSeqContFrame & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVsmSeqContFrame.cpp */ diff --git a/src/interpreter2/IPrintable_DVsmSeqContFrame.cpp b/src/interpreter2/IPrintable_DVsmSeqContFrame.cpp new file mode 100644 index 00000000..74801873 --- /dev/null +++ b/src/interpreter2/IPrintable_DVsmSeqContFrame.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DVsmSeqContFrame.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVsmSeqContFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVsmSeqContFrame.json5] +**/ + +#include "sequence/IPrintable_DVsmSeqContFrame.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DVsmSeqContFrame::pretty(const DVsmSeqContFrame & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DVsmSeqContFrame.cpp */ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 8ff78ae0..9408c966 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -7,11 +7,13 @@ #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" #include "VsmApplyClosureFrame.hpp" +#include "VsmSeqContFrame.hpp" #include "VsmRcx.hpp" #include "Closure.hpp" #include #include #include +#include #include //#include #include @@ -188,6 +190,9 @@ namespace xo { case vsm_opcode::applycoda: _do_applycoda_op(); break; + case vsm_opcode::seq_cont: + _do_seq_cont_op(); + break; } return true; @@ -328,7 +333,7 @@ namespace xo { auto apply = obj::from(expr_); - // evaluated arguments + // accumulate evaluated arguments here DArray * args = DArray::empty(mm_.to_op(), apply->n_args()); @@ -361,8 +366,42 @@ namespace xo { void VirtualSchematikaMachine::_do_eval_sequence_op() { - // not implemented - assert(false); + // assuming bump allocator: + // + // VsmEvalSequence + // v + // +-------+------+-------+-------+ + // | par x | cont | seq | i_elt | + // +-----|-+------+-------+-------+ + // | + // <-----/ + // + + auto seq_expr = obj::from(expr_); + + if (seq_expr->size() == 0) { + /* empty sequence expression does not produce a value */ + + this->value_ = VsmResult(obj()); + this->pc_ = this->cont_; + return; + } + + auto seqexpr_frame + = obj + (DVsmSeqContFrame::make(mm_.to_op(), + this->stack_ /*saved stack*/, + this->cont_ /*saved cont*/, + seq_expr.data() /*saved expr*/, + 0 /*index of seq element*/)); + + this->stack_ = seqexpr_frame; + + // Setup evaluation of first sequence element + + this->cont_ = VsmInstr::c_seq_cont; + this->expr_ = (*seq_expr.data())[0]; + this->pc_ = VsmInstr::c_eval; } void @@ -380,7 +419,7 @@ namespace xo { _do_call_closure_op(); return; } else { - _do_call_closure_op(); + _do_call_primitive_op(); return; } } @@ -393,6 +432,8 @@ namespace xo { auto closure = obj::from(fn_); + assert(closure); + // TODO: for tail recursion: // check whether stack_ already refers to a // DVsmApplyClosureFrame instance, in which case @@ -496,8 +537,8 @@ namespace xo { = evalargs_frame->apply_expr(); if (i_arg == -1) { - bool is_native_fn = value.to_facet(); bool is_closure = obj::from(value); + bool is_native_fn = value.try_to_facet(); if (is_native_fn || is_closure) { apply_frame->assign_fn(value); @@ -572,6 +613,39 @@ namespace xo { // not implemented assert(false); } + + void + VirtualSchematikaMachine::_do_seq_cont_op() + { + auto frame = obj::from(stack_); + + assert(frame); + + uint32_t i_seq = 1 + frame->i_seq(); + + auto seq_expr = frame->seq_expr(); + + assert(seq_expr); + + if (i_seq == seq_expr->size()) { + /* done with sequence + * value of sequence-expr is the value of the last expression in that sequence, + * which is already in the value_ register + */ + + this->stack_ = frame->parent(); + this->pc_ = frame->cont(); + return; + } else { + frame->incr_i_seq(); + + this->cont_ = VsmInstr::c_seq_cont; + this->expr_ = (*seq_expr)[i_seq]; + this->pc_ = VsmInstr::c_eval; + return; + } + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/VsmInstr.cpp b/src/interpreter2/VsmInstr.cpp index 02ac8325..640ac9fe 100644 --- a/src/interpreter2/VsmInstr.cpp +++ b/src/interpreter2/VsmInstr.cpp @@ -16,6 +16,7 @@ namespace xo { case vsm_opcode::apply: return "apply"; case vsm_opcode::evalargs: return "evalargs"; case vsm_opcode::applycoda: return "applycoda"; + case vsm_opcode::seq_cont: return "seq_cont"; case vsm_opcode::N: break; } @@ -37,6 +38,9 @@ namespace xo { VsmInstr VsmInstr::c_applycoda = VsmInstr(vsm_opcode::applycoda); + + VsmInstr + VsmInstr::c_seq_cont = VsmInstr(vsm_opcode::seq_cont); } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/interpreter2_register_facets.cpp b/src/interpreter2/interpreter2_register_facets.cpp index 1548aeaf..588419a2 100644 --- a/src/interpreter2/interpreter2_register_facets.cpp +++ b/src/interpreter2/interpreter2_register_facets.cpp @@ -9,6 +9,7 @@ #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" #include "VsmApplyClosureFrame.hpp" +#include "VsmSeqContFrame.hpp" #include "Primitive_gco_2_gco_gco.hpp" #include "Closure.hpp" #include "LocalEnv.hpp" @@ -32,10 +33,12 @@ namespace xo { { scope log(XO_DEBUG(true)); - // VsmStackFrame + + // VsmStqackFrame // +- VsmApplyFrame // +- VsmEvalArgsFrame - // \- VsmApplyClosureFrame + // +- VsmApplyClosureFrame + // \- VsmSeqContFrame FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -46,22 +49,27 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + // LocalEnv FacetRegistry::register_impl(); FacetRegistry::register_impl(); // Procedure - // +- Primitive_gco_2_gco_gco - // \- Closure + // \- Primitive_gco_2_gco_gco FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); -// FacetRegistry::register_impl(); -// FacetRegistry::register_impl(); -// FacetRegistry::register_impl(); + // Closure + +// FacetRegistry::register_impl(); // if/when provided + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + // RuntimeContext // \- VsmRcx @@ -70,6 +78,8 @@ namespace xo { log && log(xtag("DVsmApplyFrame.tseq", typeseq::id())); log && log(xtag("DVsmEvalArgsFrame.tseq", typeseq::id())); + log && log(xtag("DVsmApplyClosureFrame.tseq", typeseq::id())); + log && log(xtag("DVsmSeqContFrame.tseq", typeseq::id())); log && log(xtag("DClosure.tseq", typeseq::id())); log && log(xtag("DLocalEnv.tseq", typeseq::id())); log && log(xtag("DVsmRcx.tseq", typeseq::id())); From cc98f515bd168dee78ab29e47210cc2cabc34c91 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 13 Feb 2026 16:06:19 -0500 Subject: [PATCH 034/131] xo-interpreter2 stack: apply user-defined lambda passes utest --- .../xo/interpreter2/DVsmApplyClosureFrame.hpp | 4 +- .../interpreter2/VirtualSchematikaMachine.hpp | 2 +- include/xo/interpreter2/VsmInstr.hpp | 4 +- include/xo/interpreter2/VsmOpcode.hpp | 2 +- src/interpreter2/VirtualSchematikaMachine.cpp | 48 ++++++++++++++----- src/interpreter2/VsmInstr.cpp | 4 +- utest/VirtualSchematikaMachine.test.cpp | 5 +- 7 files changed, 48 insertions(+), 21 deletions(-) diff --git a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp index a98d5713..168fa1a3 100644 --- a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp @@ -30,11 +30,11 @@ namespace xo { /** create instance, using memory from @p mm **/ static DVsmApplyClosureFrame * make(obj mm, - obj stack, + obj parent, VsmInstr cont, DLocalEnv * env); - obj stack() const { return stack_; } + obj parent() const { return stack_; } VsmInstr cont() const { return cont_; } DLocalEnv * local_env() const { return local_env_; } diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index d7e1ec77..ce412391 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -185,7 +185,7 @@ namespace xo { * (specifically: local_env_, stack_, cont_) * after invoking a schematika closure **/ - void _do_applycoda_op(); + void _do_apply_cont_op(); /** loop continuation after evaluating element of a SequenceExpr **/ void _do_seq_cont_op(); diff --git a/include/xo/interpreter2/VsmInstr.hpp b/include/xo/interpreter2/VsmInstr.hpp index 4b51361d..d7444b86 100644 --- a/include/xo/interpreter2/VsmInstr.hpp +++ b/include/xo/interpreter2/VsmInstr.hpp @@ -18,8 +18,8 @@ namespace xo { static VsmInstr c_apply; static VsmInstr c_evalargs; - /** restore registers after calling a schematika closure **/ - static VsmInstr c_applycoda; + /** proceed to continuation after an ApplyExpr **/ + static VsmInstr c_apply_cont; /** loop to evaluate members of a SequenceExpr **/ static VsmInstr c_seq_cont; diff --git a/include/xo/interpreter2/VsmOpcode.hpp b/include/xo/interpreter2/VsmOpcode.hpp index 06b3d08b..2a277a49 100644 --- a/include/xo/interpreter2/VsmOpcode.hpp +++ b/include/xo/interpreter2/VsmOpcode.hpp @@ -31,7 +31,7 @@ namespace xo { /** Coda to restore vsm registers (local_env, stack, cont) * after invoking a closure **/ - applycoda, + apply_cont, /** Loop over elements of a SequenceExpr **/ seq_cont, diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 9408c966..d1b8eacb 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -187,8 +187,8 @@ namespace xo { case vsm_opcode::evalargs: _do_evalargs_op(); break; - case vsm_opcode::applycoda: - _do_applycoda_op(); + case vsm_opcode::apply_cont: + _do_apply_cont_op(); break; case vsm_opcode::seq_cont: _do_seq_cont_op(); @@ -302,8 +302,37 @@ namespace xo { void VirtualSchematikaMachine::_do_eval_varref_op() { - // not implemented - assert(false); + auto var = obj::from(expr_); + + Binding b = var->path(); + + if (!local_env_) { + // need lookup on global_env_ + assert(false); + } + + auto value = local_env_->lookup_value(b); + + if (value) { + this->value_ = VsmResult(value); + this->pc_ = this->cont_; + return; + } + + // no binding + + auto error = DRuntimeError::make(mm_.to_op(), + "_do_eval_varref_op", + "no binding for variable"); + this->value_ = VsmResult(error); + + // for now: halt VSM execution + // TODO: some combination of + // 1. emit stack trace + // 2. go to debugger + // 3. have every vsm instruction check inputs for errors + + this->pc_ = VsmInstr::c_halt; } void @@ -439,7 +468,7 @@ namespace xo { // DVsmApplyClosureFrame instance, in which case // we can just refer to it instead of pushing a new one - if (cont_ == VsmInstr::c_applycoda) { + if (cont_ == VsmInstr::c_apply_cont) { // we are making a tail call. // No need to preserve (stack, cont, local_env), // since continuation will restore on top of them @@ -454,7 +483,7 @@ namespace xo { // push frame w/ saved vsm registers this->stack_ = frame; - this->cont_ = VsmInstr::c_applycoda; + this->cont_ = VsmInstr::c_apply_cont; } auto lambda = closure->lambda(); @@ -598,7 +627,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_applycoda_op() + VirtualSchematikaMachine::_do_apply_cont_op() { // see DVsmApplyClosureFrame @@ -606,12 +635,9 @@ namespace xo { assert(frame); - this->stack_ = frame->stack(); + this->stack_ = frame->parent(); this->local_env_ = frame->local_env(); this->pc_ = frame->cont(); - - // not implemented - assert(false); } void diff --git a/src/interpreter2/VsmInstr.cpp b/src/interpreter2/VsmInstr.cpp index 640ac9fe..d1923cbd 100644 --- a/src/interpreter2/VsmInstr.cpp +++ b/src/interpreter2/VsmInstr.cpp @@ -15,7 +15,7 @@ namespace xo { case vsm_opcode::eval: return "eval"; case vsm_opcode::apply: return "apply"; case vsm_opcode::evalargs: return "evalargs"; - case vsm_opcode::applycoda: return "applycoda"; + case vsm_opcode::apply_cont: return "apply_cont"; case vsm_opcode::seq_cont: return "seq_cont"; case vsm_opcode::N: break; @@ -37,7 +37,7 @@ namespace xo { VsmInstr::c_evalargs = VsmInstr(vsm_opcode::evalargs); VsmInstr - VsmInstr::c_applycoda = VsmInstr(vsm_opcode::applycoda); + VsmInstr::c_apply_cont = VsmInstr(vsm_opcode::apply_cont); VsmInstr VsmInstr::c_seq_cont = VsmInstr(vsm_opcode::seq_cont); diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 22b50194..bd456b9d 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -246,11 +246,12 @@ namespace xo { log && log(xtag("res.tseq", res.value()->_typeseq())); // currently get not-implemented error - auto x = obj::from(*res.value()); + auto x = obj::from(*res.value()); REQUIRE(x); + REQUIRE(x->value() == 195); - log && log("runtime-error", xtag("ex.src", x->src_function()), xtag("ex.descr", x->error_descr())); + //log && log("runtime-error", xtag("ex.src", x->src_function()), xtag("ex.descr", x->error_descr())); //REQUIRE(x.data()->value() == 1.570796325); From eee8de1daba071d1ffc50076e1574f9559788af1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 13 Feb 2026 17:24:23 -0500 Subject: [PATCH 035/131] xo-reader2 stack: handle comparison expression (x == y) --- utest/VirtualSchematikaMachine.test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index bd456b9d..6b4f9cf8 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -227,7 +227,7 @@ namespace xo { TEST_CASE("VirtualSchematikaMachine-apply2", "[interpreter2][VSM]") { - scope log(XO_DEBUG(true)); + scope log(XO_DEBUG(false)); VsmConfig cfg; VirtualSchematikaMachine vsm(cfg); @@ -269,6 +269,7 @@ namespace xo { FacetRegistry::instance().visit_pools(visitor); vsm.visit_pools(visitor); } + } /*namespace ut*/ } /*namespace xo*/ From f5ed33bce3c66c96345430a80e40e12164d3035b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 13 Feb 2026 18:22:19 -0500 Subject: [PATCH 036/131] xo-interpreter2: utest: + VirtualSchematikaMachine-cmp1 --- utest/VirtualSchematikaMachine.test.cpp | 45 ++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 6b4f9cf8..90f18551 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #ifdef NOT_YET @@ -30,6 +31,7 @@ namespace xo { using xo::scm::VsmResultExt; using xo::scm::DClosure; using xo::scm::DFloat; + using xo::scm::DBoolean; using xo::scm::DInteger; using xo::scm::DRuntimeError; using xo::mm::AGCObject; @@ -188,9 +190,50 @@ namespace xo { vsm.visit_pools(visitor); } + TEST_CASE("VirtualSchematikaMachine-cmp1", "[interpreter2][VSM]") + { + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + scope log(XO_DEBUG(true), xtag("test", testname)); + + VsmConfig cfg; + VirtualSchematikaMachine vsm(cfg); + + bool eof_flag = false; + + vsm.begin_interactive_session(); + VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("123 == 123;"), eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq())); + + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(x.data()->value() == true); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + + auto visitor = [&log](const MemorySizeInfo & info) { + log && log(xtag("resource", info.resource_name_), + xtag("used", info.used_), + xtag("alloc", info.allocated_), + xtag("commit", info.committed_), + xtag("resv", info.reserved_)); + }; + + FacetRegistry::instance().visit_pools(visitor); + vsm.visit_pools(visitor); + } + TEST_CASE("VirtualSchematikaMachine-lambda1", "[interpreter2][VSM]") { - scope log(XO_DEBUG(true)); + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + scope log(XO_DEBUG(false), xtag("test", testname)); VsmConfig cfg; VirtualSchematikaMachine vsm(cfg); From 5060a6a7160825c543b35aa6bda84bd42ce3624c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 13 Feb 2026 18:23:43 -0500 Subject: [PATCH 037/131] xo-interpreter2: utest: log test names --- utest/VirtualSchematikaMachine.test.cpp | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 90f18551..7c31d645 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -64,7 +64,9 @@ namespace xo { namespace ut { TEST_CASE("VirtualSchematikaMachine-ctor", "[interpreter2][VSM]") { - scope log(XO_DEBUG(true)); + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + scope log(XO_DEBUG(true), xtag("test", testname)); VsmConfig cfg; VirtualSchematikaMachine vsm(cfg); @@ -83,7 +85,9 @@ namespace xo { TEST_CASE("VirtualSchematikaMachine-const1", "[interpreter2][VSM]") { - scope log(XO_DEBUG(true)); + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + scope log(XO_DEBUG(true), xtag("test", testname)); VsmConfig cfg; VirtualSchematikaMachine vsm(cfg); @@ -118,7 +122,9 @@ namespace xo { TEST_CASE("VirtualSchematikaMachine-const2", "[interpreter2][VSM]") { - scope log(XO_DEBUG(true)); + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + scope log(XO_DEBUG(true), xtag("test", testname)); VsmConfig cfg; VirtualSchematikaMachine vsm(cfg); @@ -155,7 +161,9 @@ namespace xo { TEST_CASE("VirtualSchematikaMachine-arith1", "[interpreter2][VSM]") { - scope log(XO_DEBUG(true)); + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + scope log(XO_DEBUG(true), xtag("test", testname)); VsmConfig cfg; VirtualSchematikaMachine vsm(cfg); @@ -270,7 +278,9 @@ namespace xo { TEST_CASE("VirtualSchematikaMachine-apply2", "[interpreter2][VSM]") { - scope log(XO_DEBUG(false)); + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + scope log(XO_DEBUG(false), xtag("test", testname)); VsmConfig cfg; VirtualSchematikaMachine vsm(cfg); From f5afee2f5486d8611db04b26ae9db6021fb4560e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 13 Feb 2026 20:46:53 -0500 Subject: [PATCH 038/131] xo-interpreter2: work on global symtab [WIP] --- include/xo/interpreter2/DGlobalEnv.hpp | 25 +++++++++++--- utest/VirtualSchematikaMachine.test.cpp | 46 +++++++++++++++++++++++-- 2 files changed, 65 insertions(+), 6 deletions(-) diff --git a/include/xo/interpreter2/DGlobalEnv.hpp b/include/xo/interpreter2/DGlobalEnv.hpp index e9f1a9c8..60fbe461 100644 --- a/include/xo/interpreter2/DGlobalEnv.hpp +++ b/include/xo/interpreter2/DGlobalEnv.hpp @@ -6,26 +6,43 @@ #pragma once #include -#include #include namespace xo { namespace scm { - /** @brief runtime bindings for global variabels + * + * Implementation here uses a DArenaHashMap to hold pairs. + * The hash map has its own memory outside GC space. + * Keys are DUniqueStrings, also outside GC space. + * Values are regular gc-aware objects, generally will be in GC space. + * + * We need collector to traverse all the values in a global env + * on each cycle. Arrange that by having DGlobalEnv itself + * in GC space. + * **/ class DGlobalEnv { + public: + using MemorySizeVisitor = xo::mm::MemorySizeVisitor; + public: DGlobalEnv() = default; + /** visit env-owned memory pools; call visitor(info) for each **/ + void visit_pools(const MemorySizeVisitor & visitor) const; + protected: // temporary, to appease compiler // absurd O(n) implementation for now // replace with gc-aware hashtable, when available. - /** globals. Slots in @ref global_v_ are numbered in DLocalSymtab **/ - DArray * global_v_ = nullptr; + /** symbol table assigns a unique index for each symbol **/ + DGlobalSymtab * symtab_; + + /** value for a symbol S will be in values_[symtab->lookup_binding(S)] **/ + DArray * values_ = nullptr; }; } } diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 7c31d645..960c1771 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -202,7 +202,8 @@ namespace xo { { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - scope log(XO_DEBUG(true), xtag("test", testname)); + constexpr bool c_debug_flag = false; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); VsmConfig cfg; VirtualSchematikaMachine vsm(cfg); @@ -237,11 +238,52 @@ namespace xo { vsm.visit_pools(visitor); } + TEST_CASE("VirtualSchematikaMachine-if", "[interpreter2][VSM]") + { + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + constexpr bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + + VsmConfig cfg; + VirtualSchematikaMachine vsm(cfg); + + bool eof_flag = false; + + vsm.begin_interactive_session(); + VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("if 123 == 123 then \"equal\" else \"notequal\";"), eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq())); + + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(x.data()->value() == true); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + + auto visitor = [&log](const MemorySizeInfo & info) { + log && log(xtag("resource", info.resource_name_), + xtag("used", info.used_), + xtag("alloc", info.allocated_), + xtag("commit", info.committed_), + xtag("resv", info.reserved_)); + }; + + FacetRegistry::instance().visit_pools(visitor); + vsm.visit_pools(visitor); + } + TEST_CASE("VirtualSchematikaMachine-lambda1", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - scope log(XO_DEBUG(false), xtag("test", testname)); + constexpr bool c_debug_flag = false; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); VsmConfig cfg; VirtualSchematikaMachine vsm(cfg); From 8ff02d52c1036aaa1018db14430039e33a90070b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 14 Feb 2026 11:15:38 -0500 Subject: [PATCH 039/131] xo-interpreter2: ifelse expressions working + utest --- CMakeLists.txt | 26 ++++++ idl/IGCObject_DVsmIfElseContFrame.json5 | 15 ++++ idl/IPrintable_DVsmIfElseContFrame.json5 | 13 +++ .../xo/interpreter2/DVsmIfElseContFrame.hpp | 82 +++++++++++++++++++ .../interpreter2/VirtualSchematikaMachine.hpp | 5 ++ .../xo/interpreter2/VsmIfElseContFrame.hpp | 12 +++ include/xo/interpreter2/VsmInstr.hpp | 9 +- include/xo/interpreter2/VsmOpcode.hpp | 6 +- .../ifelse/IGCObject_DVsmIfElseContFrame.hpp | 67 +++++++++++++++ .../ifelse/IPrintable_DVsmIfElseContFrame.hpp | 62 ++++++++++++++ src/interpreter2/CMakeLists.txt | 4 + src/interpreter2/DVsmIfElseContFrame.cpp | 66 +++++++++++++++ .../IGCObject_DVsmIfElseContFrame.cpp | 39 +++++++++ .../IPrintable_DVsmIfElseContFrame.cpp | 28 +++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 67 ++++++++++++++- src/interpreter2/VsmInstr.cpp | 4 + .../interpreter2_register_facets.cpp | 5 ++ utest/VirtualSchematikaMachine.test.cpp | 5 +- 18 files changed, 508 insertions(+), 7 deletions(-) create mode 100644 idl/IGCObject_DVsmIfElseContFrame.json5 create mode 100644 idl/IPrintable_DVsmIfElseContFrame.json5 create mode 100644 include/xo/interpreter2/DVsmIfElseContFrame.hpp create mode 100644 include/xo/interpreter2/VsmIfElseContFrame.hpp create mode 100644 include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp create mode 100644 include/xo/interpreter2/ifelse/IPrintable_DVsmIfElseContFrame.hpp create mode 100644 src/interpreter2/DVsmIfElseContFrame.cpp create mode 100644 src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp create mode 100644 src/interpreter2/IPrintable_DVsmIfElseContFrame.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 26124a21..0b5431ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -103,6 +103,32 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-gcobject-vsmifelsecontframe + FACET_PKG xo_gc + FACET GCObject + REPR VsmIfElseContFrame + INPUT idl/IGCObject_DVsmIfElseContFrame.json5 + OUTPUT_HPP_DIR include/xo/interpreter2 + OUTPUT_IMPL_SUBDIR ifelse + OUTPUT_CPP_DIR src/interpreter2 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-printable-vsmifelsecontframe + FACET_PKG xo_printable2 + FACET Printable + REPR VsmIfElseContFrame + INPUT idl/IPrintable_DVsmIfElseContFrame.json5 + OUTPUT_HPP_DIR include/xo/interpreter2 + OUTPUT_IMPL_SUBDIR ifelse + OUTPUT_CPP_DIR src/interpreter2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmseqcontframe diff --git a/idl/IGCObject_DVsmIfElseContFrame.json5 b/idl/IGCObject_DVsmIfElseContFrame.json5 new file mode 100644 index 00000000..0f78bb6d --- /dev/null +++ b/idl/IGCObject_DVsmIfElseContFrame.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DVsmIfElseContFrame", + using_doxygen: true, + repr: "DVsmIfElseContFrame", + doc: [ "implement AGCObject for DVsmIfElseContFrame" ], +} diff --git a/idl/IPrintable_DVsmIfElseContFrame.json5 b/idl/IPrintable_DVsmIfElseContFrame.json5 new file mode 100644 index 00000000..d3d63c4d --- /dev/null +++ b/idl/IPrintable_DVsmIfElseContFrame.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DVsmIfElseContFrame", + using_doxygen: true, + repr: "DVsmIfElseContFrame", + doc: [ "implement APrintable for DVsmIfElseContFrame" ], +} diff --git a/include/xo/interpreter2/DVsmIfElseContFrame.hpp b/include/xo/interpreter2/DVsmIfElseContFrame.hpp new file mode 100644 index 00000000..3d4ace12 --- /dev/null +++ b/include/xo/interpreter2/DVsmIfElseContFrame.hpp @@ -0,0 +1,82 @@ +/** @file DVsmIfElseContFrame.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "VsmInstr.hpp" +#include +#include + +namespace xo { + namespace scm { + /** @brief saved VSM state during evaluation of a SequenceExpr + **/ + class DVsmIfElseContFrame { + public: + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; + using ppindentinfo = xo::print::ppindentinfo; + + public: + /** @defgroup scm-vsmevalsequenceframe-ctors constructors **/ + ///@{ + + DVsmIfElseContFrame(obj parent, + VsmInstr cont, + DIfElseExpr * ifelse_expr); + + /** create instance using memory from allocator @p mm **/ + static DVsmIfElseContFrame * make(obj mm, + obj parent, + VsmInstr cont, + DIfElseExpr * ifelse_expr); + + ///@} + /** @defgroup scm-vsmevalsequenceframe-access-methods access methods **/ + ///@{ + + obj parent() const noexcept { return parent_; } + VsmInstr cont() const noexcept { return cont_; } + DIfElseExpr * ifelse_expr() const noexcept { return ifelse_expr_; } + + ///@} + /** @defgroup scm-vsmevalsequenceframe-general-methods general methods **/ + ///@{ + + ///@} + /** @defgroup scm-vsmevalsequenceframe-gcobject-facet gcobject facet **/ + ///@{ + + std::size_t shallow_size() const noexcept; + DVsmIfElseContFrame * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + + ///@} + /** @defgrouop scm-vsmseqcontframe-printable-facet printable facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const noexcept; + + ///@} + + private: + /** @defgroup scm-vsmevalsequenceframe-members member variables **/ + ///@{ + + /** saved VSM stack; restore when this frame consumed **/ + obj parent_; + /** saved continuation; restore when this frame consumed **/ + VsmInstr cont_; + /** saved expr. evaluate elements of this sequence in order **/ + DIfElseExpr * ifelse_expr_ = nullptr; + + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmIfElseContFrame.hpp */ diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index ce412391..b809a09d 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -187,6 +187,11 @@ namespace xo { **/ void _do_apply_cont_op(); + /** proceed with if- or else- branch of an if-else expression + * after evaluating test condition + **/ + void _do_ifelse_cont_op(); + /** loop continuation after evaluating element of a SequenceExpr **/ void _do_seq_cont_op(); diff --git a/include/xo/interpreter2/VsmIfElseContFrame.hpp b/include/xo/interpreter2/VsmIfElseContFrame.hpp new file mode 100644 index 00000000..a0494ddf --- /dev/null +++ b/include/xo/interpreter2/VsmIfElseContFrame.hpp @@ -0,0 +1,12 @@ +/** @file VsmIfElseContFrame.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DVsmIfElseContFrame.hpp" +#include "ifelse/IGCObject_DVsmIfElseContFrame.hpp" +#include "ifelse/IPrintable_DVsmIfElseContFrame.hpp" + +/* end VsmIfElseContFrame.hpp */ diff --git a/include/xo/interpreter2/VsmInstr.hpp b/include/xo/interpreter2/VsmInstr.hpp index d7444b86..1279f8b7 100644 --- a/include/xo/interpreter2/VsmInstr.hpp +++ b/include/xo/interpreter2/VsmInstr.hpp @@ -13,14 +13,21 @@ namespace xo { public: explicit VsmInstr(vsm_opcode oc) : opcode_{oc} {} + // instructions + static VsmInstr c_halt; static VsmInstr c_eval; static VsmInstr c_apply; static VsmInstr c_evalargs; - /** proceed to continuation after an ApplyExpr **/ + /** restore VSM state for continuation of an apply expression **/ static VsmInstr c_apply_cont; + /** proceed to branch of if-else expression after evaluating + * test condition + **/ + static VsmInstr c_ifelse_cont; + /** loop to evaluate members of a SequenceExpr **/ static VsmInstr c_seq_cont; diff --git a/include/xo/interpreter2/VsmOpcode.hpp b/include/xo/interpreter2/VsmOpcode.hpp index 2a277a49..e1000cb3 100644 --- a/include/xo/interpreter2/VsmOpcode.hpp +++ b/include/xo/interpreter2/VsmOpcode.hpp @@ -28,11 +28,14 @@ namespace xo { **/ evalargs, - /** Coda to restore vsm registers (local_env, stack, cont) + /** continuation to restore vsm registers (local_env, stack, cont) * after invoking a closure **/ apply_cont, + /** continuation to act on a branch **/ + ifelse_cont, + /** Loop over elements of a SequenceExpr **/ seq_cont, @@ -55,3 +58,4 @@ namespace xo { } /*namespace xo*/ /* end VsmOpcode.hpp */ + diff --git a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp new file mode 100644 index 00000000..293dd70d --- /dev/null +++ b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DVsmIfElseContFrame.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVsmIfElseContFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVsmIfElseContFrame.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DVsmIfElseContFrame.hpp" + +namespace xo { namespace scm { class IGCObject_DVsmIfElseContFrame; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DVsmIfElseContFrame + **/ + class IGCObject_DVsmIfElseContFrame { + public: + /** @defgroup scm-gcobject-dvsmifelsecontframe-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-dvsmifelsecontframe-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DVsmIfElseContFrame & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DVsmIfElseContFrame & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DVsmIfElseContFrame & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/ifelse/IPrintable_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IPrintable_DVsmIfElseContFrame.hpp new file mode 100644 index 00000000..5f0e5a7b --- /dev/null +++ b/include/xo/interpreter2/ifelse/IPrintable_DVsmIfElseContFrame.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DVsmIfElseContFrame.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVsmIfElseContFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVsmIfElseContFrame.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DVsmIfElseContFrame.hpp" + +namespace xo { namespace scm { class IPrintable_DVsmIfElseContFrame; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DVsmIfElseContFrame + **/ + class IPrintable_DVsmIfElseContFrame { + public: + /** @defgroup scm-printable-dvsmifelsecontframe-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dvsmifelsecontframe-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DVsmIfElseContFrame & 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 64e7dfe8..c21821e1 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -20,6 +20,10 @@ set(SELF_SRCS IGCObject_DVsmApplyClosureFrame.cpp IPrintable_DVsmApplyClosureFrame.cpp + DVsmIfElseContFrame.cpp + IGCObject_DVsmIfElseContFrame.cpp + IPrintable_DVsmIfElseContFrame.cpp + DVsmSeqContFrame.cpp IGCObject_DVsmSeqContFrame.cpp IPrintable_DVsmSeqContFrame.cpp diff --git a/src/interpreter2/DVsmIfElseContFrame.cpp b/src/interpreter2/DVsmIfElseContFrame.cpp new file mode 100644 index 00000000..f47419e0 --- /dev/null +++ b/src/interpreter2/DVsmIfElseContFrame.cpp @@ -0,0 +1,66 @@ +/** @file DVsmIfElseContFrame.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DVsmIfElseContFrame.hpp" + +namespace xo { + namespace scm { + + DVsmIfElseContFrame::DVsmIfElseContFrame(obj parent, + VsmInstr cont, + DIfElseExpr * ifelse_expr) + : parent_{parent}, + cont_{cont}, + ifelse_expr_{ifelse_expr} + {} + + DVsmIfElseContFrame * + DVsmIfElseContFrame::make(obj mm, + obj parent, + VsmInstr cont, + DIfElseExpr * seq_expr) + { + void * mem = mm.alloc_for(); + + return new (mem) DVsmIfElseContFrame(parent, cont, seq_expr); + } + + // gcobject facet + + std::size_t + DVsmIfElseContFrame::shallow_size() const noexcept + { + return sizeof(*this); + } + + DVsmIfElseContFrame * + DVsmIfElseContFrame::shallow_copy(obj mm) const noexcept + { + return mm.std_copy_for(this); + } + + std::size_t + DVsmIfElseContFrame::forward_children(obj gc) noexcept + { + gc.forward_inplace(&parent_); + gc.forward_inplace(&ifelse_expr_); + + return this->shallow_size(); + } + + // printable facet + + bool + DVsmIfElseContFrame::pretty(const ppindentinfo & ppii) const noexcept + { + return ppii.pps()->pretty_struct(ppii, + "DVsmIfElseContFrame", + refrtag("cont", cont_)); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmIfElseContFrame.cpp */ diff --git a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp new file mode 100644 index 00000000..ba66cd8d --- /dev/null +++ b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DVsmIfElseContFrame.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVsmIfElseContFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVsmIfElseContFrame.json5] +**/ + +#include "ifelse/IGCObject_DVsmIfElseContFrame.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DVsmIfElseContFrame::shallow_size(const DVsmIfElseContFrame & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DVsmIfElseContFrame::shallow_copy(const DVsmIfElseContFrame & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DVsmIfElseContFrame::forward_children(DVsmIfElseContFrame & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVsmIfElseContFrame.cpp */ diff --git a/src/interpreter2/IPrintable_DVsmIfElseContFrame.cpp b/src/interpreter2/IPrintable_DVsmIfElseContFrame.cpp new file mode 100644 index 00000000..e8afc908 --- /dev/null +++ b/src/interpreter2/IPrintable_DVsmIfElseContFrame.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DVsmIfElseContFrame.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVsmIfElseContFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVsmIfElseContFrame.json5] +**/ + +#include "ifelse/IPrintable_DVsmIfElseContFrame.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DVsmIfElseContFrame::pretty(const DVsmIfElseContFrame & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DVsmIfElseContFrame.cpp */ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index d1b8eacb..f3473681 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -7,6 +7,7 @@ #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" #include "VsmApplyClosureFrame.hpp" +#include "VsmIfElseContFrame.hpp" #include "VsmSeqContFrame.hpp" #include "VsmRcx.hpp" #include "Closure.hpp" @@ -14,6 +15,7 @@ #include #include #include +#include #include //#include #include @@ -190,6 +192,9 @@ namespace xo { case vsm_opcode::apply_cont: _do_apply_cont_op(); break; + case vsm_opcode::ifelse_cont: + _do_ifelse_cont_op(); + break; case vsm_opcode::seq_cont: _do_seq_cont_op(); break; @@ -388,14 +393,26 @@ namespace xo { void VirtualSchematikaMachine::_do_eval_if_else_op() { - // not implemented - assert(false); + // control: + // self -> eval(test) -> ifelse_cont -> eval(when_true) + // -> eval(when_false) + + auto ifelse_expr = obj::from(expr_); + + obj ifelse_frame + (DVsmIfElseContFrame::make(mm_.to_op(), + stack_, cont_, ifelse_expr.data())); + + this->stack_ = ifelse_frame; + this->cont_ = VsmInstr::c_ifelse_cont; + this->expr_ = ifelse_expr->test(); + this->pc_ = VsmInstr::c_eval; } void VirtualSchematikaMachine::_do_eval_sequence_op() { - // assuming bump allocator: + // stack: // // VsmEvalSequence // v @@ -640,6 +657,50 @@ namespace xo { this->pc_ = frame->cont(); } + void + VirtualSchematikaMachine::_do_ifelse_cont_op() + { + // pre: result of evaluating test condition in value_ register + + auto frame = obj::from(stack_); + + assert(frame); + assert(value_.is_value()); + + auto flag = obj::from(*value_.value()); + + if (flag.data()) { + obj next_expr; + { + if (flag->value()) { + // proceed with if-branch + next_expr = frame->ifelse_expr()->when_true(); + } else { + // proceed with else-branch + next_expr = frame->ifelse_expr()->when_false(); + } + } + + this->stack_ = frame->parent(); + this->cont_ = frame->cont(); + this->expr_ = next_expr; + this->pc_ = VsmInstr::c_eval; + } else { + auto error = DRuntimeError::make(mm_.to_op(), + "_do_ifelse_cont_op", + "expected boolean for test condition"); + this->value_ = VsmResult(error); + + // for now: halt VSM execution + // TODO: some combination of + // 1. emit stack trace + // 2. go to debugger + // 3. have every vsm instruction check inputs for errors + + this->pc_ = VsmInstr::c_halt; + } + } + void VirtualSchematikaMachine::_do_seq_cont_op() { diff --git a/src/interpreter2/VsmInstr.cpp b/src/interpreter2/VsmInstr.cpp index d1923cbd..b815c079 100644 --- a/src/interpreter2/VsmInstr.cpp +++ b/src/interpreter2/VsmInstr.cpp @@ -16,6 +16,7 @@ namespace xo { case vsm_opcode::apply: return "apply"; case vsm_opcode::evalargs: return "evalargs"; case vsm_opcode::apply_cont: return "apply_cont"; + case vsm_opcode::ifelse_cont: return "ifelse_cont"; case vsm_opcode::seq_cont: return "seq_cont"; case vsm_opcode::N: break; @@ -39,6 +40,9 @@ namespace xo { VsmInstr VsmInstr::c_apply_cont = VsmInstr(vsm_opcode::apply_cont); + VsmInstr + VsmInstr::c_ifelse_cont = VsmInstr(vsm_opcode::ifelse_cont); + VsmInstr VsmInstr::c_seq_cont = VsmInstr(vsm_opcode::seq_cont); } /*namespace scm*/ diff --git a/src/interpreter2/interpreter2_register_facets.cpp b/src/interpreter2/interpreter2_register_facets.cpp index 588419a2..dc9b31be 100644 --- a/src/interpreter2/interpreter2_register_facets.cpp +++ b/src/interpreter2/interpreter2_register_facets.cpp @@ -9,6 +9,7 @@ #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" #include "VsmApplyClosureFrame.hpp" +#include "VsmIfElseContFrame.hpp" #include "VsmSeqContFrame.hpp" #include "Primitive_gco_2_gco_gco.hpp" #include "Closure.hpp" @@ -38,6 +39,7 @@ namespace xo { // +- VsmApplyFrame // +- VsmEvalArgsFrame // +- VsmApplyClosureFrame + // +- VsmIfElseContFrame // \- VsmSeqContFrame FacetRegistry::register_impl(); @@ -49,6 +51,9 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 960c1771..eb62267e 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -30,6 +30,7 @@ namespace xo { using xo::scm::VsmConfig; using xo::scm::VsmResultExt; using xo::scm::DClosure; + using xo::scm::DString; using xo::scm::DFloat; using xo::scm::DBoolean; using xo::scm::DInteger; @@ -258,10 +259,10 @@ namespace xo { log && log(xtag("res.tseq", res.value()->_typeseq())); - auto x = obj::from(*res.value()); + auto x = obj::from(*res.value()); REQUIRE(x); - REQUIRE(x.data()->value() == true); + REQUIRE(strcmp(x.data()->chars(), "equal") == 0); REQUIRE(res.remaining_.size() == 1); REQUIRE(*res.remaining_.lo() == '\n'); From 2191eec0f867138d46147d312fef50f032dca550 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 15 Feb 2026 14:13:38 -0500 Subject: [PATCH 040/131] xo-interpreter2 stack: plumbing for aux_mm and use opportunistically --- .../interpreter2/VirtualSchematikaMachine.hpp | 22 +- include/xo/interpreter2/VsmConfig.hpp | 15 +- src/interpreter2/VirtualSchematikaMachine.cpp | 26 +-- utest/VirtualSchematikaMachine.test.cpp | 211 ++++++++---------- 4 files changed, 133 insertions(+), 141 deletions(-) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index b809a09d..2cbd08e4 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include namespace xo { namespace scm { @@ -74,7 +74,12 @@ namespace xo { using span_type = xo::mm::span; public: - VirtualSchematikaMachine(const VsmConfig & config); + /** @p config. configuration + * @p aux_mm. Allocator for miscellaneous dataN + * owned by this VSM. + **/ + VirtualSchematikaMachine(const VsmConfig & config, + obj aux_mm); /** allocator for schematika data **/ obj allocator() const noexcept; @@ -213,10 +218,17 @@ namespace xo { /** configuration **/ VsmConfig config_; +#ifdef NOT_YET + /** allocator (likely DArena) for globals. + * For example DArenaHashMap in global symtab, + **/ + obj aux_mm_; +#endif + /** allocator (likely DX1Collector or similar) for * expressions and values **/ - box mm_; + abox mm_; /** Sidecar allocator for error reporting. * Separate to mitigate interference with @ref mm_ @@ -224,12 +236,12 @@ namespace xo { * an out-of-memory error). * Likely DArena or similar **/ - box error_mm_; + abox error_mm_; /** runtime context for this vsm. * For example, provides allocator to primitives **/ - box rcx_; + abox rcx_; // consider separate allocator (which _may_ turn out to be the same) // for VM stack. Only works for code that doesn't rely on fancy diff --git a/include/xo/interpreter2/VsmConfig.hpp b/include/xo/interpreter2/VsmConfig.hpp index f05ac449..bfbe152e 100644 --- a/include/xo/interpreter2/VsmConfig.hpp +++ b/include/xo/interpreter2/VsmConfig.hpp @@ -19,15 +19,28 @@ namespace xo { VsmConfig() = default; + VsmConfig with_debug_flag(bool x) const { + VsmConfig retval = *this; + retval.debug_flag_ = x; + return retval; + } + /** true for interactive parser session; false for batch session **/ bool interactive_flag_ = true; + /** true to enable logging **/ + bool debug_flag_ = false; + /** reader configuration **/ ReaderConfig rdr_config_; /** Configuration for allocator/collector. * TODO: may want to make CollectorConfig polymorphic **/ - X1CollectorConfig x1_config_ = X1CollectorConfig().with_size(4*1024*1024); + X1CollectorConfig x1_config_ = X1CollectorConfig().with_name("gc").with_size(4*1024*1024); + /** Configuration for handful of non-moveable high-level objects + * e.g. DArenaHashMap in global symtab + **/ + ArenaConfig fixed_config_ = ArenaConfig().with_name("fixed").with_size(4*1024); /** Configuration for error allocator * TODO: may want to make ArenaConfig polymorphic **/ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index f3473681..5c2d2c57 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -54,16 +54,16 @@ namespace xo { // NOTE: using heap here for {DX1Collector, DArena, DVsmRcx} instances // (though DX1Collector allocations will be from explictly mmap'd memory) // - VirtualSchematikaMachine::VirtualSchematikaMachine(const VsmConfig & config) + VirtualSchematikaMachine::VirtualSchematikaMachine(const VsmConfig & config, + obj aux_mm) : config_{config}, - mm_(box(new DX1Collector(config.x1_config_))), - rcx_(box(new DVsmRcx(this))), - reader_{config.rdr_config_, mm_.to_op()} + mm_(abox::make(aux_mm, config.x1_config_)), + rcx_(abox::make(aux_mm, this)), + reader_{config.rdr_config_, mm_.to_op(), aux_mm} { { - DArena * arena = new DArena(); + DArena * arena = new DArena(config_.error_config_); assert(arena); - *arena = DArena::map(config_.error_config_); error_mm_.adopt(obj(arena)); } @@ -165,7 +165,7 @@ namespace xo { bool VirtualSchematikaMachine::execute_one() { - scope log(XO_DEBUG(true)); + scope log(XO_DEBUG(config_.debug_flag_)); log && log(xtag("pc", pc_), xtag("cont", cont_)); @@ -333,10 +333,10 @@ namespace xo { // for now: halt VSM execution // TODO: some combination of - // 1. emit stack trace + // 1. emit stack trace // 2. go to debugger // 3. have every vsm instruction check inputs for errors - + this->pc_ = VsmInstr::c_halt; } @@ -396,7 +396,7 @@ namespace xo { // control: // self -> eval(test) -> ifelse_cont -> eval(when_true) // -> eval(when_false) - + auto ifelse_expr = obj::from(expr_); obj ifelse_frame @@ -433,7 +433,7 @@ namespace xo { return; } - auto seqexpr_frame + auto seqexpr_frame = obj (DVsmSeqContFrame::make(mm_.to_op(), this->stack_ /*saved stack*/, @@ -693,10 +693,10 @@ namespace xo { // for now: halt VSM execution // TODO: some combination of - // 1. emit stack trace + // 1. emit stack trace // 2. go to debugger // 3. have every vsm instruction check inputs for errors - + this->pc_ = VsmInstr::c_halt; } } diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index eb62267e..1a50c555 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #ifdef NOT_YET #include @@ -37,61 +38,80 @@ namespace xo { using xo::scm::DRuntimeError; using xo::mm::AGCObject; using xo::mm::MemorySizeInfo; + using xo::mm::AAllocator; + using xo::mm::DArena; + using xo::mm::ArenaConfig; using xo::facet::FacetRegistry; using span_type = xo::scm::VirtualSchematikaMachine::span_type; using Catch::Matchers::WithinAbs; -#ifdef NOT_YET - using xo::scm::SchematikaParser; - using xo::scm::ASyntaxStateMachine; - using xo::scm::syntaxstatetype; -// using xo::scm::DDefineSsm; - using xo::scm::DExpectExprSsm; -// using xo::scm::defexprstatetype; - //using xo::scm::ParserResult; - //using xo::scm::parser_result_type; - using xo::scm::Token; - using xo::scm::DString; - using xo::mm::ArenaConfig; - using xo::mm::AAllocator; - using xo::mm::DArena; - using xo::facet::with_facet; -#endif using std::cout; using std::endl; static InitEvidence s_init = (InitSubsys::require()); namespace ut { + struct ArenaShim { + explicit ArenaShim(const std::string & name, std::size_t size = 16*1024) + : arena_(ArenaConfig().with_name(name).with_size(size)) + { + } + + obj to_op() { return obj(&arena_); } + + DArena arena_; + }; + + struct VsmFixture { + explicit VsmFixture(const std::string & testname, + bool debug_flag, + const VsmConfig & cfg = VsmConfig()) + : aux_mm_{testname}, + vsm_{cfg.with_debug_flag(debug_flag), aux_mm_.to_op()} + {} + + bool log_memory_layout(scope * p_log) { + auto visitor = [p_log](const MemorySizeInfo & info) { + *p_log && (*p_log)(xtag("resource", info.resource_name_), + xtag("used", info.used_), + xtag("alloc", info.allocated_), + xtag("commit", info.committed_), + xtag("resv", info.reserved_)); + }; + + aux_mm_.arena_.visit_pools(visitor); + FacetRegistry::instance().visit_pools(visitor); + vsm_.visit_pools(visitor); + + return true; + } + + ArenaShim aux_mm_; + VirtualSchematikaMachine vsm_; + }; + TEST_CASE("VirtualSchematikaMachine-ctor", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - scope log(XO_DEBUG(true), xtag("test", testname)); + bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmConfig cfg; - VirtualSchematikaMachine vsm(cfg); + VsmFixture vsm_fixture(testname, c_debug_flag); - auto visitor = [&log](const MemorySizeInfo & info) { - log && log(xtag("resource", info.resource_name_), - xtag("used", info.used_), - xtag("alloc", info.allocated_), - xtag("commit", info.committed_), - xtag("resv", info.reserved_)); - }; - - FacetRegistry::instance().visit_pools(visitor); - vsm.visit_pools(visitor); + log && vsm_fixture.log_memory_layout(&log); } TEST_CASE("VirtualSchematikaMachine-const1", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - scope log(XO_DEBUG(true), xtag("test", testname)); + constexpr bool c_debug_flag = false; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmConfig cfg; - VirtualSchematikaMachine vsm(cfg); + VsmFixture vsm_fixture(testname, c_debug_flag); + + auto & vsm = vsm_fixture.vsm_; bool eof_flag = false; @@ -109,26 +129,19 @@ namespace xo { REQUIRE(res.remaining_.size() == 1); REQUIRE(*res.remaining_.lo() == '\n'); - auto visitor = [&log](const MemorySizeInfo & info) { - log && log(xtag("resource", info.resource_name_), - xtag("used", info.used_), - xtag("alloc", info.allocated_), - xtag("commit", info.committed_), - xtag("resv", info.reserved_)); - }; - - FacetRegistry::instance().visit_pools(visitor); - vsm.visit_pools(visitor); + log && vsm_fixture.log_memory_layout(&log); } TEST_CASE("VirtualSchematikaMachine-const2", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - scope log(XO_DEBUG(true), xtag("test", testname)); + constexpr bool c_debug_flag = false; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmConfig cfg; - VirtualSchematikaMachine vsm(cfg); + VsmFixture vsm_fixture(testname, c_debug_flag); + + auto & vsm = vsm_fixture.vsm_; bool eof_flag = false; @@ -148,26 +161,18 @@ namespace xo { REQUIRE(res.remaining_.size() == 1); REQUIRE(*res.remaining_.lo() == '\n'); - auto visitor = [&log](const MemorySizeInfo & info) { - log && log(xtag("resource", info.resource_name_), - xtag("used", info.used_), - xtag("alloc", info.allocated_), - xtag("commit", info.committed_), - xtag("resv", info.reserved_)); - }; - - FacetRegistry::instance().visit_pools(visitor); - vsm.visit_pools(visitor); + log && vsm_fixture.log_memory_layout(&log); } TEST_CASE("VirtualSchematikaMachine-arith1", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - scope log(XO_DEBUG(true), xtag("test", testname)); + constexpr bool c_debug_flag = false; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmConfig cfg; - VirtualSchematikaMachine vsm(cfg); + VsmFixture vsm_fixture(testname, c_debug_flag); + auto & vsm = vsm_fixture.vsm_; bool eof_flag = false; @@ -187,16 +192,7 @@ namespace xo { REQUIRE(res.remaining_.size() == 1); REQUIRE(*res.remaining_.lo() == '\n'); - auto visitor = [&log](const MemorySizeInfo & info) { - log && log(xtag("resource", info.resource_name_), - xtag("used", info.used_), - xtag("alloc", info.allocated_), - xtag("commit", info.committed_), - xtag("resv", info.reserved_)); - }; - - FacetRegistry::instance().visit_pools(visitor); - vsm.visit_pools(visitor); + log && vsm_fixture.log_memory_layout(&log); } TEST_CASE("VirtualSchematikaMachine-cmp1", "[interpreter2][VSM]") @@ -206,13 +202,15 @@ namespace xo { constexpr bool c_debug_flag = false; scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmConfig cfg; - VirtualSchematikaMachine vsm(cfg); + VsmFixture vsm_fixture(testname, c_debug_flag); + auto & vsm = vsm_fixture.vsm_; bool eof_flag = false; vsm.begin_interactive_session(); - VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("123 == 123;"), eof_flag); + VsmResultExt res + = vsm.read_eval_print(span_type::from_cstr("123 == 123;"), + eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -227,32 +225,25 @@ namespace xo { REQUIRE(res.remaining_.size() == 1); REQUIRE(*res.remaining_.lo() == '\n'); - auto visitor = [&log](const MemorySizeInfo & info) { - log && log(xtag("resource", info.resource_name_), - xtag("used", info.used_), - xtag("alloc", info.allocated_), - xtag("commit", info.committed_), - xtag("resv", info.reserved_)); - }; - - FacetRegistry::instance().visit_pools(visitor); - vsm.visit_pools(visitor); + log && vsm_fixture.log_memory_layout(&log); } TEST_CASE("VirtualSchematikaMachine-if", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - constexpr bool c_debug_flag = true; + constexpr bool c_debug_flag = false; scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmConfig cfg; - VirtualSchematikaMachine vsm(cfg); + VsmFixture vsm_fixture(testname, c_debug_flag); + auto & vsm = vsm_fixture.vsm_; bool eof_flag = false; vsm.begin_interactive_session(); - VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("if 123 == 123 then \"equal\" else \"notequal\";"), eof_flag); + VsmResultExt res + = vsm.read_eval_print(span_type::from_cstr("if 123 == 123 then \"equal\" else \"notequal\";"), + eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -267,16 +258,7 @@ namespace xo { REQUIRE(res.remaining_.size() == 1); REQUIRE(*res.remaining_.lo() == '\n'); - auto visitor = [&log](const MemorySizeInfo & info) { - log && log(xtag("resource", info.resource_name_), - xtag("used", info.used_), - xtag("alloc", info.allocated_), - xtag("commit", info.committed_), - xtag("resv", info.reserved_)); - }; - - FacetRegistry::instance().visit_pools(visitor); - vsm.visit_pools(visitor); + log && vsm_fixture.log_memory_layout(&log); } TEST_CASE("VirtualSchematikaMachine-lambda1", "[interpreter2][VSM]") @@ -286,13 +268,15 @@ namespace xo { constexpr bool c_debug_flag = false; scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmConfig cfg; - VirtualSchematikaMachine vsm(cfg); + VsmFixture vsm_fixture(testname, c_debug_flag); + auto & vsm = vsm_fixture.vsm_; bool eof_flag = false; vsm.begin_interactive_session(); - VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("lambda (x : i64) -> i64 { x * x; }"), eof_flag); + VsmResultExt res + = vsm.read_eval_print(span_type::from_cstr("lambda (x : i64) -> i64 { x * x; }"), + eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -307,26 +291,18 @@ namespace xo { REQUIRE(res.remaining_.size() == 1); REQUIRE(*res.remaining_.lo() == '\n'); - auto visitor = [&log](const MemorySizeInfo & info) { - log && log(xtag("resource", info.resource_name_), - xtag("used", info.used_), - xtag("alloc", info.allocated_), - xtag("commit", info.committed_), - xtag("resv", info.reserved_)); - }; - - FacetRegistry::instance().visit_pools(visitor); - vsm.visit_pools(visitor); + log && vsm_fixture.log_memory_layout(&log); } TEST_CASE("VirtualSchematikaMachine-apply2", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - scope log(XO_DEBUG(false), xtag("test", testname)); + bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmConfig cfg; - VirtualSchematikaMachine vsm(cfg); + VsmFixture vsm_fixture(testname, c_debug_flag); + auto & vsm = vsm_fixture.vsm_; bool eof_flag = false; @@ -341,7 +317,7 @@ namespace xo { log && log(xtag("res.tseq", res.value()->_typeseq())); - // currently get not-implemented error + // currently get not-implemented error auto x = obj::from(*res.value()); REQUIRE(x); @@ -354,16 +330,7 @@ namespace xo { REQUIRE(res.remaining_.size() == 1); REQUIRE(*res.remaining_.lo() == '\n'); - auto visitor = [&log](const MemorySizeInfo & info) { - log && log(xtag("resource", info.resource_name_), - xtag("used", info.used_), - xtag("alloc", info.allocated_), - xtag("commit", info.committed_), - xtag("resv", info.reserved_)); - }; - - FacetRegistry::instance().visit_pools(visitor); - vsm.visit_pools(visitor); + log && vsm_fixture.log_memory_layout(&log); } } /*namespace ut*/ From a76703d986accc88a43b9be72fffae995bebbc79 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 15 Feb 2026 14:26:33 -0500 Subject: [PATCH 041/131] xo-interpreter2 stack: mark non-trivial dtors b/c DGlobalSymtab --- include/xo/interpreter2/VirtualSchematikaMachine.hpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 2cbd08e4..a34310ab 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -81,6 +81,11 @@ namespace xo { VirtualSchematikaMachine(const VsmConfig & config, obj aux_mm); + /** non-trivial dtor because of @ref reader_ + * indirect dependency on DGlobalSymtab + **/ + ~VirtualSchematikaMachine() = default; + /** allocator for schematika data **/ obj allocator() const noexcept; /** allocator for runtime errors **/ From f1f0a4b1e9310fb45c96b1317dd9a3f2ebf03490 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 17:46:51 -0500 Subject: [PATCH 042/131] xo-interpreter2 stack: OUTPUT_CPP_DIR cmake->idl/ --- CMakeLists.txt | 16 ---------------- idl/IGCObject_DClosure.json5 | 1 + idl/IGCObject_DLocalEnv.json5 | 1 + idl/IGCObject_DVsmApplyClosureFrame.json5 | 1 + idl/IGCObject_DVsmApplyFrame.json5 | 1 + idl/IGCObject_DVsmEvalArgsFrame.json5 | 1 + idl/IGCObject_DVsmIfElseContFrame.json5 | 1 + idl/IGCObject_DVsmSeqContFrame.json5 | 1 + idl/IPrintable_DClosure.json5 | 1 + idl/IPrintable_DLocalEnv.json5 | 1 + idl/IPrintable_DVsmApplyClosureFrame.json5 | 1 + idl/IPrintable_DVsmApplyFrame.json5 | 1 + idl/IPrintable_DVsmEvalArgsFrame.json5 | 1 + idl/IPrintable_DVsmIfElseContFrame.json5 | 1 + idl/IPrintable_DVsmSeqContFrame.json5 | 1 + idl/IRuntimeContext_DVsmRcx.json5 | 1 + 16 files changed, 15 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0b5431ba..28debaa0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,7 +34,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DVsmApplyFrame.json5 OUTPUT_HPP_DIR include/xo/interpreter2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/interpreter2 ) # note: manual target; generated code committed to git @@ -46,7 +45,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DVsmApplyFrame.json5 OUTPUT_HPP_DIR include/xo/interpreter2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/interpreter2 ) # ---------------------------------------------------------------- @@ -60,7 +58,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DVsmEvalArgsFrame.json5 OUTPUT_HPP_DIR include/xo/interpreter2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/interpreter2 ) # note: manual target; generated code committed to git @@ -72,7 +69,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DVsmEvalArgsFrame.json5 OUTPUT_HPP_DIR include/xo/interpreter2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/interpreter2 ) # ---------------------------------------------------------------- @@ -86,7 +82,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DVsmApplyClosureFrame.json5 OUTPUT_HPP_DIR include/xo/interpreter2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/interpreter2 ) # note: manual target; generated code committed to git @@ -98,7 +93,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DVsmApplyClosureFrame.json5 OUTPUT_HPP_DIR include/xo/interpreter2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/interpreter2 ) # ---------------------------------------------------------------- @@ -112,7 +106,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DVsmIfElseContFrame.json5 OUTPUT_HPP_DIR include/xo/interpreter2 OUTPUT_IMPL_SUBDIR ifelse - OUTPUT_CPP_DIR src/interpreter2 ) # note: manual target; generated code committed to git @@ -124,7 +117,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DVsmIfElseContFrame.json5 OUTPUT_HPP_DIR include/xo/interpreter2 OUTPUT_IMPL_SUBDIR ifelse - OUTPUT_CPP_DIR src/interpreter2 ) # ---------------------------------------------------------------- @@ -138,7 +130,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DVsmSeqContFrame.json5 OUTPUT_HPP_DIR include/xo/interpreter2 OUTPUT_IMPL_SUBDIR sequence - OUTPUT_CPP_DIR src/interpreter2 ) # note: manual target; generated code committed to git @@ -150,7 +141,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DVsmSeqContFrame.json5 OUTPUT_HPP_DIR include/xo/interpreter2 OUTPUT_IMPL_SUBDIR sequence - OUTPUT_CPP_DIR src/interpreter2 ) # ---------------------------------------------------------------- @@ -165,7 +155,6 @@ xo_add_genfacetimpl( # 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 @@ -177,7 +166,6 @@ xo_add_genfacetimpl( 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 @@ -189,7 +177,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DClosure.json5 OUTPUT_HPP_DIR include/xo/interpreter2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/interpreter2 ) # ---------------------------------------------------------------- @@ -203,7 +190,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DLocalEnv.json5 OUTPUT_HPP_DIR include/xo/interpreter2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/interpreter2 ) # note: manual target; generated code committed to git @@ -215,7 +201,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DLocalEnv.json5 OUTPUT_HPP_DIR include/xo/interpreter2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/interpreter2 ) # ---------------------------------------------------------------- @@ -228,7 +213,6 @@ xo_add_genfacetimpl( INPUT idl/IRuntimeContext_DVsmRcx.json5 OUTPUT_HPP_DIR include/xo/interpreter2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/interpreter2 ) # ---------------------------------------------------------------- diff --git a/idl/IGCObject_DClosure.json5 b/idl/IGCObject_DClosure.json5 index ec9f32fd..9e99a16b 100644 --- a/idl/IGCObject_DClosure.json5 +++ b/idl/IGCObject_DClosure.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ "", "" diff --git a/idl/IGCObject_DLocalEnv.json5 b/idl/IGCObject_DLocalEnv.json5 index 3c747621..fe8670f1 100644 --- a/idl/IGCObject_DLocalEnv.json5 +++ b/idl/IGCObject_DLocalEnv.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ "", "" diff --git a/idl/IGCObject_DVsmApplyClosureFrame.json5 b/idl/IGCObject_DVsmApplyClosureFrame.json5 index 398d53e9..4cced151 100644 --- a/idl/IGCObject_DVsmApplyClosureFrame.json5 +++ b/idl/IGCObject_DVsmApplyClosureFrame.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ "", "" diff --git a/idl/IGCObject_DVsmApplyFrame.json5 b/idl/IGCObject_DVsmApplyFrame.json5 index 979c14bf..175b229e 100644 --- a/idl/IGCObject_DVsmApplyFrame.json5 +++ b/idl/IGCObject_DVsmApplyFrame.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ "", "" diff --git a/idl/IGCObject_DVsmEvalArgsFrame.json5 b/idl/IGCObject_DVsmEvalArgsFrame.json5 index 8bebc6ec..7d89a5ed 100644 --- a/idl/IGCObject_DVsmEvalArgsFrame.json5 +++ b/idl/IGCObject_DVsmEvalArgsFrame.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ "", "" diff --git a/idl/IGCObject_DVsmIfElseContFrame.json5 b/idl/IGCObject_DVsmIfElseContFrame.json5 index 0f78bb6d..537c9860 100644 --- a/idl/IGCObject_DVsmIfElseContFrame.json5 +++ b/idl/IGCObject_DVsmIfElseContFrame.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ "", "" diff --git a/idl/IGCObject_DVsmSeqContFrame.json5 b/idl/IGCObject_DVsmSeqContFrame.json5 index cf7196c6..6945f3df 100644 --- a/idl/IGCObject_DVsmSeqContFrame.json5 +++ b/idl/IGCObject_DVsmSeqContFrame.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ "", "" diff --git a/idl/IPrintable_DClosure.json5 b/idl/IPrintable_DClosure.json5 index d4b16a69..2cfb3d33 100644 --- a/idl/IPrintable_DClosure.json5 +++ b/idl/IPrintable_DClosure.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DLocalEnv.json5 b/idl/IPrintable_DLocalEnv.json5 index 0302834d..0a1205f5 100644 --- a/idl/IPrintable_DLocalEnv.json5 +++ b/idl/IPrintable_DLocalEnv.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVsmApplyClosureFrame.json5 b/idl/IPrintable_DVsmApplyClosureFrame.json5 index 717aa85f..ee4e8e64 100644 --- a/idl/IPrintable_DVsmApplyClosureFrame.json5 +++ b/idl/IPrintable_DVsmApplyClosureFrame.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVsmApplyFrame.json5 b/idl/IPrintable_DVsmApplyFrame.json5 index f5957d7e..c78e0b88 100644 --- a/idl/IPrintable_DVsmApplyFrame.json5 +++ b/idl/IPrintable_DVsmApplyFrame.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVsmEvalArgsFrame.json5 b/idl/IPrintable_DVsmEvalArgsFrame.json5 index 24df6cbd..1dd1672a 100644 --- a/idl/IPrintable_DVsmEvalArgsFrame.json5 +++ b/idl/IPrintable_DVsmEvalArgsFrame.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVsmIfElseContFrame.json5 b/idl/IPrintable_DVsmIfElseContFrame.json5 index d3d63c4d..b9f70e6d 100644 --- a/idl/IPrintable_DVsmIfElseContFrame.json5 +++ b/idl/IPrintable_DVsmIfElseContFrame.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVsmSeqContFrame.json5 b/idl/IPrintable_DVsmSeqContFrame.json5 index e9ec796e..96b9c071 100644 --- a/idl/IPrintable_DVsmSeqContFrame.json5 +++ b/idl/IPrintable_DVsmSeqContFrame.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IRuntimeContext_DVsmRcx.json5 b/idl/IRuntimeContext_DVsmRcx.json5 index 8659eb66..9fa3fe40 100644 --- a/idl/IRuntimeContext_DVsmRcx.json5 +++ b/idl/IRuntimeContext_DVsmRcx.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/interpreter2", includes: [ //"", //"", From e7fc6c6325afc6f1198cb60550c75b1fece63471 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 22:33:32 -0500 Subject: [PATCH 043/131] xo-facet: move output-hpp-dir + subdir to idl/*.json5 --- idl/IGCObject_DClosure.json5 | 2 ++ idl/IGCObject_DLocalEnv.json5 | 2 ++ idl/IGCObject_DVsmApplyClosureFrame.json5 | 2 ++ idl/IGCObject_DVsmApplyFrame.json5 | 2 ++ idl/IGCObject_DVsmEvalArgsFrame.json5 | 2 ++ idl/IGCObject_DVsmIfElseContFrame.json5 | 2 ++ idl/IGCObject_DVsmSeqContFrame.json5 | 2 ++ idl/IPrintable_DClosure.json5 | 2 ++ idl/IPrintable_DLocalEnv.json5 | 2 ++ idl/IPrintable_DVsmApplyClosureFrame.json5 | 2 ++ idl/IPrintable_DVsmApplyFrame.json5 | 2 ++ idl/IPrintable_DVsmEvalArgsFrame.json5 | 2 ++ idl/IPrintable_DVsmIfElseContFrame.json5 | 2 ++ idl/IPrintable_DVsmSeqContFrame.json5 | 2 ++ idl/IProcedure_DClosure.json5 | 2 ++ idl/IRuntimeContext_DVsmRcx.json5 | 2 ++ 16 files changed, 32 insertions(+) diff --git a/idl/IGCObject_DClosure.json5 b/idl/IGCObject_DClosure.json5 index 9e99a16b..a9b5616a 100644 --- a/idl/IGCObject_DClosure.json5 +++ b/idl/IGCObject_DClosure.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", includes: [ "", "" diff --git a/idl/IGCObject_DLocalEnv.json5 b/idl/IGCObject_DLocalEnv.json5 index fe8670f1..1fbce208 100644 --- a/idl/IGCObject_DLocalEnv.json5 +++ b/idl/IGCObject_DLocalEnv.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", includes: [ "", "" diff --git a/idl/IGCObject_DVsmApplyClosureFrame.json5 b/idl/IGCObject_DVsmApplyClosureFrame.json5 index 4cced151..2b68d579 100644 --- a/idl/IGCObject_DVsmApplyClosureFrame.json5 +++ b/idl/IGCObject_DVsmApplyClosureFrame.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", includes: [ "", "" diff --git a/idl/IGCObject_DVsmApplyFrame.json5 b/idl/IGCObject_DVsmApplyFrame.json5 index 175b229e..ae284287 100644 --- a/idl/IGCObject_DVsmApplyFrame.json5 +++ b/idl/IGCObject_DVsmApplyFrame.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", includes: [ "", "" diff --git a/idl/IGCObject_DVsmEvalArgsFrame.json5 b/idl/IGCObject_DVsmEvalArgsFrame.json5 index 7d89a5ed..d36304b8 100644 --- a/idl/IGCObject_DVsmEvalArgsFrame.json5 +++ b/idl/IGCObject_DVsmEvalArgsFrame.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", includes: [ "", "" diff --git a/idl/IGCObject_DVsmIfElseContFrame.json5 b/idl/IGCObject_DVsmIfElseContFrame.json5 index 537c9860..63617067 100644 --- a/idl/IGCObject_DVsmIfElseContFrame.json5 +++ b/idl/IGCObject_DVsmIfElseContFrame.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "ifelse", includes: [ "", "" diff --git a/idl/IGCObject_DVsmSeqContFrame.json5 b/idl/IGCObject_DVsmSeqContFrame.json5 index 6945f3df..d2b68020 100644 --- a/idl/IGCObject_DVsmSeqContFrame.json5 +++ b/idl/IGCObject_DVsmSeqContFrame.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "sequence", includes: [ "", "" diff --git a/idl/IPrintable_DClosure.json5 b/idl/IPrintable_DClosure.json5 index 2cfb3d33..2a1e2db9 100644 --- a/idl/IPrintable_DClosure.json5 +++ b/idl/IPrintable_DClosure.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DLocalEnv.json5 b/idl/IPrintable_DLocalEnv.json5 index 0a1205f5..79ef4c74 100644 --- a/idl/IPrintable_DLocalEnv.json5 +++ b/idl/IPrintable_DLocalEnv.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVsmApplyClosureFrame.json5 b/idl/IPrintable_DVsmApplyClosureFrame.json5 index ee4e8e64..45927399 100644 --- a/idl/IPrintable_DVsmApplyClosureFrame.json5 +++ b/idl/IPrintable_DVsmApplyClosureFrame.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVsmApplyFrame.json5 b/idl/IPrintable_DVsmApplyFrame.json5 index c78e0b88..bef2fb62 100644 --- a/idl/IPrintable_DVsmApplyFrame.json5 +++ b/idl/IPrintable_DVsmApplyFrame.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVsmEvalArgsFrame.json5 b/idl/IPrintable_DVsmEvalArgsFrame.json5 index 1dd1672a..c43c5160 100644 --- a/idl/IPrintable_DVsmEvalArgsFrame.json5 +++ b/idl/IPrintable_DVsmEvalArgsFrame.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVsmIfElseContFrame.json5 b/idl/IPrintable_DVsmIfElseContFrame.json5 index b9f70e6d..6490d444 100644 --- a/idl/IPrintable_DVsmIfElseContFrame.json5 +++ b/idl/IPrintable_DVsmIfElseContFrame.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "ifelse", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVsmSeqContFrame.json5 b/idl/IPrintable_DVsmSeqContFrame.json5 index 96b9c071..7b8e7ddd 100644 --- a/idl/IPrintable_DVsmSeqContFrame.json5 +++ b/idl/IPrintable_DVsmSeqContFrame.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "sequence", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IProcedure_DClosure.json5 b/idl/IProcedure_DClosure.json5 index d503f5c6..eec40c0c 100644 --- a/idl/IProcedure_DClosure.json5 +++ b/idl/IProcedure_DClosure.json5 @@ -1,5 +1,7 @@ { mode: "implementation", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", includes: [ "", "", diff --git a/idl/IRuntimeContext_DVsmRcx.json5 b/idl/IRuntimeContext_DVsmRcx.json5 index 9fa3fe40..b52517ee 100644 --- a/idl/IRuntimeContext_DVsmRcx.json5 +++ b/idl/IRuntimeContext_DVsmRcx.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", includes: [ //"", //"", From 735acc966bbf052ee055411f5cb115b7c6f04516 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 22:49:27 -0500 Subject: [PATCH 044/131] xo-interpreter2: streamline facet codegen --- CMakeLists.txt | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28debaa0..7ffbebc3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,8 +32,6 @@ xo_add_genfacetimpl( FACET GCObject REPR VsmApplyFrame INPUT idl/IGCObject_DVsmApplyFrame.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -43,8 +41,6 @@ xo_add_genfacetimpl( FACET Printable REPR VsmApplyFrame INPUT idl/IPrintable_DVsmApplyFrame.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR detail ) # ---------------------------------------------------------------- @@ -56,8 +52,6 @@ xo_add_genfacetimpl( FACET GCObject REPR VsmEvalArgsFrame INPUT idl/IGCObject_DVsmEvalArgsFrame.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -67,8 +61,6 @@ xo_add_genfacetimpl( FACET Printable REPR DVsmEvalArgsFrame INPUT idl/IPrintable_DVsmEvalArgsFrame.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR detail ) # ---------------------------------------------------------------- @@ -80,8 +72,6 @@ xo_add_genfacetimpl( FACET GCObject REPR VsmApplyClosureFrame INPUT idl/IGCObject_DVsmApplyClosureFrame.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -91,8 +81,6 @@ xo_add_genfacetimpl( FACET Printable REPR DVsmApplyClosureFrame INPUT idl/IPrintable_DVsmApplyClosureFrame.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR detail ) # ---------------------------------------------------------------- @@ -104,8 +92,6 @@ xo_add_genfacetimpl( FACET GCObject REPR VsmIfElseContFrame INPUT idl/IGCObject_DVsmIfElseContFrame.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR ifelse ) # note: manual target; generated code committed to git @@ -115,8 +101,6 @@ xo_add_genfacetimpl( FACET Printable REPR VsmIfElseContFrame INPUT idl/IPrintable_DVsmIfElseContFrame.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR ifelse ) # ---------------------------------------------------------------- @@ -128,8 +112,6 @@ xo_add_genfacetimpl( FACET GCObject REPR VsmSeqContFrame INPUT idl/IGCObject_DVsmSeqContFrame.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR sequence ) # note: manual target; generated code committed to git @@ -139,8 +121,6 @@ xo_add_genfacetimpl( FACET Printable REPR DVsmSeqContFrame INPUT idl/IPrintable_DVsmSeqContFrame.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR sequence ) # ---------------------------------------------------------------- @@ -153,8 +133,6 @@ xo_add_genfacetimpl( # FACET Procedure # REPR Closure # INPUT idl/IProcedure_DClosure.json5 -# OUTPUT_HPP_DIR include/xo/interpreter2 -# OUTPUT_IMPL_SUBDIR detail #) # note: manual target; generated code committed to git @@ -164,8 +142,6 @@ xo_add_genfacetimpl( FACET GCObject REPR Closure INPUT idl/IGCObject_DClosure.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -175,8 +151,6 @@ xo_add_genfacetimpl( FACET Printable REPR Closure INPUT idl/IPrintable_DClosure.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR detail ) # ---------------------------------------------------------------- @@ -188,8 +162,6 @@ xo_add_genfacetimpl( FACET GCObject REPR LocalEnv INPUT idl/IGCObject_DLocalEnv.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -199,8 +171,6 @@ xo_add_genfacetimpl( FACET Printable REPR LocalEnv INPUT idl/IPrintable_DLocalEnv.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR detail ) # ---------------------------------------------------------------- @@ -211,8 +181,6 @@ xo_add_genfacetimpl( FACET RuntimeContext REPR DVsmRcx INPUT idl/IRuntimeContext_DVsmRcx.json5 - OUTPUT_HPP_DIR include/xo/interpreter2 - OUTPUT_IMPL_SUBDIR detail ) # ---------------------------------------------------------------- From 5e9b13c5164b741f9ebd48c0b72b3d270136883a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 17 Feb 2026 14:42:17 -0500 Subject: [PATCH 045/131] xo-interpreter2 stack: define-expr's work at top-level --- CMakeLists.txt | 40 ++++++ idl/IGCObject_DGlobalEnv.json5 | 18 +++ idl/IGCObject_DLocalEnv.json5 | 2 +- idl/IGCObject_DVsmDefContFrame.json5 | 18 +++ idl/IPrintable_DGlobalEnv.json5 | 16 +++ idl/IPrintable_DLocalEnv.json5 | 2 +- idl/IPrintable_DVsmDefContFrame.json5 | 16 +++ include/xo/interpreter2/DGlobalEnv.hpp | 49 ++++++- include/xo/interpreter2/DLocalEnv.hpp | 2 +- include/xo/interpreter2/DVsmDefContFrame.hpp | 82 +++++++++++ include/xo/interpreter2/GlobalEnv.hpp | 12 ++ .../interpreter2/VirtualSchematikaMachine.hpp | 21 +-- include/xo/interpreter2/VsmDefContFrame.hpp | 12 ++ include/xo/interpreter2/VsmInstr.hpp | 10 ++ include/xo/interpreter2/VsmOpcode.hpp | 8 +- .../define/IGCObject_DVsmDefContFrame.hpp | 67 +++++++++ .../define/IPrintable_DVsmDefContFrame.hpp | 62 +++++++++ .../interpreter2/env/IGCObject_DGlobalEnv.hpp | 67 +++++++++ .../interpreter2/env/IGCObject_DLocalEnv.hpp | 67 +++++++++ .../env/IPrintable_DGlobalEnv.hpp | 62 +++++++++ .../interpreter2/env/IPrintable_DLocalEnv.hpp | 62 +++++++++ src/interpreter2/CMakeLists.txt | 10 +- src/interpreter2/DGlobalEnv.cpp | 128 ++++++++++++++++++ src/interpreter2/DLocalEnv.cpp | 4 + src/interpreter2/DVsmDefContFrame.cpp | 68 ++++++++++ src/interpreter2/IGCObject_DGlobalEnv.cpp | 39 ++++++ src/interpreter2/IGCObject_DLocalEnv.cpp | 2 +- .../IGCObject_DVsmDefContFrame.cpp | 39 ++++++ src/interpreter2/IPrintable_DGlobalEnv.cpp | 28 ++++ src/interpreter2/IPrintable_DLocalEnv.cpp | 2 +- .../IPrintable_DVsmDefContFrame.cpp | 28 ++++ src/interpreter2/VirtualSchematikaMachine.cpp | 120 ++++++++++++++-- src/interpreter2/VsmInstr.cpp | 10 +- .../interpreter2_register_facets.cpp | 15 ++ utest/VirtualSchematikaMachine.test.cpp | 97 ++++++++++++- 35 files changed, 1247 insertions(+), 38 deletions(-) create mode 100644 idl/IGCObject_DGlobalEnv.json5 create mode 100644 idl/IGCObject_DVsmDefContFrame.json5 create mode 100644 idl/IPrintable_DGlobalEnv.json5 create mode 100644 idl/IPrintable_DVsmDefContFrame.json5 create mode 100644 include/xo/interpreter2/DVsmDefContFrame.hpp create mode 100644 include/xo/interpreter2/GlobalEnv.hpp create mode 100644 include/xo/interpreter2/VsmDefContFrame.hpp create mode 100644 include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp create mode 100644 include/xo/interpreter2/define/IPrintable_DVsmDefContFrame.hpp create mode 100644 include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp create mode 100644 include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp create mode 100644 include/xo/interpreter2/env/IPrintable_DGlobalEnv.hpp create mode 100644 include/xo/interpreter2/env/IPrintable_DLocalEnv.hpp create mode 100644 src/interpreter2/DGlobalEnv.cpp create mode 100644 src/interpreter2/DVsmDefContFrame.cpp create mode 100644 src/interpreter2/IGCObject_DGlobalEnv.cpp create mode 100644 src/interpreter2/IGCObject_DVsmDefContFrame.cpp create mode 100644 src/interpreter2/IPrintable_DGlobalEnv.cpp create mode 100644 src/interpreter2/IPrintable_DVsmDefContFrame.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ffbebc3..2d1a6db8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,6 +25,26 @@ add_subdirectory(utest) # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-gcobject-vsmdefcontframe + FACET_PKG xo_gc + FACET GCObject + REPR VsmDefContFrame + INPUT idl/IGCObject_DVsmDefContFrame.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-printable-vsmdefcontframe + FACET_PKG xo_printable2 + FACET Printable + REPR VsmDefContFrame + INPUT idl/IPrintable_DVsmDefContFrame.json5 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmapplyframe @@ -155,6 +175,26 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-gcobject-globalenv + FACET_PKG xo_gc + FACET GCObject + REPR GlobalEnv + INPUT idl/IGCObject_DGlobalEnv.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-printable-globalenv + FACET_PKG xo_printable2 + FACET Printable + REPR GlobalEnv + INPUT idl/IPrintable_DGlobalEnv.json5 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-localenv diff --git a/idl/IGCObject_DGlobalEnv.json5 b/idl/IGCObject_DGlobalEnv.json5 new file mode 100644 index 00000000..ce0bc090 --- /dev/null +++ b/idl/IGCObject_DGlobalEnv.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "env", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for GlobalEnv", + using_doxygen: true, + repr: "DGlobalEnv", + doc: [ "implement AGCObject for DGlobalEnv" ], +} diff --git a/idl/IGCObject_DLocalEnv.json5 b/idl/IGCObject_DLocalEnv.json5 index 1fbce208..252bfbd7 100644 --- a/idl/IGCObject_DLocalEnv.json5 +++ b/idl/IGCObject_DLocalEnv.json5 @@ -2,7 +2,7 @@ mode: "implementation", output_cpp_dir: "src/interpreter2", output_hpp_dir: "include/xo/interpreter2", - output_impl_subdir: "detail", + output_impl_subdir: "env", includes: [ "", "" diff --git a/idl/IGCObject_DVsmDefContFrame.json5 b/idl/IGCObject_DVsmDefContFrame.json5 new file mode 100644 index 00000000..061fca5d --- /dev/null +++ b/idl/IGCObject_DVsmDefContFrame.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "define", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DVsmDefContFrame", + using_doxygen: true, + repr: "DVsmDefContFrame", + doc: [ "implement AGCObject for DVsmDefContFrame" ], +} diff --git a/idl/IPrintable_DGlobalEnv.json5 b/idl/IPrintable_DGlobalEnv.json5 new file mode 100644 index 00000000..541146ae --- /dev/null +++ b/idl/IPrintable_DGlobalEnv.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "env", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DGlobalEnv", + using_doxygen: true, + repr: "DGlobalEnv", + doc: [ "implement APrintable for DGlobalEnv" ], +} diff --git a/idl/IPrintable_DLocalEnv.json5 b/idl/IPrintable_DLocalEnv.json5 index 79ef4c74..dfc6a644 100644 --- a/idl/IPrintable_DLocalEnv.json5 +++ b/idl/IPrintable_DLocalEnv.json5 @@ -2,7 +2,7 @@ mode: "implementation", output_cpp_dir: "src/interpreter2", output_hpp_dir: "include/xo/interpreter2", - output_impl_subdir: "detail", + output_impl_subdir: "env", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVsmDefContFrame.json5 b/idl/IPrintable_DVsmDefContFrame.json5 new file mode 100644 index 00000000..58410fd6 --- /dev/null +++ b/idl/IPrintable_DVsmDefContFrame.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "define", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DVsmDefContFrame", + using_doxygen: true, + repr: "DVsmDefContFrame", + doc: [ "implement APrintable for DVsmDefContFrame" ], +} diff --git a/include/xo/interpreter2/DGlobalEnv.hpp b/include/xo/interpreter2/DGlobalEnv.hpp index 60fbe461..e68ad55d 100644 --- a/include/xo/interpreter2/DGlobalEnv.hpp +++ b/include/xo/interpreter2/DGlobalEnv.hpp @@ -25,18 +25,55 @@ namespace xo { **/ class DGlobalEnv { public: + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; + using ppindentinfo = xo::print::ppindentinfo; + using size_type = std::uint32_t; public: - DGlobalEnv() = default; + /** @defgroup scm-globalenv-ctors constructors **/ + ///@{ - /** visit env-owned memory pools; call visitor(info) for each **/ - void visit_pools(const MemorySizeVisitor & visitor) const; + DGlobalEnv(DGlobalSymtab * symtab, DArray * values); - protected: // temporary, to appease compiler + static DGlobalEnv * _make(obj mm, + DGlobalSymtab * symtab); - // absurd O(n) implementation for now - // replace with gc-aware hashtable, when available. + + ///@} + /** @defgroup scm-globalenv-methods methods **/ + ///@{ + + /** symbol-table size. Is the number of distinct global symbols **/ + size_type size() const noexcept { return symtab_->size(); } + + /** lookup current value associated with binding @p ix **/ + obj lookup_value(Binding ix) const noexcept; + + /** assign value associated with binding @p to @p x. + * If need to expand size of this env, use memory from @p mm + **/ + void assign_value(obj mm, Binding ix, obj x); + + ///@} + /** @defgroup scm-globalenv-gcobject-facet **/ + ///@{ + + std::size_t shallow_size() const noexcept; + DGlobalEnv * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + + ///@} + /** @defgroup scm-globalenv-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + private: /** symbol table assigns a unique index for each symbol **/ DGlobalSymtab * symtab_; diff --git a/include/xo/interpreter2/DLocalEnv.hpp b/include/xo/interpreter2/DLocalEnv.hpp index c99aaad1..eaef71c2 100644 --- a/include/xo/interpreter2/DLocalEnv.hpp +++ b/include/xo/interpreter2/DLocalEnv.hpp @@ -37,7 +37,7 @@ namespace xo { DArray * args); ///@} - /** @defgroup scm-local-env-methods methods **/ + /** @defgroup scm-localenv-methods methods **/ ///@{ DLocalEnv * parent() const noexcept { return parent_; } diff --git a/include/xo/interpreter2/DVsmDefContFrame.hpp b/include/xo/interpreter2/DVsmDefContFrame.hpp new file mode 100644 index 00000000..68c2510a --- /dev/null +++ b/include/xo/interpreter2/DVsmDefContFrame.hpp @@ -0,0 +1,82 @@ +/** @file DVsmDefContFrame.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "VsmInstr.hpp" +#include +#include + +namespace xo { + namespace scm { + /** @brief saved VSM state during evaluation of a SequenceExpr + **/ + class DVsmDefContFrame { + public: + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; + using ppindentinfo = xo::print::ppindentinfo; + + public: + /** @defgroup scm-vsmdefcontframe-ctors constructors **/ + ///@{ + + DVsmDefContFrame(obj parent, + VsmInstr cont, + DDefineExpr * def_expr); + + /** create instance using memory from allocator @p mm **/ + static DVsmDefContFrame * make(obj mm, + obj parent_stack, + VsmInstr cont, + DDefineExpr * def_expr); + + ///@} + /** @defgroup scm-vsmdefcontframe-access-methods access methods **/ + ///@{ + + obj parent() const noexcept { return parent_; } + VsmInstr cont() const noexcept { return cont_; } + DDefineExpr * def_expr() const noexcept { return def_expr_; } + + ///@} + /** @defgroup scm-vsmdefcontframe-general-methods general methods **/ + ///@{ + + ///@} + /** @defgroup scm-vsmdefcontframe-gcobject-facet gcobject facet **/ + ///@{ + + std::size_t shallow_size() const noexcept; + DVsmDefContFrame * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + + ///@} + /** @defgrouop scm-vsmseqcontframe-printable-facet printable facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const noexcept; + + ///@} + + private: + /** @defgroup scm-vsmdefcontframe-members member variables **/ + ///@{ + + /** saved VSM stack; restore when this frame consumed **/ + obj parent_; + /** saved continuation; restore when this frame consumed **/ + VsmInstr cont_; + /** saved expr. evaluate elements of this sequence in order **/ + DDefineExpr * def_expr_ = nullptr; + + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmDefContFrame.hpp */ diff --git a/include/xo/interpreter2/GlobalEnv.hpp b/include/xo/interpreter2/GlobalEnv.hpp new file mode 100644 index 00000000..94bafc42 --- /dev/null +++ b/include/xo/interpreter2/GlobalEnv.hpp @@ -0,0 +1,12 @@ +/** @file GlobalEnv.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DGlobalEnv.hpp" +#include "env/IGCObject_DGlobalEnv.hpp" +#include "env/IPrintable_DGlobalEnv.hpp" + +/* end GlobalEnv.hpp */ diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index a34310ab..724e1c33 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -191,6 +191,11 @@ namespace xo { /** call primitive @ref fn_ with arguments @ref args_ **/ void _do_call_primitive_op(); + /** perform assignment after evaluating + * the rhs of a define-expr + **/ + void _do_def_cont_op(); + /** restore registers from stack frame * (specifically: local_env_, stack_, cont_) * after invoking a schematika closure @@ -225,13 +230,13 @@ namespace xo { #ifdef NOT_YET /** allocator (likely DArena) for globals. - * For example DArenaHashMap in global symtab, + * For example DArenaHashMap in global symta. **/ obj aux_mm_; #endif /** allocator (likely DX1Collector or similar) for - * expressions and values + * expressions and values. Schemaatika reader will use this also **/ abox mm_; @@ -267,19 +272,17 @@ namespace xo { /** expression register **/ obj expr_; + /** environment pointer. Maintains bindings + * for global variables. + **/ + DGlobalEnv * global_env_ = nullptr; + /** environment pointer. Provides bindings * for surrounding lexical scope at this point * in execution **/ DLocalEnv * local_env_ = nullptr; - protected: // temporarily, to appease compiler - /** environment pointer. Maintains bindings - * for global variables. - **/ - DGlobalEnv * global_env_ = nullptr; - - private: /** evaluated function to call **/ obj fn_; /** evaluated argument list **/ diff --git a/include/xo/interpreter2/VsmDefContFrame.hpp b/include/xo/interpreter2/VsmDefContFrame.hpp new file mode 100644 index 00000000..5ea2bad6 --- /dev/null +++ b/include/xo/interpreter2/VsmDefContFrame.hpp @@ -0,0 +1,12 @@ +/** @file VsmDefContFrame.hpp +* + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DVsmDefContFrame.hpp" +#include "define/IGCObject_DVsmDefContFrame.hpp" +#include "define/IPrintable_DVsmDefContFrame.hpp" + +/* end VsmDefContFrame.hpp */ diff --git a/include/xo/interpreter2/VsmInstr.hpp b/include/xo/interpreter2/VsmInstr.hpp index 1279f8b7..2417757f 100644 --- a/include/xo/interpreter2/VsmInstr.hpp +++ b/include/xo/interpreter2/VsmInstr.hpp @@ -9,15 +9,25 @@ namespace xo { namespace scm { + /** + * Thin instruction wrapper for VSM (virtual schematika machine) instructions. + * For exeuction see VirtualSchematikaMachine.cpp + **/ class VsmInstr { public: explicit VsmInstr(vsm_opcode oc) : opcode_{oc} {} // instructions + static VsmInstr c_sentinel; static VsmInstr c_halt; static VsmInstr c_eval; + /** proceed to assignment after evaluating rhs + * of define-expression + **/ + static VsmInstr c_def_cont; + static VsmInstr c_apply; static VsmInstr c_evalargs; /** restore VSM state for continuation of an apply expression **/ diff --git a/include/xo/interpreter2/VsmOpcode.hpp b/include/xo/interpreter2/VsmOpcode.hpp index e1000cb3..161b352e 100644 --- a/include/xo/interpreter2/VsmOpcode.hpp +++ b/include/xo/interpreter2/VsmOpcode.hpp @@ -14,6 +14,8 @@ namespace xo { * exeucted by VirtualSchematikaMachine **/ enum class vsm_opcode { + /** Flags bad state (defect in VSM itself) **/ + sentinel, /** Immediately halt virtual schematika machine. **/ halt, /** Evaluate expression in expr register **/ @@ -28,6 +30,11 @@ namespace xo { **/ evalargs, + /** continuation to complete execution of define-expression, + * after evaluting rhs expression + **/ + def_cont, + /** continuation to restore vsm registers (local_env, stack, cont) * after invoking a closure **/ @@ -58,4 +65,3 @@ namespace xo { } /*namespace xo*/ /* end VsmOpcode.hpp */ - diff --git a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp new file mode 100644 index 00000000..309a6ac7 --- /dev/null +++ b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DVsmDefContFrame.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVsmDefContFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVsmDefContFrame.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DVsmDefContFrame.hpp" + +namespace xo { namespace scm { class IGCObject_DVsmDefContFrame; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DVsmDefContFrame + **/ + class IGCObject_DVsmDefContFrame { + public: + /** @defgroup scm-gcobject-dvsmdefcontframe-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-dvsmdefcontframe-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DVsmDefContFrame & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DVsmDefContFrame & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DVsmDefContFrame & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/define/IPrintable_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IPrintable_DVsmDefContFrame.hpp new file mode 100644 index 00000000..46ab4ee7 --- /dev/null +++ b/include/xo/interpreter2/define/IPrintable_DVsmDefContFrame.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DVsmDefContFrame.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVsmDefContFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVsmDefContFrame.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DVsmDefContFrame.hpp" + +namespace xo { namespace scm { class IPrintable_DVsmDefContFrame; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DVsmDefContFrame + **/ + class IPrintable_DVsmDefContFrame { + public: + /** @defgroup scm-printable-dvsmdefcontframe-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dvsmdefcontframe-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DVsmDefContFrame & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp new file mode 100644 index 00000000..1f0f9281 --- /dev/null +++ b/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DGlobalEnv.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DGlobalEnv.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DGlobalEnv.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DGlobalEnv.hpp" + +namespace xo { namespace scm { class IGCObject_DGlobalEnv; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DGlobalEnv + **/ + class IGCObject_DGlobalEnv { + public: + /** @defgroup scm-gcobject-dglobalenv-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-dglobalenv-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DGlobalEnv & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DGlobalEnv & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DGlobalEnv & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp new file mode 100644 index 00000000..d318bb61 --- /dev/null +++ b/include/xo/interpreter2/env/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/env/IPrintable_DGlobalEnv.hpp b/include/xo/interpreter2/env/IPrintable_DGlobalEnv.hpp new file mode 100644 index 00000000..6efcd963 --- /dev/null +++ b/include/xo/interpreter2/env/IPrintable_DGlobalEnv.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DGlobalEnv.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DGlobalEnv.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DGlobalEnv.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DGlobalEnv.hpp" + +namespace xo { namespace scm { class IPrintable_DGlobalEnv; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DGlobalEnv + **/ + class IPrintable_DGlobalEnv { + public: + /** @defgroup scm-printable-dglobalenv-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dglobalenv-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DGlobalEnv & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/env/IPrintable_DLocalEnv.hpp b/include/xo/interpreter2/env/IPrintable_DLocalEnv.hpp new file mode 100644 index 00000000..c0ddb7f8 --- /dev/null +++ b/include/xo/interpreter2/env/IPrintable_DLocalEnv.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DLocalEnv.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DLocalEnv.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DLocalEnv.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DLocalEnv.hpp" + +namespace xo { namespace scm { class IPrintable_DLocalEnv; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DLocalEnv + **/ + class IPrintable_DLocalEnv { + public: + /** @defgroup scm-printable-dlocalenv-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dlocalenv-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DLocalEnv & 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 c21821e1..c15ddef6 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -8,6 +8,10 @@ set(SELF_SRCS VirtualSchematikaMachine.cpp + DVsmDefContFrame.cpp + IGCObject_DVsmDefContFrame.cpp + IPrintable_DVsmDefContFrame.cpp + DVsmEvalArgsFrame.cpp IGCObject_DVsmEvalArgsFrame.cpp IPrintable_DVsmEvalArgsFrame.cpp @@ -32,9 +36,13 @@ set(SELF_SRCS IGCObject_DClosure.cpp IPrintable_DClosure.cpp + DGlobalEnv.cpp + IGCObject_DGlobalEnv.cpp + IPrintable_DGlobalEnv.cpp + + DLocalEnv.cpp IGCObject_DLocalEnv.cpp IPrintable_DLocalEnv.cpp - DLocalEnv.cpp DVsmRcx.cpp IRuntimeContext_DVsmRcx.cpp diff --git a/src/interpreter2/DGlobalEnv.cpp b/src/interpreter2/DGlobalEnv.cpp new file mode 100644 index 00000000..a9285b73 --- /dev/null +++ b/src/interpreter2/DGlobalEnv.cpp @@ -0,0 +1,128 @@ +/** @file DGlobalEnv.cpp + * + * @author Roland Conybeare, Feb 2026 +**/ + +#include "GlobalEnv.hpp" +#include +#include + +namespace xo { + using xo::mm::AAllocator; + using xo::mm::AGCObject; + + namespace scm { + + DGlobalEnv::DGlobalEnv(DGlobalSymtab * symtab, DArray * values) + : symtab_{symtab}, values_{values} + {} + + DGlobalEnv * + DGlobalEnv::_make(obj mm, + DGlobalSymtab * symtab) + { + DArray * values = DArray::empty(mm, symtab->capacity()); + + void * mem = mm.alloc_for(); + + return new (mem) DGlobalEnv(symtab, values); + } + + obj + DGlobalEnv::lookup_value(Binding ix) const noexcept + { + if (!ix.is_global()) { + assert(false); + return obj(); + } + + if (ix.j_slot() >= static_cast(values_->size())) { + assert(false); + return obj(); + } + + return (*values_)[ix.j_slot()]; + } + + void + DGlobalEnv::assign_value(obj mm, Binding ix, obj x) + { + scope log(XO_DEBUG(true), + xtag("ix.j_slot", ix.j_slot()), + xtag("values.cap", values_->capacity())); + + assert(ix.is_global()); + + if (ix.j_slot() >= static_cast(values_->size())) { + // Control will come here in interpreter as new definitions are introduced. + // After seeing + // def foo = 1.2345; + // introducing new symbol foo: + // GlobalSymtab extends to include foo without this GlobalEnv + // knowing about it. + + if (ix.j_slot() + 1 > static_cast(values_->capacity())) { + // realloc global array for more size + + size_t cap_2x = 2 * values_->capacity(); + + while (cap_2x < static_cast(ix.j_slot() + 1)) + cap_2x = 2 * cap_2x; + + DArray * values_2x = DArray::copy(mm, values_, cap_2x); + assert(values_2x); + + if (values_2x) { + log && log("STUB: need write barrier for GC (also in GlobalSymtab!)"); + this->values_ = values_2x; + } else { + return; + } + } + + /** expand size sot that j_slot is valid **/ + values_->resize(ix.j_slot() + 1); + } + + log && log("STUB: need write barrier for GC here"); + (*values_)[ix.j_slot()] = x; + } + + // ----- AGCObject facet ----- + + std::size_t + DGlobalEnv::shallow_size() const noexcept + { + return sizeof(*this); + } + + DGlobalEnv * + DGlobalEnv::shallow_copy(obj mm) const noexcept + { + return mm.std_copy_for(this); + } + + std::size_t + DGlobalEnv::forward_children(obj gc) noexcept + { + gc.forward_inplace(&symtab_); + gc.forward_inplace(&values_); + + return this->shallow_size(); + } + + // ----- APrintable facet ----- + + bool + DGlobalEnv::pretty(const ppindentinfo & ppii) const + { + return ppii.pps()->pretty_struct + (ppii, + "DGlobalEnv", + refrtag("size", symtab_->size())); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DGlobalEnv.cpp */ diff --git a/src/interpreter2/DLocalEnv.cpp b/src/interpreter2/DLocalEnv.cpp index 6866fda7..8f45b38a 100644 --- a/src/interpreter2/DLocalEnv.cpp +++ b/src/interpreter2/DLocalEnv.cpp @@ -6,6 +6,7 @@ #include "LocalEnv.hpp" #include #include +#include namespace xo { using xo::mm::AGCObject; @@ -64,6 +65,8 @@ namespace xo { void DLocalEnv::assign_value(Binding ix, obj x) { + scope log(XO_DEBUG(true)); + assert(!ix.is_global()); const DLocalEnv * env = this; @@ -76,6 +79,7 @@ namespace xo { auto j = ix.j_slot(); if (j < static_cast(env->size())) { + log && log("STUB: need write barrier for GC here"); (*(env->args_))[j] = x; } else { assert(false); diff --git a/src/interpreter2/DVsmDefContFrame.cpp b/src/interpreter2/DVsmDefContFrame.cpp new file mode 100644 index 00000000..7b3b9e7a --- /dev/null +++ b/src/interpreter2/DVsmDefContFrame.cpp @@ -0,0 +1,68 @@ +/** @file DVsmDefContFrame.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DVsmDefContFrame.hpp" +#include +#include + +namespace xo { + namespace scm { + + DVsmDefContFrame::DVsmDefContFrame(obj parent, + VsmInstr cont, + DDefineExpr * def_expr) + : parent_{parent}, + cont_{cont}, + def_expr_{def_expr} + {} + + DVsmDefContFrame * + DVsmDefContFrame::make(obj mm, + obj parent, + VsmInstr cont, + DDefineExpr * def_expr) + { + void * mem = mm.alloc_for(); + + return new (mem) DVsmDefContFrame(parent, cont, def_expr); + } + + // gcobject facet + + std::size_t + DVsmDefContFrame::shallow_size() const noexcept + { + return sizeof(*this); + } + + DVsmDefContFrame * + DVsmDefContFrame::shallow_copy(obj mm) const noexcept + { + return mm.std_copy_for(this); + } + + std::size_t + DVsmDefContFrame::forward_children(obj gc) noexcept + { + gc.forward_inplace(&parent_); + gc.forward_inplace(&def_expr_); + + return this->shallow_size(); + } + + // printable facet + + bool + DVsmDefContFrame::pretty(const ppindentinfo & ppii) const noexcept + { + return ppii.pps()->pretty_struct(ppii, + "DVsmDefContFrame", + refrtag("cont", cont_)); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmDefContFrame.cpp */ diff --git a/src/interpreter2/IGCObject_DGlobalEnv.cpp b/src/interpreter2/IGCObject_DGlobalEnv.cpp new file mode 100644 index 00000000..76606d6f --- /dev/null +++ b/src/interpreter2/IGCObject_DGlobalEnv.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DGlobalEnv.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DGlobalEnv.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DGlobalEnv.json5] +**/ + +#include "env/IGCObject_DGlobalEnv.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DGlobalEnv::shallow_size(const DGlobalEnv & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DGlobalEnv::shallow_copy(const DGlobalEnv & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DGlobalEnv::forward_children(DGlobalEnv & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DGlobalEnv.cpp */ diff --git a/src/interpreter2/IGCObject_DLocalEnv.cpp b/src/interpreter2/IGCObject_DLocalEnv.cpp index 3ee3b7c7..3b6cd5f7 100644 --- a/src/interpreter2/IGCObject_DLocalEnv.cpp +++ b/src/interpreter2/IGCObject_DLocalEnv.cpp @@ -11,7 +11,7 @@ * [idl/IGCObject_DLocalEnv.json5] **/ -#include "detail/IGCObject_DLocalEnv.hpp" +#include "env/IGCObject_DLocalEnv.hpp" namespace xo { namespace scm { diff --git a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp new file mode 100644 index 00000000..26a23611 --- /dev/null +++ b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DVsmDefContFrame.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVsmDefContFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVsmDefContFrame.json5] +**/ + +#include "define/IGCObject_DVsmDefContFrame.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DVsmDefContFrame::shallow_size(const DVsmDefContFrame & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DVsmDefContFrame::shallow_copy(const DVsmDefContFrame & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DVsmDefContFrame::forward_children(DVsmDefContFrame & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVsmDefContFrame.cpp */ diff --git a/src/interpreter2/IPrintable_DGlobalEnv.cpp b/src/interpreter2/IPrintable_DGlobalEnv.cpp new file mode 100644 index 00000000..84fc561c --- /dev/null +++ b/src/interpreter2/IPrintable_DGlobalEnv.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DGlobalEnv.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DGlobalEnv.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DGlobalEnv.json5] +**/ + +#include "env/IPrintable_DGlobalEnv.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DGlobalEnv::pretty(const DGlobalEnv & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DGlobalEnv.cpp */ diff --git a/src/interpreter2/IPrintable_DLocalEnv.cpp b/src/interpreter2/IPrintable_DLocalEnv.cpp index bf701cb6..6fe745b2 100644 --- a/src/interpreter2/IPrintable_DLocalEnv.cpp +++ b/src/interpreter2/IPrintable_DLocalEnv.cpp @@ -11,7 +11,7 @@ * [idl/IPrintable_DLocalEnv.json5] **/ -#include "detail/IPrintable_DLocalEnv.hpp" +#include "env/IPrintable_DLocalEnv.hpp" namespace xo { namespace scm { diff --git a/src/interpreter2/IPrintable_DVsmDefContFrame.cpp b/src/interpreter2/IPrintable_DVsmDefContFrame.cpp new file mode 100644 index 00000000..f73b7dd6 --- /dev/null +++ b/src/interpreter2/IPrintable_DVsmDefContFrame.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DVsmDefContFrame.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVsmDefContFrame.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVsmDefContFrame.json5] +**/ + +#include "define/IPrintable_DVsmDefContFrame.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DVsmDefContFrame::pretty(const DVsmDefContFrame & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DVsmDefContFrame.cpp */ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 5c2d2c57..aa0861f5 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -4,6 +4,7 @@ **/ #include "VirtualSchematikaMachine.hpp" +#include "VsmDefContFrame.hpp" #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" #include "VsmApplyClosureFrame.hpp" @@ -11,10 +12,12 @@ #include "VsmSeqContFrame.hpp" #include "VsmRcx.hpp" #include "Closure.hpp" +#include #include #include #include #include +#include #include #include //#include @@ -65,10 +68,10 @@ namespace xo { DArena * arena = new DArena(config_.error_config_); assert(arena); - error_mm_.adopt(obj(arena)); + this->error_mm_.adopt(obj(arena)); } - // TODO: allocate global_env + this->global_env_ = DGlobalEnv::_make(mm_.to_op(), reader_.global_symtab()); } obj @@ -166,17 +169,20 @@ namespace xo { VirtualSchematikaMachine::execute_one() { scope log(XO_DEBUG(config_.debug_flag_)); + log && log(xtag("pc", pc_), xtag("cont", cont_)); - obj stack_pr = stack_.to_facet(); -// = (FacetRegistry::instance() -// .try_variant(stack_)); + auto expr_pr = expr_.to_facet(); + if (expr_pr) + log && log(xtag("expr", expr_pr)); + auto stack_pr = stack_.to_facet(); if (stack_pr) log && log(xtag("stack", stack_pr)); switch (pc_.opcode()) { + case vsm_opcode::sentinel: case vsm_opcode::halt: case vsm_opcode::N: return false; @@ -189,6 +195,9 @@ namespace xo { case vsm_opcode::evalargs: _do_evalargs_op(); break; + case vsm_opcode::def_cont: + _do_def_cont_op(); + break; case vsm_opcode::apply_cont: _do_apply_cont_op(); break; @@ -244,14 +253,84 @@ namespace xo { = obj::from(expr_); this->value_ = VsmResult(expr.data()->value()); + this->pc_ = this->cont_; + this->cont_ = VsmInstr::c_sentinel; } void VirtualSchematikaMachine::_do_eval_define_op() { - // not implemented - assert(false); + scope log(XO_DEBUG(true)); + + auto def_expr + = obj::from(expr_); + + if (local_env_ == nullptr) { + // top-level define + + // .stack_ --+ + // | + // v + // +------DVsmDefContFrame------+ + // | .parent x | .cont | .def x | + // +---------|-+-------+------|-+ + // | | + // ParserStack* <-----/ | + // | + // v + // DDefineExpr + + /* stack frame for nested continuation + * (to perform assignment) + */ + auto defcont_frame + = obj + (DVsmDefContFrame::make(mm_.to_op(), + this->stack_ /*saved stack*/, + this->cont_ /*saved cont*/, + def_expr.data() /*saved expr*/)); + + this->stack_ = defcont_frame; + + // setup evaluation of rhs + + this->expr_ = def_expr->rhs(); + this->pc_ = VsmInstr::c_eval; + this->cont_ = VsmInstr::c_def_cont; + } else { + // nested defines implemented by rewriting, + // so this branch should be unreachable + + assert(false); + } + } + + void + VirtualSchematikaMachine::_do_def_cont_op() + { + // see DVsmDefContFrame + + auto frame = obj::from(stack_); + + assert(frame); + assert(value_.is_value()); + + // TODO: verify that value satisfies expected type ? + + DVariable * lhs = frame->def_expr()->lhs(); + obj rhs = *value_.value(); + + assert(lhs->path().is_global()); + + global_env_->assign_value(mm_.to_op(), lhs->path(), rhs); + + // TODO: unfortunate const_cast here, because obj<> doesn't support const DRepr yet + this->value_ = VsmResult(obj(const_cast(lhs->name()))); + + this->stack_ = frame->parent(); + this->pc_ = frame->cont(); + this->cont_ = VsmInstr::c_sentinel; } void @@ -294,7 +373,9 @@ namespace xo { this->value_ = VsmResult(obj(obj(closure))); + this->pc_ = this->cont_; + this->cont_ = VsmInstr::c_sentinel; } void @@ -320,7 +401,9 @@ namespace xo { if (value) { this->value_ = VsmResult(value); + this->pc_ = this->cont_; + this->cont_ = VsmInstr::c_sentinel; return; } @@ -338,6 +421,7 @@ namespace xo { // 3. have every vsm instruction check inputs for errors this->pc_ = VsmInstr::c_halt; + this->cont_ = VsmInstr::c_sentinel; } void @@ -385,9 +469,9 @@ namespace xo { // Setup evaluation of first argument. No new stack for this. - this->cont_ = VsmInstr::c_evalargs; this->expr_ = apply->fn(); this->pc_ = VsmInstr::c_eval; + this->cont_ = VsmInstr::c_evalargs; } void @@ -404,9 +488,9 @@ namespace xo { stack_, cont_, ifelse_expr.data())); this->stack_ = ifelse_frame; - this->cont_ = VsmInstr::c_ifelse_cont; this->expr_ = ifelse_expr->test(); this->pc_ = VsmInstr::c_eval; + this->cont_ = VsmInstr::c_ifelse_cont; } void @@ -445,9 +529,9 @@ namespace xo { // Setup evaluation of first sequence element - this->cont_ = VsmInstr::c_seq_cont; this->expr_ = (*seq_expr.data())[0]; this->pc_ = VsmInstr::c_eval; + this->cont_ = VsmInstr::c_seq_cont; } void @@ -514,6 +598,7 @@ namespace xo { this->local_env_ = local_env; this->expr_ = lambda->body_expr(); this->pc_ = VsmInstr::c_eval; + // cont_ already established } void @@ -523,6 +608,7 @@ namespace xo { this->value_ = VsmResult(fn.apply_nocheck(rcx_.to_op(), args_)); this->pc_ = cont_; + this->cont_ = VsmInstr::c_sentinel; } void @@ -537,6 +623,7 @@ namespace xo { log && log("error in apply -> terminating app"); this->pc_ = VsmInstr::c_halt; + this->cont_ = VsmInstr::c_sentinel; return; } @@ -595,7 +682,7 @@ namespace xo { this->expr_ = apply_expr->arg(i_arg); this->pc_ = VsmInstr::c_eval; - //this->cont_ = VsmInstra::c_evalargs; // redundant, since preserved + this->cont_ = VsmInstr::c_evalargs; return; } else { @@ -633,7 +720,7 @@ namespace xo { } else { this->expr_ = apply_expr->arg(i_arg); this->pc_ = VsmInstr::c_eval; - //this->cont_ = VsmInstra::c_evalargs; // redundant, since preserved + this->cont_ = VsmInstr::c_evalargs; return; } @@ -655,6 +742,7 @@ namespace xo { this->stack_ = frame->parent(); this->local_env_ = frame->local_env(); this->pc_ = frame->cont(); + this->cont_ = VsmInstr::c_sentinel; } void @@ -682,9 +770,9 @@ namespace xo { } this->stack_ = frame->parent(); - this->cont_ = frame->cont(); this->expr_ = next_expr; this->pc_ = VsmInstr::c_eval; + this->cont_ = frame->cont(); } else { auto error = DRuntimeError::make(mm_.to_op(), "_do_ifelse_cont_op", @@ -698,6 +786,7 @@ namespace xo { // 3. have every vsm instruction check inputs for errors this->pc_ = VsmInstr::c_halt; + this->cont_ = VsmInstr::c_sentinel; } } @@ -722,13 +811,16 @@ namespace xo { this->stack_ = frame->parent(); this->pc_ = frame->cont(); + this->cont_ = VsmInstr::c_sentinel; + return; } else { frame->incr_i_seq(); - this->cont_ = VsmInstr::c_seq_cont; this->expr_ = (*seq_expr)[i_seq]; this->pc_ = VsmInstr::c_eval; + this->cont_ = VsmInstr::c_seq_cont; + return; } } diff --git a/src/interpreter2/VsmInstr.cpp b/src/interpreter2/VsmInstr.cpp index b815c079..852b6332 100644 --- a/src/interpreter2/VsmInstr.cpp +++ b/src/interpreter2/VsmInstr.cpp @@ -11,10 +11,12 @@ namespace xo { vsm_opcode_descr(vsm_opcode x) { switch (x) { + case vsm_opcode::sentinel: return "sentinel"; case vsm_opcode::halt: return "halt"; case vsm_opcode::eval: return "eval"; case vsm_opcode::apply: return "apply"; case vsm_opcode::evalargs: return "evalargs"; + case vsm_opcode::def_cont: return "def_cont"; case vsm_opcode::apply_cont: return "apply_cont"; case vsm_opcode::ifelse_cont: return "ifelse_cont"; case vsm_opcode::seq_cont: return "seq_cont"; @@ -25,6 +27,9 @@ namespace xo { return "opcode?"; } + VsmInstr + VsmInstr::c_sentinel = VsmInstr(vsm_opcode::sentinel); + VsmInstr VsmInstr::c_halt = VsmInstr(vsm_opcode::halt); @@ -37,12 +42,15 @@ namespace xo { VsmInstr VsmInstr::c_evalargs = VsmInstr(vsm_opcode::evalargs); + VsmInstr + VsmInstr::c_def_cont = VsmInstr(vsm_opcode::def_cont); + VsmInstr VsmInstr::c_apply_cont = VsmInstr(vsm_opcode::apply_cont); VsmInstr VsmInstr::c_ifelse_cont = VsmInstr(vsm_opcode::ifelse_cont); - + VsmInstr VsmInstr::c_seq_cont = VsmInstr(vsm_opcode::seq_cont); } /*namespace scm*/ diff --git a/src/interpreter2/interpreter2_register_facets.cpp b/src/interpreter2/interpreter2_register_facets.cpp index dc9b31be..22c9bfb9 100644 --- a/src/interpreter2/interpreter2_register_facets.cpp +++ b/src/interpreter2/interpreter2_register_facets.cpp @@ -6,6 +6,7 @@ #include "interpreter2_register_facets.hpp" #include "DPrimitive_gco_2_gco_gco.hpp" +#include "VsmDefContFrame.hpp" #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" #include "VsmApplyClosureFrame.hpp" @@ -13,6 +14,7 @@ #include "VsmSeqContFrame.hpp" #include "Primitive_gco_2_gco_gco.hpp" #include "Closure.hpp" +#include "GlobalEnv.hpp" #include "LocalEnv.hpp" #include "VsmRcx.hpp" @@ -39,6 +41,7 @@ namespace xo { // +- VsmApplyFrame // +- VsmEvalArgsFrame // +- VsmApplyClosureFrame + // +- VsmDefContFrame // +- VsmIfElseContFrame // \- VsmSeqContFrame @@ -51,12 +54,20 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); + // GlobalEnv + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + // LocalEnv FacetRegistry::register_impl(); @@ -84,8 +95,12 @@ namespace xo { log && log(xtag("DVsmApplyFrame.tseq", typeseq::id())); log && log(xtag("DVsmEvalArgsFrame.tseq", typeseq::id())); log && log(xtag("DVsmApplyClosureFrame.tseq", typeseq::id())); + log && log(xtag("DVsmDefContFrame.tseq", typeseq::id())); + log && log(xtag("DVsmDefContFrame.tseq", typeseq::id())); + log && log(xtag("DVsmIfElseContFrame.tseq", typeseq::id())); log && log(xtag("DVsmSeqContFrame.tseq", typeseq::id())); log && log(xtag("DClosure.tseq", typeseq::id())); + log && log(xtag("DGlobalEnv.tseq", typeseq::id())); log && log(xtag("DLocalEnv.tseq", typeseq::id())); log && log(xtag("DVsmRcx.tseq", typeseq::id())); diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 1a50c555..1af15c86 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -5,11 +5,13 @@ #include #include +#include #include #include #include #include #include +#include #ifdef NOT_YET #include @@ -32,6 +34,7 @@ namespace xo { using xo::scm::VsmResultExt; using xo::scm::DClosure; using xo::scm::DString; + using xo::scm::DUniqueString; // aks Symbol in lisp using xo::scm::DFloat; using xo::scm::DBoolean; using xo::scm::DInteger; @@ -42,6 +45,7 @@ namespace xo { using xo::mm::DArena; using xo::mm::ArenaConfig; using xo::facet::FacetRegistry; + using xo::facet::TypeRegistry; using span_type = xo::scm::VirtualSchematikaMachine::span_type; using Catch::Matchers::WithinAbs; @@ -81,6 +85,7 @@ namespace xo { aux_mm_.arena_.visit_pools(visitor); FacetRegistry::instance().visit_pools(visitor); + TypeRegistry::instance().visit_pools(visitor); vsm_.visit_pools(visitor); return true; @@ -298,7 +303,7 @@ namespace xo { { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - bool c_debug_flag = true; + bool c_debug_flag = false; scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); VsmFixture vsm_fixture(testname, c_debug_flag); @@ -333,6 +338,96 @@ namespace xo { log && vsm_fixture.log_memory_layout(&log); } + TEST_CASE("VirtualSchematikaMachine-def1", "[interpreter2][VSM]") + { + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + bool c_debug_flag = false; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + + VsmFixture vsm_fixture(testname, c_debug_flag); + auto & vsm = vsm_fixture.vsm_; + + bool eof_flag = false; + + vsm.begin_interactive_session(); + VsmResultExt res + = vsm.read_eval_print(span_type::from_cstr("def foo = 3.14159;"), + eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq()), + xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); + + // currently get not-implemented error + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(strcmp(x->chars(), "foo") == 0); + + //log && log("runtime-error", xtag("ex.src", x->src_function()), xtag("ex.descr", x->error_descr())); + + //REQUIRE(x.data()->value() == 1.570796325); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + + log && vsm_fixture.log_memory_layout(&log); + } + + TEST_CASE("VirtualSchematikaMachine-def2", "[interpreter2][VSM]") + { + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + + VsmFixture vsm_fixture(testname, c_debug_flag); + auto & vsm = vsm_fixture.vsm_; + + bool eof_flag = false; + + vsm.begin_interactive_session(); + + span_type input = span_type::from_cstr("def foo = 3.14159; foo"); + + for (int i_expr = 0; i_expr < 2; ++i_expr) { + VsmResultExt res + = vsm.read_eval_print(input, eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq()), + xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); + + if (i_expr == 0) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(strcmp(x->chars(), "foo") == 0); + + REQUIRE(res.remaining_.size() > 1); + + input = res.remaining_; + } else if (i_expr == 1) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(x->value() == 3.14159); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + input = res.remaining_; + } + + ++i_expr; + } + + log && vsm_fixture.log_memory_layout(&log); + + } + } /*namespace ut*/ } /*namespace xo*/ From a2fc3cb34a23a50546a13ec791f4fd840b5774da Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 17 Feb 2026 15:01:46 -0500 Subject: [PATCH 046/131] xo-interpreter2: global variable refs working in utest --- src/interpreter2/VirtualSchematikaMachine.cpp | 21 ++++++++++++++----- utest/VirtualSchematikaMachine.test.cpp | 8 +++---- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index aa0861f5..e7964ab4 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -113,6 +113,8 @@ namespace xo { return VsmResultExt(); } + reader_.reset_result(); + auto [expr, remaining, error1] = reader_.read_expr(input, eof); @@ -392,12 +394,21 @@ namespace xo { Binding b = var->path(); - if (!local_env_) { - // need lookup on global_env_ - assert(false); + if (local_env_) { + auto value = local_env_->lookup_value(b); + + if (value) { + this->value_ = VsmResult(value); + + this->pc_ = this->cont_; + this->cont_ = VsmInstr::c_sentinel; + return; + } } - auto value = local_env_->lookup_value(b); + // no local binding. perhaps there's a global binding + + auto value = global_env_->lookup_value(b); if (value) { this->value_ = VsmResult(value); @@ -407,7 +418,7 @@ namespace xo { return; } - // no binding + // no local or global binding auto error = DRuntimeError::make(mm_.to_op(), "_do_eval_varref_op", diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 1af15c86..3d1a76a8 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -391,9 +391,11 @@ namespace xo { vsm.begin_interactive_session(); - span_type input = span_type::from_cstr("def foo = 3.14159; foo"); + span_type input = span_type::from_cstr("def foo = 3.14159; foo;"); for (int i_expr = 0; i_expr < 2; ++i_expr) { + log && log(xtag("input", input)); + VsmResultExt res = vsm.read_eval_print(input, eof_flag); @@ -414,14 +416,12 @@ namespace xo { } else if (i_expr == 1) { auto x = obj::from(*res.value()); REQUIRE(x); - REQUIRE(x->value() == 3.14159); + REQUIRE_THAT(x->value(), WithinAbs(3.14159, 1e-6)); REQUIRE(res.remaining_.size() == 1); REQUIRE(*res.remaining_.lo() == '\n'); input = res.remaining_; } - - ++i_expr; } log && vsm_fixture.log_memory_layout(&log); From e993ee0de7d12eec6676fe7c3dbca4f4699c0073 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 17 Feb 2026 20:07:43 -0500 Subject: [PATCH 047/131] xo-interpreter2: recursive factorial utest. working! --- src/interpreter2/VirtualSchematikaMachine.cpp | 18 ++-- utest/VirtualSchematikaMachine.test.cpp | 89 +++++++++++++++++++ 2 files changed, 94 insertions(+), 13 deletions(-) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index e7964ab4..dc8844e2 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -394,22 +394,14 @@ namespace xo { Binding b = var->path(); - if (local_env_) { - auto value = local_env_->lookup_value(b); + obj value; - if (value) { - this->value_ = VsmResult(value); - - this->pc_ = this->cont_; - this->cont_ = VsmInstr::c_sentinel; - return; - } + if (b.is_local() && local_env_) { + value = local_env_->lookup_value(b); + } else if (b.is_global()) { + value = global_env_->lookup_value(b); } - // no local binding. perhaps there's a global binding - - auto value = global_env_->lookup_value(b); - if (value) { this->value_ = VsmResult(value); diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 3d1a76a8..8d4188a6 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -428,6 +428,95 @@ namespace xo { } + TEST_CASE("VirtualSchematikaMachine-def3", "[interpreter2][VSM]") + { + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + + VsmFixture vsm_fixture(testname, c_debug_flag); + auto & vsm = vsm_fixture.vsm_; + + bool eof_flag = true; + + vsm.begin_interactive_session(); + + span_type input = span_type::from_cstr("def fact = lambda (n) { if (n == 0) then 1 else n * fact(n - 1) };"); + + for (int i_expr = 0; i_expr < 1; ++i_expr) { + log && log(xtag("input", input)); + + VsmResultExt res + = vsm.read_eval_print(input, eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq()), + xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); + + if (i_expr == 0) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(strcmp(x->chars(), "fact") == 0); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + input = res.remaining_; + } + } + + log && vsm_fixture.log_memory_layout(&log); + } + + TEST_CASE("VirtualSchematikaMachine-fact0", "[interpreter2][VSM]") + { + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + + VsmFixture vsm_fixture(testname, c_debug_flag); + auto & vsm = vsm_fixture.vsm_; + + bool eof_flag = true; + + vsm.begin_interactive_session(); + + span_type input = span_type::from_cstr("def fact = lambda (n) { if (n == 0) then 1 else n * fact(n - 1) }; fact(4);"); + + for (int i_expr = 0; i_expr < 2; ++i_expr) { + log && log(xtag("input", input)); + + VsmResultExt res + = vsm.read_eval_print(input, eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq()), + xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); + + if (i_expr == 0) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(strcmp(x->chars(), "fact") == 0); + input = res.remaining_; + } else if (i_expr == 1) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(x->value() == 24); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + input = res.remaining_; + } + } + + log && vsm_fixture.log_memory_layout(&log); + } + } /*namespace ut*/ } /*namespace xo*/ From 3c20facb34bd72ee380fc8b2ef6c18427b2b6761 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 18 Feb 2026 01:46:45 -0500 Subject: [PATCH 048/131] xo-interpreter2: + skrepl (read eval print loop) --- CMakeLists.txt | 1 + .../interpreter2/VirtualSchematikaMachine.hpp | 5 + src/interpreter2/VirtualSchematikaMachine.cpp | 6 + src/skrepl/CMakeLists.txt | 13 + src/skrepl/skreplxx.cpp | 242 ++++++++++++++++++ utest/VirtualSchematikaMachine.test.cpp | 13 +- 6 files changed, 268 insertions(+), 12 deletions(-) create mode 100644 src/skrepl/CMakeLists.txt create mode 100644 src/skrepl/skreplxx.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d1a6db8..426e4112 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -21,6 +21,7 @@ add_definitions(${PROJECT_CXX_FLAGS}) # output targets add_subdirectory(src/interpreter2) +add_subdirectory(src/skrepl) add_subdirectory(utest) # ---------------------------------------------------------------- diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 724e1c33..75fb968f 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -91,6 +91,11 @@ namespace xo { /** allocator for runtime errors **/ obj error_allocator() const noexcept; + /** true iff parser is at top-level -> does not contain + * state for a incomplete/partial expression + **/ + bool is_at_toplevel() const noexcept; + /** visit vsm-owned memory pools; call visitor(info) for each **/ void visit_pools(const MemorySizeVisitor & visitor) const; diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index dc8844e2..9104fa2f 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -86,6 +86,12 @@ namespace xo { return error_mm_.to_op(); } + bool + VirtualSchematikaMachine::is_at_toplevel() const noexcept + { + return reader_.is_at_toplevel(); + } + void VirtualSchematikaMachine::visit_pools(const MemorySizeVisitor & visitor) const { diff --git a/src/skrepl/CMakeLists.txt b/src/skrepl/CMakeLists.txt new file mode 100644 index 00000000..b5511114 --- /dev/null +++ b/src/skrepl/CMakeLists.txt @@ -0,0 +1,13 @@ +# xo-interpreter2/src/repl/CMakeLists.txt + +set(SELF_EXE skrepl) +set(SELF_SRCS skreplxx.cpp) + +xo_add_executable(${SELF_EXE} ${SELF_SRCS}) +xo_self_dependency(${SELF_EXE} xo_interpreter2) +xo_external_target_dependency(${SELF_EXE} replxx replxx::replxx) + +# replxx requires this +find_package(Threads REQUIRED) +target_link_libraries(${SELF_EXE} PUBLIC Threads::Threads) + diff --git a/src/skrepl/skreplxx.cpp b/src/skrepl/skreplxx.cpp new file mode 100644 index 00000000..df6be29d --- /dev/null +++ b/src/skrepl/skreplxx.cpp @@ -0,0 +1,242 @@ +/** @file skreplxx.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include +#include +#include +#include +#include +#include + +namespace xo { + using xo::scm::VirtualSchematikaMachine; + using xo::scm::VsmResultExt; + using xo::mm::AAllocator; + using xo::mm::ArenaConfig; + using xo::mm::DArena; + using span_type = xo::mm::span; + using xo::facet::FacetRegistry; + using xo::facet::TypeRegistry; + using std::cerr; + + // presumeably replxx assumes input is a tty anyway? + // + bool replxx_getline(bool interactive, + bool is_at_toplevel, + replxx::Replxx & rx, + span_type * p_input + //const char ** p_input + ) + { + using namespace std; + + char const * prompt = ""; + + if (interactive) { + prompt = ((is_at_toplevel) ? "> " : ". "); + } + + const char * input_cstr = rx.input(prompt); + + bool retval = (input_cstr != nullptr); + + if (retval) + *p_input = span_type::from_cstr(input_cstr); + + if (input_cstr) + rx.history_add(input_cstr); + + return retval; + } + + void + welcome(std::ostream & os) + { + using namespace std; + + os << "schematika repl" << endl; + os << " ctrl-a/ctrl-e beginning/end of line" << endl; + os << " ctrl-u delete entire line" << endl; + os << " ctrl-k delete to end of line" << endl; + os << " meta- backward delete word" << endl; + os << " |meta-p previous command from history" << endl; + os << " |meta-n next command from history" << endl; + os << " / page through history faster" << endl; + os << " ctrl-s/ctrl-r forward/backward history search" << endl; + os << endl; + } + + struct ReplConfig { + ReplConfig() = default; + + std::size_t max_history_size_ = 1000; + std::string repl_history_fname_ = "skrepl_history.txt"; + bool debug_flag_ = false; + }; + + struct AppConfig { + using VsmConfig = xo::scm::VsmConfig; + + //using ReaderConfig = xo::scm::ReaderConfig; + //using X1CollectorConfig = xo::mm::X1CollectorConfig; + //using ArenaConfig = xo::mm::ArenaConfig; + + AppConfig(const ReplConfig & repl_cfg = ReplConfig(), + const ArenaConfig & app_arena_cfg = ArenaConfig().with_name("skreplxx").with_size(16 * 1024), + const VsmConfig & vsm_cfg = VsmConfig()) + : repl_config_{repl_cfg}, app_arena_config_{app_arena_cfg}, vsm_config_{vsm_cfg} + { + //rdr_config_.reader_debug_flag_ = true; + //rdr_config.parser_debug_flag_ = true; + //rdr_config.tk_debug_flag_ = true; + } + + ReplConfig repl_config_; + ArenaConfig app_arena_config_; + VsmConfig vsm_config_; + //ReaderConfig rdr_config_; + //X1CollectorConfig x1_config_ = (X1CollectorConfig().with_name("gc").with_size(4*1024*1024)); + //ArenaConfig fixed_config_ = (ArenaConfig().with_name("fixed").with_size(4*1024)); + }; + + struct App { + //using AAllocator = xo::mm::AAllocator; + //using DX1Collector = xo::mm::DX1Collector; + //using X1CollectorConfig = xo::mm::X1CollectorConfig; + //using DArena = xo::mm::DArena; + //using ArenaConfig = xo::mm::ArenaConfig; + using Replxx = replxx::Replxx; + using span_type = VirtualSchematikaMachine::span_type; + + App(const AppConfig & cfg = AppConfig()) + : repl_config_{cfg.repl_config_}, + app_arena_{cfg.app_arena_config_}, + vsm_{cfg.vsm_config_, obj(&app_arena_)} + { + this->interactive_ = isatty(STDIN_FILENO); + + rx_.set_max_history_size(repl_config_.max_history_size_); + rx_.history_load(repl_config_.repl_history_fname_); + // rx.bind_key_internal(Replxx::KEY::control('p'), "history_previous"); + // rx.bind_key_internal(Replxx::KEY::control('n'), "history_next"); + } + + /** borrows calling thread to run application **/ + void run(); + + private: + void _init(); + void _start(); + void _repl(); + bool _read_eval_print(span_type * p_input, bool eof); + + private: + InitEvidence init_evidence_ = 0; + ReplConfig repl_config_; + bool interactive_ = false; + Replxx rx_; + ///** collector/allocator for schematika expressions **/ + //DX1Collector x1_; + ///** e.g. for DArenaHashMap within global symtab **/ + //DArena fixed_; + + /** arena with same lifetime as this application **/ + DArena app_arena_; + /** schematika virtual machine **/ + VirtualSchematikaMachine vsm_; + }; + + void + App::run() + { + this->_init(); + this->_start(); + this->_repl(); + } + + void + App::_init() + { + // window to contorl size of registries ends as soon as we init other subsystems + TypeRegistry::instance(1024); + FacetRegistry::instance(1024); + + InitEvidence init_evidence_ = (InitSubsys::require()); + + Subsystem::initialize_all(); + } + + void + App::_start() + { + welcome(cerr); + + vsm_.begin_interactive_session(); + } + + void + App::_repl() + { + bool eof = false; + span_type input; + + // outer loop: fetch one line of interactive input + while (replxx_getline(interactive_, vsm_.is_at_toplevel(), rx_, &input)) { + + // inner lo9op: consume up to one expression at a time. + while (!input.empty() && this->_read_eval_print(&input, false /*eof*/)) + { + ; + } + + /* here: either: + * 1. input.empty() or + * 2. error encountered + */ + } + + /* reminder: eof can complete at most one token */ + this->_read_eval_print(&input, true /*eof*/); + } + + /** body of read-parse-print loop + * + * true -> no errors; + * false -> reader encountered error + **/ + bool + App::_read_eval_print(span_type * p_input, + bool eof) + { + scope log(XO_DEBUG(repl_config_.debug_flag_)); + + if (!p_input || p_input->empty()) + return true; + + VsmResultExt res = vsm_.read_eval_print(*p_input, eof); + + *p_input = res.remaining_; + + return !res.is_tk_error() && !res.is_eval_error(); + } + +} /*namespace xo*/ + +int +main (int argc, char * argv[]) +{ + using xo::AppConfig; + using xo::App; + + AppConfig cfg; + // [cmdline options here] + + App app(cfg); + + app.run(); +} /*main*/ + +/* end skreplxx.cpp */ + diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 8d4188a6..77b3a30b 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -3,6 +3,7 @@ * @author Roland Conybeare, Jan 2026 **/ +#include #include #include #include @@ -12,18 +13,6 @@ #include #include #include - -#ifdef NOT_YET -#include -#include -#include -#include -#include -#endif -#include -#ifdef NOT_YET -#include -#endif #include #include From a13e5efa6156bfce9ba81c9882e850df014aa715 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 18 Feb 2026 21:47:02 -0800 Subject: [PATCH 049/131] xo-reader2 stack: + xo-numeric + setup multi dispatch for *,/ --- src/skrepl/skreplxx.cpp | 6 +++-- utest/VirtualSchematikaMachine.test.cpp | 33 ++++++++++++++++++++++++- 2 files changed, 36 insertions(+), 3 deletions(-) diff --git a/src/skrepl/skreplxx.cpp b/src/skrepl/skreplxx.cpp index df6be29d..6d68fb32 100644 --- a/src/skrepl/skreplxx.cpp +++ b/src/skrepl/skreplxx.cpp @@ -9,6 +9,9 @@ #include #include #include +#ifdef __APPLE__ +#include // for STDIN_FILENO on OSX +#endif namespace xo { using xo::scm::VirtualSchematikaMachine; @@ -85,7 +88,7 @@ namespace xo { AppConfig(const ReplConfig & repl_cfg = ReplConfig(), const ArenaConfig & app_arena_cfg = ArenaConfig().with_name("skreplxx").with_size(16 * 1024), - const VsmConfig & vsm_cfg = VsmConfig()) + const VsmConfig & vsm_cfg = VsmConfig()) : repl_config_{repl_cfg}, app_arena_config_{app_arena_cfg}, vsm_config_{vsm_cfg} { //rdr_config_.reader_debug_flag_ = true; @@ -239,4 +242,3 @@ main (int argc, char * argv[]) } /*main*/ /* end skreplxx.cpp */ - diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 77b3a30b..75726b72 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -73,8 +73,8 @@ namespace xo { }; aux_mm_.arena_.visit_pools(visitor); - FacetRegistry::instance().visit_pools(visitor); TypeRegistry::instance().visit_pools(visitor); + FacetRegistry::instance().visit_pools(visitor); vsm_.visit_pools(visitor); return true; @@ -189,6 +189,37 @@ namespace xo { log && vsm_fixture.log_memory_layout(&log); } + TEST_CASE("VirtualSchematikaMachine-arith2", "[interpreter2][VSM]") + { + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + constexpr bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + + VsmFixture vsm_fixture(testname, c_debug_flag); + auto & vsm = vsm_fixture.vsm_; + + bool eof_flag = false; + + vsm.begin_interactive_session(); + VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("3.14159265 / 0.5;"), eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq())); + + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(x.data()->value() == 6.2831853); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + + log && vsm_fixture.log_memory_layout(&log); + } + TEST_CASE("VirtualSchematikaMachine-cmp1", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); From 1750c0681e971fd4b7dffb7683411e4eceeb24a3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 19 Feb 2026 09:03:02 -0800 Subject: [PATCH 050/131] xo-interpreter2 stack: streamline op== impl + utests --- src/interpreter2/VirtualSchematikaMachine.cpp | 8 +++ utest/VirtualSchematikaMachine.test.cpp | 49 ++++++++++++++++++- 2 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 9104fa2f..40ccb834 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -185,6 +185,14 @@ namespace xo { if (expr_pr) log && log(xtag("expr", expr_pr)); + if (value_.value()) { + auto value_pr = const_cast *>(value_.value())->to_facet(); + if (value_pr) + log && log(xtag("value", value_pr)); + } else { + log && log("value not present or tk error"); + } + auto stack_pr = stack_.to_facet(); if (stack_pr) log && log(xtag("stack", stack_pr)); diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 75726b72..a42746ae 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -490,7 +490,7 @@ namespace xo { log && vsm_fixture.log_memory_layout(&log); } - TEST_CASE("VirtualSchematikaMachine-fact0", "[interpreter2][VSM]") + TEST_CASE("VirtualSchematikaMachine-if2", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); @@ -504,6 +504,53 @@ namespace xo { vsm.begin_interactive_session(); + span_type input = span_type::from_cstr("def n = 4; if (n == 4) then n * 3 else n * 5;"); + + for (int i_expr = 0; i_expr < 2; ++i_expr) { + log && log(xtag("input", input)); + + VsmResultExt res + = vsm.read_eval_print(input, eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq()), + xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); + + if (i_expr == 0) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(strcmp(x->chars(), "n") == 0); + input = res.remaining_; + } else if (i_expr == 1) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(x->value() == 12); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + input = res.remaining_; + } + } + + log && vsm_fixture.log_memory_layout(&log); + } + + TEST_CASE("VirtualSchematikaMachine-fact0", "[interpreter2][VSM]") + { + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + bool c_debug_flag = false; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + + VsmFixture vsm_fixture(testname, c_debug_flag); + auto & vsm = vsm_fixture.vsm_; + + bool eof_flag = true; + + vsm.begin_interactive_session(); + span_type input = span_type::from_cstr("def fact = lambda (n) { if (n == 0) then 1 else n * fact(n - 1) }; fact(4);"); for (int i_expr = 0; i_expr < 2; ++i_expr) { From b6f0e04c100e38316e0bb4621075ba11cb853b43 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 19 Feb 2026 11:56:06 -0800 Subject: [PATCH 051/131] xo-interpreter2 stack: support op!= + trial numeric refactor --- src/interpreter2/VirtualSchematikaMachine.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 40ccb834..c258cdd6 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -132,7 +132,9 @@ namespace xo { VsmResult evalresult = this->start_eval(expr); - if (evalresult.is_eval_error() || evalresult.is_tk_error()) { + if (evalresult.is_tk_error()) { + // TODO: print error here + return VsmResultExt(evalresult, remaining); } From dba44f5a2baa598ef2256b4914822a4f2e3e1c6d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 27 Feb 2026 19:38:53 +1100 Subject: [PATCH 052/131] xo-cmake: setup to make share target available via cmake install --- cmake/xo_interpreter2Config.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/xo_interpreter2Config.cmake.in b/cmake/xo_interpreter2Config.cmake.in index bea8e9cc..3310d075 100644 --- a/cmake/xo_interpreter2Config.cmake.in +++ b/cmake/xo_interpreter2Config.cmake.in @@ -10,4 +10,5 @@ find_dependency(xo_expression2) find_dependency(xo_gc) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Share.cmake") check_required_components("@PROJECT_NAME@") From dbbfddde9f30e94d1d4dac635b8bea6091c47b12 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 27 Feb 2026 19:42:29 +1100 Subject: [PATCH 053/131] osx build: + unistd.h for isatty() --- src/skrepl/skreplxx.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/skrepl/skreplxx.cpp b/src/skrepl/skreplxx.cpp index df6be29d..123d323f 100644 --- a/src/skrepl/skreplxx.cpp +++ b/src/skrepl/skreplxx.cpp @@ -9,6 +9,7 @@ #include #include #include +#include // for isatty() namespace xo { using xo::scm::VirtualSchematikaMachine; @@ -85,7 +86,7 @@ namespace xo { AppConfig(const ReplConfig & repl_cfg = ReplConfig(), const ArenaConfig & app_arena_cfg = ArenaConfig().with_name("skreplxx").with_size(16 * 1024), - const VsmConfig & vsm_cfg = VsmConfig()) + const VsmConfig & vsm_cfg = VsmConfig()) : repl_config_{repl_cfg}, app_arena_config_{app_arena_cfg}, vsm_config_{vsm_cfg} { //rdr_config_.reader_debug_flag_ = true; @@ -239,4 +240,3 @@ main (int argc, char * argv[]) } /*main*/ /* end skreplxx.cpp */ - From 9ee2c1b59ee3fee021692907767cba758a482b66 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 27 Feb 2026 19:42:43 +1100 Subject: [PATCH 054/131] build: + for osx build --- include/xo/interpreter2/VirtualSchematikaMachine.hpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 75fb968f..0df50ced 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -15,6 +15,7 @@ #include #include #include +#include namespace xo { namespace scm { @@ -91,7 +92,7 @@ namespace xo { /** allocator for runtime errors **/ obj error_allocator() const noexcept; - /** true iff parser is at top-level -> does not contain + /** true iff parser is at top-level -> does not contain * state for a incomplete/partial expression **/ bool is_at_toplevel() const noexcept; From 878e12badcc573c1b312859382a956552a711b5d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 28 Feb 2026 13:20:11 +1100 Subject: [PATCH 055/131] xo-interpreter2 stack: support 0-argument function calls --- src/interpreter2/VirtualSchematikaMachine.cpp | 21 +++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index c258cdd6..c2221aed 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -699,11 +699,24 @@ namespace xo { // now i_arg is 0 -> evaluate that argument - this->expr_ = apply_expr->arg(i_arg); - this->pc_ = VsmInstr::c_eval; - this->cont_ = VsmInstr::c_evalargs; + if (i_arg >= static_cast(apply_expr->n_args())) { + // corner case: function with 0 arguments - return; + this->fn_ = apply_frame->fn(); // = value; + this->args_ = apply_frame->args(); // empty + + this->stack_ = apply_frame->parent(); + this->pc_ = VsmInstr::c_apply; + this->cont_ = apply_frame->cont(); + + return; + } else { + this->expr_ = apply_expr->arg(i_arg); + this->pc_ = VsmInstr::c_eval; + this->cont_ = VsmInstr::c_evalargs; + + return; + } } else { // error - function position must deliver something with AProcedure? // or DClosure, but we'll get to that. From 5675e12d97f53a139511d28bd346620db9cb0eca Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 28 Feb 2026 13:22:59 +1100 Subject: [PATCH 056/131] xo-interpreter2: + DGlobalEnv::_upsert_value() --- include/xo/interpreter2/DGlobalEnv.hpp | 9 +++++++++ src/interpreter2/DGlobalEnv.cpp | 17 +++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/xo/interpreter2/DGlobalEnv.hpp b/include/xo/interpreter2/DGlobalEnv.hpp index e68ad55d..e2df166b 100644 --- a/include/xo/interpreter2/DGlobalEnv.hpp +++ b/include/xo/interpreter2/DGlobalEnv.hpp @@ -25,6 +25,7 @@ namespace xo { **/ class DGlobalEnv { public: + using TypeDescr = xo::reflect::TypeDescr; using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; @@ -57,6 +58,14 @@ namespace xo { **/ void assign_value(obj mm, Binding ix, obj x); + /** create/establish global for symbol @p sym with resolved type @p td + * and associate with @p value. + **/ + DVariable * _upsert_value(obj mm, + const DUniqueString * sym, + TypeDescr td, + obj value); + ///@} /** @defgroup scm-globalenv-gcobject-facet **/ ///@{ diff --git a/src/interpreter2/DGlobalEnv.cpp b/src/interpreter2/DGlobalEnv.cpp index a9285b73..2ad6c1ba 100644 --- a/src/interpreter2/DGlobalEnv.cpp +++ b/src/interpreter2/DGlobalEnv.cpp @@ -88,6 +88,23 @@ namespace xo { (*values_)[ix.j_slot()] = x; } + DVariable * + DGlobalEnv::_upsert_value(obj mm, + const DUniqueString * sym, + TypeDescr td, + obj value) + { + DVariable * var + = DVariable::make(mm, sym, TypeRef::resolved(td)); + + assert(var); + + symtab_->upsert_variable(mm, var); + this->assign_value(mm, var->path(), value); + + return var; + } + // ----- AGCObject facet ----- std::size_t From 038a931fa5f66b467269c3f339dea2021d4db59a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 28 Feb 2026 13:26:10 +1100 Subject: [PATCH 057/131] xo-interpreter2 stack: + RuntimeContext.visit_pools() method --- include/xo/interpreter2/DVsmRcx.hpp | 6 ++++-- include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp | 3 +++ src/interpreter2/DVsmRcx.cpp | 6 ++++++ src/interpreter2/IRuntimeContext_DVsmRcx.cpp | 6 ++++++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/include/xo/interpreter2/DVsmRcx.hpp b/include/xo/interpreter2/DVsmRcx.hpp index eeeb7289..3323f7d7 100644 --- a/include/xo/interpreter2/DVsmRcx.hpp +++ b/include/xo/interpreter2/DVsmRcx.hpp @@ -6,11 +6,12 @@ #pragma once #include +#include namespace xo { namespace scm { // see xo-interpreter/ VirtualSchematikaMachine.hpp - class VirtualSchematikaMachine; + class VirtualSchematikaMachine; /** @brief Runtime context for schematika interpreter * @@ -19,12 +20,14 @@ namespace xo { class DVsmRcx { public: using AAllocator = xo::mm::AAllocator; + using MemorySizeVisitor = xo::mm::MemorySizeVisitor; public: DVsmRcx(VirtualSchematikaMachine * vsm); obj allocator() const noexcept; obj error_allocator() const noexcept; + void visit_pools(const MemorySizeVisitor & visitor) const; private: /** schematika interpreter **/ @@ -34,4 +37,3 @@ namespace xo { } /*namespace xo*/ /* end DVsmRcx.hpp */ - diff --git a/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp b/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp index ecb81f1f..0305e3e5 100644 --- a/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp +++ b/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp @@ -40,6 +40,7 @@ namespace xo { /** @defgroup scm-runtimecontext-dvsmrcx-type-traits **/ ///@{ using AAllocator = xo::scm::ARuntimeContext::AAllocator; + using MemorySizeVisitor = xo::scm::ARuntimeContext::MemorySizeVisitor; using Copaque = xo::scm::ARuntimeContext::Copaque; using Opaque = xo::scm::ARuntimeContext::Opaque; ///@} @@ -48,6 +49,8 @@ namespace xo { // const methods /** default allocator to use for objects **/ static obj allocator(const DVsmRcx & self) noexcept; + /** invoke visitor for each distinct memory pool **/ + static void visit_pools(const DVsmRcx & self, MemorySizeVisitor visitor); // non-const methods ///@} diff --git a/src/interpreter2/DVsmRcx.cpp b/src/interpreter2/DVsmRcx.cpp index 71916771..fa81b9c8 100644 --- a/src/interpreter2/DVsmRcx.cpp +++ b/src/interpreter2/DVsmRcx.cpp @@ -25,6 +25,12 @@ namespace xo { return vsm_->error_allocator(); } + void + DVsmRcx::visit_pools(const MemorySizeVisitor & visitor) const + { + vsm_->visit_pools(visitor); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/interpreter2/IRuntimeContext_DVsmRcx.cpp b/src/interpreter2/IRuntimeContext_DVsmRcx.cpp index 3fd3730d..d201051a 100644 --- a/src/interpreter2/IRuntimeContext_DVsmRcx.cpp +++ b/src/interpreter2/IRuntimeContext_DVsmRcx.cpp @@ -21,6 +21,12 @@ namespace xo { return self.allocator(); } + auto + IRuntimeContext_DVsmRcx::visit_pools(const DVsmRcx & self, MemorySizeVisitor visitor) -> void + { + self.visit_pools(visitor); + } + } /*namespace scm*/ } /*namespace xo*/ From baab64c0367bf957800efc3fec8f782917e4fca8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 28 Feb 2026 13:27:34 +1100 Subject: [PATCH 058/131] xo-procedure2: + DPrimitive_gco_0 (primitive with 0 arguments) --- include/xo/interpreter2/VirtualSchematikaMachine.hpp | 2 -- 1 file changed, 2 deletions(-) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 0df50ced..1e19bcdb 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -234,12 +234,10 @@ namespace xo { /** configuration **/ VsmConfig config_; -#ifdef NOT_YET /** allocator (likely DArena) for globals. * For example DArenaHashMap in global symta. **/ obj aux_mm_; -#endif /** allocator (likely DX1Collector or similar) for * expressions and values. Schemaatika reader will use this also From a41ff13f09951ecd9a7b12208a9e29df6e91ea34 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 28 Feb 2026 13:29:05 +1100 Subject: [PATCH 059/131] xo-interpreter2: + report_memory_use() built-in --- .../interpreter2/VirtualSchematikaMachine.hpp | 3 + src/interpreter2/VirtualSchematikaMachine.cpp | 57 ++++++++++++++++--- 2 files changed, 52 insertions(+), 8 deletions(-) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 1e19bcdb..1bfa5ecb 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -100,6 +100,9 @@ namespace xo { /** visit vsm-owned memory pools; call visitor(info) for each **/ void visit_pools(const MemorySizeVisitor & visitor) const; + /** install hardwired functions into global {symtab,env} **/ + void install_core_primitives(); + /** begin interactive session. **/ void begin_interactive_session(); /** begin batch session **/ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index c2221aed..dc600768 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -20,9 +20,9 @@ #include #include #include -//#include -#include -#include +#include +#include +#include #include #include #include @@ -32,8 +32,9 @@ namespace xo { using xo::print::APrintable; using xo::print::ppconfig; using xo::print::ppstate_standalone; + using xo::reflect::Reflect; using xo::mm::AGCObject; - //using xo::mm::MemorySizeInfo; // not used yet + using xo::mm::MemorySizeInfo; using xo::mm::AAllocator; using xo::mm::DX1Collector; using xo::mm::DArena; @@ -60,9 +61,10 @@ namespace xo { VirtualSchematikaMachine::VirtualSchematikaMachine(const VsmConfig & config, obj aux_mm) : config_{config}, - mm_(abox::make(aux_mm, config.x1_config_)), - rcx_(abox::make(aux_mm, this)), - reader_{config.rdr_config_, mm_.to_op(), aux_mm} + aux_mm_{aux_mm}, + mm_(abox::make(aux_mm_, config.x1_config_)), + rcx_(abox::make(aux_mm_, this)), + reader_{config.rdr_config_, mm_.to_op(), aux_mm_} { { DArena * arena = new DArena(config_.error_config_); @@ -72,6 +74,8 @@ namespace xo { } this->global_env_ = DGlobalEnv::_make(mm_.to_op(), reader_.global_symtab()); + + this->install_core_primitives(); } obj @@ -95,6 +99,7 @@ namespace xo { void VirtualSchematikaMachine::visit_pools(const MemorySizeVisitor & visitor) const { + aux_mm_.visit_pools(visitor); mm_.visit_pools(visitor); error_mm_.visit_pools(visitor); reader_.visit_pools(visitor); @@ -857,7 +862,43 @@ namespace xo { } } + obj + xfer_report_memory_use(obj rcx) + { + scope log(XO_DEBUG(true)); + + auto visitor = [&log](const MemorySizeInfo & info) { + log && log(xtag("resource", info.resource_name_), + xtag("used", info.used_), + xtag("alloc", info.allocated_), + xtag("commit", info.committed_), + xtag("resv", info.reserved_)); + }; + + rcx.visit_pools(visitor); + + return DBoolean::box(rcx.allocator(), true); + } + + static DPrimitive_gco_0 s_report_memory_use_pm("_report_memory_use", + &xfer_report_memory_use); + + void + VirtualSchematikaMachine::install_core_primitives() + { + { + const DUniqueString * name + = reader_.intern_string("report_memory_use"); + + global_env_->_upsert_value + (mm_.to_op(), + name, + Reflect::require(), + obj(&s_report_memory_use_pm)); + } + } + } /*namespace scm*/ } /*namespace xo*/ -/* end VirtualSchematikaMachine.hpp */ +/* end VirtualSchematikaMachine.cpp */ From a1e85d65bc463e01cb00fbaafc1cc4aa35e706cd Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 28 Feb 2026 13:36:27 +1100 Subject: [PATCH 060/131] xo-interpreter2: report_memory_use() unit test --- include/xo/interpreter2/VsmConfig.hpp | 6 ++++ src/skrepl/skreplxx.cpp | 2 +- utest/VirtualSchematikaMachine.test.cpp | 37 +++++++++++++++++++++++++ 3 files changed, 44 insertions(+), 1 deletion(-) diff --git a/include/xo/interpreter2/VsmConfig.hpp b/include/xo/interpreter2/VsmConfig.hpp index bfbe152e..bfd6dbf6 100644 --- a/include/xo/interpreter2/VsmConfig.hpp +++ b/include/xo/interpreter2/VsmConfig.hpp @@ -25,6 +25,12 @@ namespace xo { return retval; } + VsmConfig with_parser_debug_flag(bool x) const { + VsmConfig retval = *this; + retval.rdr_config_.parser_debug_flag_ = x; + return retval; + } + /** true for interactive parser session; false for batch session **/ bool interactive_flag_ = true; diff --git a/src/skrepl/skreplxx.cpp b/src/skrepl/skreplxx.cpp index 6d68fb32..3362b823 100644 --- a/src/skrepl/skreplxx.cpp +++ b/src/skrepl/skreplxx.cpp @@ -188,7 +188,7 @@ namespace xo { // outer loop: fetch one line of interactive input while (replxx_getline(interactive_, vsm_.is_at_toplevel(), rx_, &input)) { - // inner lo9op: consume up to one expression at a time. + // inner loop: consume up to one expression at a time. while (!input.empty() && this->_read_eval_print(&input, false /*eof*/)) { ; diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index a42746ae..4e5d6355 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -584,6 +584,43 @@ namespace xo { log && vsm_fixture.log_memory_layout(&log); } + TEST_CASE("VirtualSchematikaMachine-report_memory_use", "[interpreter2][VSM]") + { + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + bool c_debug_flag = false; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + + VsmFixture vsm_fixture(testname, c_debug_flag, + VsmConfig().with_parser_debug_flag(c_debug_flag)); + auto & vsm = vsm_fixture.vsm_; + + bool eof_flag = true; + + vsm.begin_interactive_session(); + + span_type input = span_type::from_cstr("report_memory_use();"); + + log && log(xtag("input", input)); + + VsmResultExt res + = vsm.read_eval_print(input, eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq()), + xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); + + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(x->value() == true); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + + //log && vsm_fixture.log_memory_layout(&log); + } } /*namespace ut*/ } /*namespace xo*/ From 0dea33846d610ebc8120e1843fb150170f75316c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 1 Mar 2026 13:06:57 +1100 Subject: [PATCH 061/131] xo-reader2 stack: + #q token + QuoteSsm [WIP - not functional] --- src/interpreter2/VirtualSchematikaMachine.cpp | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index dc600768..bc3cc913 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -27,6 +27,7 @@ #include #include #include +#include // for getcwd() namespace xo { using xo::print::APrintable; @@ -862,6 +863,8 @@ namespace xo { } } + // ----- primitive: report_memory_use() ----- + obj xfer_report_memory_use(obj rcx) { @@ -883,6 +886,22 @@ namespace xo { static DPrimitive_gco_0 s_report_memory_use_pm("_report_memory_use", &xfer_report_memory_use); + // ----- primitive: cwd() ----- + + obj + xfer_cwd(obj rcx) + { + char buf[PATH_MAX]; + ::getcwd(buf, sizeof(buf)); + + return obj(DString::from_cstr(rcx.allocator(), buf)); + } + + static DPrimitive_gco_0 s_cwd_pm("_cwd", + &xfer_cwd); + + // ----- install primitives ----- + void VirtualSchematikaMachine::install_core_primitives() { @@ -896,6 +915,17 @@ namespace xo { Reflect::require(), obj(&s_report_memory_use_pm)); } + + { + const DUniqueString * name + = reader_.intern_string("cwd"); + + global_env_->_upsert_value + (mm_.to_op(), + name, + Reflect::require(), + obj(&s_cwd_pm)); + } } } /*namespace scm*/ From 830a2c8d7da5ae18b64d3dc533ccb1a9cce9f199 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 2 Mar 2026 11:05:12 +1100 Subject: [PATCH 062/131] xo-interpreter2 stack: handle operator expressions w/ qliterals --- utest/VirtualSchematikaMachine.test.cpp | 38 +++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 4e5d6355..649fc00e 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -584,6 +584,44 @@ namespace xo { log && vsm_fixture.log_memory_layout(&log); } + TEST_CASE("VirtualSchematikaMachine-qliteral1", "[interpreter2][VSM]") + { + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + + VsmFixture vsm_fixture(testname, c_debug_flag, + VsmConfig().with_parser_debug_flag(c_debug_flag)); + auto & vsm = vsm_fixture.vsm_; + + bool eof_flag = true; + + vsm.begin_interactive_session(); + + span_type input = span_type::from_cstr("#q{ 4.5 };"); + + log && log(xtag("input", input)); + + VsmResultExt res + = vsm.read_eval_print(input, eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq()), + xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); + + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(x->value() == 4.5); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + + //log && vsm_fixture.log_memory_layout(&log); + } + TEST_CASE("VirtualSchematikaMachine-report_memory_use", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); From 43447a7587dd8c2595722016b92375337cca8fb1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 2 Mar 2026 23:21:10 +1100 Subject: [PATCH 063/131] xo-interpreter2 stack: parse literal lists (w/ implicit types) --- utest/VirtualSchematikaMachine.test.cpp | 48 ++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 649fc00e..a27d06f7 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -24,6 +25,7 @@ namespace xo { using xo::scm::DClosure; using xo::scm::DString; using xo::scm::DUniqueString; // aks Symbol in lisp + using xo::scm::DList; using xo::scm::DFloat; using xo::scm::DBoolean; using xo::scm::DInteger; @@ -595,7 +597,7 @@ namespace xo { VsmConfig().with_parser_debug_flag(c_debug_flag)); auto & vsm = vsm_fixture.vsm_; - bool eof_flag = true; + bool eof_flag = false; vsm.begin_interactive_session(); @@ -622,6 +624,50 @@ namespace xo { //log && vsm_fixture.log_memory_layout(&log); } + TEST_CASE("VirtualSchematikaMachine-qlist", "[interpreter2][VSM]") + { + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + + VsmFixture vsm_fixture(testname, c_debug_flag, + VsmConfig().with_parser_debug_flag(c_debug_flag)); + auto & vsm = vsm_fixture.vsm_; + + bool eof_flag = true; + + vsm.begin_interactive_session(); + + span_type input = span_type::from_cstr("#q{ (4.5 7.2) };"); + + log && log(xtag("input", input)); + + VsmResultExt res + = vsm.read_eval_print(input, eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq()), + xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); + + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(x->size() == 2); + auto x0 = obj::from(x->at(0)); + REQUIRE(x0); + REQUIRE(x0->value() == 4.5); + auto x1 = obj::from(x->at(1)); + REQUIRE(x1); + REQUIRE(x1->value() == 7.2); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + + //log && vsm_fixture.log_memory_layout(&log); + } + TEST_CASE("VirtualSchematikaMachine-report_memory_use", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); From 82d9fb7759bc4d93aeb87cd1bde25546fe9b5748 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Mar 2026 12:12:09 +1100 Subject: [PATCH 064/131] xo-interpreter2 stack: + literal array parsing --- utest/VirtualSchematikaMachine.test.cpp | 48 ++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index a27d06f7..b312395c 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -7,6 +7,7 @@ #include #include #include +#include #include #include #include @@ -26,6 +27,7 @@ namespace xo { using xo::scm::DString; using xo::scm::DUniqueString; // aks Symbol in lisp using xo::scm::DList; + using xo::scm::DArray; using xo::scm::DFloat; using xo::scm::DBoolean; using xo::scm::DInteger; @@ -628,7 +630,7 @@ namespace xo { { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - bool c_debug_flag = true; + bool c_debug_flag = false; scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); VsmFixture vsm_fixture(testname, c_debug_flag, @@ -668,6 +670,50 @@ namespace xo { //log && vsm_fixture.log_memory_layout(&log); } + TEST_CASE("VirtualSchematikaMachine-qarray", "[interpreter2][VSM]") + { + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + + bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + + VsmFixture vsm_fixture(testname, c_debug_flag, + VsmConfig().with_parser_debug_flag(c_debug_flag)); + auto & vsm = vsm_fixture.vsm_; + + bool eof_flag = true; + + vsm.begin_interactive_session(); + + span_type input = span_type::from_cstr("#q{ [4.5 7.2] };"); + + log && log(xtag("input", input)); + + VsmResultExt res + = vsm.read_eval_print(input, eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq()), + xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); + + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(x->size() == 2); + auto x0 = obj::from(x->at(0)); + REQUIRE(x0); + REQUIRE(x0->value() == 4.5); + auto x1 = obj::from(x->at(1)); + REQUIRE(x1); + REQUIRE(x1->value() == 7.2); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + + //log && vsm_fixture.log_memory_layout(&log); + } + TEST_CASE("VirtualSchematikaMachine-report_memory_use", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); From 9050b6dcf9eed642c55d04fc64cbc084069cf3c9 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Mar 2026 16:45:54 +1100 Subject: [PATCH 065/131] xo-interpreter2 stack: + dict.make() + Dictionary impl --- src/interpreter2/VirtualSchematikaMachine.cpp | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index bc3cc913..714b2804 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -30,6 +31,7 @@ #include // for getcwd() namespace xo { + using xo::scm::DDictionary; using xo::print::APrintable; using xo::print::ppconfig; using xo::print::ppstate_standalone; @@ -40,6 +42,7 @@ namespace xo { using xo::mm::DX1Collector; using xo::mm::DArena; using xo::facet::FacetRegistry; + using xo::facet::TypeRegistry; using std::cout; namespace scm { @@ -878,6 +881,8 @@ namespace xo { xtag("resv", info.reserved_)); }; + FacetRegistry::instance().visit_pools(visitor); + TypeRegistry::instance().visit_pools(visitor); rcx.visit_pools(visitor); return DBoolean::box(rcx.allocator(), true); @@ -900,11 +905,24 @@ namespace xo { static DPrimitive_gco_0 s_cwd_pm("_cwd", &xfer_cwd); + // ----- primitive: dict_make() ----- + + obj + xfer_dict_make(obj rcx) + { + return obj(DDictionary::empty(rcx.allocator(), + 8 /*cap*/)); + } + + static DPrimitive_gco_0 s_dict_make_pm("_dict_make", + &xfer_dict_make); + // ----- install primitives ----- void VirtualSchematikaMachine::install_core_primitives() { + /* report_memory_use */ { const DUniqueString * name = reader_.intern_string("report_memory_use"); @@ -916,6 +934,7 @@ namespace xo { obj(&s_report_memory_use_pm)); } + /* cwd */ { const DUniqueString * name = reader_.intern_string("cwd"); @@ -926,6 +945,18 @@ namespace xo { Reflect::require(), obj(&s_cwd_pm)); } + + /* dict_make */ + { + const DUniqueString * name + = reader_.intern_string("dict_make"); + + global_env_->_upsert_value + (mm_.to_op(), + name, + Reflect::require(), + obj(&s_dict_make_pm)); + } } } /*namespace scm*/ From b6fbf88cec2d836868958fb95cd5ffb7218e3e94 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Mar 2026 14:18:50 +1100 Subject: [PATCH 066/131] xo-interpreter2 stack: + DPrimitive_gco_1_gco [foundation] --- src/interpreter2/VirtualSchematikaMachine.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 714b2804..1dac6dc6 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include From b260b5fdd5fd329508ae8102ed567337abe0e0c4 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Mar 2026 14:21:52 +1100 Subject: [PATCH 067/131] xo-interpreter2: + fn_n_args() primitive --- src/interpreter2/VirtualSchematikaMachine.cpp | 33 +++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 1dac6dc6..1b3d338c 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -906,6 +906,27 @@ namespace xo { static DPrimitive_gco_0 s_cwd_pm("_cwd", &xfer_cwd); + // ----- primitive: fn_n_args() ----- + + obj + xfer_fn_n_args(obj rcx, + obj fn_gco) + { + scope log(XO_DEBUG(true)); + + log && log(xtag("fn_gco.tseq", fn_gco._typeseq())); + log && log(xtag("fn_gco.tname", TypeRegistry::id2name(fn_gco._typeseq()))); + + auto fn_proc = FacetRegistry::instance().try_variant(fn_gco); + + assert(fn_proc); + + return DInteger::box(rcx.allocator(), fn_proc.n_args()); + } + + static DPrimitive_gco_1_gco s_fn_n_args_pm("_fn_n_args", + &xfer_fn_n_args); + // ----- primitive: dict_make() ----- obj @@ -947,6 +968,18 @@ namespace xo { obj(&s_cwd_pm)); } + /* fn_n_args */ + { + const DUniqueString * name + = reader_.intern_string("fn_n_args"); + + global_env_->_upsert_value + (mm_.to_op(), + name, + Reflect::require(), + obj(&s_fn_n_args_pm)); + } + /* dict_make */ { const DUniqueString * name From 9fe9cd4626a69c62cfc4a06fc4eb94f1ff356cf3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Mar 2026 14:22:50 +1100 Subject: [PATCH 068/131] xo-interpreter2: report_memory_use() +visit NumericDispatch arena --- src/interpreter2/VirtualSchematikaMachine.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 1b3d338c..012d18ec 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -12,6 +12,7 @@ #include "VsmSeqContFrame.hpp" #include "VsmRcx.hpp" #include "Closure.hpp" +#include #include #include #include @@ -19,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -884,6 +886,7 @@ namespace xo { FacetRegistry::instance().visit_pools(visitor); TypeRegistry::instance().visit_pools(visitor); + NumericDispatch::instance().visit_pools(visitor); rcx.visit_pools(visitor); return DBoolean::box(rcx.allocator(), true); From 1f9177093a37518c62e88323429dcd3ffa75dc7a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Mar 2026 14:34:57 +1100 Subject: [PATCH 069/131] xo-interpreter2 stack: + DPrimitive_gco_3_dict_string_gco + dict_upsert --- src/interpreter2/VirtualSchematikaMachine.cpp | 44 +++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 012d18ec..b2d1a675 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -4,6 +4,7 @@ **/ #include "VirtualSchematikaMachine.hpp" +#include "DPrimitive_gco_3_dict_string_gco.hpp" #include "VsmDefContFrame.hpp" #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" @@ -25,6 +26,7 @@ #include #include #include +#include #include #include #include @@ -942,6 +944,36 @@ namespace xo { static DPrimitive_gco_0 s_dict_make_pm("_dict_make", &xfer_dict_make); + // ----- primitive: dict_upsert() ----- + + obj + xfer_dict_upsert(obj rcx, + obj dict, + obj key, + obj value) + { + scope log(XO_DEBUG(true)); + + log && log(xtag("dict.tseq", dict._typeseq()), + xtag("dict.tname", TypeRegistry::id2name(dict._typeseq()))); + log && log(xtag("key.tseq", key._typeseq()), + xtag("key.tname", TypeRegistry::id2name(key._typeseq()))); + log && log(xtag("value.tseq", value._typeseq()), + xtag("value.tname", TypeRegistry::id2name(value._typeseq()))); + + auto value_pr = FacetRegistry::instance().variant(value); + + log && log(xtag("value", value_pr)); + + dict->upsert(rcx.allocator(), + DDictionary::pair_type(key.data(), value)); + + return dict; + } + + static DPrimitive_gco_3_dict_string_gco s_dict_upsert_pm("_dict_upsert", + &xfer_dict_upsert); + // ----- install primitives ----- void @@ -994,6 +1026,18 @@ namespace xo { Reflect::require(), obj(&s_dict_make_pm)); } + + /* dict_upsert */ + { + const DUniqueString * name + = reader_.intern_string("dict_upsert"); + + global_env_->_upsert_value + (mm_.to_op(), + name, + Reflect::require(), + obj(&s_dict_upsert_pm)); + } } } /*namespace scm*/ From 2d80908872e85ca0fb9d0f5afb30cab4a2cf4bc8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Mar 2026 22:26:31 +1100 Subject: [PATCH 070/131] xo-gc xo-alloc2: move Collector faceet gc/ -> alloc2/ for levelling --- include/xo/interpreter2/DVsmDefContFrame.hpp | 2 +- include/xo/interpreter2/DVsmIfElseContFrame.hpp | 4 ++-- include/xo/interpreter2/DVsmSeqContFrame.hpp | 6 +++--- include/xo/interpreter2/VirtualSchematikaMachine.hpp | 2 +- .../xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp | 4 ++-- include/xo/interpreter2/detail/IGCObject_DClosure.hpp | 4 ++-- include/xo/interpreter2/detail/IGCObject_DLocalEnv.hpp | 4 ++-- .../interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp | 4 ++-- include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp | 4 ++-- .../xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp | 4 ++-- include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp | 4 ++-- include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp | 4 ++-- .../interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp | 4 ++-- include/xo/interpreter2/interpreter2_register_types.hpp | 2 +- .../xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp | 4 ++-- src/interpreter2/DVsmDefContFrame.cpp | 2 +- 16 files changed, 29 insertions(+), 29 deletions(-) diff --git a/include/xo/interpreter2/DVsmDefContFrame.hpp b/include/xo/interpreter2/DVsmDefContFrame.hpp index 68c2510a..c0e6ed0f 100644 --- a/include/xo/interpreter2/DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/DVsmDefContFrame.hpp @@ -7,7 +7,7 @@ #include "VsmInstr.hpp" #include -#include +#include namespace xo { namespace scm { diff --git a/include/xo/interpreter2/DVsmIfElseContFrame.hpp b/include/xo/interpreter2/DVsmIfElseContFrame.hpp index 3d4ace12..8efd9299 100644 --- a/include/xo/interpreter2/DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/DVsmIfElseContFrame.hpp @@ -7,7 +7,7 @@ #include "VsmInstr.hpp" #include -#include +#include namespace xo { namespace scm { @@ -61,7 +61,7 @@ namespace xo { bool pretty(const ppindentinfo & ppii) const noexcept; ///@} - + private: /** @defgroup scm-vsmevalsequenceframe-members member variables **/ ///@{ diff --git a/include/xo/interpreter2/DVsmSeqContFrame.hpp b/include/xo/interpreter2/DVsmSeqContFrame.hpp index cb63f0d4..6b543d8b 100644 --- a/include/xo/interpreter2/DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/DVsmSeqContFrame.hpp @@ -7,7 +7,7 @@ #include "VsmInstr.hpp" #include -#include +#include namespace xo { namespace scm { @@ -50,7 +50,7 @@ namespace xo { ///@{ uint32_t incr_i_seq() noexcept { return ++(this->i_seq_); } - + ///@} /** @defgroup scm-vsmevalsequenceframe-gcobject-facet gcobject facet **/ ///@{ @@ -66,7 +66,7 @@ namespace xo { bool pretty(const ppindentinfo & ppii) const noexcept; ///@} - + private: /** @defgroup scm-vsmevalsequenceframe-members member variables **/ ///@{ diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 1bfa5ecb..ec7eda34 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -13,7 +13,7 @@ #include #include #include -#include +#include #include #include diff --git a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp index 309a6ac7..bc3423d9 100644 --- a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmDefContFrame.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp index fb863205..8507d640 100644 --- a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DClosure.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/interpreter2/detail/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/detail/IGCObject_DLocalEnv.hpp index d318bb61..25db925a 100644 --- a/include/xo/interpreter2/detail/IGCObject_DLocalEnv.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DLocalEnv.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DLocalEnv.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp index 2baacd05..7db673e7 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmApplyClosureFrame.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp index ca6d3b10..401a91d7 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmApplyFrame.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp index 4a8ad18a..1a91c32f 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmEvalArgsFrame.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp index 1f0f9281..71ac3e49 100644 --- a/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DGlobalEnv.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp index d318bb61..25db925a 100644 --- a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DLocalEnv.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp index 293dd70d..1d29a8ac 100644 --- a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmIfElseContFrame.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/interpreter2/interpreter2_register_types.hpp b/include/xo/interpreter2/interpreter2_register_types.hpp index 1409d13a..b545f356 100644 --- a/include/xo/interpreter2/interpreter2_register_types.hpp +++ b/include/xo/interpreter2/interpreter2_register_types.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include namespace xo { namespace scm { diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index 1bdbe2ab..9b686c6c 100644 --- a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmSeqContFrame.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/src/interpreter2/DVsmDefContFrame.cpp b/src/interpreter2/DVsmDefContFrame.cpp index 7b3b9e7a..2d5c9adf 100644 --- a/src/interpreter2/DVsmDefContFrame.cpp +++ b/src/interpreter2/DVsmDefContFrame.cpp @@ -5,7 +5,7 @@ #include "DVsmDefContFrame.hpp" #include -#include +#include namespace xo { namespace scm { From 692144df583198293b5dbc30b596628eaeed2e89 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 5 Mar 2026 00:50:58 +1100 Subject: [PATCH 071/131] refactor: + xo-stringtable2 w/ DString impl --- src/interpreter2/init_interpreter2.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interpreter2/init_interpreter2.cpp b/src/interpreter2/init_interpreter2.cpp index 07308863..73a6a5c2 100644 --- a/src/interpreter2/init_interpreter2.cpp +++ b/src/interpreter2/init_interpreter2.cpp @@ -9,7 +9,7 @@ #include "interpreter2_register_types.hpp" #include -#include +#include namespace xo { using xo::scm::interpreter2_register_facets; From 27e2990f4caf1f05a46f27a0374bc9d3b1dd79bc Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 5 Mar 2026 13:02:12 +1100 Subject: [PATCH 072/131] xo-interpreter2 stack: refactor: string clases -> xo-stringtable2/ --- src/interpreter2/VirtualSchematikaMachine.cpp | 2 +- utest/VirtualSchematikaMachine.test.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index b2d1a675..d0889fa3 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -19,7 +19,6 @@ #include #include #include -#include #include #include #include @@ -29,6 +28,7 @@ #include #include #include +#include #include #include #include diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index b312395c..21b5faa3 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -6,13 +6,13 @@ #include #include #include -#include #include #include #include #include #include #include +#include #include #include #include From 7cc7a277a39f725d0c0f3fdea8c75fd14bca39eb Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 07:49:14 -0500 Subject: [PATCH 073/131] xo-reader2 stack: expand symbol table to store typedefs + typedef utest + misc qol policy choices --- include/xo/interpreter2/DGlobalEnv.hpp | 4 ++-- include/xo/interpreter2/DLocalEnv.hpp | 3 ++- src/interpreter2/DGlobalEnv.cpp | 4 ++-- src/interpreter2/DLocalEnv.cpp | 4 ++-- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/include/xo/interpreter2/DGlobalEnv.hpp b/include/xo/interpreter2/DGlobalEnv.hpp index e2df166b..da7f8536 100644 --- a/include/xo/interpreter2/DGlobalEnv.hpp +++ b/include/xo/interpreter2/DGlobalEnv.hpp @@ -47,8 +47,8 @@ namespace xo { /** @defgroup scm-globalenv-methods methods **/ ///@{ - /** symbol-table size. Is the number of distinct global symbols **/ - size_type size() const noexcept { return symtab_->size(); } + /** symbol-table size. Is the number of distinct global variables **/ + size_type n_vars() const noexcept { return symtab_->n_vars(); } /** lookup current value associated with binding @p ix **/ obj lookup_value(Binding ix) const noexcept; diff --git a/include/xo/interpreter2/DLocalEnv.hpp b/include/xo/interpreter2/DLocalEnv.hpp index eaef71c2..ab407063 100644 --- a/include/xo/interpreter2/DLocalEnv.hpp +++ b/include/xo/interpreter2/DLocalEnv.hpp @@ -41,7 +41,8 @@ namespace xo { ///@{ DLocalEnv * parent() const noexcept { return parent_; } - size_type size() const noexcept { return symtab_->size(); } + size_type n_vars() const noexcept { return symtab_->n_vars(); } + size_type n_types() const noexcept { return symtab_->n_types(); } /** lookup current value associated with binding @p ix **/ obj lookup_value(Binding ix) const noexcept; diff --git a/src/interpreter2/DGlobalEnv.cpp b/src/interpreter2/DGlobalEnv.cpp index 2ad6c1ba..fcc92efa 100644 --- a/src/interpreter2/DGlobalEnv.cpp +++ b/src/interpreter2/DGlobalEnv.cpp @@ -21,7 +21,7 @@ namespace xo { DGlobalEnv::_make(obj mm, DGlobalSymtab * symtab) { - DArray * values = DArray::empty(mm, symtab->capacity()); + DArray * values = DArray::empty(mm, symtab->var_capacity()); void * mem = mm.alloc_for(); @@ -136,7 +136,7 @@ namespace xo { return ppii.pps()->pretty_struct (ppii, "DGlobalEnv", - refrtag("size", symtab_->size())); + refrtag("n_vars", symtab_->n_vars())); } } /*namespace scm*/ diff --git a/src/interpreter2/DLocalEnv.cpp b/src/interpreter2/DLocalEnv.cpp index 8f45b38a..3831b647 100644 --- a/src/interpreter2/DLocalEnv.cpp +++ b/src/interpreter2/DLocalEnv.cpp @@ -49,7 +49,7 @@ namespace xo { if (env) { auto j = ix.j_slot(); - if (j < static_cast(env->size())) { + if (j < static_cast(env->n_vars())) { return (*(env->args_))[j]; } else { assert(false); @@ -78,7 +78,7 @@ namespace xo { if (env) { auto j = ix.j_slot(); - if (j < static_cast(env->size())) { + if (j < static_cast(env->n_vars())) { log && log("STUB: need write barrier for GC here"); (*(env->args_))[j] = x; } else { From 3976bd42cbd2410d85c0f10cc818a5a3e85312af Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 08:41:57 -0500 Subject: [PATCH 074/131] build: retiring REPR argument to xo_add_genfacetimpl() --- CMakeLists.txt | 56 +++++++++---------- .../define/IGCObject_DVsmDefContFrame.hpp | 4 +- .../detail/IGCObject_DClosure.hpp | 4 +- .../IGCObject_DVsmApplyClosureFrame.hpp | 4 +- .../detail/IGCObject_DVsmApplyFrame.hpp | 4 +- .../detail/IGCObject_DVsmEvalArgsFrame.hpp | 4 +- .../interpreter2/env/IGCObject_DGlobalEnv.hpp | 4 +- .../interpreter2/env/IGCObject_DLocalEnv.hpp | 4 +- .../ifelse/IGCObject_DVsmIfElseContFrame.hpp | 4 +- .../sequence/IGCObject_DVsmSeqContFrame.hpp | 4 +- 10 files changed, 46 insertions(+), 46 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 426e4112..32db85f2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,9 +29,9 @@ add_subdirectory(utest) # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmdefcontframe - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject - REPR VsmDefContFrame +# REPR VsmDefContFrame INPUT idl/IGCObject_DVsmDefContFrame.json5 ) @@ -40,7 +40,7 @@ xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmdefcontframe FACET_PKG xo_printable2 FACET Printable - REPR VsmDefContFrame +# REPR VsmDefContFrame INPUT idl/IPrintable_DVsmDefContFrame.json5 ) @@ -49,9 +49,9 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmapplyframe - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject - REPR VsmApplyFrame +# REPR VsmApplyFrame INPUT idl/IGCObject_DVsmApplyFrame.json5 ) @@ -60,7 +60,7 @@ xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmapplyframe FACET_PKG xo_printable2 FACET Printable - REPR VsmApplyFrame +# REPR VsmApplyFrame INPUT idl/IPrintable_DVsmApplyFrame.json5 ) @@ -69,9 +69,9 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmevalargsframe - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject - REPR VsmEvalArgsFrame +# REPR VsmEvalArgsFrame INPUT idl/IGCObject_DVsmEvalArgsFrame.json5 ) @@ -80,7 +80,7 @@ xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmevalargsframe FACET_PKG xo_printable2 FACET Printable - REPR DVsmEvalArgsFrame +# REPR DVsmEvalArgsFrame INPUT idl/IPrintable_DVsmEvalArgsFrame.json5 ) @@ -89,9 +89,9 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmapplyclosureframe - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject - REPR VsmApplyClosureFrame +# REPR VsmApplyClosureFrame INPUT idl/IGCObject_DVsmApplyClosureFrame.json5 ) @@ -100,7 +100,7 @@ xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmapplyclosureframe FACET_PKG xo_printable2 FACET Printable - REPR DVsmApplyClosureFrame +# REPR DVsmApplyClosureFrame INPUT idl/IPrintable_DVsmApplyClosureFrame.json5 ) @@ -109,9 +109,9 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmifelsecontframe - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject - REPR VsmIfElseContFrame +# REPR VsmIfElseContFrame INPUT idl/IGCObject_DVsmIfElseContFrame.json5 ) @@ -120,7 +120,7 @@ xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmifelsecontframe FACET_PKG xo_printable2 FACET Printable - REPR VsmIfElseContFrame +# REPR VsmIfElseContFrame INPUT idl/IPrintable_DVsmIfElseContFrame.json5 ) @@ -129,9 +129,9 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmseqcontframe - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject - REPR VsmSeqContFrame +# REPR VsmSeqContFrame INPUT idl/IGCObject_DVsmSeqContFrame.json5 ) @@ -140,7 +140,7 @@ xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmseqcontframe FACET_PKG xo_printable2 FACET Printable - REPR DVsmSeqContFrame +# REPR DVsmSeqContFrame INPUT idl/IPrintable_DVsmSeqContFrame.json5 ) @@ -159,9 +159,9 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-closure - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject - REPR Closure +# REPR Closure INPUT idl/IGCObject_DClosure.json5 ) @@ -170,7 +170,7 @@ xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-closure FACET_PKG xo_printable2 FACET Printable - REPR Closure +# REPR Closure INPUT idl/IPrintable_DClosure.json5 ) @@ -179,9 +179,9 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-globalenv - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject - REPR GlobalEnv +# REPR GlobalEnv INPUT idl/IGCObject_DGlobalEnv.json5 ) @@ -190,7 +190,7 @@ xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-globalenv FACET_PKG xo_printable2 FACET Printable - REPR GlobalEnv +# REPR GlobalEnv INPUT idl/IPrintable_DGlobalEnv.json5 ) @@ -199,9 +199,9 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-localenv - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject - REPR LocalEnv +# REPR LocalEnv INPUT idl/IGCObject_DLocalEnv.json5 ) @@ -210,7 +210,7 @@ xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-localenv FACET_PKG xo_printable2 FACET Printable - REPR LocalEnv +# REPR LocalEnv INPUT idl/IPrintable_DLocalEnv.json5 ) @@ -220,7 +220,7 @@ xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-runtimecontext-vsmrcx FACET_PKG xo_procedure2 FACET RuntimeContext - REPR DVsmRcx +# REPR DVsmRcx INPUT idl/IRuntimeContext_DVsmRcx.json5 ) diff --git a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp index bc3423d9..309a6ac7 100644 --- a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmDefContFrame.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp index 8507d640..fb863205 100644 --- a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DClosure.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp index 7db673e7..2baacd05 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmApplyClosureFrame.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp index 401a91d7..ca6d3b10 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmApplyFrame.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp index 1a91c32f..4a8ad18a 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmEvalArgsFrame.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp index 71ac3e49..1f0f9281 100644 --- a/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DGlobalEnv.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp index 25db925a..d318bb61 100644 --- a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DLocalEnv.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp index 1d29a8ac..293dd70d 100644 --- a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmIfElseContFrame.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index 9b686c6c..1bdbe2ab 100644 --- a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmSeqContFrame.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file From d34c678f46564e6514a24eb2852e95b384ea8515 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 08:49:03 -0500 Subject: [PATCH 075/131] xo-interpreter2 stack: bugfix after GCObject facet location change --- idl/IGCObject_DClosure.json5 | 2 +- idl/IGCObject_DGlobalEnv.json5 | 2 +- idl/IGCObject_DLocalEnv.json5 | 2 +- idl/IGCObject_DVsmApplyClosureFrame.json5 | 2 +- idl/IGCObject_DVsmApplyFrame.json5 | 2 +- idl/IGCObject_DVsmDefContFrame.json5 | 2 +- idl/IGCObject_DVsmEvalArgsFrame.json5 | 2 +- idl/IGCObject_DVsmIfElseContFrame.json5 | 2 +- idl/IGCObject_DVsmSeqContFrame.json5 | 2 +- include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp | 2 +- include/xo/interpreter2/detail/IGCObject_DClosure.hpp | 2 +- .../xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp | 2 +- include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp | 2 +- include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp | 2 +- include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp | 2 +- include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp | 2 +- .../xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp | 2 +- include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp | 2 +- 18 files changed, 18 insertions(+), 18 deletions(-) diff --git a/idl/IGCObject_DClosure.json5 b/idl/IGCObject_DClosure.json5 index a9b5616a..944ee2f4 100644 --- a/idl/IGCObject_DClosure.json5 +++ b/idl/IGCObject_DClosure.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/interpreter2", output_impl_subdir: "detail", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DGlobalEnv.json5 b/idl/IGCObject_DGlobalEnv.json5 index ce0bc090..9ce50388 100644 --- a/idl/IGCObject_DGlobalEnv.json5 +++ b/idl/IGCObject_DGlobalEnv.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/interpreter2", output_impl_subdir: "env", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DLocalEnv.json5 b/idl/IGCObject_DLocalEnv.json5 index 252bfbd7..82dd7ed0 100644 --- a/idl/IGCObject_DLocalEnv.json5 +++ b/idl/IGCObject_DLocalEnv.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/interpreter2", output_impl_subdir: "env", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DVsmApplyClosureFrame.json5 b/idl/IGCObject_DVsmApplyClosureFrame.json5 index 2b68d579..bfdb8c96 100644 --- a/idl/IGCObject_DVsmApplyClosureFrame.json5 +++ b/idl/IGCObject_DVsmApplyClosureFrame.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/interpreter2", output_impl_subdir: "detail", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DVsmApplyFrame.json5 b/idl/IGCObject_DVsmApplyFrame.json5 index ae284287..4bb09a61 100644 --- a/idl/IGCObject_DVsmApplyFrame.json5 +++ b/idl/IGCObject_DVsmApplyFrame.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/interpreter2", output_impl_subdir: "detail", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DVsmDefContFrame.json5 b/idl/IGCObject_DVsmDefContFrame.json5 index 061fca5d..faaee199 100644 --- a/idl/IGCObject_DVsmDefContFrame.json5 +++ b/idl/IGCObject_DVsmDefContFrame.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/interpreter2", output_impl_subdir: "define", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DVsmEvalArgsFrame.json5 b/idl/IGCObject_DVsmEvalArgsFrame.json5 index d36304b8..90781d9c 100644 --- a/idl/IGCObject_DVsmEvalArgsFrame.json5 +++ b/idl/IGCObject_DVsmEvalArgsFrame.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/interpreter2", output_impl_subdir: "detail", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DVsmIfElseContFrame.json5 b/idl/IGCObject_DVsmIfElseContFrame.json5 index 63617067..29e980ae 100644 --- a/idl/IGCObject_DVsmIfElseContFrame.json5 +++ b/idl/IGCObject_DVsmIfElseContFrame.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/interpreter2", output_impl_subdir: "ifelse", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DVsmSeqContFrame.json5 b/idl/IGCObject_DVsmSeqContFrame.json5 index d2b68020..5e8fcc25 100644 --- a/idl/IGCObject_DVsmSeqContFrame.json5 +++ b/idl/IGCObject_DVsmSeqContFrame.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/interpreter2", output_impl_subdir: "sequence", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp index 309a6ac7..f287f9fb 100644 --- a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmDefContFrame.hpp" diff --git a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp index fb863205..592b1640 100644 --- a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DClosure.hpp" diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp index 2baacd05..1d455a71 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmApplyClosureFrame.hpp" diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp index ca6d3b10..a2257125 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmApplyFrame.hpp" diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp index 4a8ad18a..3816203c 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmEvalArgsFrame.hpp" diff --git a/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp index 1f0f9281..a2fcb5f6 100644 --- a/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DGlobalEnv.hpp" diff --git a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp index d318bb61..93f1cce3 100644 --- a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DLocalEnv.hpp" diff --git a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp index 293dd70d..d62c896b 100644 --- a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmIfElseContFrame.hpp" diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index 1bdbe2ab..acf77945 100644 --- a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVsmSeqContFrame.hpp" From 336701b9a022f8a1d0e56ad09c39e7bb4a53d4f6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 10:03:46 -0500 Subject: [PATCH 076/131] build: retire FACET argument to genfacetimpl --- CMakeLists.txt | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 32db85f2..229bf176 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -30,7 +30,6 @@ add_subdirectory(utest) xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmdefcontframe FACET_PKG xo_alloc2 - FACET GCObject # REPR VsmDefContFrame INPUT idl/IGCObject_DVsmDefContFrame.json5 ) @@ -39,7 +38,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmdefcontframe FACET_PKG xo_printable2 - FACET Printable # REPR VsmDefContFrame INPUT idl/IPrintable_DVsmDefContFrame.json5 ) @@ -50,7 +48,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmapplyframe FACET_PKG xo_alloc2 - FACET GCObject # REPR VsmApplyFrame INPUT idl/IGCObject_DVsmApplyFrame.json5 ) @@ -59,7 +56,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmapplyframe FACET_PKG xo_printable2 - FACET Printable # REPR VsmApplyFrame INPUT idl/IPrintable_DVsmApplyFrame.json5 ) @@ -70,7 +66,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmevalargsframe FACET_PKG xo_alloc2 - FACET GCObject # REPR VsmEvalArgsFrame INPUT idl/IGCObject_DVsmEvalArgsFrame.json5 ) @@ -79,7 +74,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmevalargsframe FACET_PKG xo_printable2 - FACET Printable # REPR DVsmEvalArgsFrame INPUT idl/IPrintable_DVsmEvalArgsFrame.json5 ) @@ -90,7 +84,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmapplyclosureframe FACET_PKG xo_alloc2 - FACET GCObject # REPR VsmApplyClosureFrame INPUT idl/IGCObject_DVsmApplyClosureFrame.json5 ) @@ -99,7 +92,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmapplyclosureframe FACET_PKG xo_printable2 - FACET Printable # REPR DVsmApplyClosureFrame INPUT idl/IPrintable_DVsmApplyClosureFrame.json5 ) @@ -110,7 +102,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmifelsecontframe FACET_PKG xo_alloc2 - FACET GCObject # REPR VsmIfElseContFrame INPUT idl/IGCObject_DVsmIfElseContFrame.json5 ) @@ -119,7 +110,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmifelsecontframe FACET_PKG xo_printable2 - FACET Printable # REPR VsmIfElseContFrame INPUT idl/IPrintable_DVsmIfElseContFrame.json5 ) @@ -130,7 +120,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmseqcontframe FACET_PKG xo_alloc2 - FACET GCObject # REPR VsmSeqContFrame INPUT idl/IGCObject_DVsmSeqContFrame.json5 ) @@ -139,7 +128,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmseqcontframe FACET_PKG xo_printable2 - FACET Printable # REPR DVsmSeqContFrame INPUT idl/IPrintable_DVsmSeqContFrame.json5 ) @@ -151,7 +139,6 @@ xo_add_genfacetimpl( #xo_add_genfacetimpl( # TARGET xo-interpreter2-facetimpl-procedure-closure # FACET_PKG xo_procedure2 -# FACET Procedure # REPR Closure # INPUT idl/IProcedure_DClosure.json5 #) @@ -160,7 +147,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-closure FACET_PKG xo_alloc2 - FACET GCObject # REPR Closure INPUT idl/IGCObject_DClosure.json5 ) @@ -169,7 +155,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-closure FACET_PKG xo_printable2 - FACET Printable # REPR Closure INPUT idl/IPrintable_DClosure.json5 ) @@ -180,7 +165,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-globalenv FACET_PKG xo_alloc2 - FACET GCObject # REPR GlobalEnv INPUT idl/IGCObject_DGlobalEnv.json5 ) @@ -189,7 +173,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-globalenv FACET_PKG xo_printable2 - FACET Printable # REPR GlobalEnv INPUT idl/IPrintable_DGlobalEnv.json5 ) @@ -200,7 +183,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-localenv FACET_PKG xo_alloc2 - FACET GCObject # REPR LocalEnv INPUT idl/IGCObject_DLocalEnv.json5 ) @@ -209,7 +191,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-localenv FACET_PKG xo_printable2 - FACET Printable # REPR LocalEnv INPUT idl/IPrintable_DLocalEnv.json5 ) @@ -219,7 +200,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-runtimecontext-vsmrcx FACET_PKG xo_procedure2 - FACET RuntimeContext # REPR DVsmRcx INPUT idl/IRuntimeContext_DVsmRcx.json5 ) From 1305788778c35430d0998a0265f2b5de925bfc99 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 15:40:38 -0500 Subject: [PATCH 077/131] xo-interpreter2 stack: + nth() primitive --- src/interpreter2/VirtualSchematikaMachine.cpp | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index d0889fa3..8807a72c 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -5,6 +5,7 @@ #include "VirtualSchematikaMachine.hpp" #include "DPrimitive_gco_3_dict_string_gco.hpp" +#include "DPrimitive_gco_2_gco_gco.hpp" #include "VsmDefContFrame.hpp" #include "VsmApplyFrame.hpp" #include "VsmEvalArgsFrame.hpp" @@ -13,6 +14,7 @@ #include "VsmSeqContFrame.hpp" #include "VsmRcx.hpp" #include "Closure.hpp" +#include #include #include #include @@ -25,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -911,6 +914,26 @@ namespace xo { static DPrimitive_gco_0 s_cwd_pm("_cwd", &xfer_cwd); + // ----- primitive: fn_nth() ----- + + // TODO: seq_gc -> obj + // n_gco -> obj + // + obj + xfer_nth(obj rcx, + obj seq_gco, + obj n_gco) + { + (void)rcx; + + obj seq = seq_gco.to_facet(); + auto n = obj::from(n_gco); + + return seq.at(n->value()); + } + + static DPrimitive_gco_2_gco_gco s_nth_pm("_nth", &xfer_nth); + // ----- primitive: fn_n_args() ----- obj @@ -1003,6 +1026,18 @@ namespace xo { obj(&s_cwd_pm)); } + /* nth */ + { + const DUniqueString * name + = reader_.intern_string("nth"); + + global_env_->_upsert_value + (mm_.to_op(), + name, + Reflect::require(), + obj(&s_nth_pm)); + } + /* fn_n_args */ { const DUniqueString * name From 7c3d546982db561cfa0f3553abbcd40da15c2175 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 16:19:40 -0500 Subject: [PATCH 078/131] xo-interpreter2: + nil + cons --- src/interpreter2/VirtualSchematikaMachine.cpp | 33 ++++++++++++++++++- utest/VirtualSchematikaMachine.test.cpp | 2 +- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 8807a72c..6bcbe8bf 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -15,6 +15,7 @@ #include "VsmRcx.hpp" #include "Closure.hpp" #include +#include #include #include #include @@ -914,7 +915,7 @@ namespace xo { static DPrimitive_gco_0 s_cwd_pm("_cwd", &xfer_cwd); - // ----- primitive: fn_nth() ----- + // ----- primitive: nth() ----- // TODO: seq_gc -> obj // n_gco -> obj @@ -934,6 +935,24 @@ namespace xo { static DPrimitive_gco_2_gco_gco s_nth_pm("_nth", &xfer_nth); + // ----- primitive: cons() ----- + + obj + xfer_cons(obj rcx, + obj car, + obj cdr) + { + (void)rcx; + + auto cdr_list = obj::from(cdr); + + return DList::cons(rcx.allocator(), + car, + cdr_list.data()); + } + + static DPrimitive_gco_2_gco_gco s_cons_pm("_cons", &xfer_cons); + // ----- primitive: fn_n_args() ----- obj @@ -1038,6 +1057,18 @@ namespace xo { obj(&s_nth_pm)); } + /* cons */ + { + const DUniqueString * name + = reader_.intern_string("cons"); + + global_env_->_upsert_value + (mm_.to_op(), + name, + Reflect::require(), + obj(&s_cons_pm)); + } + /* fn_n_args */ { const DUniqueString * name diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 21b5faa3..9fb85ffc 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -31,7 +31,7 @@ namespace xo { using xo::scm::DFloat; using xo::scm::DBoolean; using xo::scm::DInteger; - using xo::scm::DRuntimeError; +// using xo::scm::DRuntimeError; using xo::mm::AGCObject; using xo::mm::MemorySizeInfo; using xo::mm::AAllocator; From 93b613e8feb7f7ed8db1a49fba2743d95cb02a61 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 12 Mar 2026 20:26:08 -0500 Subject: [PATCH 079/131] xo-interpreter2 stack: refactor + bugfix operator expr --- CMakeLists.txt | 18 --- idl/IGCObject_DGlobalEnv.json5 | 18 --- idl/IPrintable_DGlobalEnv.json5 | 16 -- include/xo/interpreter2/DGlobalEnv.hpp | 94 ------------ include/xo/interpreter2/GlobalEnv.hpp | 12 -- .../interpreter2/env/IGCObject_DGlobalEnv.hpp | 67 -------- .../env/IPrintable_DGlobalEnv.hpp | 62 -------- src/interpreter2/CMakeLists.txt | 4 - src/interpreter2/DGlobalEnv.cpp | 145 ------------------ src/interpreter2/IGCObject_DGlobalEnv.cpp | 39 ----- src/interpreter2/IPrintable_DGlobalEnv.cpp | 28 ---- src/interpreter2/init_interpreter2.cpp | 2 + .../interpreter2_register_facets.cpp | 7 +- src/skrepl/skreplxx.cpp | 18 ++- 14 files changed, 15 insertions(+), 515 deletions(-) delete mode 100644 idl/IGCObject_DGlobalEnv.json5 delete mode 100644 idl/IPrintable_DGlobalEnv.json5 delete mode 100644 include/xo/interpreter2/DGlobalEnv.hpp delete mode 100644 include/xo/interpreter2/GlobalEnv.hpp delete mode 100644 include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp delete mode 100644 include/xo/interpreter2/env/IPrintable_DGlobalEnv.hpp delete mode 100644 src/interpreter2/DGlobalEnv.cpp delete mode 100644 src/interpreter2/IGCObject_DGlobalEnv.cpp delete mode 100644 src/interpreter2/IPrintable_DGlobalEnv.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 229bf176..f325441b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -161,24 +161,6 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- -# note: manual target; generated code committed to git -xo_add_genfacetimpl( - TARGET xo-interpreter2-facetimpl-gcobject-globalenv - FACET_PKG xo_alloc2 -# REPR GlobalEnv - INPUT idl/IGCObject_DGlobalEnv.json5 -) - -# note: manual target; generated code committed to git -xo_add_genfacetimpl( - TARGET xo-interpreter2-facetimpl-printable-globalenv - FACET_PKG xo_printable2 -# REPR GlobalEnv - INPUT idl/IPrintable_DGlobalEnv.json5 -) - -# ---------------------------------------------------------------- - # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-localenv diff --git a/idl/IGCObject_DGlobalEnv.json5 b/idl/IGCObject_DGlobalEnv.json5 deleted file mode 100644 index 9ce50388..00000000 --- a/idl/IGCObject_DGlobalEnv.json5 +++ /dev/null @@ -1,18 +0,0 @@ -{ - mode: "implementation", - output_cpp_dir: "src/interpreter2", - output_hpp_dir: "include/xo/interpreter2", - output_impl_subdir: "env", - includes: [ - "", - "" - ], - local_types: [ ], - namespace1: "xo", - namespace2: "scm", - facet_idl: "idl/GCObject.json5", - brief: "provide AGCObject interface for GlobalEnv", - using_doxygen: true, - repr: "DGlobalEnv", - doc: [ "implement AGCObject for DGlobalEnv" ], -} diff --git a/idl/IPrintable_DGlobalEnv.json5 b/idl/IPrintable_DGlobalEnv.json5 deleted file mode 100644 index 541146ae..00000000 --- a/idl/IPrintable_DGlobalEnv.json5 +++ /dev/null @@ -1,16 +0,0 @@ -{ - mode: "implementation", - output_cpp_dir: "src/interpreter2", - output_hpp_dir: "include/xo/interpreter2", - output_impl_subdir: "env", - includes: [ "", - "" ], - local_types: [ ], - namespace1: "xo", - namespace2: "scm", - facet_idl: "idl/Printable.json5", - brief: "provide APrintable interface for DGlobalEnv", - using_doxygen: true, - repr: "DGlobalEnv", - doc: [ "implement APrintable for DGlobalEnv" ], -} diff --git a/include/xo/interpreter2/DGlobalEnv.hpp b/include/xo/interpreter2/DGlobalEnv.hpp deleted file mode 100644 index da7f8536..00000000 --- a/include/xo/interpreter2/DGlobalEnv.hpp +++ /dev/null @@ -1,94 +0,0 @@ -/** @file DGlobalEnv.hpp - * - * @author Roland Conybeare, Feb 2026 - **/ - -#pragma once - -#include -#include - -namespace xo { - namespace scm { - - /** @brief runtime bindings for global variabels - * - * Implementation here uses a DArenaHashMap to hold pairs. - * The hash map has its own memory outside GC space. - * Keys are DUniqueStrings, also outside GC space. - * Values are regular gc-aware objects, generally will be in GC space. - * - * We need collector to traverse all the values in a global env - * on each cycle. Arrange that by having DGlobalEnv itself - * in GC space. - * - **/ - class DGlobalEnv { - public: - using TypeDescr = xo::reflect::TypeDescr; - using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; - using AGCObject = xo::mm::AGCObject; - using MemorySizeVisitor = xo::mm::MemorySizeVisitor; - using ppindentinfo = xo::print::ppindentinfo; - using size_type = std::uint32_t; - - public: - /** @defgroup scm-globalenv-ctors constructors **/ - ///@{ - - DGlobalEnv(DGlobalSymtab * symtab, DArray * values); - - static DGlobalEnv * _make(obj mm, - DGlobalSymtab * symtab); - - - ///@} - /** @defgroup scm-globalenv-methods methods **/ - ///@{ - - /** symbol-table size. Is the number of distinct global variables **/ - size_type n_vars() const noexcept { return symtab_->n_vars(); } - - /** lookup current value associated with binding @p ix **/ - obj lookup_value(Binding ix) const noexcept; - - /** assign value associated with binding @p to @p x. - * If need to expand size of this env, use memory from @p mm - **/ - void assign_value(obj mm, Binding ix, obj x); - - /** create/establish global for symbol @p sym with resolved type @p td - * and associate with @p value. - **/ - DVariable * _upsert_value(obj mm, - const DUniqueString * sym, - TypeDescr td, - obj value); - - ///@} - /** @defgroup scm-globalenv-gcobject-facet **/ - ///@{ - - std::size_t shallow_size() const noexcept; - DGlobalEnv * shallow_copy(obj mm) const noexcept; - std::size_t forward_children(obj gc) noexcept; - - ///@} - /** @defgroup scm-globalenv-printable-facet **/ - ///@{ - - bool pretty(const ppindentinfo & ppii) const; - - ///@} - - private: - - /** symbol table assigns a unique index for each symbol **/ - DGlobalSymtab * symtab_; - - /** value for a symbol S will be in values_[symtab->lookup_binding(S)] **/ - DArray * values_ = nullptr; - }; - } -} diff --git a/include/xo/interpreter2/GlobalEnv.hpp b/include/xo/interpreter2/GlobalEnv.hpp deleted file mode 100644 index 94bafc42..00000000 --- a/include/xo/interpreter2/GlobalEnv.hpp +++ /dev/null @@ -1,12 +0,0 @@ -/** @file GlobalEnv.hpp - * - * @author Roland Conybeare, Feb 2026 - **/ - -#pragma once - -#include "DGlobalEnv.hpp" -#include "env/IGCObject_DGlobalEnv.hpp" -#include "env/IPrintable_DGlobalEnv.hpp" - -/* end GlobalEnv.hpp */ diff --git a/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp deleted file mode 100644 index a2fcb5f6..00000000 --- a/include/xo/interpreter2/env/IGCObject_DGlobalEnv.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/** @file IGCObject_DGlobalEnv.hpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IGCObject_DGlobalEnv.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_repr.hpp.j2] - * 3. idl for facet methods - * [idl/IGCObject_DGlobalEnv.json5] - **/ - -#pragma once - -#include "GCObject.hpp" -#include -#include -#include "DGlobalEnv.hpp" - -namespace xo { namespace scm { class IGCObject_DGlobalEnv; } } - -namespace xo { - namespace facet { - template <> - struct FacetImplementation - { - using ImplType = xo::mm::IGCObject_Xfer - ; - }; - } -} - -namespace xo { - namespace scm { - /** @class IGCObject_DGlobalEnv - **/ - class IGCObject_DGlobalEnv { - public: - /** @defgroup scm-gcobject-dglobalenv-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-dglobalenv-methods **/ - ///@{ - // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DGlobalEnv & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DGlobalEnv & self, obj mm) noexcept; - - // non-const methods - /** during GC: forward immdiate children **/ - static size_type forward_children(DGlobalEnv & self, obj gc) noexcept; - ///@} - }; - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/env/IPrintable_DGlobalEnv.hpp b/include/xo/interpreter2/env/IPrintable_DGlobalEnv.hpp deleted file mode 100644 index 6efcd963..00000000 --- a/include/xo/interpreter2/env/IPrintable_DGlobalEnv.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/** @file IPrintable_DGlobalEnv.hpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IPrintable_DGlobalEnv.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_repr.hpp.j2] - * 3. idl for facet methods - * [idl/IPrintable_DGlobalEnv.json5] - **/ - -#pragma once - -#include "Printable.hpp" -#include -#include -#include "DGlobalEnv.hpp" - -namespace xo { namespace scm { class IPrintable_DGlobalEnv; } } - -namespace xo { - namespace facet { - template <> - struct FacetImplementation - { - using ImplType = xo::print::IPrintable_Xfer - ; - }; - } -} - -namespace xo { - namespace scm { - /** @class IPrintable_DGlobalEnv - **/ - class IPrintable_DGlobalEnv { - public: - /** @defgroup scm-printable-dglobalenv-type-traits **/ - ///@{ - using ppindentinfo = xo::print::APrintable::ppindentinfo; - using Copaque = xo::print::APrintable::Copaque; - using Opaque = xo::print::APrintable::Opaque; - ///@} - /** @defgroup scm-printable-dglobalenv-methods **/ - ///@{ - // const methods - /** Pretty-printing support for this object. -See [xo-indentlog/xo/indentlog/pretty.hpp] **/ - static bool pretty(const DGlobalEnv & 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 c15ddef6..27927606 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -36,10 +36,6 @@ set(SELF_SRCS IGCObject_DClosure.cpp IPrintable_DClosure.cpp - DGlobalEnv.cpp - IGCObject_DGlobalEnv.cpp - IPrintable_DGlobalEnv.cpp - DLocalEnv.cpp IGCObject_DLocalEnv.cpp IPrintable_DLocalEnv.cpp diff --git a/src/interpreter2/DGlobalEnv.cpp b/src/interpreter2/DGlobalEnv.cpp deleted file mode 100644 index fcc92efa..00000000 --- a/src/interpreter2/DGlobalEnv.cpp +++ /dev/null @@ -1,145 +0,0 @@ -/** @file DGlobalEnv.cpp - * - * @author Roland Conybeare, Feb 2026 -**/ - -#include "GlobalEnv.hpp" -#include -#include - -namespace xo { - using xo::mm::AAllocator; - using xo::mm::AGCObject; - - namespace scm { - - DGlobalEnv::DGlobalEnv(DGlobalSymtab * symtab, DArray * values) - : symtab_{symtab}, values_{values} - {} - - DGlobalEnv * - DGlobalEnv::_make(obj mm, - DGlobalSymtab * symtab) - { - DArray * values = DArray::empty(mm, symtab->var_capacity()); - - void * mem = mm.alloc_for(); - - return new (mem) DGlobalEnv(symtab, values); - } - - obj - DGlobalEnv::lookup_value(Binding ix) const noexcept - { - if (!ix.is_global()) { - assert(false); - return obj(); - } - - if (ix.j_slot() >= static_cast(values_->size())) { - assert(false); - return obj(); - } - - return (*values_)[ix.j_slot()]; - } - - void - DGlobalEnv::assign_value(obj mm, Binding ix, obj x) - { - scope log(XO_DEBUG(true), - xtag("ix.j_slot", ix.j_slot()), - xtag("values.cap", values_->capacity())); - - assert(ix.is_global()); - - if (ix.j_slot() >= static_cast(values_->size())) { - // Control will come here in interpreter as new definitions are introduced. - // After seeing - // def foo = 1.2345; - // introducing new symbol foo: - // GlobalSymtab extends to include foo without this GlobalEnv - // knowing about it. - - if (ix.j_slot() + 1 > static_cast(values_->capacity())) { - // realloc global array for more size - - size_t cap_2x = 2 * values_->capacity(); - - while (cap_2x < static_cast(ix.j_slot() + 1)) - cap_2x = 2 * cap_2x; - - DArray * values_2x = DArray::copy(mm, values_, cap_2x); - assert(values_2x); - - if (values_2x) { - log && log("STUB: need write barrier for GC (also in GlobalSymtab!)"); - this->values_ = values_2x; - } else { - return; - } - } - - /** expand size sot that j_slot is valid **/ - values_->resize(ix.j_slot() + 1); - } - - log && log("STUB: need write barrier for GC here"); - (*values_)[ix.j_slot()] = x; - } - - DVariable * - DGlobalEnv::_upsert_value(obj mm, - const DUniqueString * sym, - TypeDescr td, - obj value) - { - DVariable * var - = DVariable::make(mm, sym, TypeRef::resolved(td)); - - assert(var); - - symtab_->upsert_variable(mm, var); - this->assign_value(mm, var->path(), value); - - return var; - } - - // ----- AGCObject facet ----- - - std::size_t - DGlobalEnv::shallow_size() const noexcept - { - return sizeof(*this); - } - - DGlobalEnv * - DGlobalEnv::shallow_copy(obj mm) const noexcept - { - return mm.std_copy_for(this); - } - - std::size_t - DGlobalEnv::forward_children(obj gc) noexcept - { - gc.forward_inplace(&symtab_); - gc.forward_inplace(&values_); - - return this->shallow_size(); - } - - // ----- APrintable facet ----- - - bool - DGlobalEnv::pretty(const ppindentinfo & ppii) const - { - return ppii.pps()->pretty_struct - (ppii, - "DGlobalEnv", - refrtag("n_vars", symtab_->n_vars())); - } - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end DGlobalEnv.cpp */ diff --git a/src/interpreter2/IGCObject_DGlobalEnv.cpp b/src/interpreter2/IGCObject_DGlobalEnv.cpp deleted file mode 100644 index 76606d6f..00000000 --- a/src/interpreter2/IGCObject_DGlobalEnv.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/** @file IGCObject_DGlobalEnv.cpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IGCObject_DGlobalEnv.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] - * 3. idl for facet methods - * [idl/IGCObject_DGlobalEnv.json5] -**/ - -#include "env/IGCObject_DGlobalEnv.hpp" - -namespace xo { - namespace scm { - auto - IGCObject_DGlobalEnv::shallow_size(const DGlobalEnv & self) noexcept -> size_type - { - return self.shallow_size(); - } - - auto - IGCObject_DGlobalEnv::shallow_copy(const DGlobalEnv & self, obj mm) noexcept -> Opaque - { - return self.shallow_copy(mm); - } - - auto - IGCObject_DGlobalEnv::forward_children(DGlobalEnv & self, obj gc) noexcept -> size_type - { - return self.forward_children(gc); - } - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end IGCObject_DGlobalEnv.cpp */ diff --git a/src/interpreter2/IPrintable_DGlobalEnv.cpp b/src/interpreter2/IPrintable_DGlobalEnv.cpp deleted file mode 100644 index 84fc561c..00000000 --- a/src/interpreter2/IPrintable_DGlobalEnv.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/** @file IPrintable_DGlobalEnv.cpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IPrintable_DGlobalEnv.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] - * 3. idl for facet methods - * [idl/IPrintable_DGlobalEnv.json5] -**/ - -#include "env/IPrintable_DGlobalEnv.hpp" - -namespace xo { - namespace scm { - auto - IPrintable_DGlobalEnv::pretty(const DGlobalEnv & self, const ppindentinfo & ppii) -> bool - { - return self.pretty(ppii); - } - - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end IPrintable_DGlobalEnv.cpp */ diff --git a/src/interpreter2/init_interpreter2.cpp b/src/interpreter2/init_interpreter2.cpp index 73a6a5c2..6302be0c 100644 --- a/src/interpreter2/init_interpreter2.cpp +++ b/src/interpreter2/init_interpreter2.cpp @@ -27,6 +27,8 @@ namespace xo { InitEvidence InitSubsys::require() { + scope log(XO_DEBUG(true)); + InitEvidence retval; /* direct subsystem deps for xo-interpreter2/ */ diff --git a/src/interpreter2/interpreter2_register_facets.cpp b/src/interpreter2/interpreter2_register_facets.cpp index 22c9bfb9..24801f66 100644 --- a/src/interpreter2/interpreter2_register_facets.cpp +++ b/src/interpreter2/interpreter2_register_facets.cpp @@ -63,12 +63,7 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); - // GlobalEnv - - FacetRegistry::register_impl(); - FacetRegistry::register_impl(); - - // LocalEnv + // LocalEnv (see xo-reader2/ for GlobalEnv) FacetRegistry::register_impl(); FacetRegistry::register_impl(); diff --git a/src/skrepl/skreplxx.cpp b/src/skrepl/skreplxx.cpp index 3362b823..e3d5564e 100644 --- a/src/skrepl/skreplxx.cpp +++ b/src/skrepl/skreplxx.cpp @@ -110,13 +110,15 @@ namespace xo { //using X1CollectorConfig = xo::mm::X1CollectorConfig; //using DArena = xo::mm::DArena; //using ArenaConfig = xo::mm::ArenaConfig; + using VsmConfig = xo::scm::VsmConfig; using Replxx = replxx::Replxx; using span_type = VirtualSchematikaMachine::span_type; App(const AppConfig & cfg = AppConfig()) : repl_config_{cfg.repl_config_}, app_arena_{cfg.app_arena_config_}, - vsm_{cfg.vsm_config_, obj(&app_arena_)} + vsm_config_{cfg.vsm_config_} + //vsm_{cfg.vsm_config_, obj(&app_arena_)} { this->interactive_ = isatty(STDIN_FILENO); @@ -148,7 +150,8 @@ namespace xo { /** arena with same lifetime as this application **/ DArena app_arena_; /** schematika virtual machine **/ - VirtualSchematikaMachine vsm_; + VsmConfig vsm_config_; + std::unique_ptr vsm_; }; void @@ -162,13 +165,16 @@ namespace xo { void App::_init() { - // window to contorl size of registries ends as soon as we init other subsystems + // window to control size of registries ends as soon as we init other subsystems TypeRegistry::instance(1024); FacetRegistry::instance(1024); InitEvidence init_evidence_ = (InitSubsys::require()); Subsystem::initialize_all(); + + vsm_.reset(new VirtualSchematikaMachine(vsm_config_, + obj(&app_arena_))); } void @@ -176,7 +182,7 @@ namespace xo { { welcome(cerr); - vsm_.begin_interactive_session(); + vsm_->begin_interactive_session(); } void @@ -186,7 +192,7 @@ namespace xo { span_type input; // outer loop: fetch one line of interactive input - while (replxx_getline(interactive_, vsm_.is_at_toplevel(), rx_, &input)) { + while (replxx_getline(interactive_, vsm_->is_at_toplevel(), rx_, &input)) { // inner loop: consume up to one expression at a time. while (!input.empty() && this->_read_eval_print(&input, false /*eof*/)) @@ -218,7 +224,7 @@ namespace xo { if (!p_input || p_input->empty()) return true; - VsmResultExt res = vsm_.read_eval_print(*p_input, eof); + VsmResultExt res = vsm_->read_eval_print(*p_input, eof); *p_input = res.remaining_; From 9061bd20ee9ca237097d360806dee42f5eb2df3e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 15 Mar 2026 09:47:14 -0500 Subject: [PATCH 080/131] xo-interpreter2 stack: modularize nth() primitive setup/install --- .../interpreter2/VirtualSchematikaMachine.hpp | 2 +- src/interpreter2/VirtualSchematikaMachine.cpp | 34 +------------------ 2 files changed, 2 insertions(+), 34 deletions(-) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index ec7eda34..6663538e 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -280,7 +280,7 @@ namespace xo { obj expr_; /** environment pointer. Maintains bindings - * for global variables. + * for global variables. Obtained from reader **/ DGlobalEnv * global_env_ = nullptr; diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 6bcbe8bf..a4ed2810 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -86,7 +86,7 @@ namespace xo { this->error_mm_.adopt(obj(arena)); } - this->global_env_ = DGlobalEnv::_make(mm_.to_op(), reader_.global_symtab()); + this->global_env_ = reader_.global_env(); this->install_core_primitives(); } @@ -915,26 +915,6 @@ namespace xo { static DPrimitive_gco_0 s_cwd_pm("_cwd", &xfer_cwd); - // ----- primitive: nth() ----- - - // TODO: seq_gc -> obj - // n_gco -> obj - // - obj - xfer_nth(obj rcx, - obj seq_gco, - obj n_gco) - { - (void)rcx; - - obj seq = seq_gco.to_facet(); - auto n = obj::from(n_gco); - - return seq.at(n->value()); - } - - static DPrimitive_gco_2_gco_gco s_nth_pm("_nth", &xfer_nth); - // ----- primitive: cons() ----- obj @@ -1045,18 +1025,6 @@ namespace xo { obj(&s_cwd_pm)); } - /* nth */ - { - const DUniqueString * name - = reader_.intern_string("nth"); - - global_env_->_upsert_value - (mm_.to_op(), - name, - Reflect::require(), - obj(&s_nth_pm)); - } - /* cons */ { const DUniqueString * name From 174e363c9a6279503e5f14d0ce1627b26c5bc287 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 15 Mar 2026 11:40:24 -0500 Subject: [PATCH 081/131] xo-interpreter2 stack: refactor: move dict pms to object2/ --- src/interpreter2/VirtualSchematikaMachine.cpp | 69 +------------------ 1 file changed, 2 insertions(+), 67 deletions(-) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index a4ed2810..b02d5c58 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -206,7 +206,8 @@ namespace xo { log && log(xtag("expr", expr_pr)); if (value_.value()) { - auto value_pr = const_cast *>(value_.value())->to_facet(); + auto value_pr + = const_cast *>(value_.value())->to_facet(); if (value_pr) log && log(xtag("value", value_pr)); } else { @@ -954,48 +955,6 @@ namespace xo { static DPrimitive_gco_1_gco s_fn_n_args_pm("_fn_n_args", &xfer_fn_n_args); - // ----- primitive: dict_make() ----- - - obj - xfer_dict_make(obj rcx) - { - return obj(DDictionary::empty(rcx.allocator(), - 8 /*cap*/)); - } - - static DPrimitive_gco_0 s_dict_make_pm("_dict_make", - &xfer_dict_make); - - // ----- primitive: dict_upsert() ----- - - obj - xfer_dict_upsert(obj rcx, - obj dict, - obj key, - obj value) - { - scope log(XO_DEBUG(true)); - - log && log(xtag("dict.tseq", dict._typeseq()), - xtag("dict.tname", TypeRegistry::id2name(dict._typeseq()))); - log && log(xtag("key.tseq", key._typeseq()), - xtag("key.tname", TypeRegistry::id2name(key._typeseq()))); - log && log(xtag("value.tseq", value._typeseq()), - xtag("value.tname", TypeRegistry::id2name(value._typeseq()))); - - auto value_pr = FacetRegistry::instance().variant(value); - - log && log(xtag("value", value_pr)); - - dict->upsert(rcx.allocator(), - DDictionary::pair_type(key.data(), value)); - - return dict; - } - - static DPrimitive_gco_3_dict_string_gco s_dict_upsert_pm("_dict_upsert", - &xfer_dict_upsert); - // ----- install primitives ----- void @@ -1048,30 +1007,6 @@ namespace xo { Reflect::require(), obj(&s_fn_n_args_pm)); } - - /* dict_make */ - { - const DUniqueString * name - = reader_.intern_string("dict_make"); - - global_env_->_upsert_value - (mm_.to_op(), - name, - Reflect::require(), - obj(&s_dict_make_pm)); - } - - /* dict_upsert */ - { - const DUniqueString * name - = reader_.intern_string("dict_upsert"); - - global_env_->_upsert_value - (mm_.to_op(), - name, - Reflect::require(), - obj(&s_dict_upsert_pm)); - } } } /*namespace scm*/ From be680fcc552e5de588e67182c76fd46ea1d89a92 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 15 Mar 2026 11:51:37 -0500 Subject: [PATCH 082/131] xo-interpreter2 stack: refactor: move cons() pm to object2/ --- src/interpreter2/VirtualSchematikaMachine.cpp | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index b02d5c58..a021a865 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -918,21 +918,6 @@ namespace xo { // ----- primitive: cons() ----- - obj - xfer_cons(obj rcx, - obj car, - obj cdr) - { - (void)rcx; - - auto cdr_list = obj::from(cdr); - - return DList::cons(rcx.allocator(), - car, - cdr_list.data()); - } - - static DPrimitive_gco_2_gco_gco s_cons_pm("_cons", &xfer_cons); // ----- primitive: fn_n_args() ----- @@ -984,18 +969,6 @@ namespace xo { obj(&s_cwd_pm)); } - /* cons */ - { - const DUniqueString * name - = reader_.intern_string("cons"); - - global_env_->_upsert_value - (mm_.to_op(), - name, - Reflect::require(), - obj(&s_cons_pm)); - } - /* fn_n_args */ { const DUniqueString * name From 1f596e6172a3293b7e1bcce08bb4b39dfe74dfda Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 15 Mar 2026 12:10:21 -0500 Subject: [PATCH 083/131] xo-interpreter2 stack: refactor: do report_memory_use() modular --- include/xo/interpreter2/VsmPrimitives.hpp | 27 +++++++ .../interpreter2_register_primitives.hpp | 20 +++++ src/interpreter2/CMakeLists.txt | 2 + src/interpreter2/VirtualSchematikaMachine.cpp | 41 ---------- src/interpreter2/VsmPrimitives.cpp | 52 +++++++++++++ src/interpreter2/init_interpreter2.cpp | 4 + .../interpreter2_register_primitives.cpp | 75 +++++++++++++++++++ 7 files changed, 180 insertions(+), 41 deletions(-) create mode 100644 include/xo/interpreter2/VsmPrimitives.hpp create mode 100644 include/xo/interpreter2/interpreter2_register_primitives.hpp create mode 100644 src/interpreter2/VsmPrimitives.cpp create mode 100644 src/interpreter2/interpreter2_register_primitives.cpp diff --git a/include/xo/interpreter2/VsmPrimitives.hpp b/include/xo/interpreter2/VsmPrimitives.hpp new file mode 100644 index 00000000..59f52fc3 --- /dev/null +++ b/include/xo/interpreter2/VsmPrimitives.hpp @@ -0,0 +1,27 @@ +/** @file VsmPrimitives.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + /** @brief primitives centered on interpreter2/ data + * + **/ + class VsmPrimitives { + public: + using AAllocator = xo::mm::AAllocator; + + public: + /** create primitive: report memory use to console **/ + static DPrimitive_gco_0 * make_report_memory_use_pm(obj mm); + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VsmPrimitives.hpp */ diff --git a/include/xo/interpreter2/interpreter2_register_primitives.hpp b/include/xo/interpreter2/interpreter2_register_primitives.hpp new file mode 100644 index 00000000..1946969a --- /dev/null +++ b/include/xo/interpreter2/interpreter2_register_primitives.hpp @@ -0,0 +1,20 @@ +/** @file interpreter2_register_primitives.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "PrimitiveRegistry.hpp" +#include + +namespace xo { + namespace scm { + /** Register primitive-factories **/ + bool interpreter2_register_primitives(obj gc, + InstallSink sink, + InstallFlags flags); + } +} + +/* end interpreter2_register_primitives.hpp */ diff --git a/src/interpreter2/CMakeLists.txt b/src/interpreter2/CMakeLists.txt index 27927606..60974aeb 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -3,10 +3,12 @@ set(SELF_LIB xo_interpreter2) set(SELF_SRCS init_interpreter2.cpp + interpreter2_register_primitives.cpp interpreter2_register_facets.cpp interpreter2_register_types.cpp VirtualSchematikaMachine.cpp + VsmPrimitives.cpp DVsmDefContFrame.cpp IGCObject_DVsmDefContFrame.cpp diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index a021a865..9473d15e 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -876,32 +876,6 @@ namespace xo { } } - // ----- primitive: report_memory_use() ----- - - obj - xfer_report_memory_use(obj rcx) - { - scope log(XO_DEBUG(true)); - - auto visitor = [&log](const MemorySizeInfo & info) { - log && log(xtag("resource", info.resource_name_), - xtag("used", info.used_), - xtag("alloc", info.allocated_), - xtag("commit", info.committed_), - xtag("resv", info.reserved_)); - }; - - FacetRegistry::instance().visit_pools(visitor); - TypeRegistry::instance().visit_pools(visitor); - NumericDispatch::instance().visit_pools(visitor); - rcx.visit_pools(visitor); - - return DBoolean::box(rcx.allocator(), true); - } - - static DPrimitive_gco_0 s_report_memory_use_pm("_report_memory_use", - &xfer_report_memory_use); - // ----- primitive: cwd() ----- obj @@ -916,9 +890,6 @@ namespace xo { static DPrimitive_gco_0 s_cwd_pm("_cwd", &xfer_cwd); - // ----- primitive: cons() ----- - - // ----- primitive: fn_n_args() ----- obj @@ -945,18 +916,6 @@ namespace xo { void VirtualSchematikaMachine::install_core_primitives() { - /* report_memory_use */ - { - const DUniqueString * name - = reader_.intern_string("report_memory_use"); - - global_env_->_upsert_value - (mm_.to_op(), - name, - Reflect::require(), - obj(&s_report_memory_use_pm)); - } - /* cwd */ { const DUniqueString * name diff --git a/src/interpreter2/VsmPrimitives.cpp b/src/interpreter2/VsmPrimitives.cpp new file mode 100644 index 00000000..a3eb79e0 --- /dev/null +++ b/src/interpreter2/VsmPrimitives.cpp @@ -0,0 +1,52 @@ +/** @file VsmPrimitives.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "VsmPrimitives.hpp" +#include +#include + +namespace xo { + //using xo::scm::NumericDispatch; + using xo::mm::MemorySizeInfo; + using xo::facet::FacetRegistry; + using xo::facet::TypeRegistry; + + namespace scm { + // ----- primitive: report_memory_use() ----- + + obj + xfer_report_memory_use(obj rcx) + { + scope log(XO_DEBUG(true)); + + auto visitor = [&log](const MemorySizeInfo & info) { + log && log(xtag("resource", info.resource_name_), + xtag("used", info.used_), + xtag("alloc", info.allocated_), + xtag("commit", info.committed_), + xtag("resv", info.reserved_)); + }; + + FacetRegistry::instance().visit_pools(visitor); + TypeRegistry::instance().visit_pools(visitor); + NumericDispatch::instance().visit_pools(visitor); + rcx.visit_pools(visitor); + + return DBoolean::box(rcx.allocator(), true); + } + + DPrimitive_gco_0 * + VsmPrimitives::make_report_memory_use_pm(obj mm) + { + return DPrimitive_gco_0::_make(mm, + "report_memory_use", + &xfer_report_memory_use); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VsmPrimitives.cpp */ diff --git a/src/interpreter2/init_interpreter2.cpp b/src/interpreter2/init_interpreter2.cpp index 6302be0c..fddbf21a 100644 --- a/src/interpreter2/init_interpreter2.cpp +++ b/src/interpreter2/init_interpreter2.cpp @@ -5,6 +5,7 @@ #include "init_interpreter2.hpp" +#include "interpreter2_register_primitives.hpp" #include "interpreter2_register_facets.hpp" #include "interpreter2_register_types.hpp" @@ -12,8 +13,10 @@ #include namespace xo { + using xo::scm::interpreter2_register_primitives; using xo::scm::interpreter2_register_facets; using xo::scm::interpreter2_register_types; + using xo::scm::PrimitiveRegistry; using xo::mm::CollectorTypeRegistry; void @@ -22,6 +25,7 @@ namespace xo { interpreter2_register_facets(); CollectorTypeRegistry::instance().register_types(&interpreter2_register_types); + PrimitiveRegistry::instance().register_primitives(&interpreter2_register_primitives); } InitEvidence diff --git a/src/interpreter2/interpreter2_register_primitives.cpp b/src/interpreter2/interpreter2_register_primitives.cpp new file mode 100644 index 00000000..17512f4b --- /dev/null +++ b/src/interpreter2/interpreter2_register_primitives.cpp @@ -0,0 +1,75 @@ +/** @file interpreter2_register_primitives.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "interpreter2_register_primitives.hpp" +#include "VsmPrimitives.hpp" + +namespace xo { + using xo::mm::AAllocator; + + namespace scm { + /** TODO: MOVE THESE install_aux() remplates SOMEWHERE COMMON **/ + + template + bool install_aux(InstallSink sink, + PrimitiveRepr * pm, + InstallFlags flags) + { + scope log(XO_DEBUG(true)); + + if ((flags & InstallFlags::f_generalpurpose) == InstallFlags::f_generalpurpose) { + log && log("create primitive", xtag("name", pm->name())); + + return sink(pm->name(), + pm->fn_td(), + obj(pm), + flags); + } else { + log && log("skip primitive", xtag("name", pm->name())); + + return true; + } + } + + template + bool install_aux(InstallSink sink, + obj mm, + std::string_view name, + typename Primitive::FunctionPtrType impl, + InstallFlags flags) + { + if (flags != InstallFlags::f_none) { + auto pm + = Primitive::_make(mm, name, impl); + + return install_aux(sink, pm, flags); + } else { + return true; + } + } + + bool + interpreter2_register_primitives(obj mm, + InstallSink sink, + InstallFlags flags) + { + (void)mm; + (void)sink; + (void)flags; + + scope log(XO_DEBUG(true)); + + bool ok = true; + + ok = ok & install_aux(sink, VsmPrimitives::make_report_memory_use_pm(mm), flags); + + return ok; + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end interpreter2_register_primitives.cpp **/ From 1e3e8799666386daadf7048da701cd343e8dc9ba Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 15 Mar 2026 14:25:35 -0500 Subject: [PATCH 084/131] xo-interpreter2 stack: refactor: move cwd() -> ObjectPrimitives --- src/interpreter2/VirtualSchematikaMachine.cpp | 27 ------------------- 1 file changed, 27 deletions(-) diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 9473d15e..74612aa6 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -37,7 +37,6 @@ #include #include #include -#include // for getcwd() namespace xo { using xo::scm::DDictionary; @@ -876,20 +875,6 @@ namespace xo { } } - // ----- primitive: cwd() ----- - - obj - xfer_cwd(obj rcx) - { - char buf[PATH_MAX]; - ::getcwd(buf, sizeof(buf)); - - return obj(DString::from_cstr(rcx.allocator(), buf)); - } - - static DPrimitive_gco_0 s_cwd_pm("_cwd", - &xfer_cwd); - // ----- primitive: fn_n_args() ----- obj @@ -916,18 +901,6 @@ namespace xo { void VirtualSchematikaMachine::install_core_primitives() { - /* cwd */ - { - const DUniqueString * name - = reader_.intern_string("cwd"); - - global_env_->_upsert_value - (mm_.to_op(), - name, - Reflect::require(), - obj(&s_cwd_pm)); - } - /* fn_n_args */ { const DUniqueString * name From aed354cf678e12aac78aeb5048b11cad3ef34845 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 15 Mar 2026 14:35:44 -0500 Subject: [PATCH 085/131] xo-interpreter2 stack: move fn_n_args() to ObjectPrimitives --- .../interpreter2/VirtualSchematikaMachine.hpp | 3 -- src/interpreter2/VirtualSchematikaMachine.cpp | 41 ------------------- 2 files changed, 44 deletions(-) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 6663538e..290eaf09 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -100,9 +100,6 @@ namespace xo { /** visit vsm-owned memory pools; call visitor(info) for each **/ void visit_pools(const MemorySizeVisitor & visitor) const; - /** install hardwired functions into global {symtab,env} **/ - void install_core_primitives(); - /** begin interactive session. **/ void begin_interactive_session(); /** begin batch session **/ diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 74612aa6..d459622a 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -86,8 +86,6 @@ namespace xo { } this->global_env_ = reader_.global_env(); - - this->install_core_primitives(); } obj @@ -875,45 +873,6 @@ namespace xo { } } - // ----- primitive: fn_n_args() ----- - - obj - xfer_fn_n_args(obj rcx, - obj fn_gco) - { - scope log(XO_DEBUG(true)); - - log && log(xtag("fn_gco.tseq", fn_gco._typeseq())); - log && log(xtag("fn_gco.tname", TypeRegistry::id2name(fn_gco._typeseq()))); - - auto fn_proc = FacetRegistry::instance().try_variant(fn_gco); - - assert(fn_proc); - - return DInteger::box(rcx.allocator(), fn_proc.n_args()); - } - - static DPrimitive_gco_1_gco s_fn_n_args_pm("_fn_n_args", - &xfer_fn_n_args); - - // ----- install primitives ----- - - void - VirtualSchematikaMachine::install_core_primitives() - { - /* fn_n_args */ - { - const DUniqueString * name - = reader_.intern_string("fn_n_args"); - - global_env_->_upsert_value - (mm_.to_op(), - name, - Reflect::require(), - obj(&s_fn_n_args_pm)); - } - } - } /*namespace scm*/ } /*namespace xo*/ From 383e1983a3166395c0947016afbf689c69d058b5 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 01:27:25 -0500 Subject: [PATCH 086/131] xo-interpreter2 stack: + stringtable() in RuntimeContext api --- include/xo/interpreter2/DVsmRcx.hpp | 3 +++ include/xo/interpreter2/VirtualSchematikaMachine.hpp | 2 ++ include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp | 2 ++ src/interpreter2/DVsmRcx.cpp | 6 ++++++ src/interpreter2/IRuntimeContext_DVsmRcx.cpp | 6 ++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 6 ++++++ 6 files changed, 25 insertions(+) diff --git a/include/xo/interpreter2/DVsmRcx.hpp b/include/xo/interpreter2/DVsmRcx.hpp index 3323f7d7..1f3a8f57 100644 --- a/include/xo/interpreter2/DVsmRcx.hpp +++ b/include/xo/interpreter2/DVsmRcx.hpp @@ -5,6 +5,7 @@ #pragma once +#include #include #include @@ -19,6 +20,7 @@ namespace xo { **/ class DVsmRcx { public: + using StringTable = xo::scm::StringTable; using AAllocator = xo::mm::AAllocator; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; @@ -26,6 +28,7 @@ namespace xo { DVsmRcx(VirtualSchematikaMachine * vsm); obj allocator() const noexcept; + StringTable * stringtable() const noexcept; obj error_allocator() const noexcept; void visit_pools(const MemorySizeVisitor & visitor) const; diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 290eaf09..382dbc5d 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -91,6 +91,8 @@ namespace xo { obj allocator() const noexcept; /** allocator for runtime errors **/ obj error_allocator() const noexcept; + /** global unique-string table **/ + StringTable * stringtable() noexcept; /** true iff parser is at top-level -> does not contain * state for a incomplete/partial expression diff --git a/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp b/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp index 0305e3e5..1b4c1567 100644 --- a/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp +++ b/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp @@ -49,6 +49,8 @@ namespace xo { // const methods /** default allocator to use for objects **/ static obj allocator(const DVsmRcx & self) noexcept; + /** stringtable for unique symbols **/ + static StringTable * stringtable(const DVsmRcx & self) noexcept; /** invoke visitor for each distinct memory pool **/ static void visit_pools(const DVsmRcx & self, MemorySizeVisitor visitor); diff --git a/src/interpreter2/DVsmRcx.cpp b/src/interpreter2/DVsmRcx.cpp index fa81b9c8..b7ea4112 100644 --- a/src/interpreter2/DVsmRcx.cpp +++ b/src/interpreter2/DVsmRcx.cpp @@ -25,6 +25,12 @@ namespace xo { return vsm_->error_allocator(); } + StringTable * + DVsmRcx::stringtable() const noexcept + { + return vsm_->stringtable(); + } + void DVsmRcx::visit_pools(const MemorySizeVisitor & visitor) const { diff --git a/src/interpreter2/IRuntimeContext_DVsmRcx.cpp b/src/interpreter2/IRuntimeContext_DVsmRcx.cpp index d201051a..e879d4ed 100644 --- a/src/interpreter2/IRuntimeContext_DVsmRcx.cpp +++ b/src/interpreter2/IRuntimeContext_DVsmRcx.cpp @@ -21,6 +21,12 @@ namespace xo { return self.allocator(); } + auto + IRuntimeContext_DVsmRcx::stringtable(const DVsmRcx & self) noexcept -> StringTable * + { + return self.stringtable(); + } + auto IRuntimeContext_DVsmRcx::visit_pools(const DVsmRcx & self, MemorySizeVisitor visitor) -> void { diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index d459622a..5633c7d0 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -100,6 +100,12 @@ namespace xo { return error_mm_.to_op(); } + StringTable * + VirtualSchematikaMachine::stringtable() noexcept + { + return reader_.stringtable(); + } + bool VirtualSchematikaMachine::is_at_toplevel() const noexcept { From 637df4983bc844c254352a60ef61f5845f47c5b3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 09:03:24 -0500 Subject: [PATCH 087/131] xo-interpreter2 stack: + dict type + pop more pm types --- include/xo/interpreter2/interpreter2_register_primitives.hpp | 1 + src/interpreter2/interpreter2_register_primitives.cpp | 5 ++--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/xo/interpreter2/interpreter2_register_primitives.hpp b/include/xo/interpreter2/interpreter2_register_primitives.hpp index 1946969a..5d3f0fb1 100644 --- a/include/xo/interpreter2/interpreter2_register_primitives.hpp +++ b/include/xo/interpreter2/interpreter2_register_primitives.hpp @@ -12,6 +12,7 @@ namespace xo { namespace scm { /** Register primitive-factories **/ bool interpreter2_register_primitives(obj gc, + StringTable * stbl, InstallSink sink, InstallFlags flags); } diff --git a/src/interpreter2/interpreter2_register_primitives.cpp b/src/interpreter2/interpreter2_register_primitives.cpp index 17512f4b..9b165b17 100644 --- a/src/interpreter2/interpreter2_register_primitives.cpp +++ b/src/interpreter2/interpreter2_register_primitives.cpp @@ -52,12 +52,11 @@ namespace xo { bool interpreter2_register_primitives(obj mm, + StringTable * stbl, InstallSink sink, InstallFlags flags) { - (void)mm; - (void)sink; - (void)flags; + (void)stbl; scope log(XO_DEBUG(true)); From ea31dbf0d3b90beed6714fa556ecf69789f8722f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 12:34:59 -0500 Subject: [PATCH 088/131] xo-interpreter2 stack: + more primitive function-type decoration --- include/xo/interpreter2/VsmPrimitives.hpp | 3 ++- src/interpreter2/VsmPrimitives.cpp | 12 +++++++++++- .../interpreter2_register_primitives.cpp | 4 +--- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/include/xo/interpreter2/VsmPrimitives.hpp b/include/xo/interpreter2/VsmPrimitives.hpp index 59f52fc3..9690d03e 100644 --- a/include/xo/interpreter2/VsmPrimitives.hpp +++ b/include/xo/interpreter2/VsmPrimitives.hpp @@ -18,7 +18,8 @@ namespace xo { public: /** create primitive: report memory use to console **/ - static DPrimitive_gco_0 * make_report_memory_use_pm(obj mm); + static DPrimitive_gco_0 * make_report_memory_use_pm(obj mm, + StringTable * stbl); }; } /*namespace scm*/ diff --git a/src/interpreter2/VsmPrimitives.cpp b/src/interpreter2/VsmPrimitives.cpp index a3eb79e0..e725c241 100644 --- a/src/interpreter2/VsmPrimitives.cpp +++ b/src/interpreter2/VsmPrimitives.cpp @@ -6,6 +6,8 @@ #include "VsmPrimitives.hpp" #include #include +#include +#include namespace xo { //using xo::scm::NumericDispatch; @@ -38,10 +40,18 @@ namespace xo { } DPrimitive_gco_0 * - VsmPrimitives::make_report_memory_use_pm(obj mm) + VsmPrimitives::make_report_memory_use_pm(obj mm, + StringTable * stbl) { + (void)stbl; + + auto bool_ty = DAtomicType::make(mm, Metatype::t_bool()); + // report_memory_use: () -> bool + auto pm_ty = obj(DFunctionType::_make(mm, bool_ty)); + return DPrimitive_gco_0::_make(mm, "report_memory_use", + pm_ty, &xfer_report_memory_use); } diff --git a/src/interpreter2/interpreter2_register_primitives.cpp b/src/interpreter2/interpreter2_register_primitives.cpp index 9b165b17..f0da9a8e 100644 --- a/src/interpreter2/interpreter2_register_primitives.cpp +++ b/src/interpreter2/interpreter2_register_primitives.cpp @@ -56,13 +56,11 @@ namespace xo { InstallSink sink, InstallFlags flags) { - (void)stbl; - scope log(XO_DEBUG(true)); bool ok = true; - ok = ok & install_aux(sink, VsmPrimitives::make_report_memory_use_pm(mm), flags); + ok = ok & install_aux(sink, VsmPrimitives::make_report_memory_use_pm(mm, stbl), flags); return ok; } From ad1260bd548afa730040a792d5c5c56a8d38cee6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 14:09:03 -0500 Subject: [PATCH 089/131] xo-interpreter2 stack: use RuntimeContext to streamline setup --- .../interpreter2_register_primitives.hpp | 5 +++-- .../interpreter2_register_primitives.cpp | 12 +++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/include/xo/interpreter2/interpreter2_register_primitives.hpp b/include/xo/interpreter2/interpreter2_register_primitives.hpp index 5d3f0fb1..b2e1063b 100644 --- a/include/xo/interpreter2/interpreter2_register_primitives.hpp +++ b/include/xo/interpreter2/interpreter2_register_primitives.hpp @@ -11,8 +11,9 @@ namespace xo { namespace scm { /** Register primitive-factories **/ - bool interpreter2_register_primitives(obj gc, - StringTable * stbl, + bool interpreter2_register_primitives(obj rcx, + //xo::mm::AAllocator> gc, + //StringTable * stbl, InstallSink sink, InstallFlags flags); } diff --git a/src/interpreter2/interpreter2_register_primitives.cpp b/src/interpreter2/interpreter2_register_primitives.cpp index f0da9a8e..dba9337c 100644 --- a/src/interpreter2/interpreter2_register_primitives.cpp +++ b/src/interpreter2/interpreter2_register_primitives.cpp @@ -51,16 +51,22 @@ namespace xo { } bool - interpreter2_register_primitives(obj mm, - StringTable * stbl, + interpreter2_register_primitives(obj rcx, + //obj mm, + //StringTable * stbl, InstallSink sink, InstallFlags flags) { scope log(XO_DEBUG(true)); + obj mm = rcx.allocator(); + StringTable * stbl = rcx.stringtable(); + bool ok = true; - ok = ok & install_aux(sink, VsmPrimitives::make_report_memory_use_pm(mm, stbl), flags); + ok = ok & install_aux(sink, + VsmPrimitives::make_report_memory_use_pm(mm, stbl), + flags); return ok; } From 9321b57adb5e6ca2a720079e491c2801ecb9f4af Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 14:28:27 -0500 Subject: [PATCH 090/131] xo-interpreter2: streamline setup --- include/xo/interpreter2/SetupInterpreter2.hpp | 27 ++++++ .../interpreter2_register_facets.hpp | 15 ---- .../interpreter2_register_primitives.hpp | 22 ----- .../interpreter2_register_types.hpp | 17 ---- src/interpreter2/CMakeLists.txt | 4 +- ...ister_facets.cpp => SetupInterpreter2.cpp} | 88 +++++++++++++++++-- src/interpreter2/init_interpreter2.cpp | 16 ++-- .../interpreter2_register_primitives.cpp | 78 ---------------- .../interpreter2_register_types.cpp | 36 -------- 9 files changed, 115 insertions(+), 188 deletions(-) create mode 100644 include/xo/interpreter2/SetupInterpreter2.hpp delete mode 100644 include/xo/interpreter2/interpreter2_register_facets.hpp delete mode 100644 include/xo/interpreter2/interpreter2_register_primitives.hpp delete mode 100644 include/xo/interpreter2/interpreter2_register_types.hpp rename src/interpreter2/{interpreter2_register_facets.cpp => SetupInterpreter2.cpp} (59%) delete mode 100644 src/interpreter2/interpreter2_register_primitives.cpp delete mode 100644 src/interpreter2/interpreter2_register_types.cpp diff --git a/include/xo/interpreter2/SetupInterpreter2.hpp b/include/xo/interpreter2/SetupInterpreter2.hpp new file mode 100644 index 00000000..be751bda --- /dev/null +++ b/include/xo/interpreter2/SetupInterpreter2.hpp @@ -0,0 +1,27 @@ +/** @file SetupInterpreter2.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "PrimitiveRegistry.hpp" +#include + +namespace xo { + namespace scm { + struct SetupInterpreter2 { + public: + using ACollector = xo::mm::ACollector; + + public: + static bool register_facets(); + static bool register_types(obj gc); + static bool register_primitives(obj rcx, + InstallSink sink, + InstallFlags flags); + }; + } +} + +/* end SetupInterpreter2.hpp */ diff --git a/include/xo/interpreter2/interpreter2_register_facets.hpp b/include/xo/interpreter2/interpreter2_register_facets.hpp deleted file mode 100644 index 587f882b..00000000 --- a/include/xo/interpreter2/interpreter2_register_facets.hpp +++ /dev/null @@ -1,15 +0,0 @@ -/** @file interpreter2_register_facets.hpp - * - * @author Roland Conybeare, Feb 2026 - **/ - -#pragma once - -namespace xo { - namespace scm { - /** Register interpreter2 (facet,impl) combinations with FacetRegistry **/ - bool interpreter2_register_facets(); - } -} - -/* end interpreter2_register_facets.hpp */ diff --git a/include/xo/interpreter2/interpreter2_register_primitives.hpp b/include/xo/interpreter2/interpreter2_register_primitives.hpp deleted file mode 100644 index b2e1063b..00000000 --- a/include/xo/interpreter2/interpreter2_register_primitives.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/** @file interpreter2_register_primitives.hpp - * - * @author Roland Conybeare, Mar 2026 - **/ - -#pragma once - -#include "PrimitiveRegistry.hpp" -#include - -namespace xo { - namespace scm { - /** Register primitive-factories **/ - bool interpreter2_register_primitives(obj rcx, - //xo::mm::AAllocator> gc, - //StringTable * stbl, - InstallSink sink, - InstallFlags flags); - } -} - -/* end interpreter2_register_primitives.hpp */ diff --git a/include/xo/interpreter2/interpreter2_register_types.hpp b/include/xo/interpreter2/interpreter2_register_types.hpp deleted file mode 100644 index b545f356..00000000 --- a/include/xo/interpreter2/interpreter2_register_types.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/** @file interpreter2_register_types.hpp - * - * @author Roland Conybeare, Dec 2025 - **/ - -#pragma once - -#include - -namespace xo { - namespace scm { - /** Register interpreter2 (facet,impl) combinations with FacetRegistry **/ - bool interpreter2_register_types(obj gc); - } -} - -/* end interpreter2_register_types.hpp */ diff --git a/src/interpreter2/CMakeLists.txt b/src/interpreter2/CMakeLists.txt index 60974aeb..fd6953dd 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -3,9 +3,7 @@ set(SELF_LIB xo_interpreter2) set(SELF_SRCS init_interpreter2.cpp - interpreter2_register_primitives.cpp - interpreter2_register_facets.cpp - interpreter2_register_types.cpp + SetupInterpreter2.cpp VirtualSchematikaMachine.cpp VsmPrimitives.cpp diff --git a/src/interpreter2/interpreter2_register_facets.cpp b/src/interpreter2/SetupInterpreter2.cpp similarity index 59% rename from src/interpreter2/interpreter2_register_facets.cpp rename to src/interpreter2/SetupInterpreter2.cpp index 24801f66..643ceab2 100644 --- a/src/interpreter2/interpreter2_register_facets.cpp +++ b/src/interpreter2/SetupInterpreter2.cpp @@ -1,10 +1,10 @@ -/** @file interpreter2_register_facets.cpp +/** @file SetupInterpreter2.cpp * - * @author Roland Conybeare, Feb 2026 + * @author Roland Conybeare, Mar 2026 **/ -#include "interpreter2_register_facets.hpp" - +#include "SetupInterpreter2.hpp" +#include "VsmPrimitives.hpp" #include "DPrimitive_gco_2_gco_gco.hpp" #include "VsmDefContFrame.hpp" #include "VsmApplyFrame.hpp" @@ -24,15 +24,77 @@ #include namespace xo { + using xo::mm::ACollector; + using xo::mm::AAllocator; using xo::mm::AGCObject; using xo::print::APrintable; using xo::facet::FacetRegistry; + using xo::facet::impl_for; using xo::reflect::typeseq; using xo::xtag; namespace scm { + /** TODO: MOVE THESE install_aux() remplates SOMEWHERE COMMON **/ + + template + bool install_aux(InstallSink sink, + PrimitiveRepr * pm, + InstallFlags flags) + { + scope log(XO_DEBUG(true)); + + if ((flags & InstallFlags::f_generalpurpose) == InstallFlags::f_generalpurpose) { + log && log("create primitive", xtag("name", pm->name())); + + return sink(pm->name(), + pm->fn_td(), + obj(pm), + flags); + } else { + log && log("skip primitive", xtag("name", pm->name())); + + return true; + } + } + + template + bool install_aux(InstallSink sink, + obj mm, + std::string_view name, + typename Primitive::FunctionPtrType impl, + InstallFlags flags) + { + if (flags != InstallFlags::f_none) { + auto pm + = Primitive::_make(mm, name, impl); + + return install_aux(sink, pm, flags); + } else { + return true; + } + } + bool - interpreter2_register_facets() + SetupInterpreter2::register_primitives(obj rcx, + InstallSink sink, + InstallFlags flags) + { + scope log(XO_DEBUG(true)); + + obj mm = rcx.allocator(); + StringTable * stbl = rcx.stringtable(); + + bool ok = true; + + ok = ok & install_aux(sink, + VsmPrimitives::make_report_memory_use_pm(mm, stbl), + flags); + + return ok; + } + + bool + SetupInterpreter2::register_facets() { scope log(XO_DEBUG(true)); @@ -101,7 +163,21 @@ namespace xo { return true; } + + bool + SetupInterpreter2::register_types(obj gc) + { + scope log(XO_DEBUG(true)); + + bool ok = true; + + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + + return ok; + } + } /*namespace scm*/ } /*namespace xo*/ -/* end interpreter2_register_facets.cpp */ +/* end SetupInterpreter2.cpp */ diff --git a/src/interpreter2/init_interpreter2.cpp b/src/interpreter2/init_interpreter2.cpp index fddbf21a..77b997d2 100644 --- a/src/interpreter2/init_interpreter2.cpp +++ b/src/interpreter2/init_interpreter2.cpp @@ -4,28 +4,22 @@ **/ #include "init_interpreter2.hpp" - -#include "interpreter2_register_primitives.hpp" -#include "interpreter2_register_facets.hpp" -#include "interpreter2_register_types.hpp" +#include "SetupInterpreter2.hpp" #include #include namespace xo { - using xo::scm::interpreter2_register_primitives; - using xo::scm::interpreter2_register_facets; - using xo::scm::interpreter2_register_types; + using xo::scm::SetupInterpreter2; using xo::scm::PrimitiveRegistry; using xo::mm::CollectorTypeRegistry; void InitSubsys::init() { - interpreter2_register_facets(); - - CollectorTypeRegistry::instance().register_types(&interpreter2_register_types); - PrimitiveRegistry::instance().register_primitives(&interpreter2_register_primitives); + SetupInterpreter2::register_facets(); + CollectorTypeRegistry::instance().register_types(&SetupInterpreter2::register_types); + PrimitiveRegistry::instance().register_primitives(&SetupInterpreter2::register_primitives); } InitEvidence diff --git a/src/interpreter2/interpreter2_register_primitives.cpp b/src/interpreter2/interpreter2_register_primitives.cpp deleted file mode 100644 index dba9337c..00000000 --- a/src/interpreter2/interpreter2_register_primitives.cpp +++ /dev/null @@ -1,78 +0,0 @@ -/** @file interpreter2_register_primitives.cpp - * - * @author Roland Conybeare, Mar 2026 - **/ - -#include "interpreter2_register_primitives.hpp" -#include "VsmPrimitives.hpp" - -namespace xo { - using xo::mm::AAllocator; - - namespace scm { - /** TODO: MOVE THESE install_aux() remplates SOMEWHERE COMMON **/ - - template - bool install_aux(InstallSink sink, - PrimitiveRepr * pm, - InstallFlags flags) - { - scope log(XO_DEBUG(true)); - - if ((flags & InstallFlags::f_generalpurpose) == InstallFlags::f_generalpurpose) { - log && log("create primitive", xtag("name", pm->name())); - - return sink(pm->name(), - pm->fn_td(), - obj(pm), - flags); - } else { - log && log("skip primitive", xtag("name", pm->name())); - - return true; - } - } - - template - bool install_aux(InstallSink sink, - obj mm, - std::string_view name, - typename Primitive::FunctionPtrType impl, - InstallFlags flags) - { - if (flags != InstallFlags::f_none) { - auto pm - = Primitive::_make(mm, name, impl); - - return install_aux(sink, pm, flags); - } else { - return true; - } - } - - bool - interpreter2_register_primitives(obj rcx, - //obj mm, - //StringTable * stbl, - InstallSink sink, - InstallFlags flags) - { - scope log(XO_DEBUG(true)); - - obj mm = rcx.allocator(); - StringTable * stbl = rcx.stringtable(); - - bool ok = true; - - ok = ok & install_aux(sink, - VsmPrimitives::make_report_memory_use_pm(mm, stbl), - flags); - - return ok; - } - - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end interpreter2_register_primitives.cpp **/ diff --git a/src/interpreter2/interpreter2_register_types.cpp b/src/interpreter2/interpreter2_register_types.cpp deleted file mode 100644 index 54351beb..00000000 --- a/src/interpreter2/interpreter2_register_types.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/** @file interpreter2_register_types.cpp - * - * @author Roland Conybeare, Jan 2026 - **/ - -#include "interpreter2_register_types.hpp" - -#include "VsmApplyFrame.hpp" -#include "VsmEvalArgsFrame.hpp" - -#include - -namespace xo { - using xo::mm::ACollector; - using xo::mm::AGCObject; - using xo::facet::impl_for; - //using xo::facet::typeseq; - using xo::scope; - - namespace scm { - bool - interpreter2_register_types(obj gc) - { - scope log(XO_DEBUG(true)); - - bool ok = true; - - ok &= gc.install_type(impl_for()); - ok &= gc.install_type(impl_for()); - - return ok; - } - } -} /*namespace xo*/ - -/* end interpreter2_register_types.cpp */ From 9f8d61fe9070a6782984c36a35728e82e35a479f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 20:18:52 -0500 Subject: [PATCH 091/131] xo-interpreter2: streamline pm setup --- src/interpreter2/SetupInterpreter2.cpp | 80 +++++++------------------- 1 file changed, 20 insertions(+), 60 deletions(-) diff --git a/src/interpreter2/SetupInterpreter2.cpp b/src/interpreter2/SetupInterpreter2.cpp index 643ceab2..d6013741 100644 --- a/src/interpreter2/SetupInterpreter2.cpp +++ b/src/interpreter2/SetupInterpreter2.cpp @@ -34,71 +34,11 @@ namespace xo { using xo::xtag; namespace scm { - /** TODO: MOVE THESE install_aux() remplates SOMEWHERE COMMON **/ - - template - bool install_aux(InstallSink sink, - PrimitiveRepr * pm, - InstallFlags flags) - { - scope log(XO_DEBUG(true)); - - if ((flags & InstallFlags::f_generalpurpose) == InstallFlags::f_generalpurpose) { - log && log("create primitive", xtag("name", pm->name())); - - return sink(pm->name(), - pm->fn_td(), - obj(pm), - flags); - } else { - log && log("skip primitive", xtag("name", pm->name())); - - return true; - } - } - - template - bool install_aux(InstallSink sink, - obj mm, - std::string_view name, - typename Primitive::FunctionPtrType impl, - InstallFlags flags) - { - if (flags != InstallFlags::f_none) { - auto pm - = Primitive::_make(mm, name, impl); - - return install_aux(sink, pm, flags); - } else { - return true; - } - } - - bool - SetupInterpreter2::register_primitives(obj rcx, - InstallSink sink, - InstallFlags flags) - { - scope log(XO_DEBUG(true)); - - obj mm = rcx.allocator(); - StringTable * stbl = rcx.stringtable(); - - bool ok = true; - - ok = ok & install_aux(sink, - VsmPrimitives::make_report_memory_use_pm(mm, stbl), - flags); - - return ok; - } - bool SetupInterpreter2::register_facets() { scope log(XO_DEBUG(true)); - // VsmStqackFrame // +- VsmApplyFrame // +- VsmEvalArgsFrame @@ -177,6 +117,26 @@ namespace xo { return ok; } + bool + SetupInterpreter2::register_primitives(obj rcx, + InstallSink sink, + InstallFlags flags) + { + scope log(XO_DEBUG(true)); + + obj mm = rcx.allocator(); + StringTable * stbl = rcx.stringtable(); + + bool ok = true; + + ok = ok & (PrimitiveRegistry::install_aux + (sink, + VsmPrimitives::make_report_memory_use_pm(mm, stbl), + flags & InstallFlags::f_generalpurpose)); + + return ok; + } + } /*namespace scm*/ } /*namespace xo*/ From 19ff2eab00245e65eb91f1965860f2839613b310 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 20:19:57 -0500 Subject: [PATCH 092/131] xo-interpreter2: report_memory_use() -> report-memory-use(); --- src/interpreter2/VsmPrimitives.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/interpreter2/VsmPrimitives.cpp b/src/interpreter2/VsmPrimitives.cpp index e725c241..aebb5866 100644 --- a/src/interpreter2/VsmPrimitives.cpp +++ b/src/interpreter2/VsmPrimitives.cpp @@ -50,7 +50,7 @@ namespace xo { auto pm_ty = obj(DFunctionType::_make(mm, bool_ty)); return DPrimitive_gco_0::_make(mm, - "report_memory_use", + "report-memory-use", pm_ty, &xfer_report_memory_use); } From 8bc5f58259e5d2c329acfe8d860f902edffaa849 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 17 Mar 2026 12:26:58 -0400 Subject: [PATCH 093/131] xo-interpreter2: utest: match changed report-memory-use spelling --- utest/VirtualSchematikaMachine.test.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 9fb85ffc..3f5d145c 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -729,7 +729,7 @@ namespace xo { vsm.begin_interactive_session(); - span_type input = span_type::from_cstr("report_memory_use();"); + span_type input = span_type::from_cstr("report-memory-use();"); log && log(xtag("input", input)); From 3220cb1b5982ff27d8edf3336c4b869b586fab62 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Mar 2026 21:59:59 -0400 Subject: [PATCH 094/131] xo-reader2 stack: + ARuntimeContext.collector() access Collector API (if present) from runtime context --- include/xo/interpreter2/DVsmRcx.hpp | 2 ++ .../xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp | 3 +++ src/interpreter2/DVsmRcx.cpp | 8 ++++++++ src/interpreter2/IRuntimeContext_DVsmRcx.cpp | 6 ++++++ 4 files changed, 19 insertions(+) diff --git a/include/xo/interpreter2/DVsmRcx.hpp b/include/xo/interpreter2/DVsmRcx.hpp index 1f3a8f57..1ab7e773 100644 --- a/include/xo/interpreter2/DVsmRcx.hpp +++ b/include/xo/interpreter2/DVsmRcx.hpp @@ -22,12 +22,14 @@ namespace xo { public: using StringTable = xo::scm::StringTable; using AAllocator = xo::mm::AAllocator; + using ACollector = xo::mm::ACollector; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; public: DVsmRcx(VirtualSchematikaMachine * vsm); obj allocator() const noexcept; + obj collector() const noexcept; StringTable * stringtable() const noexcept; obj error_allocator() const noexcept; void visit_pools(const MemorySizeVisitor & visitor) const; diff --git a/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp b/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp index 1b4c1567..1eddf28c 100644 --- a/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp +++ b/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp @@ -40,6 +40,7 @@ namespace xo { /** @defgroup scm-runtimecontext-dvsmrcx-type-traits **/ ///@{ using AAllocator = xo::scm::ARuntimeContext::AAllocator; + using ACollector = xo::scm::ARuntimeContext::ACollector; using MemorySizeVisitor = xo::scm::ARuntimeContext::MemorySizeVisitor; using Copaque = xo::scm::ARuntimeContext::Copaque; using Opaque = xo::scm::ARuntimeContext::Opaque; @@ -49,6 +50,8 @@ namespace xo { // const methods /** default allocator to use for objects **/ static obj allocator(const DVsmRcx & self) noexcept; + /** collector facet for allocator. If non-null, same data pointer as allocator **/ + static obj collector(const DVsmRcx & self) noexcept; /** stringtable for unique symbols **/ static StringTable * stringtable(const DVsmRcx & self) noexcept; /** invoke visitor for each distinct memory pool **/ diff --git a/src/interpreter2/DVsmRcx.cpp b/src/interpreter2/DVsmRcx.cpp index b7ea4112..856f38e4 100644 --- a/src/interpreter2/DVsmRcx.cpp +++ b/src/interpreter2/DVsmRcx.cpp @@ -5,9 +5,11 @@ #include "DVsmRcx.hpp" #include "VirtualSchematikaMachine.hpp" +#include namespace xo { using xo::mm::AAllocator; + using xo::mm::ACollector; namespace scm { @@ -19,6 +21,12 @@ namespace xo { return vsm_->allocator(); } + obj + DVsmRcx::collector() const noexcept + { + return vsm_->allocator().try_to_facet(); + } + obj DVsmRcx::error_allocator() const noexcept { diff --git a/src/interpreter2/IRuntimeContext_DVsmRcx.cpp b/src/interpreter2/IRuntimeContext_DVsmRcx.cpp index e879d4ed..9b1a73d0 100644 --- a/src/interpreter2/IRuntimeContext_DVsmRcx.cpp +++ b/src/interpreter2/IRuntimeContext_DVsmRcx.cpp @@ -21,6 +21,12 @@ namespace xo { return self.allocator(); } + auto + IRuntimeContext_DVsmRcx::collector(const DVsmRcx & self) noexcept -> obj + { + return self.collector(); + } + auto IRuntimeContext_DVsmRcx::stringtable(const DVsmRcx & self) noexcept -> StringTable * { From 12d3b1a21ca15bff8f4ac4a502175fe4b114e571 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Mar 2026 22:12:38 -0400 Subject: [PATCH 095/131] xo-interpreter2: + xo-gc dep for primitives --- include/xo/interpreter2/VsmConfig.hpp | 6 ++++++ src/interpreter2/VirtualSchematikaMachine.cpp | 2 ++ src/interpreter2/init_interpreter2.cpp | 2 ++ 3 files changed, 10 insertions(+) diff --git a/include/xo/interpreter2/VsmConfig.hpp b/include/xo/interpreter2/VsmConfig.hpp index bfd6dbf6..166a63dd 100644 --- a/include/xo/interpreter2/VsmConfig.hpp +++ b/include/xo/interpreter2/VsmConfig.hpp @@ -31,6 +31,12 @@ namespace xo { return retval; } + VsmConfig with_x1_debug_flag(bool x) const { + VsmConfig retval = *this; + retval.x1_config_.debug_flag_ = x; + return retval; + } + /** true for interactive parser session; false for batch session **/ bool interactive_flag_ = true; diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 5633c7d0..37f24390 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -86,6 +86,8 @@ namespace xo { } this->global_env_ = reader_.global_env(); + + //this->_add_gc_roots(); } obj diff --git a/src/interpreter2/init_interpreter2.cpp b/src/interpreter2/init_interpreter2.cpp index 77b997d2..56630794 100644 --- a/src/interpreter2/init_interpreter2.cpp +++ b/src/interpreter2/init_interpreter2.cpp @@ -7,6 +7,7 @@ #include "SetupInterpreter2.hpp" #include +#include #include namespace xo { @@ -31,6 +32,7 @@ namespace xo { /* direct subsystem deps for xo-interpreter2/ */ retval ^= InitSubsys::require(); + retval ^= InitSubsys::require(); /* xo-interpreter2/'s own initialization code */ retval ^= Subsystem::provide("interpreter2", &init); From f0f17d2eaecad5f5a2c1cdd2638d7bbe3046c01d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Mar 2026 22:21:17 -0400 Subject: [PATCH 096/131] skrepl: enable VsmConfig debug --- src/skrepl/skreplxx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/skrepl/skreplxx.cpp b/src/skrepl/skreplxx.cpp index e3d5564e..86ab461a 100644 --- a/src/skrepl/skreplxx.cpp +++ b/src/skrepl/skreplxx.cpp @@ -88,7 +88,7 @@ namespace xo { AppConfig(const ReplConfig & repl_cfg = ReplConfig(), const ArenaConfig & app_arena_cfg = ArenaConfig().with_name("skreplxx").with_size(16 * 1024), - const VsmConfig & vsm_cfg = VsmConfig()) + const VsmConfig & vsm_cfg = VsmConfig().with_x1_debug_flag(true)) : repl_config_{repl_cfg}, app_arena_config_{app_arena_cfg}, vsm_config_{vsm_cfg} { //rdr_config_.reader_debug_flag_ = true; From 364f34cc8a8702e52a6f0e5cbd88d6a4e3b7d393 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 25 Mar 2026 18:00:36 -0400 Subject: [PATCH 097/131] xo-interpreter2 stack: scaffold for virtual root VSM [WIP] --- .../interpreter2/VirtualSchematikaMachine.hpp | 25 +++++++-- src/interpreter2/VirtualSchematikaMachine.cpp | 55 +++++++++++++++---- 2 files changed, 64 insertions(+), 16 deletions(-) diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index 382dbc5d..d39db5bc 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -8,9 +8,10 @@ #include "VsmConfig.hpp" #include "VsmInstr.hpp" #include "VsmFrame.hpp" -#include "DLocalEnv.hpp" -#include "DGlobalEnv.hpp" +#include "LocalEnv.hpp" +#include "GlobalEnv.hpp" #include +#include #include #include #include @@ -46,6 +47,7 @@ namespace xo { bool is_eval_error() const; const obj * value() const { return std::get_if>(&result_); } + obj & value_ref() { return std::get>(result_); } /** result of evaluating first expression encountered in input **/ std::variant, TokenizerError> result_; @@ -69,6 +71,7 @@ namespace xo { public: // will be DArenaVector> probably using Stack = void *; + using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; @@ -127,6 +130,18 @@ namespace xo { **/ bool execute_one(); + /** @defgroup scm-virtualschematikamachine-gcobject-facet gcobject facet **/ + ///@{ + + /** object size **/ + std::size_t shallow_size() const noexcept; + + /** forward gc-aware child pointers + **/ + std::size_t forward_children(obj gc) noexcept; + + ///@} + private: /** Require: * - expression in @ref expr_ @@ -281,18 +296,18 @@ namespace xo { /** environment pointer. Maintains bindings * for global variables. Obtained from reader **/ - DGlobalEnv * global_env_ = nullptr; + obj global_env_; /** environment pointer. Provides bindings * for surrounding lexical scope at this point * in execution **/ - DLocalEnv * local_env_ = nullptr; + obj local_env_; /** evaluated function to call **/ obj fn_; /** evaluated argument list **/ - DArray * args_; + obj args_; /** result register **/ VsmResult value_; diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/VirtualSchematikaMachine.cpp index 37f24390..5c0430e8 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/VirtualSchematikaMachine.cpp @@ -85,11 +85,20 @@ namespace xo { this->error_mm_.adopt(obj(arena)); } - this->global_env_ = reader_.global_env(); + this->global_env_ + = obj(reader_.global_env()); //this->_add_gc_roots(); } + VirtualSchematikaMachine * + VirtualSchematikaMachine::_make(obj mm, + const VsmConfig & config, + obj aux_mm) + { + xxx; + } + obj VirtualSchematikaMachine::allocator() const noexcept { @@ -308,7 +317,7 @@ namespace xo { auto def_expr = obj::from(expr_); - if (local_env_ == nullptr) { + if (local_env_) { // top-level define // .stack_ --+ @@ -411,7 +420,7 @@ namespace xo { DClosure * closure = DClosure::make(mm_.to_op(), lambda.data(), - local_env_); + local_env_.data()); this->value_ = VsmResult(obj(obj(closure))); @@ -623,7 +632,7 @@ namespace xo { DVsmApplyClosureFrame::make(mm_.to_op(), stack_, cont_, - local_env_)); + local_env_.data())); // push frame w/ saved vsm registers this->stack_ = frame; @@ -634,11 +643,11 @@ namespace xo { auto local_env = DLocalEnv::_make(mm_.to_op(), - local_env_, + local_env_.data(), lambda->local_symtab(), - args_); + args_.data()); - this->local_env_ = local_env; + this->local_env_ = obj(local_env); this->expr_ = lambda->body_expr(); this->pc_ = VsmInstr::c_eval; // cont_ already established @@ -649,7 +658,7 @@ namespace xo { { auto fn = fn_.to_facet(); - this->value_ = VsmResult(fn.apply_nocheck(rcx_.to_op(), args_)); + this->value_ = VsmResult(fn.apply_nocheck(rcx_.to_op(), args_.data())); this->pc_ = cont_; this->cont_ = VsmInstr::c_sentinel; } @@ -727,7 +736,7 @@ namespace xo { // corner case: function with 0 arguments this->fn_ = apply_frame->fn(); // = value; - this->args_ = apply_frame->args(); // empty + this->args_ = obj(apply_frame->args()); // empty this->stack_ = apply_frame->parent(); this->pc_ = VsmInstr::c_apply; @@ -765,7 +774,7 @@ namespace xo { // this->fn_ = apply_frame->fn(); - this->args_ = apply_frame->args(); + this->args_ = obj(apply_frame->args()); this->stack_ = apply_frame->parent(); this->pc_ = VsmInstr::c_apply; @@ -796,7 +805,7 @@ namespace xo { assert(frame); this->stack_ = frame->parent(); - this->local_env_ = frame->local_env(); + this->local_env_ = obj(frame->local_env()); this->pc_ = frame->cont(); this->cont_ = VsmInstr::c_sentinel; } @@ -881,6 +890,30 @@ namespace xo { } } + std::size_t + VirtualSchematikaMachine::shallow_size() const noexcept + { + return sizeof(VirtualSchematikaMachine); + } + + std::size_t + VirtualSchematikaMachine::forward_children(obj gc) noexcept + { + reader_.forward_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_); + if (value_.is_value()) { + gc.forward_inplace(&value_.value_ref()); + } + + return this->shallow_size(); + } + } /*namespace scm*/ } /*namespace xo*/ From 92bea14aa0b8f5ce75c42937de46bc7b8c0ef0ab Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 25 Mar 2026 19:31:59 -0400 Subject: [PATCH 098/131] xo-interpreter2 stack: VSM as AGCObject for virtual root --- CMakeLists.txt | 11 +- idl/IGCObject_DLocalEnv.json5 | 2 +- idl/IGCObject_DVirtualSchematikaMachine.json5 | 18 + include/xo/interpreter2/DVsmRcx.hpp | 6 +- .../interpreter2/VirtualSchematikaMachine.hpp | 316 +--------------- .../vsm/DVirtualSchematikaMachine.hpp | 340 ++++++++++++++++++ .../interpreter2/vsm/IGCObject_DLocalEnv.hpp | 67 ++++ .../IGCObject_DVirtualSchematikaMachine.hpp | 67 ++++ src/interpreter2/CMakeLists.txt | 6 +- ...hine.cpp => DVirtualSchematikaMachine.cpp} | 105 +++--- src/interpreter2/DVsmRcx.cpp | 2 +- .../{ => facet}/IGCObject_DLocalEnv.cpp | 0 .../IGCObject_DVirtualSchematikaMachine.cpp | 39 ++ src/skrepl/skreplxx.cpp | 20 +- utest/VirtualSchematikaMachine.test.cpp | 92 ++--- 15 files changed, 679 insertions(+), 412 deletions(-) create mode 100644 idl/IGCObject_DVirtualSchematikaMachine.json5 create mode 100644 include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp create mode 100644 include/xo/interpreter2/vsm/IGCObject_DLocalEnv.hpp create mode 100644 include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp rename src/interpreter2/{VirtualSchematikaMachine.cpp => DVirtualSchematikaMachine.cpp} (91%) rename src/interpreter2/{ => facet}/IGCObject_DLocalEnv.cpp (100%) create mode 100644 src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f325441b..d31bbd4c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -26,11 +26,19 @@ add_subdirectory(utest) # ---------------------------------------------------------------- +# only supporting forward_children(), for virtual root. +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-gcobject-virtualschematikamachine + FACET_PKG xo_alloc2 + INPUT idl/IGCObject_DVirtualSchematikaMachine.json5 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmdefcontframe FACET_PKG xo_alloc2 -# REPR VsmDefContFrame INPUT idl/IGCObject_DVsmDefContFrame.json5 ) @@ -38,7 +46,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmdefcontframe FACET_PKG xo_printable2 -# REPR VsmDefContFrame INPUT idl/IPrintable_DVsmDefContFrame.json5 ) diff --git a/idl/IGCObject_DLocalEnv.json5 b/idl/IGCObject_DLocalEnv.json5 index 82dd7ed0..a4a252a4 100644 --- a/idl/IGCObject_DLocalEnv.json5 +++ b/idl/IGCObject_DLocalEnv.json5 @@ -1,6 +1,6 @@ { mode: "implementation", - output_cpp_dir: "src/interpreter2", + output_cpp_dir: "src/interpreter2/facet", output_hpp_dir: "include/xo/interpreter2", output_impl_subdir: "env", includes: [ diff --git a/idl/IGCObject_DVirtualSchematikaMachine.json5 b/idl/IGCObject_DVirtualSchematikaMachine.json5 new file mode 100644 index 00000000..50275848 --- /dev/null +++ b/idl/IGCObject_DVirtualSchematikaMachine.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2/facet", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "vsm", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DVirtualSchematikaMachine", + using_doxygen: true, + repr: "DVirtualSchematikaMachine", + doc: [ "implement AGCObject for DVirtualSchematikaMachine" ], +} diff --git a/include/xo/interpreter2/DVsmRcx.hpp b/include/xo/interpreter2/DVsmRcx.hpp index 1ab7e773..a8c8c524 100644 --- a/include/xo/interpreter2/DVsmRcx.hpp +++ b/include/xo/interpreter2/DVsmRcx.hpp @@ -12,7 +12,7 @@ namespace xo { namespace scm { // see xo-interpreter/ VirtualSchematikaMachine.hpp - class VirtualSchematikaMachine; + class DVirtualSchematikaMachine; /** @brief Runtime context for schematika interpreter * @@ -26,7 +26,7 @@ namespace xo { using MemorySizeVisitor = xo::mm::MemorySizeVisitor; public: - DVsmRcx(VirtualSchematikaMachine * vsm); + DVsmRcx(DVirtualSchematikaMachine * vsm); obj allocator() const noexcept; obj collector() const noexcept; @@ -36,7 +36,7 @@ namespace xo { private: /** schematika interpreter **/ - VirtualSchematikaMachine * vsm_ = nullptr;; + DVirtualSchematikaMachine * vsm_ = nullptr;; }; } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/include/xo/interpreter2/VirtualSchematikaMachine.hpp index d39db5bc..ee16d1e7 100644 --- a/include/xo/interpreter2/VirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -1,321 +1,11 @@ /** @file VirtualSchematikaMachine.hpp * - * @author Roland Conybare, Jan 2026 + * @author Roland Conybeare, Mar 2026 **/ #pragma once -#include "VsmConfig.hpp" -#include "VsmInstr.hpp" -#include "VsmFrame.hpp" -#include "LocalEnv.hpp" -#include "GlobalEnv.hpp" -#include -#include -#include -#include -#include -#include -#include - -namespace xo { - namespace scm { -#ifdef OBSOLETE // see DVsmError - // TODO: move error to collected space? - // or special arena? - // - struct EvaluationError { - /** source location (in vsm implementation) at which error identified **/ - std::string_view src_function_; - /** error description (allocated from ErrorArena) **/ - std::string_view error_description_; - // TODO: info about location in schematika source - }; -#endif - - /** similar to @ref xo::scm::ReaderResult **/ - struct VsmResult { - using AGCObject = xo::mm::AGCObject; - using span_type = xo::mm::span; - - VsmResult() = default; - explicit VsmResult(obj value) : result_{value} {} - explicit VsmResult(TokenizerError err) : result_{err} {} - - bool is_value() const { return std::holds_alternative>(result_); } - bool is_tk_error() const { return std::holds_alternative(result_); } - bool is_eval_error() const; - - const obj * value() const { return std::get_if>(&result_); } - obj & value_ref() { return std::get>(result_); } - - /** result of evaluating first expression encountered in input **/ - std::variant, TokenizerError> result_; - }; - - /** vsm result + reamining span **/ - struct VsmResultExt : public VsmResult { - using span_type = VsmResult::span_type; - - VsmResultExt() = default; - VsmResultExt(const VsmResult & result, span_type rem) : VsmResult{result}, remaining_{rem} {} - - /** unconsumed portion of input **/ - VsmResult::span_type remaining_; - }; - - /** @class VirtualSchematikaMachine - * @brief virtual machine for schematika - **/ - class VirtualSchematikaMachine { - public: - // will be DArenaVector> probably - using Stack = void *; - using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; - using AGCObject = xo::mm::AGCObject; - using MemorySizeVisitor = xo::mm::MemorySizeVisitor; - using span_type = xo::mm::span; - - public: - /** @p config. configuration - * @p aux_mm. Allocator for miscellaneous dataN - * owned by this VSM. - **/ - VirtualSchematikaMachine(const VsmConfig & config, - obj aux_mm); - - /** non-trivial dtor because of @ref reader_ - * indirect dependency on DGlobalSymtab - **/ - ~VirtualSchematikaMachine() = default; - - /** allocator for schematika data **/ - obj allocator() const noexcept; - /** allocator for runtime errors **/ - obj error_allocator() const noexcept; - /** global unique-string table **/ - StringTable * stringtable() noexcept; - - /** true iff parser is at top-level -> does not contain - * state for a incomplete/partial expression - **/ - bool is_at_toplevel() const noexcept; - - /** visit vsm-owned memory pools; call visitor(info) for each **/ - void visit_pools(const MemorySizeVisitor & visitor) const; - - /** begin interactive session. **/ - void begin_interactive_session(); - /** begin batch session **/ - void begin_batch_session(); - - /** consume input @p input_cstr. - * Require: must first start interactive/batch session - **/ - VsmResultExt read_eval_print(span_type input_span, bool eof); - - /** evaluate expression @p expr - * Require: must first start interactive/batch session - **/ - VsmResult start_eval(obj expr); - - /** borrow calling thread to run indefinitely, - * until halt instruction - **/ - void run(); - - /** execute vsm instruction in @ref pc_. - * @retval instruction count. 1 unless pc_ is halt. - **/ - bool execute_one(); - - /** @defgroup scm-virtualschematikamachine-gcobject-facet gcobject facet **/ - ///@{ - - /** object size **/ - std::size_t shallow_size() const noexcept; - - /** forward gc-aware child pointers - **/ - std::size_t forward_children(obj gc) noexcept; - - ///@} - - private: - /** Require: - * - expression in @ref expr_ - **/ - void _do_eval_op(); - - /** evaluate a constant expression - * Require: - * - expression in @ref expr_ - **/ - void _do_eval_constant_op(); - - /** evaluate a define-expression - * Require: - * - expression in @ref expr_ - **/ - void _do_eval_define_op(); - - /** evaluate a lambda expression - * Require: - * - expression in @ref expr_ - **/ - void _do_eval_lambda_op(); - - /** evaluate variable expression (definition) - * Require: - * - expression in @ref expr_ - **/ - void _do_eval_variable_op(); - - /** evaluate a variable reference (use after definition) - * Require: - * - expression in @ref expr_ - **/ - void _do_eval_varref_op(); - - /** evaluate an apply expression - * Require: - * - expression in @ref expr_ - **/ - void _do_eval_apply_op(); - - /** evaluate an if-else expression - * Require: - * - expression in @ref expr_ - **/ - void _do_eval_if_else_op(); - - /** evaluate a sequence expression - * Require: - * - expression in @ref expr_ - **/ - void _do_eval_sequence_op(); - - /** apply a function to evaluated arguments **/ - void _do_apply_op(); - - /** evaluate arguments on behalf of a function call - * Require: - * - expression value in @ref value_ - * - stack: - * [0] VsmEvalArgsFrame - * [1] VsmApplyFrame - * ... - **/ - void _do_evalargs_op(); - - /** call closure @ref fn_ with arguments @ref args_ **/ - void _do_call_closure_op(); - /** call primitive @ref fn_ with arguments @ref args_ **/ - void _do_call_primitive_op(); - - /** perform assignment after evaluating - * the rhs of a define-expr - **/ - void _do_def_cont_op(); - - /** restore registers from stack frame - * (specifically: local_env_, stack_, cont_) - * after invoking a schematika closure - **/ - void _do_apply_cont_op(); - - /** proceed with if- or else- branch of an if-else expression - * after evaluating test condition - **/ - void _do_ifelse_cont_op(); - - /** loop continuation after evaluating element of a SequenceExpr **/ - void _do_seq_cont_op(); - - private: - /* - * Some registers are preserved by evaluation: - * stack_ - * cont_ - * local_env_ - * - * Other registers not preserved - * pc_ - * expr_ - * fn_ - * args_ - * value_ - */ - - /** configuration **/ - VsmConfig config_; - - /** allocator (likely DArena) for globals. - * For example DArenaHashMap in global symta. - **/ - obj aux_mm_; - - /** allocator (likely DX1Collector or similar) for - * expressions and values. Schemaatika reader will use this also - **/ - abox mm_; - - /** Sidecar allocator for error reporting. - * Separate to mitigate interference with @ref mm_ - * (separate memory so we can for example report - * an out-of-memory error). - * Likely DArena or similar - **/ - abox error_mm_; - - /** runtime context for this vsm. - * For example, provides allocator to primitives - **/ - abox rcx_; - - // consider separate allocator (which _may_ turn out to be the same) - // for VM stack. Only works for code that doesn't rely on fancy - // lexical scoping - - // consider separate allocator for reader (i.e. program code) - // and data (program execution) - - /** reader: text -> expression **/ - SchematikaReader reader_; - - /** program counter **/ - VsmInstr pc_ = VsmInstr::c_halt; - - /** stack pointer **/ - obj stack_; - - /** expression register **/ - obj expr_; - - /** environment pointer. Maintains bindings - * for global variables. Obtained from reader - **/ - obj global_env_; - - /** environment pointer. Provides bindings - * for surrounding lexical scope at this point - * in execution - **/ - obj local_env_; - - /** evaluated function to call **/ - obj fn_; - /** evaluated argument list **/ - obj args_; - - /** result register **/ - VsmResult value_; - - /** continuation register **/ - VsmInstr cont_ = VsmInstr::c_halt; - }; - } /*namespace scm*/ -} /*namespace xo*/ +#include "vsm/DVirtualSchematikaMachine.hpp" +#include "vsm/IGCObject_DVirtualSchematikaMachine.hpp" /* end VirtualSchematikaMachine.hpp */ diff --git a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp new file mode 100644 index 00000000..0e6eb8f0 --- /dev/null +++ b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp @@ -0,0 +1,340 @@ +/** @file VirtualSchematikaMachine.hpp + * + * @author Roland Conybare, Jan 2026 + **/ + +#pragma once + +#include "VsmConfig.hpp" +#include "VsmInstr.hpp" +#include "VsmFrame.hpp" +#include "LocalEnv.hpp" +#include "GlobalEnv.hpp" +#include +#include +#include +#include +#include +#include +#include + +namespace xo { + namespace scm { +#ifdef OBSOLETE // see DVsmError + // TODO: move error to collected space? + // or special arena? + // + struct EvaluationError { + /** source location (in vsm implementation) at which error identified **/ + std::string_view src_function_; + /** error description (allocated from ErrorArena) **/ + std::string_view error_description_; + // TODO: info about location in schematika source + }; +#endif + + /** similar to @ref xo::scm::ReaderResult **/ + struct VsmResult { + using AGCObject = xo::mm::AGCObject; + using span_type = xo::mm::span; + + VsmResult() = default; + explicit VsmResult(obj value) : result_{value} {} + explicit VsmResult(TokenizerError err) : result_{err} {} + + bool is_value() const { return std::holds_alternative>(result_); } + bool is_tk_error() const { return std::holds_alternative(result_); } + bool is_eval_error() const; + + const obj * value() const { return std::get_if>(&result_); } + obj & value_ref() { return std::get>(result_); } + + /** result of evaluating first expression encountered in input **/ + std::variant, TokenizerError> result_; + }; + + /** vsm result + reamining span **/ + struct VsmResultExt : public VsmResult { + using span_type = VsmResult::span_type; + + VsmResultExt() = default; + VsmResultExt(const VsmResult & result, span_type rem) : VsmResult{result}, remaining_{rem} {} + + /** unconsumed portion of input **/ + VsmResult::span_type remaining_; + }; + + /** @class VirtualSchematikaMachine + * @brief virtual machine for schematika + **/ + class DVirtualSchematikaMachine { + public: + // will be DArenaVector> probably + using Stack = void *; + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; + using MemorySizeVisitor = xo::mm::MemorySizeVisitor; + using span_type = xo::mm::span; + + public: + /** @p config. configuration + * @p aux_mm. Allocator for miscellaneous dataN + * owned by this VSM. + **/ + DVirtualSchematikaMachine(const VsmConfig & config, + obj aux_mm); + + /** non-trivial dtor because of @ref reader_ + * indirect dependency on DGlobalSymtab + **/ + ~DVirtualSchematikaMachine() = default; + + /** create instance using memory from @p mm. + * with configuration @p config. + * Machine will use @p aux_mm for auxiliary (non-GC, non-arena) + * memory. + **/ + static DVirtualSchematikaMachine * _make(obj mm, + const VsmConfig & config, + obj aux_mm); + + /** like _make(), but create fop **/ + static obj make(obj mm, + const VsmConfig & config, + obj aux_mm); + + /** allocator for schematika data **/ + obj allocator() const noexcept; + /** allocator for runtime errors **/ + obj error_allocator() const noexcept; + /** global unique-string table **/ + StringTable * stringtable() noexcept; + + /** true iff parser is at top-level -> does not contain + * state for a incomplete/partial expression + **/ + bool is_at_toplevel() const noexcept; + + /** visit vsm-owned memory pools; call visitor(info) for each **/ + void visit_pools(const MemorySizeVisitor & visitor) const; + + /** begin interactive session. **/ + void begin_interactive_session(); + /** begin batch session **/ + void begin_batch_session(); + + /** consume input @p input_cstr. + * Require: must first start interactive/batch session + **/ + VsmResultExt read_eval_print(span_type input_span, bool eof); + + /** evaluate expression @p expr + * Require: must first start interactive/batch session + **/ + VsmResult start_eval(obj expr); + + /** borrow calling thread to run indefinitely, + * until halt instruction + **/ + void run(); + + /** execute vsm instruction in @ref pc_. + * @retval instruction count. 1 unless pc_ is halt. + **/ + bool execute_one(); + + /** @defgroup scm-virtualschematikamachine-gcobject-facet gcobject facet **/ + ///@{ + + /** object size. Not implemented. Only intending to support VSM as virtual root **/ + std::size_t shallow_size() const noexcept; + + /** shallow copy during gc cycle. Not implemented! Only intending to support + * VSM as virtual root + **/ + DVirtualSchematikaMachine * shallow_copy(obj mm) const noexcept; + + /** forward gc-aware child pointers + **/ + std::size_t forward_children(obj gc) noexcept; + + ///@} + + private: + /** Require: + * - expression in @ref expr_ + **/ + void _do_eval_op(); + + /** evaluate a constant expression + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_constant_op(); + + /** evaluate a define-expression + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_define_op(); + + /** evaluate a lambda expression + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_lambda_op(); + + /** evaluate variable expression (definition) + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_variable_op(); + + /** evaluate a variable reference (use after definition) + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_varref_op(); + + /** evaluate an apply expression + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_apply_op(); + + /** evaluate an if-else expression + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_if_else_op(); + + /** evaluate a sequence expression + * Require: + * - expression in @ref expr_ + **/ + void _do_eval_sequence_op(); + + /** apply a function to evaluated arguments **/ + void _do_apply_op(); + + /** evaluate arguments on behalf of a function call + * Require: + * - expression value in @ref value_ + * - stack: + * [0] VsmEvalArgsFrame + * [1] VsmApplyFrame + * ... + **/ + void _do_evalargs_op(); + + /** call closure @ref fn_ with arguments @ref args_ **/ + void _do_call_closure_op(); + /** call primitive @ref fn_ with arguments @ref args_ **/ + void _do_call_primitive_op(); + + /** perform assignment after evaluating + * the rhs of a define-expr + **/ + void _do_def_cont_op(); + + /** restore registers from stack frame + * (specifically: local_env_, stack_, cont_) + * after invoking a schematika closure + **/ + void _do_apply_cont_op(); + + /** proceed with if- or else- branch of an if-else expression + * after evaluating test condition + **/ + void _do_ifelse_cont_op(); + + /** loop continuation after evaluating element of a SequenceExpr **/ + void _do_seq_cont_op(); + + private: + /* + * Some registers are preserved by evaluation: + * stack_ + * cont_ + * local_env_ + * + * Other registers not preserved + * pc_ + * expr_ + * fn_ + * args_ + * value_ + */ + + /** configuration **/ + VsmConfig config_; + + /** allocator (likely DArena) for globals. + * For example DArenaHashMap in global symta. + **/ + obj aux_mm_; + + /** allocator (likely DX1Collector or similar) for + * expressions and values. Schemaatika reader will use this also + **/ + abox mm_; + + /** Sidecar allocator for error reporting. + * Separate to mitigate interference with @ref mm_ + * (separate memory so we can for example report + * an out-of-memory error). + * Likely DArena or similar + **/ + abox error_mm_; + + /** runtime context for this vsm. + * For example, provides allocator to primitives + **/ + abox rcx_; + + // consider separate allocator (which _may_ turn out to be the same) + // for VM stack. Only works for code that doesn't rely on fancy + // lexical scoping + + // consider separate allocator for reader (i.e. program code) + // and data (program execution) + + /** reader: text -> expression **/ + SchematikaReader reader_; + + /** program counter **/ + VsmInstr pc_ = VsmInstr::c_halt; + + /** stack pointer **/ + obj stack_; + + /** expression register **/ + obj expr_; + + /** environment pointer. Maintains bindings + * for global variables. Obtained from reader + **/ + obj global_env_; + + /** environment pointer. Provides bindings + * for surrounding lexical scope at this point + * in execution + **/ + obj local_env_; + + /** evaluated function to call **/ + obj fn_; + /** evaluated argument list **/ + obj args_; + + /** result register **/ + VsmResult value_; + + /** continuation register **/ + VsmInstr cont_ = VsmInstr::c_halt; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVirtualSchematikaMachine.hpp */ diff --git a/include/xo/interpreter2/vsm/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/vsm/IGCObject_DLocalEnv.hpp new file mode 100644 index 00000000..48b624d6 --- /dev/null +++ b/include/xo/interpreter2/vsm/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_DVirtualSchematikaMachine.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVirtualSchematikaMachine.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/vsm/IGCObject_DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp new file mode 100644 index 00000000..a9f61740 --- /dev/null +++ b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DVirtualSchematikaMachine.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVirtualSchematikaMachine.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVirtualSchematikaMachine.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DVirtualSchematikaMachine.hpp" + +namespace xo { namespace scm { class IGCObject_DVirtualSchematikaMachine; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DVirtualSchematikaMachine + **/ + class IGCObject_DVirtualSchematikaMachine { + public: + /** @defgroup scm-gcobject-dvirtualschematikamachine-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-dvirtualschematikamachine-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DVirtualSchematikaMachine & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DVirtualSchematikaMachine & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DVirtualSchematikaMachine & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/interpreter2/CMakeLists.txt b/src/interpreter2/CMakeLists.txt index fd6953dd..5f40b44f 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -5,9 +5,11 @@ set(SELF_SRCS init_interpreter2.cpp SetupInterpreter2.cpp - VirtualSchematikaMachine.cpp VsmPrimitives.cpp + DVirtualSchematikaMachine.cpp + facet/IGCObject_DVirtualSchematikaMachine.cpp + DVsmDefContFrame.cpp IGCObject_DVsmDefContFrame.cpp IPrintable_DVsmDefContFrame.cpp @@ -37,7 +39,7 @@ set(SELF_SRCS IPrintable_DClosure.cpp DLocalEnv.cpp - IGCObject_DLocalEnv.cpp + facet/IGCObject_DLocalEnv.cpp IPrintable_DLocalEnv.cpp DVsmRcx.cpp diff --git a/src/interpreter2/VirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp similarity index 91% rename from src/interpreter2/VirtualSchematikaMachine.cpp rename to src/interpreter2/DVirtualSchematikaMachine.cpp index 5c0430e8..788a16a4 100644 --- a/src/interpreter2/VirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -70,7 +70,7 @@ namespace xo { // NOTE: using heap here for {DX1Collector, DArena, DVsmRcx} instances // (though DX1Collector allocations will be from explictly mmap'd memory) // - VirtualSchematikaMachine::VirtualSchematikaMachine(const VsmConfig & config, + DVirtualSchematikaMachine::DVirtualSchematikaMachine(const VsmConfig & config, obj aux_mm) : config_{config}, aux_mm_{aux_mm}, @@ -91,40 +91,51 @@ namespace xo { //this->_add_gc_roots(); } - VirtualSchematikaMachine * - VirtualSchematikaMachine::_make(obj mm, + DVirtualSchematikaMachine * + DVirtualSchematikaMachine::_make(obj mm, const VsmConfig & config, obj aux_mm) { - xxx; + void * mem = mm.alloc_for(); + + return new (mem) DVirtualSchematikaMachine(config, aux_mm); + } + + obj + DVirtualSchematikaMachine::make(obj mm, + const VsmConfig & config, + obj aux_mm) + { + return obj( + _make(mm, config, aux_mm)); } obj - VirtualSchematikaMachine::allocator() const noexcept + DVirtualSchematikaMachine::allocator() const noexcept { return mm_.to_op(); } obj - VirtualSchematikaMachine::error_allocator() const noexcept + DVirtualSchematikaMachine::error_allocator() const noexcept { return error_mm_.to_op(); } StringTable * - VirtualSchematikaMachine::stringtable() noexcept + DVirtualSchematikaMachine::stringtable() noexcept { return reader_.stringtable(); } bool - VirtualSchematikaMachine::is_at_toplevel() const noexcept + DVirtualSchematikaMachine::is_at_toplevel() const noexcept { return reader_.is_at_toplevel(); } void - VirtualSchematikaMachine::visit_pools(const MemorySizeVisitor & visitor) const + DVirtualSchematikaMachine::visit_pools(const MemorySizeVisitor & visitor) const { aux_mm_.visit_pools(visitor); mm_.visit_pools(visitor); @@ -133,19 +144,19 @@ namespace xo { } void - VirtualSchematikaMachine::begin_interactive_session() + DVirtualSchematikaMachine::begin_interactive_session() { reader_.begin_interactive_session(); } void - VirtualSchematikaMachine::begin_batch_session() + DVirtualSchematikaMachine::begin_batch_session() { reader_.begin_batch_session(); } VsmResultExt - VirtualSchematikaMachine::read_eval_print(span_type input, bool eof) + DVirtualSchematikaMachine::read_eval_print(span_type input, bool eof) { if (input.empty()) { return VsmResultExt(); @@ -188,7 +199,7 @@ namespace xo { } VsmResult - VirtualSchematikaMachine::start_eval(obj expr) + DVirtualSchematikaMachine::start_eval(obj expr) { this->pc_ = VsmInstr::c_eval; this->expr_ = expr; @@ -201,14 +212,14 @@ namespace xo { } void - VirtualSchematikaMachine::run() + DVirtualSchematikaMachine::run() { while (this->execute_one()) ; } bool - VirtualSchematikaMachine::execute_one() + DVirtualSchematikaMachine::execute_one() { scope log(XO_DEBUG(config_.debug_flag_)); @@ -264,7 +275,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_eval_op() + DVirtualSchematikaMachine::_do_eval_op() { switch(expr_.extype()) { case exprtype::invalid: @@ -298,7 +309,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_eval_constant_op() + DVirtualSchematikaMachine::_do_eval_constant_op() { auto expr = obj::from(expr_); @@ -310,7 +321,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_eval_define_op() + DVirtualSchematikaMachine::_do_eval_define_op() { scope log(XO_DEBUG(true)); @@ -318,6 +329,11 @@ namespace xo { = obj::from(expr_); if (local_env_) { + // nested defines implemented by rewriting, + // so this branch should be unreachable + + assert(false); + } else { // top-level define // .stack_ --+ @@ -349,16 +365,11 @@ namespace xo { this->expr_ = def_expr->rhs(); this->pc_ = VsmInstr::c_eval; this->cont_ = VsmInstr::c_def_cont; - } else { - // nested defines implemented by rewriting, - // so this branch should be unreachable - - assert(false); } } void - VirtualSchematikaMachine::_do_def_cont_op() + DVirtualSchematikaMachine::_do_def_cont_op() { // see DVsmDefContFrame @@ -385,7 +396,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_eval_lambda_op() + DVirtualSchematikaMachine::_do_eval_lambda_op() { // assuming bump allocator // @@ -430,14 +441,14 @@ namespace xo { } void - VirtualSchematikaMachine::_do_eval_variable_op() + DVirtualSchematikaMachine::_do_eval_variable_op() { // not implemented assert(false); } void - VirtualSchematikaMachine::_do_eval_varref_op() + DVirtualSchematikaMachine::_do_eval_varref_op() { auto var = obj::from(expr_); @@ -477,7 +488,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_eval_apply_op() + DVirtualSchematikaMachine::_do_eval_apply_op() { // ApplyExpr in expr_ register @@ -527,7 +538,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_eval_if_else_op() + DVirtualSchematikaMachine::_do_eval_if_else_op() { // control: // self -> eval(test) -> ifelse_cont -> eval(when_true) @@ -546,7 +557,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_eval_sequence_op() + DVirtualSchematikaMachine::_do_eval_sequence_op() { // stack: // @@ -587,7 +598,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_apply_op() + DVirtualSchematikaMachine::_do_apply_op() { // rcx_ : runtime context // fn_ : function to call @@ -607,7 +618,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_call_closure_op() + DVirtualSchematikaMachine::_do_call_closure_op() { // We need to preserve registers while evaluating // lambda body @@ -654,7 +665,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_call_primitive_op() + DVirtualSchematikaMachine::_do_call_primitive_op() { auto fn = fn_.to_facet(); @@ -664,7 +675,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_evalargs_op() + DVirtualSchematikaMachine::_do_evalargs_op() { scope log(XO_DEBUG(false)); @@ -796,7 +807,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_apply_cont_op() + DVirtualSchematikaMachine::_do_apply_cont_op() { // see DVsmApplyClosureFrame @@ -811,7 +822,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_ifelse_cont_op() + DVirtualSchematikaMachine::_do_ifelse_cont_op() { // pre: result of evaluating test condition in value_ register @@ -856,7 +867,7 @@ namespace xo { } void - VirtualSchematikaMachine::_do_seq_cont_op() + DVirtualSchematikaMachine::_do_seq_cont_op() { auto frame = obj::from(stack_); @@ -891,13 +902,25 @@ namespace xo { } std::size_t - VirtualSchematikaMachine::shallow_size() const noexcept + DVirtualSchematikaMachine::shallow_size() const noexcept { - return sizeof(VirtualSchematikaMachine); + return sizeof(DVirtualSchematikaMachine); + } + + DVirtualSchematikaMachine * + DVirtualSchematikaMachine::shallow_copy(obj mm) const noexcept + { + (void)mm; + + /** not copyable (because SchematikaReader isn't) **/ + + assert(false); + + return nullptr; } std::size_t - VirtualSchematikaMachine::forward_children(obj gc) noexcept + DVirtualSchematikaMachine::forward_children(obj gc) noexcept { reader_.forward_children(gc); @@ -917,4 +940,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end VirtualSchematikaMachine.cpp */ +/* end DVirtualSchematikaMachine.cpp */ diff --git a/src/interpreter2/DVsmRcx.cpp b/src/interpreter2/DVsmRcx.cpp index 856f38e4..c083d2c5 100644 --- a/src/interpreter2/DVsmRcx.cpp +++ b/src/interpreter2/DVsmRcx.cpp @@ -13,7 +13,7 @@ namespace xo { namespace scm { - DVsmRcx::DVsmRcx(VirtualSchematikaMachine * vsm) : vsm_{vsm} {} + DVsmRcx::DVsmRcx(DVirtualSchematikaMachine * vsm) : vsm_{vsm} {} obj DVsmRcx::allocator() const noexcept diff --git a/src/interpreter2/IGCObject_DLocalEnv.cpp b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp similarity index 100% rename from src/interpreter2/IGCObject_DLocalEnv.cpp rename to src/interpreter2/facet/IGCObject_DLocalEnv.cpp diff --git a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp new file mode 100644 index 00000000..557990f8 --- /dev/null +++ b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DVirtualSchematikaMachine.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVirtualSchematikaMachine.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVirtualSchematikaMachine.json5] +**/ + +#include "vsm/IGCObject_DVirtualSchematikaMachine.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DVirtualSchematikaMachine::shallow_size(const DVirtualSchematikaMachine & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DVirtualSchematikaMachine::shallow_copy(const DVirtualSchematikaMachine & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DVirtualSchematikaMachine::forward_children(DVirtualSchematikaMachine & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVirtualSchematikaMachine.cpp */ diff --git a/src/skrepl/skreplxx.cpp b/src/skrepl/skreplxx.cpp index 86ab461a..8e65c299 100644 --- a/src/skrepl/skreplxx.cpp +++ b/src/skrepl/skreplxx.cpp @@ -14,7 +14,7 @@ #endif namespace xo { - using xo::scm::VirtualSchematikaMachine; + using xo::scm::DVirtualSchematikaMachine; using xo::scm::VsmResultExt; using xo::mm::AAllocator; using xo::mm::ArenaConfig; @@ -108,17 +108,17 @@ namespace xo { //using AAllocator = xo::mm::AAllocator; //using DX1Collector = xo::mm::DX1Collector; //using X1CollectorConfig = xo::mm::X1CollectorConfig; + using AGCObject = xo::mm::AGCObject; //using DArena = xo::mm::DArena; //using ArenaConfig = xo::mm::ArenaConfig; using VsmConfig = xo::scm::VsmConfig; using Replxx = replxx::Replxx; - using span_type = VirtualSchematikaMachine::span_type; + using span_type = DVirtualSchematikaMachine::span_type; App(const AppConfig & cfg = AppConfig()) : repl_config_{cfg.repl_config_}, app_arena_{cfg.app_arena_config_}, vsm_config_{cfg.vsm_config_} - //vsm_{cfg.vsm_config_, obj(&app_arena_)} { this->interactive_ = isatty(STDIN_FILENO); @@ -136,6 +136,7 @@ namespace xo { void _start(); void _repl(); bool _read_eval_print(span_type * p_input, bool eof); + void _stop(); private: InitEvidence init_evidence_ = 0; @@ -151,7 +152,7 @@ namespace xo { DArena app_arena_; /** schematika virtual machine **/ VsmConfig vsm_config_; - std::unique_ptr vsm_; + abox vsm_; }; void @@ -173,8 +174,9 @@ namespace xo { Subsystem::initialize_all(); - vsm_.reset(new VirtualSchematikaMachine(vsm_config_, - obj(&app_arena_))); + vsm_.adopt(DVirtualSchematikaMachine::make(obj(&app_arena_), + vsm_config_, + obj(&app_arena_))); } void @@ -231,6 +233,12 @@ namespace xo { return !res.is_tk_error() && !res.is_eval_error(); } + void + App::_stop() + { + vsm_._drop(); + } + } /*namespace xo*/ int diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index 3f5d145c..e6732996 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -14,13 +14,14 @@ #include #include #include +#include #include #include #include namespace xo { - using xo::scm::VirtualSchematikaMachine; + using xo::scm::DVirtualSchematikaMachine; using xo::scm::VsmConfig; using xo::scm::VsmResultExt; using xo::scm::DClosure; @@ -39,7 +40,7 @@ namespace xo { using xo::mm::ArenaConfig; using xo::facet::FacetRegistry; using xo::facet::TypeRegistry; - using span_type = xo::scm::VirtualSchematikaMachine::span_type; + using span_type = xo::scm::DVirtualSchematikaMachine::span_type; using Catch::Matchers::WithinAbs; using std::cout; @@ -63,9 +64,14 @@ namespace xo { explicit VsmFixture(const std::string & testname, bool debug_flag, const VsmConfig & cfg = VsmConfig()) - : aux_mm_{testname}, - vsm_{cfg.with_debug_flag(debug_flag), aux_mm_.to_op()} - {} + : aux_mm_{testname} + { + vsm_.adopt(DVirtualSchematikaMachine::make(aux_mm_.to_op(), + cfg.with_debug_flag(debug_flag), + aux_mm_.to_op())); + } + + ~VsmFixture() {} bool log_memory_layout(scope * p_log) { auto visitor = [p_log](const MemorySizeInfo & info) { @@ -79,13 +85,13 @@ namespace xo { aux_mm_.arena_.visit_pools(visitor); TypeRegistry::instance().visit_pools(visitor); FacetRegistry::instance().visit_pools(visitor); - vsm_.visit_pools(visitor); + vsm_->visit_pools(visitor); return true; } ArenaShim aux_mm_; - VirtualSchematikaMachine vsm_; + abox vsm_; }; TEST_CASE("VirtualSchematikaMachine-ctor", "[interpreter2][VSM]") @@ -113,8 +119,8 @@ namespace xo { bool eof_flag = false; - vsm.begin_interactive_session(); - VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("3.141592635;"), eof_flag); + vsm->begin_interactive_session(); + VsmResultExt res = vsm->read_eval_print(span_type::from_cstr("3.141592635;"), eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -143,8 +149,8 @@ namespace xo { bool eof_flag = false; - vsm.begin_interactive_session(); - VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("1011;"), eof_flag); + vsm->begin_interactive_session(); + VsmResultExt res = vsm->read_eval_print(span_type::from_cstr("1011;"), eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -174,8 +180,8 @@ namespace xo { bool eof_flag = false; - vsm.begin_interactive_session(); - VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("3.14159265 * 0.5;"), eof_flag); + vsm->begin_interactive_session(); + VsmResultExt res = vsm->read_eval_print(span_type::from_cstr("3.14159265 * 0.5;"), eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -205,8 +211,8 @@ namespace xo { bool eof_flag = false; - vsm.begin_interactive_session(); - VsmResultExt res = vsm.read_eval_print(span_type::from_cstr("3.14159265 / 0.5;"), eof_flag); + vsm->begin_interactive_session(); + VsmResultExt res = vsm->read_eval_print(span_type::from_cstr("3.14159265 / 0.5;"), eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -236,10 +242,10 @@ namespace xo { bool eof_flag = false; - vsm.begin_interactive_session(); + vsm->begin_interactive_session(); VsmResultExt res - = vsm.read_eval_print(span_type::from_cstr("123 == 123;"), - eof_flag); + = vsm->read_eval_print(span_type::from_cstr("123 == 123;"), + eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -269,10 +275,10 @@ namespace xo { bool eof_flag = false; - vsm.begin_interactive_session(); + vsm->begin_interactive_session(); VsmResultExt res - = vsm.read_eval_print(span_type::from_cstr("if 123 == 123 then \"equal\" else \"notequal\";"), - eof_flag); + = vsm->read_eval_print(span_type::from_cstr("if 123 == 123 then \"equal\" else \"notequal\";"), + eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -302,9 +308,9 @@ namespace xo { bool eof_flag = false; - vsm.begin_interactive_session(); + vsm->begin_interactive_session(); VsmResultExt res - = vsm.read_eval_print(span_type::from_cstr("lambda (x : i64) -> i64 { x * x; }"), + = vsm->read_eval_print(span_type::from_cstr("lambda (x : i64) -> i64 { x * x; }"), eof_flag); REQUIRE(res.is_value()); @@ -335,9 +341,9 @@ namespace xo { bool eof_flag = false; - vsm.begin_interactive_session(); + vsm->begin_interactive_session(); VsmResultExt res - = vsm.read_eval_print(span_type::from_cstr + = vsm->read_eval_print(span_type::from_cstr ("(lambda (x : i64, y : i64) { x * y; })(13, 15);"), eof_flag); @@ -374,9 +380,9 @@ namespace xo { bool eof_flag = false; - vsm.begin_interactive_session(); + vsm->begin_interactive_session(); VsmResultExt res - = vsm.read_eval_print(span_type::from_cstr("def foo = 3.14159;"), + = vsm->read_eval_print(span_type::from_cstr("def foo = 3.14159;"), eof_flag); REQUIRE(res.is_value()); @@ -413,7 +419,7 @@ namespace xo { bool eof_flag = false; - vsm.begin_interactive_session(); + vsm->begin_interactive_session(); span_type input = span_type::from_cstr("def foo = 3.14159; foo;"); @@ -421,7 +427,7 @@ namespace xo { log && log(xtag("input", input)); VsmResultExt res - = vsm.read_eval_print(input, eof_flag); + = vsm->read_eval_print(input, eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -464,7 +470,7 @@ namespace xo { bool eof_flag = true; - vsm.begin_interactive_session(); + vsm->begin_interactive_session(); span_type input = span_type::from_cstr("def fact = lambda (n) { if (n == 0) then 1 else n * fact(n - 1) };"); @@ -472,7 +478,7 @@ namespace xo { log && log(xtag("input", input)); VsmResultExt res - = vsm.read_eval_print(input, eof_flag); + = vsm->read_eval_print(input, eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -506,7 +512,7 @@ namespace xo { bool eof_flag = true; - vsm.begin_interactive_session(); + vsm->begin_interactive_session(); span_type input = span_type::from_cstr("def n = 4; if (n == 4) then n * 3 else n * 5;"); @@ -514,7 +520,7 @@ namespace xo { log && log(xtag("input", input)); VsmResultExt res - = vsm.read_eval_print(input, eof_flag); + = vsm->read_eval_print(input, eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -553,7 +559,7 @@ namespace xo { bool eof_flag = true; - vsm.begin_interactive_session(); + vsm->begin_interactive_session(); span_type input = span_type::from_cstr("def fact = lambda (n) { if (n == 0) then 1 else n * fact(n - 1) }; fact(4);"); @@ -561,7 +567,7 @@ namespace xo { log && log(xtag("input", input)); VsmResultExt res - = vsm.read_eval_print(input, eof_flag); + = vsm->read_eval_print(input, eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -601,14 +607,14 @@ namespace xo { bool eof_flag = false; - vsm.begin_interactive_session(); + vsm->begin_interactive_session(); span_type input = span_type::from_cstr("#q{ 4.5 };"); log && log(xtag("input", input)); VsmResultExt res - = vsm.read_eval_print(input, eof_flag); + = vsm->read_eval_print(input, eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -639,14 +645,14 @@ namespace xo { bool eof_flag = true; - vsm.begin_interactive_session(); + vsm->begin_interactive_session(); span_type input = span_type::from_cstr("#q{ (4.5 7.2) };"); log && log(xtag("input", input)); VsmResultExt res - = vsm.read_eval_print(input, eof_flag); + = vsm->read_eval_print(input, eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -683,14 +689,14 @@ namespace xo { bool eof_flag = true; - vsm.begin_interactive_session(); + vsm->begin_interactive_session(); span_type input = span_type::from_cstr("#q{ [4.5 7.2] };"); log && log(xtag("input", input)); VsmResultExt res - = vsm.read_eval_print(input, eof_flag); + = vsm->read_eval_print(input, eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); @@ -727,14 +733,14 @@ namespace xo { bool eof_flag = true; - vsm.begin_interactive_session(); + vsm->begin_interactive_session(); span_type input = span_type::from_cstr("report-memory-use();"); log && log(xtag("input", input)); VsmResultExt res - = vsm.read_eval_print(input, eof_flag); + = vsm->read_eval_print(input, eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); From fe752bc6d31d73d11cb2fd0a5a7363aea2d5e1ba Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 25 Mar 2026 20:06:40 -0400 Subject: [PATCH 099/131] xo-interpreter2: virtual root for VSM itself --- src/interpreter2/DVirtualSchematikaMachine.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/interpreter2/DVirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp index 788a16a4..52cdbf78 100644 --- a/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -47,6 +47,7 @@ namespace xo { using xo::mm::AGCObject; using xo::mm::MemorySizeInfo; using xo::mm::AAllocator; + using xo::mm::ACollector; using xo::mm::DX1Collector; using xo::mm::DArena; using xo::facet::FacetRegistry; @@ -71,8 +72,9 @@ namespace xo { // (though DX1Collector allocations will be from explictly mmap'd memory) // DVirtualSchematikaMachine::DVirtualSchematikaMachine(const VsmConfig & config, - obj aux_mm) + obj aux_mm) : config_{config}, + self_vroot_{obj(this)}, aux_mm_{aux_mm}, mm_(abox::make(aux_mm_, config.x1_config_)), rcx_(abox::make(aux_mm_, this)), @@ -88,7 +90,13 @@ namespace xo { this->global_env_ = obj(reader_.global_env()); - //this->_add_gc_roots(); + // TODO: + // annoying to have to create self_vroot_ to appease + // add_gc_root_poly() signature. + // In practice gc won't modify the pointer + // (instead traverses it to find +update children) + // + mm_.to_op().to_facet().add_gc_root_poly(&self_vroot_); } DVirtualSchematikaMachine * From 729348799f83bc804ea00c63445a9852113c6339 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 25 Mar 2026 20:15:55 -0400 Subject: [PATCH 100/131] xo-interpreter2: missed self_vroot_ member of VSM --- include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp index 0e6eb8f0..41b9ad66 100644 --- a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp @@ -270,6 +270,13 @@ namespace xo { /** configuration **/ VsmConfig config_; + /** virtual gc root. + * Arranges for gc to traverse+forward pointers exiting VSM. + * It won't (and can't) copy/move the VSM itself, since alloc'd + * outside gc. + **/ + obj self_vroot_; + /** allocator (likely DArena) for globals. * For example DArenaHashMap in global symta. **/ From 459abd4925a4a761fa8285fcd093beb0bffc8fb8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 25 Mar 2026 21:12:50 -0400 Subject: [PATCH 101/131] xo-interpreter2: skrepl: increase aux arena size 16k not sufficient on osx (with VirtualSchematikaMachine alloc'd). Increase to 32k --- src/skrepl/skreplxx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/skrepl/skreplxx.cpp b/src/skrepl/skreplxx.cpp index 8e65c299..bb7fc2e5 100644 --- a/src/skrepl/skreplxx.cpp +++ b/src/skrepl/skreplxx.cpp @@ -87,7 +87,7 @@ namespace xo { //using ArenaConfig = xo::mm::ArenaConfig; AppConfig(const ReplConfig & repl_cfg = ReplConfig(), - const ArenaConfig & app_arena_cfg = ArenaConfig().with_name("skreplxx").with_size(16 * 1024), + const ArenaConfig & app_arena_cfg = ArenaConfig().with_name("skreplxx").with_size(32 * 1024), const VsmConfig & vsm_cfg = VsmConfig().with_x1_debug_flag(true)) : repl_config_{repl_cfg}, app_arena_config_{app_arena_cfg}, vsm_config_{vsm_cfg} { From a891f5d2c27903e28a18e3a969d2c9e10a7fd332 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 25 Mar 2026 21:13:40 -0400 Subject: [PATCH 102/131] xo-interpreter2: skrepl: enable debug for X1 collector --- src/skrepl/skreplxx.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/skrepl/skreplxx.cpp b/src/skrepl/skreplxx.cpp index bb7fc2e5..92d9f883 100644 --- a/src/skrepl/skreplxx.cpp +++ b/src/skrepl/skreplxx.cpp @@ -250,6 +250,8 @@ main (int argc, char * argv[]) AppConfig cfg; // [cmdline options here] + cfg.vsm_config_.x1_config_.debug_flag_ = true; + App app(cfg); app.run(); From 5a5b9187030f974dcd84044e54604fd195c3c82c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 26 Mar 2026 15:04:22 -0400 Subject: [PATCH 103/131] xo-interpreter2: bugfix: install types for vsm collector instance --- include/xo/interpreter2/VsmConfig.hpp | 10 +++++++++ .../DVirtualSchematikaMachine.cpp | 21 ++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/include/xo/interpreter2/VsmConfig.hpp b/include/xo/interpreter2/VsmConfig.hpp index 166a63dd..21d25234 100644 --- a/include/xo/interpreter2/VsmConfig.hpp +++ b/include/xo/interpreter2/VsmConfig.hpp @@ -31,12 +31,22 @@ namespace xo { return retval; } + VsmConfig with_x1_config(const X1CollectorConfig & x) const { + VsmConfig retval = *this; + retval.x1_config_ = x; + return retval; + } + VsmConfig with_x1_debug_flag(bool x) const { VsmConfig retval = *this; retval.x1_config_.debug_flag_ = x; return retval; } + static X1CollectorConfig std_x1_config() { + return X1CollectorConfig().with_name("gc").with_size(4*1024*1024); + } + /** true for interactive parser session; false for batch session **/ bool interactive_flag_ = true; diff --git a/src/interpreter2/DVirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp index 52cdbf78..5c3d35d2 100644 --- a/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -46,9 +47,11 @@ namespace xo { using xo::reflect::Reflect; using xo::mm::AGCObject; using xo::mm::MemorySizeInfo; + using xo::mm::CollectorTypeRegistry; using xo::mm::AAllocator; using xo::mm::ACollector; using xo::mm::DX1Collector; + using xo::mm::X1CollectorConfig; using xo::mm::DArena; using xo::facet::FacetRegistry; using xo::facet::TypeRegistry; @@ -68,6 +71,22 @@ namespace xo { } } + namespace { + /** helper function to create X1 collector instance **/ + abox + vsm_make_gc(obj aux_mm, + const X1CollectorConfig & config) + { + auto retval = abox::make(aux_mm, config); + + // establish the set of types that mm_ will be able to collect + + CollectorTypeRegistry::instance().install_types(retval.to_op().to_facet()); + + return retval; + } + } + // NOTE: using heap here for {DX1Collector, DArena, DVsmRcx} instances // (though DX1Collector allocations will be from explictly mmap'd memory) // @@ -76,7 +95,7 @@ namespace xo { : config_{config}, self_vroot_{obj(this)}, aux_mm_{aux_mm}, - mm_(abox::make(aux_mm_, config.x1_config_)), + mm_(vsm_make_gc(aux_mm_, config.x1_config_)), rcx_(abox::make(aux_mm_, this)), reader_{config.rdr_config_, mm_.to_op(), aux_mm_} { From 9b2e27a635e6849b805d4a80c95cfa40aee59905 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 26 Mar 2026 15:05:06 -0400 Subject: [PATCH 104/131] xo-interpreter2: tiny: streamline vsm setup --- include/xo/interpreter2/VsmConfig.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/xo/interpreter2/VsmConfig.hpp b/include/xo/interpreter2/VsmConfig.hpp index 21d25234..ff211609 100644 --- a/include/xo/interpreter2/VsmConfig.hpp +++ b/include/xo/interpreter2/VsmConfig.hpp @@ -58,7 +58,7 @@ namespace xo { /** Configuration for allocator/collector. * TODO: may want to make CollectorConfig polymorphic **/ - X1CollectorConfig x1_config_ = X1CollectorConfig().with_name("gc").with_size(4*1024*1024); + X1CollectorConfig x1_config_ = std_x1_config(); /** Configuration for handful of non-moveable high-level objects * e.g. DArenaHashMap in global symtab **/ From e69a55dc6b33c13b900593eaa8910883c59eb5e9 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 26 Mar 2026 15:06:01 -0400 Subject: [PATCH 105/131] xo-interpreter2: skrepl: sanitize enabled for VSM gc --- src/skrepl/skreplxx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/skrepl/skreplxx.cpp b/src/skrepl/skreplxx.cpp index 92d9f883..51f9df06 100644 --- a/src/skrepl/skreplxx.cpp +++ b/src/skrepl/skreplxx.cpp @@ -88,7 +88,7 @@ namespace xo { AppConfig(const ReplConfig & repl_cfg = ReplConfig(), const ArenaConfig & app_arena_cfg = ArenaConfig().with_name("skreplxx").with_size(32 * 1024), - const VsmConfig & vsm_cfg = VsmConfig().with_x1_debug_flag(true)) + const VsmConfig & vsm_cfg = VsmConfig().with_x1_config(VsmConfig::std_x1_config().with_debug_flag(true).with_sanitize_flag(true))) : repl_config_{repl_cfg}, app_arena_config_{app_arena_cfg}, vsm_config_{vsm_cfg} { //rdr_config_.reader_debug_flag_ = true; From eb9354e5dd7e89ebbd6f1b8dc79540352451b005 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 26 Mar 2026 15:06:27 -0400 Subject: [PATCH 106/131] xo-interpreter2: trash unused type --- .../interpreter2/vsm/DVirtualSchematikaMachine.hpp | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp index 41b9ad66..9f8f49d8 100644 --- a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp @@ -20,19 +20,6 @@ namespace xo { namespace scm { -#ifdef OBSOLETE // see DVsmError - // TODO: move error to collected space? - // or special arena? - // - struct EvaluationError { - /** source location (in vsm implementation) at which error identified **/ - std::string_view src_function_; - /** error description (allocated from ErrorArena) **/ - std::string_view error_description_; - // TODO: info about location in schematika source - }; -#endif - /** similar to @ref xo::scm::ReaderResult **/ struct VsmResult { using AGCObject = xo::mm::AGCObject; From 3d852ccd70d98f0b5d518188095c8c9e33b43979 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 26 Mar 2026 16:06:31 -0400 Subject: [PATCH 107/131] xo-interpreter2: utest: refactor to reduce repetition --- utest/VirtualSchematikaMachine.test.cpp | 791 +++++++++--------------- 1 file changed, 288 insertions(+), 503 deletions(-) diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index e6732996..aa1286ea 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -40,6 +40,7 @@ namespace xo { using xo::mm::ArenaConfig; using xo::facet::FacetRegistry; using xo::facet::TypeRegistry; + using xo::reflect::typeseq; using span_type = xo::scm::DVirtualSchematikaMachine::span_type; using Catch::Matchers::WithinAbs; @@ -73,7 +74,8 @@ namespace xo { ~VsmFixture() {} - bool log_memory_layout(scope * p_log) { + bool log_memory_layout(scope * p_log) + { auto visitor = [p_log](const MemorySizeInfo & info) { *p_log && (*p_log)(xtag("resource", info.resource_name_), xtag("used", info.used_), @@ -90,10 +92,90 @@ namespace xo { return true; } + bool session_with_complete_input(const char * input_text, + std::function verify_result) + { + INFO(xtag("input_text", input_text)); + + bool eof_flag = false; + + vsm_->begin_interactive_session(); + + VsmResultExt res = vsm_->read_eval_print(span_type::from_cstr(input_text), + eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + REQUIRE(verify_result(res)); + + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + + return true; + } + ArenaShim aux_mm_; abox vsm_; }; + void vsm_std_utest_pattern(bool debug_flag, + const std::string & testname, + const char * input, + std::function verify_fn, + const VsmConfig & cfg = VsmConfig()) + { + scope log(XO_DEBUG(debug_flag), xtag("test", testname)); + + VsmFixture vsm_fixture(testname, debug_flag, cfg); + + vsm_fixture.session_with_complete_input(input, verify_fn); + + log && vsm_fixture.log_memory_layout(&log); + } + + void vsm_multi_utest_pattern(bool debug_flag, + const std::string & testname, + const char * input, + std::vector> verify_fns, + bool eof_flag = false, + const VsmConfig & cfg = VsmConfig()) + { + scope log(XO_DEBUG(debug_flag), xtag("test", testname)); + + VsmFixture vsm_fixture(testname, debug_flag, cfg); + auto & vsm = vsm_fixture.vsm_; + + vsm->begin_interactive_session(); + + span_type remaining = span_type::from_cstr(input); + + for (std::size_t i = 0; i < verify_fns.size(); ++i) { + log && log(xtag("i_expr", i), xtag("input", remaining)); + + VsmResultExt res = vsm->read_eval_print(remaining, eof_flag); + + REQUIRE(res.is_value()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq()), + xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); + + REQUIRE(verify_fns[i](res)); + + if (i + 1 == verify_fns.size()) { + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + } else { + REQUIRE(res.remaining_.size() > 1); + } + + remaining = res.remaining_; + } + + log && vsm_fixture.log_memory_layout(&log); + } + TEST_CASE("VirtualSchematikaMachine-ctor", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); @@ -109,653 +191,356 @@ namespace xo { TEST_CASE("VirtualSchematikaMachine-const1", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - constexpr bool c_debug_flag = false; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmFixture vsm_fixture(testname, c_debug_flag); + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); - auto & vsm = vsm_fixture.vsm_; + REQUIRE(x); + REQUIRE(x._typeseq() == typeseq::id()); + REQUIRE_THAT(x.data()->value(), WithinAbs(3.141592635, 1e-6)); - bool eof_flag = false; + return true; + }; - vsm->begin_interactive_session(); - VsmResultExt res = vsm->read_eval_print(span_type::from_cstr("3.141592635;"), eof_flag); - - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - auto x = obj::from(*res.value()); - - REQUIRE(x); - REQUIRE_THAT(x.data()->value(), WithinAbs(3.141592635, 1e-6)); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - - log && vsm_fixture.log_memory_layout(&log); + vsm_std_utest_pattern(c_debug_flag, testname, "3.1415926535;", verify_fn); } TEST_CASE("VirtualSchematikaMachine-const2", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - constexpr bool c_debug_flag = false; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmFixture vsm_fixture(testname, c_debug_flag); + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); - auto & vsm = vsm_fixture.vsm_; + REQUIRE(x); + REQUIRE(x._typeseq() == typeseq::id()); + REQUIRE(x.data()->value() == 1011); - bool eof_flag = false; + return true; + }; - vsm->begin_interactive_session(); - VsmResultExt res = vsm->read_eval_print(span_type::from_cstr("1011;"), eof_flag); - - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq())); - - auto x = obj::from(*res.value()); - - REQUIRE(x); - REQUIRE(x.data()->value() == 1011); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - - log && vsm_fixture.log_memory_layout(&log); + vsm_std_utest_pattern(c_debug_flag, testname, "1011;", verify_fn); } TEST_CASE("VirtualSchematikaMachine-arith1", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - constexpr bool c_debug_flag = false; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmFixture vsm_fixture(testname, c_debug_flag); - auto & vsm = vsm_fixture.vsm_; + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); - bool eof_flag = false; + REQUIRE(x); + REQUIRE(x._typeseq() == typeseq::id()); + REQUIRE(x.data()->value() == 1.570796325); - vsm->begin_interactive_session(); - VsmResultExt res = vsm->read_eval_print(span_type::from_cstr("3.14159265 * 0.5;"), eof_flag); + return true; + }; - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq())); - - auto x = obj::from(*res.value()); - - REQUIRE(x); - REQUIRE(x.data()->value() == 1.570796325); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - - log && vsm_fixture.log_memory_layout(&log); + vsm_std_utest_pattern(c_debug_flag, testname, + "3.14159265 * 0.5;", + verify_fn); } TEST_CASE("VirtualSchematikaMachine-arith2", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - constexpr bool c_debug_flag = true; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmFixture vsm_fixture(testname, c_debug_flag); - auto & vsm = vsm_fixture.vsm_; + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); - bool eof_flag = false; + REQUIRE(x); + REQUIRE(x.data()->value() == 6.2831853); - vsm->begin_interactive_session(); - VsmResultExt res = vsm->read_eval_print(span_type::from_cstr("3.14159265 / 0.5;"), eof_flag); + return true; + }; - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq())); - - auto x = obj::from(*res.value()); - - REQUIRE(x); - REQUIRE(x.data()->value() == 6.2831853); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - - log && vsm_fixture.log_memory_layout(&log); + vsm_std_utest_pattern(c_debug_flag, testname, + "3.14159265 / 0.5;", verify_fn); } TEST_CASE("VirtualSchematikaMachine-cmp1", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - constexpr bool c_debug_flag = false; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmFixture vsm_fixture(testname, c_debug_flag); - auto & vsm = vsm_fixture.vsm_; + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); - bool eof_flag = false; + REQUIRE(x); + REQUIRE(x.data()->value() == true); - vsm->begin_interactive_session(); - VsmResultExt res - = vsm->read_eval_print(span_type::from_cstr("123 == 123;"), - eof_flag); + return true; + }; - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq())); - - auto x = obj::from(*res.value()); - - REQUIRE(x); - REQUIRE(x.data()->value() == true); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - - log && vsm_fixture.log_memory_layout(&log); + vsm_std_utest_pattern(c_debug_flag, testname, + "123 == 123;", + verify_fn); } TEST_CASE("VirtualSchematikaMachine-if", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - constexpr bool c_debug_flag = false; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmFixture vsm_fixture(testname, c_debug_flag); - auto & vsm = vsm_fixture.vsm_; + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); - bool eof_flag = false; + REQUIRE(x); + REQUIRE(strcmp(x.data()->chars(), "equal") == 0); - vsm->begin_interactive_session(); - VsmResultExt res - = vsm->read_eval_print(span_type::from_cstr("if 123 == 123 then \"equal\" else \"notequal\";"), - eof_flag); + return true; + }; - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq())); - - auto x = obj::from(*res.value()); - - REQUIRE(x); - REQUIRE(strcmp(x.data()->chars(), "equal") == 0); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - - log && vsm_fixture.log_memory_layout(&log); + vsm_std_utest_pattern(c_debug_flag, testname, + "if 123 == 123 then \"equal\" else \"notequal\";", + verify_fn); } TEST_CASE("VirtualSchematikaMachine-lambda1", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); - constexpr bool c_debug_flag = false; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - VsmFixture vsm_fixture(testname, c_debug_flag); - auto & vsm = vsm_fixture.vsm_; + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); - bool eof_flag = false; + REQUIRE(x); - vsm->begin_interactive_session(); - VsmResultExt res - = vsm->read_eval_print(span_type::from_cstr("lambda (x : i64) -> i64 { x * x; }"), - eof_flag); + return true; + }; - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq())); - - auto x = obj::from(*res.value()); - - REQUIRE(x); - //REQUIRE(x.data()->value() == 1.570796325); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - - log && vsm_fixture.log_memory_layout(&log); + vsm_std_utest_pattern(c_debug_flag, testname, + "lambda (x : i64) -> i64 { x * x; }", + verify_fn); } TEST_CASE("VirtualSchematikaMachine-apply2", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); + constexpr bool c_debug_flag = false; - bool c_debug_flag = false; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); - VsmFixture vsm_fixture(testname, c_debug_flag); - auto & vsm = vsm_fixture.vsm_; + REQUIRE(x); + REQUIRE(x->value() == 195); - bool eof_flag = false; + return true; + }; - vsm->begin_interactive_session(); - VsmResultExt res - = vsm->read_eval_print(span_type::from_cstr - ("(lambda (x : i64, y : i64) { x * y; })(13, 15);"), - eof_flag); - - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq())); - - // currently get not-implemented error - auto x = obj::from(*res.value()); - - REQUIRE(x); - REQUIRE(x->value() == 195); - - //log && log("runtime-error", xtag("ex.src", x->src_function()), xtag("ex.descr", x->error_descr())); - - //REQUIRE(x.data()->value() == 1.570796325); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - - log && vsm_fixture.log_memory_layout(&log); + vsm_std_utest_pattern(c_debug_flag, testname, + "(lambda (x : i64, y : i64) { x * y; })(13, 15);", + verify_fn); } TEST_CASE("VirtualSchematikaMachine-def1", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); + constexpr bool c_debug_flag = false; - bool c_debug_flag = false; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); - VsmFixture vsm_fixture(testname, c_debug_flag); - auto & vsm = vsm_fixture.vsm_; + REQUIRE(x); + REQUIRE(strcmp(x->chars(), "foo") == 0); - bool eof_flag = false; + return true; + }; - vsm->begin_interactive_session(); - VsmResultExt res - = vsm->read_eval_print(span_type::from_cstr("def foo = 3.14159;"), - eof_flag); - - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq()), - xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); - - // currently get not-implemented error - auto x = obj::from(*res.value()); - - REQUIRE(x); - REQUIRE(strcmp(x->chars(), "foo") == 0); - - //log && log("runtime-error", xtag("ex.src", x->src_function()), xtag("ex.descr", x->error_descr())); - - //REQUIRE(x.data()->value() == 1.570796325); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - - log && vsm_fixture.log_memory_layout(&log); + vsm_std_utest_pattern(c_debug_flag, testname, + "def foo = 3.14159;", + verify_fn); } TEST_CASE("VirtualSchematikaMachine-def2", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); + constexpr bool c_debug_flag = true; - bool c_debug_flag = true; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - - VsmFixture vsm_fixture(testname, c_debug_flag); - auto & vsm = vsm_fixture.vsm_; - - bool eof_flag = false; - - vsm->begin_interactive_session(); - - span_type input = span_type::from_cstr("def foo = 3.14159; foo;"); - - for (int i_expr = 0; i_expr < 2; ++i_expr) { - log && log(xtag("input", input)); - - VsmResultExt res - = vsm->read_eval_print(input, eof_flag); - - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq()), - xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); - - if (i_expr == 0) { - auto x = obj::from(*res.value()); - REQUIRE(x); - REQUIRE(strcmp(x->chars(), "foo") == 0); - - REQUIRE(res.remaining_.size() > 1); - - input = res.remaining_; - } else if (i_expr == 1) { - auto x = obj::from(*res.value()); - REQUIRE(x); - REQUIRE_THAT(x->value(), WithinAbs(3.14159, 1e-6)); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - input = res.remaining_; - } - } - - log && vsm_fixture.log_memory_layout(&log); - + vsm_multi_utest_pattern( + c_debug_flag, testname, + "def foo = 3.14159; foo;", + { + [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(strcmp(x->chars(), "foo") == 0); + return true; + }, + [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE_THAT(x->value(), WithinAbs(3.14159, 1e-6)); + return true; + } + }); } TEST_CASE("VirtualSchematikaMachine-def3", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); + constexpr bool c_debug_flag = true; - bool c_debug_flag = true; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - - VsmFixture vsm_fixture(testname, c_debug_flag); - auto & vsm = vsm_fixture.vsm_; - - bool eof_flag = true; - - vsm->begin_interactive_session(); - - span_type input = span_type::from_cstr("def fact = lambda (n) { if (n == 0) then 1 else n * fact(n - 1) };"); - - for (int i_expr = 0; i_expr < 1; ++i_expr) { - log && log(xtag("input", input)); - - VsmResultExt res - = vsm->read_eval_print(input, eof_flag); - - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq()), - xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); - - if (i_expr == 0) { - auto x = obj::from(*res.value()); - REQUIRE(x); - REQUIRE(strcmp(x->chars(), "fact") == 0); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - input = res.remaining_; - } - } - - log && vsm_fixture.log_memory_layout(&log); + vsm_multi_utest_pattern( + c_debug_flag, testname, + "def fact = lambda (n) { if (n == 0) then 1 else n * fact(n - 1) };", + { + [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(strcmp(x->chars(), "fact") == 0); + return true; + } + }, + /*eof_flag=*/true); } TEST_CASE("VirtualSchematikaMachine-if2", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); + constexpr bool c_debug_flag = true; - bool c_debug_flag = true; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - - VsmFixture vsm_fixture(testname, c_debug_flag); - auto & vsm = vsm_fixture.vsm_; - - bool eof_flag = true; - - vsm->begin_interactive_session(); - - span_type input = span_type::from_cstr("def n = 4; if (n == 4) then n * 3 else n * 5;"); - - for (int i_expr = 0; i_expr < 2; ++i_expr) { - log && log(xtag("input", input)); - - VsmResultExt res - = vsm->read_eval_print(input, eof_flag); - - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq()), - xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); - - if (i_expr == 0) { - auto x = obj::from(*res.value()); - REQUIRE(x); - REQUIRE(strcmp(x->chars(), "n") == 0); - input = res.remaining_; - } else if (i_expr == 1) { - auto x = obj::from(*res.value()); - REQUIRE(x); - REQUIRE(x->value() == 12); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - input = res.remaining_; - } - } - - log && vsm_fixture.log_memory_layout(&log); + vsm_multi_utest_pattern( + c_debug_flag, testname, + "def n = 4; if (n == 4) then n * 3 else n * 5;", + { + [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(strcmp(x->chars(), "n") == 0); + return true; + }, + [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(x->value() == 12); + return true; + } + }, + /*eof_flag=*/true); } TEST_CASE("VirtualSchematikaMachine-fact0", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); + constexpr bool c_debug_flag = false; - bool c_debug_flag = false; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); - - VsmFixture vsm_fixture(testname, c_debug_flag); - auto & vsm = vsm_fixture.vsm_; - - bool eof_flag = true; - - vsm->begin_interactive_session(); - - span_type input = span_type::from_cstr("def fact = lambda (n) { if (n == 0) then 1 else n * fact(n - 1) }; fact(4);"); - - for (int i_expr = 0; i_expr < 2; ++i_expr) { - log && log(xtag("input", input)); - - VsmResultExt res - = vsm->read_eval_print(input, eof_flag); - - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq()), - xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); - - if (i_expr == 0) { - auto x = obj::from(*res.value()); - REQUIRE(x); - REQUIRE(strcmp(x->chars(), "fact") == 0); - input = res.remaining_; - } else if (i_expr == 1) { - auto x = obj::from(*res.value()); - REQUIRE(x); - REQUIRE(x->value() == 24); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - input = res.remaining_; - } - } - - log && vsm_fixture.log_memory_layout(&log); + vsm_multi_utest_pattern( + c_debug_flag, testname, + "def fact = lambda (n) { if (n == 0) then 1 else n * fact(n - 1) }; fact(4);", + { + [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(strcmp(x->chars(), "fact") == 0); + return true; + }, + [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(x->value() == 24); + return true; + } + }, + /*eof_flag=*/true); } TEST_CASE("VirtualSchematikaMachine-qliteral1", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); + constexpr bool c_debug_flag = true; - bool c_debug_flag = true; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); - VsmFixture vsm_fixture(testname, c_debug_flag, - VsmConfig().with_parser_debug_flag(c_debug_flag)); - auto & vsm = vsm_fixture.vsm_; + REQUIRE(x); + REQUIRE(x->value() == 4.5); - bool eof_flag = false; + return true; + }; - vsm->begin_interactive_session(); - - span_type input = span_type::from_cstr("#q{ 4.5 };"); - - log && log(xtag("input", input)); - - VsmResultExt res - = vsm->read_eval_print(input, eof_flag); - - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq()), - xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); - - auto x = obj::from(*res.value()); - REQUIRE(x); - REQUIRE(x->value() == 4.5); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - - //log && vsm_fixture.log_memory_layout(&log); + vsm_std_utest_pattern(c_debug_flag, testname, + "#q{ 4.5 };", + verify_fn, + VsmConfig().with_parser_debug_flag(c_debug_flag)); } TEST_CASE("VirtualSchematikaMachine-qlist", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); + constexpr bool c_debug_flag = false; - bool c_debug_flag = false; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(x->size() == 2); - VsmFixture vsm_fixture(testname, c_debug_flag, - VsmConfig().with_parser_debug_flag(c_debug_flag)); - auto & vsm = vsm_fixture.vsm_; + auto x0 = obj::from(x->at(0)); + REQUIRE(x0); + REQUIRE(x0->value() == 4.5); - bool eof_flag = true; + auto x1 = obj::from(x->at(1)); + REQUIRE(x1); + REQUIRE(x1->value() == 7.2); - vsm->begin_interactive_session(); + return true; + }; - span_type input = span_type::from_cstr("#q{ (4.5 7.2) };"); - - log && log(xtag("input", input)); - - VsmResultExt res - = vsm->read_eval_print(input, eof_flag); - - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq()), - xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); - - auto x = obj::from(*res.value()); - REQUIRE(x); - REQUIRE(x->size() == 2); - auto x0 = obj::from(x->at(0)); - REQUIRE(x0); - REQUIRE(x0->value() == 4.5); - auto x1 = obj::from(x->at(1)); - REQUIRE(x1); - REQUIRE(x1->value() == 7.2); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - - //log && vsm_fixture.log_memory_layout(&log); + vsm_std_utest_pattern(c_debug_flag, testname, + "#q{ (4.5 7.2) };", + verify_fn, + VsmConfig().with_parser_debug_flag(c_debug_flag)); } TEST_CASE("VirtualSchematikaMachine-qarray", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); + constexpr bool c_debug_flag = true; - bool c_debug_flag = true; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + REQUIRE(x); + REQUIRE(x->size() == 2); - VsmFixture vsm_fixture(testname, c_debug_flag, - VsmConfig().with_parser_debug_flag(c_debug_flag)); - auto & vsm = vsm_fixture.vsm_; + auto x0 = obj::from(x->at(0)); + REQUIRE(x0); + REQUIRE(x0->value() == 4.5); - bool eof_flag = true; + auto x1 = obj::from(x->at(1)); + REQUIRE(x1); + REQUIRE(x1->value() == 7.2); - vsm->begin_interactive_session(); + return true; + }; - span_type input = span_type::from_cstr("#q{ [4.5 7.2] };"); - - log && log(xtag("input", input)); - - VsmResultExt res - = vsm->read_eval_print(input, eof_flag); - - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq()), - xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); - - auto x = obj::from(*res.value()); - REQUIRE(x); - REQUIRE(x->size() == 2); - auto x0 = obj::from(x->at(0)); - REQUIRE(x0); - REQUIRE(x0->value() == 4.5); - auto x1 = obj::from(x->at(1)); - REQUIRE(x1); - REQUIRE(x1->value() == 7.2); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - - //log && vsm_fixture.log_memory_layout(&log); + vsm_std_utest_pattern(c_debug_flag, testname, + "#q{ [4.5 7.2] };", + verify_fn, + VsmConfig().with_parser_debug_flag(c_debug_flag)); } TEST_CASE("VirtualSchematikaMachine-report_memory_use", "[interpreter2][VSM]") { const auto & testname = Catch::getResultCapture().getCurrentTestName(); + constexpr bool c_debug_flag = false; - bool c_debug_flag = false; - scope log(XO_DEBUG(c_debug_flag), xtag("test", testname)); + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); - VsmFixture vsm_fixture(testname, c_debug_flag, - VsmConfig().with_parser_debug_flag(c_debug_flag)); - auto & vsm = vsm_fixture.vsm_; + REQUIRE(x); + REQUIRE(x->value() == true); - bool eof_flag = true; + return true; + }; - vsm->begin_interactive_session(); - - span_type input = span_type::from_cstr("report-memory-use();"); - - log && log(xtag("input", input)); - - VsmResultExt res - = vsm->read_eval_print(input, eof_flag); - - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq()), - xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); - - auto x = obj::from(*res.value()); - REQUIRE(x); - REQUIRE(x->value() == true); - - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - - //log && vsm_fixture.log_memory_layout(&log); + vsm_std_utest_pattern(c_debug_flag, testname, + "report-memory-use();", + verify_fn, + VsmConfig().with_parser_debug_flag(c_debug_flag)); } } /*namespace ut*/ } /*namespace xo*/ From 8a78b94cd4c159519614cab582d910496312c3fc Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 26 Mar 2026 17:04:35 -0400 Subject: [PATCH 108/131] xo-interpreter2: utest: refactor to simplify/share --- utest/VirtualSchematikaMachine.test.cpp | 71 ++++++++++++++----------- 1 file changed, 39 insertions(+), 32 deletions(-) diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index aa1286ea..ac74bab3 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -92,27 +92,35 @@ namespace xo { return true; } - bool session_with_complete_input(const char * input_text, - std::function verify_result) + /** @p must_exhaust expression must exhaust input. + * otherwise mut *not* exhaust input + **/ + span_type read_eval_verify(bool debug_flag, + span_type input_span, + std::function verify_result, + bool must_exhaust, + bool eof_flag) { - INFO(xtag("input_text", input_text)); + scope log(XO_DEBUG(debug_flag)); - bool eof_flag = false; - - vsm_->begin_interactive_session(); - - VsmResultExt res = vsm_->read_eval_print(span_type::from_cstr(input_text), - eof_flag); + VsmResultExt res = vsm_->read_eval_print(input_span, eof_flag); REQUIRE(res.is_value()); REQUIRE(res.value()); + log && log(xtag("res.tseq", res.value()->_typeseq()), + xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); + REQUIRE(verify_result(res)); - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); + if (must_exhaust) { + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + } else { + REQUIRE(res.remaining_.size() > 1); + } - return true; + return res.remaining_; } ArenaShim aux_mm_; @@ -125,15 +133,25 @@ namespace xo { std::function verify_fn, const VsmConfig & cfg = VsmConfig()) { - scope log(XO_DEBUG(debug_flag), xtag("test", testname)); + scope log(XO_DEBUG(debug_flag), xtag("test", testname), xtag("input", input)); + bool eof_flag = false; + bool must_exhaust = true; + + INFO(xtag("input", input)); VsmFixture vsm_fixture(testname, debug_flag, cfg); - vsm_fixture.session_with_complete_input(input, verify_fn); + vsm_fixture.vsm_->begin_interactive_session(); + + vsm_fixture.read_eval_verify(debug_flag, + span_type::from_cstr(input), verify_fn, + must_exhaust, eof_flag); log && vsm_fixture.log_memory_layout(&log); } + /** input comprises N expressions, with verify_fns.size() = N. + **/ void vsm_multi_utest_pattern(bool debug_flag, const std::string & testname, const char * input, @@ -146,31 +164,20 @@ namespace xo { VsmFixture vsm_fixture(testname, debug_flag, cfg); auto & vsm = vsm_fixture.vsm_; - vsm->begin_interactive_session(); + vsm_fixture.vsm_->begin_interactive_session(); span_type remaining = span_type::from_cstr(input); for (std::size_t i = 0; i < verify_fns.size(); ++i) { log && log(xtag("i_expr", i), xtag("input", remaining)); - VsmResultExt res = vsm->read_eval_print(remaining, eof_flag); + bool must_exhaust = (i + 1 == verify_fns.size()); - REQUIRE(res.is_value()); - REQUIRE(res.value()); - - log && log(xtag("res.tseq", res.value()->_typeseq()), - xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); - - REQUIRE(verify_fns[i](res)); - - if (i + 1 == verify_fns.size()) { - REQUIRE(res.remaining_.size() == 1); - REQUIRE(*res.remaining_.lo() == '\n'); - } else { - REQUIRE(res.remaining_.size() > 1); - } - - remaining = res.remaining_; + remaining + = vsm_fixture.read_eval_verify(debug_flag, + remaining, + verify_fns[i], + must_exhaust, eof_flag); } log && vsm_fixture.log_memory_layout(&log); From 3e9759099061225504d432a2dfd1cac2bc039f75 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 26 Mar 2026 17:08:39 -0400 Subject: [PATCH 109/131] xo-interpreter2: VSM.start_eval() returns const ref If copied get unstable value, since may be moved away on next gc --- include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp | 2 +- src/interpreter2/DVirtualSchematikaMachine.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp index 9f8f49d8..46de95f3 100644 --- a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp @@ -119,7 +119,7 @@ namespace xo { /** evaluate expression @p expr * Require: must first start interactive/batch session **/ - VsmResult start_eval(obj expr); + const VsmResult & start_eval(obj expr); /** borrow calling thread to run indefinitely, * until halt instruction diff --git a/src/interpreter2/DVirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp index 5c3d35d2..8edc0538 100644 --- a/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -225,7 +225,7 @@ namespace xo { return VsmResultExt(VsmResult(*p_value), remaining); } - VsmResult + const VsmResult & DVirtualSchematikaMachine::start_eval(obj expr) { this->pc_ = VsmInstr::c_eval; From 822fef7de3232d703778dc30e6f4c719e99283ed Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 27 Mar 2026 11:16:28 -0400 Subject: [PATCH 110/131] xo-interpreter2 stack: wrap TokenizerError as DRuntimeError Also fix _read_eval_print() to report them! --- .../vsm/DVirtualSchematikaMachine.hpp | 16 ++--- .../DVirtualSchematikaMachine.cpp | 59 ++++++++++++------- src/skrepl/skreplxx.cpp | 2 +- 3 files changed, 47 insertions(+), 30 deletions(-) diff --git a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp index 46de95f3..84070673 100644 --- a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp @@ -27,17 +27,15 @@ namespace xo { VsmResult() = default; explicit VsmResult(obj value) : result_{value} {} - explicit VsmResult(TokenizerError err) : result_{err} {} - bool is_value() const { return std::holds_alternative>(result_); } - bool is_tk_error() const { return std::holds_alternative(result_); } - bool is_eval_error() const; + bool is_value() const { return result_; } + bool is_error() const; - const obj * value() const { return std::get_if>(&result_); } - obj & value_ref() { return std::get>(result_); } + const obj * value() const { return &result_; } + obj & value_ref() { return result_; } /** result of evaluating first expression encountered in input **/ - std::variant, TokenizerError> result_; + obj result_; }; /** vsm result + reamining span **/ @@ -270,7 +268,9 @@ namespace xo { obj aux_mm_; /** allocator (likely DX1Collector or similar) for - * expressions and values. Schemaatika reader will use this also + * expressions and values. Schemaatika reader will use this also. + * + * Allocations must represent a type that supports GCObject. **/ abox mm_; diff --git a/src/interpreter2/DVirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp index 8edc0538..9ceb8fac 100644 --- a/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -60,15 +60,9 @@ namespace xo { namespace scm { bool - VsmResult::is_eval_error() const + VsmResult::is_error() const { - if (std::holds_alternative>(result_)) { - auto err = obj::from(*(this->value())); - - return err; - } else { - return false; - } + return (*this->value() && obj::from(*(this->value()))); } namespace { @@ -191,18 +185,39 @@ namespace xo { reader_.reset_result(); - auto [expr, remaining, error1] + auto [expr, remaining, tk_error] = reader_.read_expr(input, eof); if (!expr) { - /* tokenizer error */ + if (tk_error.is_error()) { + // tokenizer error -> convert to runtime error - return VsmResultExt(VsmResult(error1), remaining); + DString * src = DString::from_view(mm_.to_op(), tk_error.src_function()); + DString * msg = tk_error.report_to_string(mm_.to_op()); + + auto error = obj(DRuntimeError::_make(mm_.to_op(), src, msg)); + + { + obj error_pr + = FacetRegistry::instance().variant(error); + + ppconfig ppc; + ppstate_standalone pps(&cout, 0, &ppc); + pps.prettyn(error_pr); + } + + return VsmResultExt(VsmResult(error), remaining); + } else { + // incomplete input + return VsmResultExt(VsmResult(), remaining); + } } + // here: have obtained complete input expression + VsmResult evalresult = this->start_eval(expr); - if (evalresult.is_tk_error()) { + if (evalresult.is_error()) { // TODO: print error here return VsmResultExt(evalresult, remaining); @@ -210,19 +225,21 @@ namespace xo { assert(evalresult.is_value()); - obj * p_value = std::get_if>(&(evalresult.result_)); + obj value = evalresult.result_; - assert(p_value); + assert(value); - obj value_pr - = FacetRegistry::instance().variant(*p_value); + { + obj value_pr + = FacetRegistry::instance().variant(value); - // pretty_toplevel(value_pr, &cout, ppconfig()); - ppconfig ppc; - ppstate_standalone pps(&cout, 0, &ppc); - pps.prettyn(value_pr); + // pretty_toplevel(value_pr, &cout, ppconfig()); + ppconfig ppc; + ppstate_standalone pps(&cout, 0, &ppc); + pps.prettyn(value_pr); + } - return VsmResultExt(VsmResult(*p_value), remaining); + return VsmResultExt(VsmResult(value), remaining); } const VsmResult & diff --git a/src/skrepl/skreplxx.cpp b/src/skrepl/skreplxx.cpp index 51f9df06..a4f86857 100644 --- a/src/skrepl/skreplxx.cpp +++ b/src/skrepl/skreplxx.cpp @@ -230,7 +230,7 @@ namespace xo { *p_input = res.remaining_; - return !res.is_tk_error() && !res.is_eval_error(); + return !res.is_error(); } void From a067d0f7b2917e8fde3b45c76a9e20ad0ad73caa Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 27 Mar 2026 12:13:09 -0400 Subject: [PATCH 111/131] xo-inteerpreter2: rework VsmResult to use pointer Preefer to maintain ref to VSM.result_, since gc will preserve it. --- .../vsm/DVirtualSchematikaMachine.hpp | 23 +++++++++++++++---- .../DVirtualSchematikaMachine.cpp | 10 ++++---- utest/VirtualSchematikaMachine.test.cpp | 2 ++ 3 files changed, 27 insertions(+), 8 deletions(-) diff --git a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp index 84070673..e6badf83 100644 --- a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp @@ -32,18 +32,33 @@ namespace xo { bool is_error() const; const obj * value() const { return &result_; } - obj & value_ref() { return result_; } + const obj & value_ref() const { return result_; } /** result of evaluating first expression encountered in input **/ obj result_; }; - /** vsm result + reamining span **/ - struct VsmResultExt : public VsmResult { + /** vsm result + reamining span + * + * Preserves address of wrapped VsmResult + * (so it can continue to be owned by DVirtualSchematikaMachine, + * and to be known to gc without add'l effort) + **/ + struct VsmResultExt { + using AGCObject = xo::mm::AGCObject; using span_type = VsmResult::span_type; VsmResultExt() = default; - VsmResultExt(const VsmResult & result, span_type rem) : VsmResult{result}, remaining_{rem} {} + VsmResultExt(const VsmResult & result, span_type rem) : p_result_{&result}, remaining_{rem} {} + + bool is_empty() const { return !p_result_; } + bool is_value() const { return p_result_ ? p_result_->is_value() : false; } + bool is_error() const { return p_result_ ? p_result_->is_error() : false; } + + const obj * value() const { return p_result_ ? p_result_->value() : nullptr; } + //const obj & value_ref() { return result_.value_ref(); } + + const VsmResult * p_result_ = nullptr; /** unconsumed portion of input **/ VsmResult::span_type remaining_; diff --git a/src/interpreter2/DVirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp index 9ceb8fac..f9977eb9 100644 --- a/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -197,6 +197,8 @@ namespace xo { auto error = obj(DRuntimeError::_make(mm_.to_op(), src, msg)); + this->value_ = VsmResult(error); + { obj error_pr = FacetRegistry::instance().variant(error); @@ -206,7 +208,7 @@ namespace xo { pps.prettyn(error_pr); } - return VsmResultExt(VsmResult(error), remaining); + return VsmResultExt(value_, remaining); } else { // incomplete input return VsmResultExt(VsmResult(), remaining); @@ -215,7 +217,7 @@ namespace xo { // here: have obtained complete input expression - VsmResult evalresult = this->start_eval(expr); + const VsmResult & evalresult = this->start_eval(expr); if (evalresult.is_error()) { // TODO: print error here @@ -239,7 +241,7 @@ namespace xo { pps.prettyn(value_pr); } - return VsmResultExt(VsmResult(value), remaining); + return VsmResultExt(evalresult, remaining); } const VsmResult & @@ -975,7 +977,7 @@ namespace xo { gc.forward_inplace(&fn_); gc.forward_inplace(&args_); if (value_.is_value()) { - gc.forward_inplace(&value_.value_ref()); + gc.forward_inplace(const_cast *>(&value_.value_ref())); } return this->shallow_size(); diff --git a/utest/VirtualSchematikaMachine.test.cpp b/utest/VirtualSchematikaMachine.test.cpp index ac74bab3..aabda3a3 100644 --- a/utest/VirtualSchematikaMachine.test.cpp +++ b/utest/VirtualSchematikaMachine.test.cpp @@ -103,6 +103,8 @@ namespace xo { { scope log(XO_DEBUG(debug_flag)); + // WARNING: res.value() is unstable - gc may move it + VsmResultExt res = vsm_->read_eval_print(input_span, eof_flag); REQUIRE(res.is_value()); From 02127138e7683911e319c64190784dddae3c55d0 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 28 Mar 2026 13:14:04 -0400 Subject: [PATCH 112/131] xo-interpreter2: must register DClosure with collector --- src/interpreter2/SetupInterpreter2.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/interpreter2/SetupInterpreter2.cpp b/src/interpreter2/SetupInterpreter2.cpp index d6013741..02ba2f13 100644 --- a/src/interpreter2/SetupInterpreter2.cpp +++ b/src/interpreter2/SetupInterpreter2.cpp @@ -113,6 +113,7 @@ namespace xo { ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); return ok; } From c9a86dde2a923055de95dbf561e15c83bde08087 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 28 Mar 2026 13:14:53 -0400 Subject: [PATCH 113/131] xo-interpreter2: DClosure: streamline forward_children() method --- src/interpreter2/DClosure.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/interpreter2/DClosure.cpp b/src/interpreter2/DClosure.cpp index 53015068..e052ca4d 100644 --- a/src/interpreter2/DClosure.cpp +++ b/src/interpreter2/DClosure.cpp @@ -8,6 +8,7 @@ #include "LocalEnv.hpp" #include "VsmRcx.hpp" #include +#include #include #include @@ -82,16 +83,18 @@ namespace xo { DClosure::forward_children(obj gc) noexcept { { - auto iface = xo::facet::impl_for(); - gc.forward_inplace(&iface, (void **)(&lambda_)); + gc.forward_inplace(&lambda_); + //auto iface = xo::facet::impl_for(); + //gc.forward_inplace(&iface, (void **)(&lambda_)); } { - auto iface = xo::facet::impl_for(); - gc.forward_inplace(&iface, (void **)(&env_)); + gc.forward_inplace(&env_); + //auto iface = xo::facet::impl_for(); + //gc.forward_inplace(&iface, (void **)(&env_)); } - return shallow_size(); + return this->shallow_size(); } // ----- printable facet ----- From e21808de3cd06aee58c9987872571ae74d4438c8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 29 Mar 2026 13:44:19 -0400 Subject: [PATCH 114/131] xo-gc stack: + request-gc-statistics() primitive 1. xo-gc now depends on xo-object2. 2. use genfacet for ICollector_DX1Collector 3. moves xo-gc utest previously in xo-object2 to more natural location in xo-gc/ --- include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp | 2 ++ src/interpreter2/IRuntimeContext_DVsmRcx.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp b/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp index 1eddf28c..d87596e6 100644 --- a/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp +++ b/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp @@ -52,6 +52,8 @@ namespace xo { static obj allocator(const DVsmRcx & self) noexcept; /** collector facet for allocator. If non-null, same data pointer as allocator **/ static obj collector(const DVsmRcx & self) noexcept; + /** last-resort allocator for erros. e.g. regular allocator exhausted **/ + static obj error_allocator(const DVsmRcx & self) noexcept; /** stringtable for unique symbols **/ static StringTable * stringtable(const DVsmRcx & self) noexcept; /** invoke visitor for each distinct memory pool **/ diff --git a/src/interpreter2/IRuntimeContext_DVsmRcx.cpp b/src/interpreter2/IRuntimeContext_DVsmRcx.cpp index 9b1a73d0..b2259c75 100644 --- a/src/interpreter2/IRuntimeContext_DVsmRcx.cpp +++ b/src/interpreter2/IRuntimeContext_DVsmRcx.cpp @@ -27,6 +27,12 @@ namespace xo { return self.collector(); } + auto + IRuntimeContext_DVsmRcx::error_allocator(const DVsmRcx & self) noexcept -> obj + { + return self.error_allocator(); + } + auto IRuntimeContext_DVsmRcx::stringtable(const DVsmRcx & self) noexcept -> StringTable * { From b7cb810913f608143d0d334c8be460aeab4f1bb2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 29 Mar 2026 15:17:31 -0400 Subject: [PATCH 115/131] xo-gc: use DArenaVector for DX1Collector.object_types_ Original implementation predated DArenaVector, using it is more natural --- src/interpreter2/SetupInterpreter2.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/interpreter2/SetupInterpreter2.cpp b/src/interpreter2/SetupInterpreter2.cpp index 02ba2f13..6af697bd 100644 --- a/src/interpreter2/SetupInterpreter2.cpp +++ b/src/interpreter2/SetupInterpreter2.cpp @@ -93,7 +93,7 @@ namespace xo { log && log(xtag("DVsmEvalArgsFrame.tseq", typeseq::id())); log && log(xtag("DVsmApplyClosureFrame.tseq", typeseq::id())); log && log(xtag("DVsmDefContFrame.tseq", typeseq::id())); - log && log(xtag("DVsmDefContFrame.tseq", typeseq::id())); + //log && log(xtag("DVsmDefContFrame.tseq", typeseq::id())); log && log(xtag("DVsmIfElseContFrame.tseq", typeseq::id())); log && log(xtag("DVsmSeqContFrame.tseq", typeseq::id())); log && log(xtag("DClosure.tseq", typeseq::id())); @@ -113,6 +113,8 @@ namespace xo { ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); return ok; From 761bff734e60bccbc9b16d318823c5f16e10ec3d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 14:38:14 -0400 Subject: [PATCH 116/131] refactor: make AGCObject.shallow_copy() non-const prep for moving to ACollector interface --- CMakeLists.txt | 3 - include/xo/interpreter2/DVsmDefContFrame.hpp | 2 +- .../xo/interpreter2/DVsmIfElseContFrame.hpp | 2 +- include/xo/interpreter2/DVsmSeqContFrame.hpp | 2 +- include/xo/interpreter2/LocalEnv.hpp | 2 +- .../define/IGCObject_DVsmDefContFrame.hpp | 4 +- .../detail/IGCObject_DClosure.hpp | 4 +- .../detail/IGCObject_DLocalEnv.hpp | 67 ------------------- .../IGCObject_DVsmApplyClosureFrame.hpp | 4 +- .../detail/IGCObject_DVsmApplyFrame.hpp | 4 +- .../detail/IGCObject_DVsmEvalArgsFrame.hpp | 4 +- .../interpreter2/env/IGCObject_DLocalEnv.hpp | 4 +- .../ifelse/IGCObject_DVsmIfElseContFrame.hpp | 4 +- .../sequence/IGCObject_DVsmSeqContFrame.hpp | 4 +- .../IGCObject_DVirtualSchematikaMachine.hpp | 4 +- src/interpreter2/DVsmDefContFrame.cpp | 2 +- src/interpreter2/DVsmIfElseContFrame.cpp | 2 +- src/interpreter2/DVsmSeqContFrame.cpp | 2 +- src/interpreter2/IGCObject_DClosure.cpp | 3 +- .../IGCObject_DVsmApplyClosureFrame.cpp | 3 +- src/interpreter2/IGCObject_DVsmApplyFrame.cpp | 3 +- .../IGCObject_DVsmDefContFrame.cpp | 3 +- .../IGCObject_DVsmEvalArgsFrame.cpp | 3 +- .../IGCObject_DVsmIfElseContFrame.cpp | 3 +- .../IGCObject_DVsmSeqContFrame.cpp | 3 +- .../facet/IGCObject_DLocalEnv.cpp | 3 +- .../IGCObject_DVirtualSchematikaMachine.cpp | 3 +- 27 files changed, 34 insertions(+), 113 deletions(-) delete mode 100644 include/xo/interpreter2/detail/IGCObject_DLocalEnv.hpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d31bbd4c..18463e9d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -172,7 +172,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-localenv FACET_PKG xo_alloc2 -# REPR LocalEnv INPUT idl/IGCObject_DLocalEnv.json5 ) @@ -180,7 +179,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-localenv FACET_PKG xo_printable2 -# REPR LocalEnv INPUT idl/IPrintable_DLocalEnv.json5 ) @@ -189,7 +187,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-runtimecontext-vsmrcx FACET_PKG xo_procedure2 -# REPR DVsmRcx INPUT idl/IRuntimeContext_DVsmRcx.json5 ) diff --git a/include/xo/interpreter2/DVsmDefContFrame.hpp b/include/xo/interpreter2/DVsmDefContFrame.hpp index c0e6ed0f..249ead9c 100644 --- a/include/xo/interpreter2/DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/DVsmDefContFrame.hpp @@ -51,7 +51,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DVsmDefContFrame * shallow_copy(obj mm) const noexcept; + DVsmDefContFrame * shallow_copy(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/DVsmIfElseContFrame.hpp b/include/xo/interpreter2/DVsmIfElseContFrame.hpp index 8efd9299..af98b9a5 100644 --- a/include/xo/interpreter2/DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/DVsmIfElseContFrame.hpp @@ -51,7 +51,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DVsmIfElseContFrame * shallow_copy(obj mm) const noexcept; + DVsmIfElseContFrame * shallow_copy(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/DVsmSeqContFrame.hpp b/include/xo/interpreter2/DVsmSeqContFrame.hpp index 6b543d8b..bb4e64fc 100644 --- a/include/xo/interpreter2/DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/DVsmSeqContFrame.hpp @@ -56,7 +56,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DVsmSeqContFrame * shallow_copy(obj mm) const noexcept; + DVsmSeqContFrame * shallow_copy(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/LocalEnv.hpp b/include/xo/interpreter2/LocalEnv.hpp index 8955e35d..b1b302fd 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 "env/IGCObject_DLocalEnv.hpp" #include "detail/IPrintable_DLocalEnv.hpp" /* end LocalEnv.hpp */ diff --git a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp index f287f9fb..33192f6e 100644 --- a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DVsmDefContFrame & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DVsmDefContFrame & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DVsmDefContFrame & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmDefContFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp index 592b1640..67bb24ae 100644 --- a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -52,10 +52,10 @@ namespace xo { // 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 + /** copy instance using allocator **/ + static Opaque shallow_copy(DClosure & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DClosure & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/detail/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/detail/IGCObject_DLocalEnv.hpp deleted file mode 100644 index 25db925a..00000000 --- a/include/xo/interpreter2/detail/IGCObject_DLocalEnv.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/** @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 */ diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp index 1d455a71..6151d76b 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DVsmApplyClosureFrame & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DVsmApplyClosureFrame & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DVsmApplyClosureFrame & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmApplyClosureFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp index a2257125..384b5b32 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DVsmApplyFrame & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DVsmApplyFrame & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DVsmApplyFrame & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmApplyFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp index 3816203c..17651a71 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DVsmEvalArgsFrame & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DVsmEvalArgsFrame & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DVsmEvalArgsFrame & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmEvalArgsFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp index 93f1cce3..9d2cc682 100644 --- a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp @@ -52,10 +52,10 @@ namespace xo { // 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 + /** copy instance using allocator **/ + static Opaque shallow_copy(DLocalEnv & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DLocalEnv & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp index d62c896b..71afdd6a 100644 --- a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DVsmIfElseContFrame & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DVsmIfElseContFrame & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DVsmIfElseContFrame & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmIfElseContFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index acf77945..e778456d 100644 --- a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DVsmSeqContFrame & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DVsmSeqContFrame & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DVsmSeqContFrame & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmSeqContFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp index a9f61740..7b391c2f 100644 --- a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DVirtualSchematikaMachine & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DVirtualSchematikaMachine & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DVirtualSchematikaMachine & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVirtualSchematikaMachine & self, obj gc) noexcept; ///@} diff --git a/src/interpreter2/DVsmDefContFrame.cpp b/src/interpreter2/DVsmDefContFrame.cpp index 2d5c9adf..6d39d1f1 100644 --- a/src/interpreter2/DVsmDefContFrame.cpp +++ b/src/interpreter2/DVsmDefContFrame.cpp @@ -38,7 +38,7 @@ namespace xo { } DVsmDefContFrame * - DVsmDefContFrame::shallow_copy(obj mm) const noexcept + DVsmDefContFrame::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/interpreter2/DVsmIfElseContFrame.cpp b/src/interpreter2/DVsmIfElseContFrame.cpp index f47419e0..cc5427aa 100644 --- a/src/interpreter2/DVsmIfElseContFrame.cpp +++ b/src/interpreter2/DVsmIfElseContFrame.cpp @@ -36,7 +36,7 @@ namespace xo { } DVsmIfElseContFrame * - DVsmIfElseContFrame::shallow_copy(obj mm) const noexcept + DVsmIfElseContFrame::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/interpreter2/DVsmSeqContFrame.cpp b/src/interpreter2/DVsmSeqContFrame.cpp index 80c1665f..8a4fc555 100644 --- a/src/interpreter2/DVsmSeqContFrame.cpp +++ b/src/interpreter2/DVsmSeqContFrame.cpp @@ -39,7 +39,7 @@ namespace xo { } DVsmSeqContFrame * - DVsmSeqContFrame::shallow_copy(obj mm) const noexcept + DVsmSeqContFrame::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/interpreter2/IGCObject_DClosure.cpp b/src/interpreter2/IGCObject_DClosure.cpp index 28dd3277..be8edfc4 100644 --- a/src/interpreter2/IGCObject_DClosure.cpp +++ b/src/interpreter2/IGCObject_DClosure.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DClosure::shallow_copy(const DClosure & self, obj mm) noexcept -> Opaque + IGCObject_DClosure::shallow_copy(DClosure & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DClosure::forward_children(DClosure & self, obj gc) noexcept -> size_type { diff --git a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp index 7a05d47e..9bfd8cb3 100644 --- a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DVsmApplyClosureFrame::shallow_copy(const DVsmApplyClosureFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmApplyClosureFrame::shallow_copy(DVsmApplyClosureFrame & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DVsmApplyClosureFrame::forward_children(DVsmApplyClosureFrame & self, obj gc) noexcept -> size_type { diff --git a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp index 1e794477..0c544c22 100644 --- a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DVsmApplyFrame::shallow_copy(const DVsmApplyFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmApplyFrame::shallow_copy(DVsmApplyFrame & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DVsmApplyFrame::forward_children(DVsmApplyFrame & self, obj gc) noexcept -> size_type { diff --git a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp index 26a23611..c133e714 100644 --- a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DVsmDefContFrame::shallow_copy(const DVsmDefContFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmDefContFrame::shallow_copy(DVsmDefContFrame & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DVsmDefContFrame::forward_children(DVsmDefContFrame & self, obj gc) noexcept -> size_type { diff --git a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp index d64b47bd..13c72cfe 100644 --- a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DVsmEvalArgsFrame::shallow_copy(const DVsmEvalArgsFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmEvalArgsFrame::shallow_copy(DVsmEvalArgsFrame & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DVsmEvalArgsFrame::forward_children(DVsmEvalArgsFrame & self, obj gc) noexcept -> size_type { diff --git a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp index ba66cd8d..e28d5121 100644 --- a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DVsmIfElseContFrame::shallow_copy(const DVsmIfElseContFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmIfElseContFrame::shallow_copy(DVsmIfElseContFrame & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DVsmIfElseContFrame::forward_children(DVsmIfElseContFrame & self, obj gc) noexcept -> size_type { diff --git a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp index eecdf291..8bdbd2fc 100644 --- a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DVsmSeqContFrame::shallow_copy(const DVsmSeqContFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmSeqContFrame::shallow_copy(DVsmSeqContFrame & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DVsmSeqContFrame::forward_children(DVsmSeqContFrame & self, obj gc) noexcept -> size_type { diff --git a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp index 3b6cd5f7..7e36de26 100644 --- a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp +++ b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DLocalEnv::shallow_copy(const DLocalEnv & self, obj mm) noexcept -> Opaque + IGCObject_DLocalEnv::shallow_copy(DLocalEnv & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DLocalEnv::forward_children(DLocalEnv & self, obj gc) noexcept -> size_type { diff --git a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp index 557990f8..acb698ac 100644 --- a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DVirtualSchematikaMachine::shallow_copy(const DVirtualSchematikaMachine & self, obj mm) noexcept -> Opaque + IGCObject_DVirtualSchematikaMachine::shallow_copy(DVirtualSchematikaMachine & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DVirtualSchematikaMachine::forward_children(DVirtualSchematikaMachine & self, obj gc) noexcept -> size_type { From bd88f441fcf96a3934729d5ebce61274425a7613 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 15:00:53 -0400 Subject: [PATCH 117/131] refactor: rename GCObject.shallow_copy -> shallow_move resolve conflict since relying on move constructor in std_copy_for --- include/xo/interpreter2/DClosure.hpp | 2 +- include/xo/interpreter2/DLocalEnv.hpp | 2 +- include/xo/interpreter2/DVsmApplyClosureFrame.hpp | 2 +- include/xo/interpreter2/DVsmApplyFrame.hpp | 2 +- include/xo/interpreter2/DVsmDefContFrame.hpp | 2 +- include/xo/interpreter2/DVsmEvalArgsFrame.hpp | 2 +- include/xo/interpreter2/DVsmIfElseContFrame.hpp | 2 +- include/xo/interpreter2/DVsmSeqContFrame.hpp | 2 +- include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp | 4 ++-- include/xo/interpreter2/detail/IGCObject_DClosure.hpp | 4 ++-- .../interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp | 4 ++-- include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp | 4 ++-- .../xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp | 4 ++-- include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp | 4 ++-- .../xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp | 4 ++-- .../xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp | 4 ++-- include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp | 2 +- .../interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp | 4 ++-- src/interpreter2/DClosure.cpp | 2 +- src/interpreter2/DLocalEnv.cpp | 2 +- src/interpreter2/DVirtualSchematikaMachine.cpp | 2 +- src/interpreter2/DVsmApplyClosureFrame.cpp | 2 +- src/interpreter2/DVsmApplyFrame.cpp | 2 +- src/interpreter2/DVsmDefContFrame.cpp | 2 +- src/interpreter2/DVsmEvalArgsFrame.cpp | 2 +- src/interpreter2/DVsmIfElseContFrame.cpp | 2 +- src/interpreter2/DVsmSeqContFrame.cpp | 2 +- src/interpreter2/IGCObject_DClosure.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmApplyFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmDefContFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmSeqContFrame.cpp | 4 ++-- src/interpreter2/facet/IGCObject_DLocalEnv.cpp | 4 ++-- .../facet/IGCObject_DVirtualSchematikaMachine.cpp | 4 ++-- 36 files changed, 54 insertions(+), 54 deletions(-) diff --git a/include/xo/interpreter2/DClosure.hpp b/include/xo/interpreter2/DClosure.hpp index 26ff2703..aef74663 100644 --- a/include/xo/interpreter2/DClosure.hpp +++ b/include/xo/interpreter2/DClosure.hpp @@ -58,7 +58,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DClosure * shallow_copy(obj mm) const noexcept; + DClosure * shallow_move(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/DLocalEnv.hpp b/include/xo/interpreter2/DLocalEnv.hpp index ab407063..76cac024 100644 --- a/include/xo/interpreter2/DLocalEnv.hpp +++ b/include/xo/interpreter2/DLocalEnv.hpp @@ -55,7 +55,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DLocalEnv * shallow_copy(obj mm) const noexcept; + DLocalEnv * shallow_move(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp index 168fa1a3..718c52b3 100644 --- a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp @@ -40,7 +40,7 @@ namespace xo { /** gcobject facet **/ std::size_t shallow_size() const noexcept; - DVsmApplyClosureFrame * shallow_copy(obj mm) const noexcept; + DVsmApplyClosureFrame * shallow_move(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; /** pretty-printing support **/ diff --git a/include/xo/interpreter2/DVsmApplyFrame.hpp b/include/xo/interpreter2/DVsmApplyFrame.hpp index 47735afe..d761cd18 100644 --- a/include/xo/interpreter2/DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyFrame.hpp @@ -38,7 +38,7 @@ namespace xo { void assign_fn(obj x) { this->fn_ = x; } std::size_t shallow_size() const noexcept; - DVsmApplyFrame * shallow_copy(obj mm) const noexcept; + DVsmApplyFrame * shallow_move(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; /** pretty-printing support **/ diff --git a/include/xo/interpreter2/DVsmDefContFrame.hpp b/include/xo/interpreter2/DVsmDefContFrame.hpp index 249ead9c..d128d357 100644 --- a/include/xo/interpreter2/DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/DVsmDefContFrame.hpp @@ -51,7 +51,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DVsmDefContFrame * shallow_copy(obj mm) noexcept; + DVsmDefContFrame * shallow_move(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp index e3b8b2b5..c389f214 100644 --- a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp @@ -43,7 +43,7 @@ namespace xo { int32_t increment_arg() { return ++i_arg_; } std::size_t shallow_size() const noexcept; - DVsmEvalArgsFrame * shallow_copy(obj mm) const noexcept; + DVsmEvalArgsFrame * shallow_move(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; bool pretty(const ppindentinfo & ppii) const; diff --git a/include/xo/interpreter2/DVsmIfElseContFrame.hpp b/include/xo/interpreter2/DVsmIfElseContFrame.hpp index af98b9a5..09fcd076 100644 --- a/include/xo/interpreter2/DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/DVsmIfElseContFrame.hpp @@ -51,7 +51,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DVsmIfElseContFrame * shallow_copy(obj mm) noexcept; + DVsmIfElseContFrame * shallow_move(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/DVsmSeqContFrame.hpp b/include/xo/interpreter2/DVsmSeqContFrame.hpp index bb4e64fc..4692425b 100644 --- a/include/xo/interpreter2/DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/DVsmSeqContFrame.hpp @@ -56,7 +56,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DVsmSeqContFrame * shallow_copy(obj mm) noexcept; + DVsmSeqContFrame * shallow_move(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp index 33192f6e..f4a7c4d1 100644 --- a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DVsmDefContFrame & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DVsmDefContFrame & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DVsmDefContFrame & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmDefContFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp index 67bb24ae..d5933283 100644 --- a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DClosure & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DClosure & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DClosure & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DClosure & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp index 6151d76b..ab9e223a 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DVsmApplyClosureFrame & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DVsmApplyClosureFrame & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DVsmApplyClosureFrame & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmApplyClosureFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp index 384b5b32..aa65d6e9 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DVsmApplyFrame & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DVsmApplyFrame & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DVsmApplyFrame & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmApplyFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp index 17651a71..57d28ebe 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DVsmEvalArgsFrame & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DVsmEvalArgsFrame & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DVsmEvalArgsFrame & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmEvalArgsFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp index 9d2cc682..7105768a 100644 --- a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DLocalEnv & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DLocalEnv & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DLocalEnv & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DLocalEnv & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp index 71afdd6a..63e3ad2a 100644 --- a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DVsmIfElseContFrame & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DVsmIfElseContFrame & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DVsmIfElseContFrame & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmIfElseContFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index e778456d..a657a217 100644 --- a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DVsmSeqContFrame & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DVsmSeqContFrame & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DVsmSeqContFrame & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmSeqContFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp index e6badf83..ecaac469 100644 --- a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp @@ -153,7 +153,7 @@ namespace xo { /** shallow copy during gc cycle. Not implemented! Only intending to support * VSM as virtual root **/ - DVirtualSchematikaMachine * shallow_copy(obj mm) const noexcept; + DVirtualSchematikaMachine * shallow_move(obj mm) const noexcept; /** forward gc-aware child pointers **/ diff --git a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp index 7b391c2f..6f7c0eb8 100644 --- a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DVirtualSchematikaMachine & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DVirtualSchematikaMachine & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DVirtualSchematikaMachine & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVirtualSchematikaMachine & self, obj gc) noexcept; ///@} diff --git a/src/interpreter2/DClosure.cpp b/src/interpreter2/DClosure.cpp index e052ca4d..ed95334f 100644 --- a/src/interpreter2/DClosure.cpp +++ b/src/interpreter2/DClosure.cpp @@ -70,7 +70,7 @@ namespace xo { } DClosure * - DClosure::shallow_copy(obj mm) const noexcept { + DClosure::shallow_move(obj mm) const noexcept { DClosure * copy = (DClosure *)mm.alloc_copy((std::byte *)this); if (copy) diff --git a/src/interpreter2/DLocalEnv.cpp b/src/interpreter2/DLocalEnv.cpp index 3831b647..94f27422 100644 --- a/src/interpreter2/DLocalEnv.cpp +++ b/src/interpreter2/DLocalEnv.cpp @@ -97,7 +97,7 @@ namespace xo { } DLocalEnv * - DLocalEnv::shallow_copy(obj mm) const noexcept { + DLocalEnv::shallow_move(obj mm) const noexcept { DLocalEnv * copy = (DLocalEnv *)mm.alloc_copy((std::byte *)this); if (copy) diff --git a/src/interpreter2/DVirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp index f9977eb9..a196363e 100644 --- a/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -954,7 +954,7 @@ namespace xo { } DVirtualSchematikaMachine * - DVirtualSchematikaMachine::shallow_copy(obj mm) const noexcept + DVirtualSchematikaMachine::shallow_move(obj mm) const noexcept { (void)mm; diff --git a/src/interpreter2/DVsmApplyClosureFrame.cpp b/src/interpreter2/DVsmApplyClosureFrame.cpp index 26a215a4..d2cfdb35 100644 --- a/src/interpreter2/DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/DVsmApplyClosureFrame.cpp @@ -39,7 +39,7 @@ namespace xo { } DVsmApplyClosureFrame * - DVsmApplyClosureFrame::shallow_copy(obj mm) const noexcept + DVsmApplyClosureFrame::shallow_move(obj mm) const noexcept { DVsmApplyClosureFrame * copy = (DVsmApplyClosureFrame *)mm.alloc_copy((std::byte *)this); diff --git a/src/interpreter2/DVsmApplyFrame.cpp b/src/interpreter2/DVsmApplyFrame.cpp index 72b81405..9a50c117 100644 --- a/src/interpreter2/DVsmApplyFrame.cpp +++ b/src/interpreter2/DVsmApplyFrame.cpp @@ -47,7 +47,7 @@ namespace xo { } DVsmApplyFrame * - DVsmApplyFrame::shallow_copy(obj mm) const noexcept + DVsmApplyFrame::shallow_move(obj mm) const noexcept { DVsmApplyFrame * copy = (DVsmApplyFrame *)mm.alloc_copy((std::byte *)this); diff --git a/src/interpreter2/DVsmDefContFrame.cpp b/src/interpreter2/DVsmDefContFrame.cpp index 6d39d1f1..d1f3e2b2 100644 --- a/src/interpreter2/DVsmDefContFrame.cpp +++ b/src/interpreter2/DVsmDefContFrame.cpp @@ -38,7 +38,7 @@ namespace xo { } DVsmDefContFrame * - DVsmDefContFrame::shallow_copy(obj mm) noexcept + DVsmDefContFrame::shallow_move(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/interpreter2/DVsmEvalArgsFrame.cpp b/src/interpreter2/DVsmEvalArgsFrame.cpp index 09439f2e..0ff4ceb2 100644 --- a/src/interpreter2/DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/DVsmEvalArgsFrame.cpp @@ -48,7 +48,7 @@ namespace xo { } DVsmEvalArgsFrame * - DVsmEvalArgsFrame::shallow_copy(obj mm) const noexcept + DVsmEvalArgsFrame::shallow_move(obj mm) const noexcept { DVsmEvalArgsFrame * copy = (DVsmEvalArgsFrame *)mm.alloc_copy((std::byte *)this); diff --git a/src/interpreter2/DVsmIfElseContFrame.cpp b/src/interpreter2/DVsmIfElseContFrame.cpp index cc5427aa..075f7bd3 100644 --- a/src/interpreter2/DVsmIfElseContFrame.cpp +++ b/src/interpreter2/DVsmIfElseContFrame.cpp @@ -36,7 +36,7 @@ namespace xo { } DVsmIfElseContFrame * - DVsmIfElseContFrame::shallow_copy(obj mm) noexcept + DVsmIfElseContFrame::shallow_move(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/interpreter2/DVsmSeqContFrame.cpp b/src/interpreter2/DVsmSeqContFrame.cpp index 8a4fc555..d6160e8d 100644 --- a/src/interpreter2/DVsmSeqContFrame.cpp +++ b/src/interpreter2/DVsmSeqContFrame.cpp @@ -39,7 +39,7 @@ namespace xo { } DVsmSeqContFrame * - DVsmSeqContFrame::shallow_copy(obj mm) noexcept + DVsmSeqContFrame::shallow_move(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/interpreter2/IGCObject_DClosure.cpp b/src/interpreter2/IGCObject_DClosure.cpp index be8edfc4..33544907 100644 --- a/src/interpreter2/IGCObject_DClosure.cpp +++ b/src/interpreter2/IGCObject_DClosure.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DClosure::shallow_copy(DClosure & self, obj mm) noexcept -> Opaque + IGCObject_DClosure::shallow_move(DClosure & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DClosure::forward_children(DClosure & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp index 9bfd8cb3..3aa994fd 100644 --- a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVsmApplyClosureFrame::shallow_copy(DVsmApplyClosureFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmApplyClosureFrame::shallow_move(DVsmApplyClosureFrame & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DVsmApplyClosureFrame::forward_children(DVsmApplyClosureFrame & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp index 0c544c22..a1da32b8 100644 --- a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVsmApplyFrame::shallow_copy(DVsmApplyFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmApplyFrame::shallow_move(DVsmApplyFrame & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DVsmApplyFrame::forward_children(DVsmApplyFrame & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp index c133e714..02abd4cb 100644 --- a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVsmDefContFrame::shallow_copy(DVsmDefContFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmDefContFrame::shallow_move(DVsmDefContFrame & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DVsmDefContFrame::forward_children(DVsmDefContFrame & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp index 13c72cfe..8f33ece1 100644 --- a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVsmEvalArgsFrame::shallow_copy(DVsmEvalArgsFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmEvalArgsFrame::shallow_move(DVsmEvalArgsFrame & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DVsmEvalArgsFrame::forward_children(DVsmEvalArgsFrame & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp index e28d5121..939d7ce4 100644 --- a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVsmIfElseContFrame::shallow_copy(DVsmIfElseContFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmIfElseContFrame::shallow_move(DVsmIfElseContFrame & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DVsmIfElseContFrame::forward_children(DVsmIfElseContFrame & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp index 8bdbd2fc..5d52ae74 100644 --- a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVsmSeqContFrame::shallow_copy(DVsmSeqContFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmSeqContFrame::shallow_move(DVsmSeqContFrame & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DVsmSeqContFrame::forward_children(DVsmSeqContFrame & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp index 7e36de26..61e645f6 100644 --- a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp +++ b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DLocalEnv::shallow_copy(DLocalEnv & self, obj mm) noexcept -> Opaque + IGCObject_DLocalEnv::shallow_move(DLocalEnv & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DLocalEnv::forward_children(DLocalEnv & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp index acb698ac..354478ad 100644 --- a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVirtualSchematikaMachine::shallow_copy(DVirtualSchematikaMachine & self, obj mm) noexcept -> Opaque + IGCObject_DVirtualSchematikaMachine::shallow_move(DVirtualSchematikaMachine & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DVirtualSchematikaMachine::forward_children(DVirtualSchematikaMachine & self, obj gc) noexcept -> size_type From e179c9795bce6eedd405e18801e33dcc68e411c2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 16:33:35 -0400 Subject: [PATCH 118/131] refactor: rename shallow_copy -> shallow_move + streamline Use RCollector.std_copy_for where appropriate --- include/xo/interpreter2/DClosure.hpp | 2 +- include/xo/interpreter2/DLocalEnv.hpp | 2 +- include/xo/interpreter2/DVsmApplyClosureFrame.hpp | 2 +- include/xo/interpreter2/DVsmApplyFrame.hpp | 2 +- include/xo/interpreter2/DVsmDefContFrame.hpp | 2 +- include/xo/interpreter2/DVsmEvalArgsFrame.hpp | 2 +- include/xo/interpreter2/DVsmIfElseContFrame.hpp | 2 +- include/xo/interpreter2/DVsmSeqContFrame.hpp | 2 +- .../interpreter2/define/IGCObject_DVsmDefContFrame.hpp | 2 +- include/xo/interpreter2/detail/IGCObject_DClosure.hpp | 2 +- .../detail/IGCObject_DVsmApplyClosureFrame.hpp | 2 +- .../interpreter2/detail/IGCObject_DVsmApplyFrame.hpp | 2 +- .../detail/IGCObject_DVsmEvalArgsFrame.hpp | 2 +- include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp | 2 +- .../ifelse/IGCObject_DVsmIfElseContFrame.hpp | 2 +- .../sequence/IGCObject_DVsmSeqContFrame.hpp | 2 +- .../xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp | 2 +- .../vsm/IGCObject_DVirtualSchematikaMachine.hpp | 2 +- src/interpreter2/DClosure.cpp | 9 ++------- src/interpreter2/DLocalEnv.cpp | 9 ++------- src/interpreter2/DVirtualSchematikaMachine.cpp | 9 ++++++--- src/interpreter2/DVsmApplyClosureFrame.cpp | 10 ++-------- src/interpreter2/DVsmApplyFrame.cpp | 9 ++------- src/interpreter2/DVsmDefContFrame.cpp | 4 ++-- src/interpreter2/DVsmEvalArgsFrame.cpp | 10 ++-------- src/interpreter2/DVsmIfElseContFrame.cpp | 4 ++-- src/interpreter2/DVsmSeqContFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DClosure.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmApplyFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmDefContFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmSeqContFrame.cpp | 4 ++-- src/interpreter2/facet/IGCObject_DLocalEnv.cpp | 4 ++-- .../facet/IGCObject_DVirtualSchematikaMachine.cpp | 4 ++-- 36 files changed, 58 insertions(+), 82 deletions(-) diff --git a/include/xo/interpreter2/DClosure.hpp b/include/xo/interpreter2/DClosure.hpp index aef74663..e57f6a1a 100644 --- a/include/xo/interpreter2/DClosure.hpp +++ b/include/xo/interpreter2/DClosure.hpp @@ -58,7 +58,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DClosure * shallow_move(obj mm) const noexcept; + DClosure * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/DLocalEnv.hpp b/include/xo/interpreter2/DLocalEnv.hpp index 76cac024..6ecd3eb6 100644 --- a/include/xo/interpreter2/DLocalEnv.hpp +++ b/include/xo/interpreter2/DLocalEnv.hpp @@ -55,7 +55,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DLocalEnv * shallow_move(obj mm) const noexcept; + DLocalEnv * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp index 718c52b3..ae422cb1 100644 --- a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp @@ -40,7 +40,7 @@ namespace xo { /** gcobject facet **/ std::size_t shallow_size() const noexcept; - DVsmApplyClosureFrame * shallow_move(obj mm) const noexcept; + DVsmApplyClosureFrame * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; /** pretty-printing support **/ diff --git a/include/xo/interpreter2/DVsmApplyFrame.hpp b/include/xo/interpreter2/DVsmApplyFrame.hpp index d761cd18..99093f37 100644 --- a/include/xo/interpreter2/DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyFrame.hpp @@ -38,7 +38,7 @@ namespace xo { void assign_fn(obj x) { this->fn_ = x; } std::size_t shallow_size() const noexcept; - DVsmApplyFrame * shallow_move(obj mm) const noexcept; + DVsmApplyFrame * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; /** pretty-printing support **/ diff --git a/include/xo/interpreter2/DVsmDefContFrame.hpp b/include/xo/interpreter2/DVsmDefContFrame.hpp index d128d357..0ad31cca 100644 --- a/include/xo/interpreter2/DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/DVsmDefContFrame.hpp @@ -51,7 +51,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DVsmDefContFrame * shallow_move(obj mm) noexcept; + DVsmDefContFrame * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp index c389f214..a1903e94 100644 --- a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp @@ -43,7 +43,7 @@ namespace xo { int32_t increment_arg() { return ++i_arg_; } std::size_t shallow_size() const noexcept; - DVsmEvalArgsFrame * shallow_move(obj mm) const noexcept; + DVsmEvalArgsFrame * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; bool pretty(const ppindentinfo & ppii) const; diff --git a/include/xo/interpreter2/DVsmIfElseContFrame.hpp b/include/xo/interpreter2/DVsmIfElseContFrame.hpp index 09fcd076..3c438e51 100644 --- a/include/xo/interpreter2/DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/DVsmIfElseContFrame.hpp @@ -51,7 +51,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DVsmIfElseContFrame * shallow_move(obj mm) noexcept; + DVsmIfElseContFrame * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/DVsmSeqContFrame.hpp b/include/xo/interpreter2/DVsmSeqContFrame.hpp index 4692425b..959edfb0 100644 --- a/include/xo/interpreter2/DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/DVsmSeqContFrame.hpp @@ -56,7 +56,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DVsmSeqContFrame * shallow_move(obj mm) noexcept; + DVsmSeqContFrame * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp index f4a7c4d1..4cb21afa 100644 --- a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DVsmDefContFrame & self, obj mm) noexcept; + static Opaque shallow_move(DVsmDefContFrame & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmDefContFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp index d5933283..86becbdf 100644 --- a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DClosure & self, obj mm) noexcept; + static Opaque shallow_move(DClosure & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DClosure & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp index ab9e223a..01bef341 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DVsmApplyClosureFrame & self, obj mm) noexcept; + static Opaque shallow_move(DVsmApplyClosureFrame & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmApplyClosureFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp index aa65d6e9..a3e0d31b 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DVsmApplyFrame & self, obj mm) noexcept; + static Opaque shallow_move(DVsmApplyFrame & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmApplyFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp index 57d28ebe..42c26b03 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DVsmEvalArgsFrame & self, obj mm) noexcept; + static Opaque shallow_move(DVsmEvalArgsFrame & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmEvalArgsFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp index 7105768a..55064b27 100644 --- a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DLocalEnv & self, obj mm) noexcept; + static Opaque shallow_move(DLocalEnv & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DLocalEnv & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp index 63e3ad2a..ab9a13c8 100644 --- a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DVsmIfElseContFrame & self, obj mm) noexcept; + static Opaque shallow_move(DVsmIfElseContFrame & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmIfElseContFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index a657a217..d654d8a1 100644 --- a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DVsmSeqContFrame & self, obj mm) noexcept; + static Opaque shallow_move(DVsmSeqContFrame & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVsmSeqContFrame & self, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp index ecaac469..fa9a6929 100644 --- a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp @@ -153,7 +153,7 @@ namespace xo { /** shallow copy during gc cycle. Not implemented! Only intending to support * VSM as virtual root **/ - DVirtualSchematikaMachine * shallow_move(obj mm) const noexcept; + DVirtualSchematikaMachine * shallow_move(obj gc) noexcept; /** forward gc-aware child pointers **/ diff --git a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp index 6f7c0eb8..71786a28 100644 --- a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DVirtualSchematikaMachine & self, obj mm) noexcept; + static Opaque shallow_move(DVirtualSchematikaMachine & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVirtualSchematikaMachine & self, obj gc) noexcept; ///@} diff --git a/src/interpreter2/DClosure.cpp b/src/interpreter2/DClosure.cpp index ed95334f..ca8f3bee 100644 --- a/src/interpreter2/DClosure.cpp +++ b/src/interpreter2/DClosure.cpp @@ -70,13 +70,8 @@ namespace xo { } DClosure * - DClosure::shallow_move(obj mm) const noexcept { - DClosure * copy = (DClosure *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + DClosure::shallow_move(obj gc) noexcept { + return gc.std_copy_for(this); } std::size_t diff --git a/src/interpreter2/DLocalEnv.cpp b/src/interpreter2/DLocalEnv.cpp index 94f27422..a12200a0 100644 --- a/src/interpreter2/DLocalEnv.cpp +++ b/src/interpreter2/DLocalEnv.cpp @@ -97,13 +97,8 @@ namespace xo { } DLocalEnv * - DLocalEnv::shallow_move(obj mm) const noexcept { - DLocalEnv * copy = (DLocalEnv *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + DLocalEnv::shallow_move(obj gc) noexcept { + return gc.std_copy_for(this); } std::size_t diff --git a/src/interpreter2/DVirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp index a196363e..5ccb333c 100644 --- a/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -954,11 +954,14 @@ namespace xo { } DVirtualSchematikaMachine * - DVirtualSchematikaMachine::shallow_move(obj mm) const noexcept + DVirtualSchematikaMachine::shallow_move(obj gc) noexcept { - (void)mm; + (void)gc; - /** not copyable (because SchematikaReader isn't) **/ + /** TODO: should be able to use gc.std_copy_for(this) now + * that shallow_move uses move construction. + * DVirtualSchematikaMachine is (or can be made) moveable. + **/ assert(false); diff --git a/src/interpreter2/DVsmApplyClosureFrame.cpp b/src/interpreter2/DVsmApplyClosureFrame.cpp index d2cfdb35..c7dca412 100644 --- a/src/interpreter2/DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/DVsmApplyClosureFrame.cpp @@ -39,15 +39,9 @@ namespace xo { } DVsmApplyClosureFrame * - DVsmApplyClosureFrame::shallow_move(obj mm) const noexcept + DVsmApplyClosureFrame::shallow_move(obj gc) noexcept { - DVsmApplyClosureFrame * copy - = (DVsmApplyClosureFrame *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } std::size_t diff --git a/src/interpreter2/DVsmApplyFrame.cpp b/src/interpreter2/DVsmApplyFrame.cpp index 9a50c117..f51742f7 100644 --- a/src/interpreter2/DVsmApplyFrame.cpp +++ b/src/interpreter2/DVsmApplyFrame.cpp @@ -47,14 +47,9 @@ namespace xo { } DVsmApplyFrame * - DVsmApplyFrame::shallow_move(obj mm) const noexcept + DVsmApplyFrame::shallow_move(obj gc) noexcept { - DVsmApplyFrame * copy = (DVsmApplyFrame *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } std::size_t diff --git a/src/interpreter2/DVsmDefContFrame.cpp b/src/interpreter2/DVsmDefContFrame.cpp index d1f3e2b2..f3a8b35b 100644 --- a/src/interpreter2/DVsmDefContFrame.cpp +++ b/src/interpreter2/DVsmDefContFrame.cpp @@ -38,9 +38,9 @@ namespace xo { } DVsmDefContFrame * - DVsmDefContFrame::shallow_move(obj mm) noexcept + DVsmDefContFrame::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } std::size_t diff --git a/src/interpreter2/DVsmEvalArgsFrame.cpp b/src/interpreter2/DVsmEvalArgsFrame.cpp index 0ff4ceb2..c487ae59 100644 --- a/src/interpreter2/DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/DVsmEvalArgsFrame.cpp @@ -48,15 +48,9 @@ namespace xo { } DVsmEvalArgsFrame * - DVsmEvalArgsFrame::shallow_move(obj mm) const noexcept + DVsmEvalArgsFrame::shallow_move(obj gc) noexcept { - DVsmEvalArgsFrame * copy - = (DVsmEvalArgsFrame *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } std::size_t diff --git a/src/interpreter2/DVsmIfElseContFrame.cpp b/src/interpreter2/DVsmIfElseContFrame.cpp index 075f7bd3..4978ff9c 100644 --- a/src/interpreter2/DVsmIfElseContFrame.cpp +++ b/src/interpreter2/DVsmIfElseContFrame.cpp @@ -36,9 +36,9 @@ namespace xo { } DVsmIfElseContFrame * - DVsmIfElseContFrame::shallow_move(obj mm) noexcept + DVsmIfElseContFrame::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } std::size_t diff --git a/src/interpreter2/DVsmSeqContFrame.cpp b/src/interpreter2/DVsmSeqContFrame.cpp index d6160e8d..7ffea82e 100644 --- a/src/interpreter2/DVsmSeqContFrame.cpp +++ b/src/interpreter2/DVsmSeqContFrame.cpp @@ -39,9 +39,9 @@ namespace xo { } DVsmSeqContFrame * - DVsmSeqContFrame::shallow_move(obj mm) noexcept + DVsmSeqContFrame::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } std::size_t diff --git a/src/interpreter2/IGCObject_DClosure.cpp b/src/interpreter2/IGCObject_DClosure.cpp index 33544907..99e834b8 100644 --- a/src/interpreter2/IGCObject_DClosure.cpp +++ b/src/interpreter2/IGCObject_DClosure.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DClosure::shallow_move(DClosure & self, obj mm) noexcept -> Opaque + IGCObject_DClosure::shallow_move(DClosure & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DClosure::forward_children(DClosure & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp index 3aa994fd..a96ad2d7 100644 --- a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVsmApplyClosureFrame::shallow_move(DVsmApplyClosureFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmApplyClosureFrame::shallow_move(DVsmApplyClosureFrame & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DVsmApplyClosureFrame::forward_children(DVsmApplyClosureFrame & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp index a1da32b8..9666fdec 100644 --- a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVsmApplyFrame::shallow_move(DVsmApplyFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmApplyFrame::shallow_move(DVsmApplyFrame & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DVsmApplyFrame::forward_children(DVsmApplyFrame & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp index 02abd4cb..2acd7b24 100644 --- a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVsmDefContFrame::shallow_move(DVsmDefContFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmDefContFrame::shallow_move(DVsmDefContFrame & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DVsmDefContFrame::forward_children(DVsmDefContFrame & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp index 8f33ece1..d1d6a0b6 100644 --- a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVsmEvalArgsFrame::shallow_move(DVsmEvalArgsFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmEvalArgsFrame::shallow_move(DVsmEvalArgsFrame & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DVsmEvalArgsFrame::forward_children(DVsmEvalArgsFrame & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp index 939d7ce4..38f4881d 100644 --- a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVsmIfElseContFrame::shallow_move(DVsmIfElseContFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmIfElseContFrame::shallow_move(DVsmIfElseContFrame & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DVsmIfElseContFrame::forward_children(DVsmIfElseContFrame & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp index 5d52ae74..3d57aaa1 100644 --- a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVsmSeqContFrame::shallow_move(DVsmSeqContFrame & self, obj mm) noexcept -> Opaque + IGCObject_DVsmSeqContFrame::shallow_move(DVsmSeqContFrame & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DVsmSeqContFrame::forward_children(DVsmSeqContFrame & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp index 61e645f6..ed9f18fd 100644 --- a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp +++ b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DLocalEnv::shallow_move(DLocalEnv & self, obj mm) noexcept -> Opaque + IGCObject_DLocalEnv::shallow_move(DLocalEnv & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DLocalEnv::forward_children(DLocalEnv & self, obj gc) noexcept -> size_type diff --git a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp index 354478ad..ddf77335 100644 --- a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVirtualSchematikaMachine::shallow_move(DVirtualSchematikaMachine & self, obj mm) noexcept -> Opaque + IGCObject_DVirtualSchematikaMachine::shallow_move(DVirtualSchematikaMachine & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DVirtualSchematikaMachine::forward_children(DVirtualSchematikaMachine & self, obj gc) noexcept -> size_type From a0de9b8ebd6c05e01c34fb84cb055b11b9a3c4e7 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 16:37:17 -0400 Subject: [PATCH 119/131] refactor: rename RCollector.std_copy_for -> std_move_for --- src/interpreter2/DClosure.cpp | 2 +- src/interpreter2/DLocalEnv.cpp | 2 +- src/interpreter2/DVirtualSchematikaMachine.cpp | 2 +- src/interpreter2/DVsmApplyClosureFrame.cpp | 2 +- src/interpreter2/DVsmApplyFrame.cpp | 2 +- src/interpreter2/DVsmDefContFrame.cpp | 2 +- src/interpreter2/DVsmEvalArgsFrame.cpp | 2 +- src/interpreter2/DVsmIfElseContFrame.cpp | 2 +- src/interpreter2/DVsmSeqContFrame.cpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/interpreter2/DClosure.cpp b/src/interpreter2/DClosure.cpp index ca8f3bee..6b346463 100644 --- a/src/interpreter2/DClosure.cpp +++ b/src/interpreter2/DClosure.cpp @@ -71,7 +71,7 @@ namespace xo { DClosure * DClosure::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/interpreter2/DLocalEnv.cpp b/src/interpreter2/DLocalEnv.cpp index a12200a0..4124e280 100644 --- a/src/interpreter2/DLocalEnv.cpp +++ b/src/interpreter2/DLocalEnv.cpp @@ -98,7 +98,7 @@ namespace xo { DLocalEnv * DLocalEnv::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/interpreter2/DVirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp index 5ccb333c..06a4c23f 100644 --- a/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -958,7 +958,7 @@ namespace xo { { (void)gc; - /** TODO: should be able to use gc.std_copy_for(this) now + /** TODO: should be able to use gc.std_move_for(this) now * that shallow_move uses move construction. * DVirtualSchematikaMachine is (or can be made) moveable. **/ diff --git a/src/interpreter2/DVsmApplyClosureFrame.cpp b/src/interpreter2/DVsmApplyClosureFrame.cpp index c7dca412..129d0d46 100644 --- a/src/interpreter2/DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/DVsmApplyClosureFrame.cpp @@ -41,7 +41,7 @@ namespace xo { DVsmApplyClosureFrame * DVsmApplyClosureFrame::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/interpreter2/DVsmApplyFrame.cpp b/src/interpreter2/DVsmApplyFrame.cpp index f51742f7..d388f9c4 100644 --- a/src/interpreter2/DVsmApplyFrame.cpp +++ b/src/interpreter2/DVsmApplyFrame.cpp @@ -49,7 +49,7 @@ namespace xo { DVsmApplyFrame * DVsmApplyFrame::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/interpreter2/DVsmDefContFrame.cpp b/src/interpreter2/DVsmDefContFrame.cpp index f3a8b35b..02094534 100644 --- a/src/interpreter2/DVsmDefContFrame.cpp +++ b/src/interpreter2/DVsmDefContFrame.cpp @@ -40,7 +40,7 @@ namespace xo { DVsmDefContFrame * DVsmDefContFrame::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/interpreter2/DVsmEvalArgsFrame.cpp b/src/interpreter2/DVsmEvalArgsFrame.cpp index c487ae59..204bfb44 100644 --- a/src/interpreter2/DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/DVsmEvalArgsFrame.cpp @@ -50,7 +50,7 @@ namespace xo { DVsmEvalArgsFrame * DVsmEvalArgsFrame::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/interpreter2/DVsmIfElseContFrame.cpp b/src/interpreter2/DVsmIfElseContFrame.cpp index 4978ff9c..511af900 100644 --- a/src/interpreter2/DVsmIfElseContFrame.cpp +++ b/src/interpreter2/DVsmIfElseContFrame.cpp @@ -38,7 +38,7 @@ namespace xo { DVsmIfElseContFrame * DVsmIfElseContFrame::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/interpreter2/DVsmSeqContFrame.cpp b/src/interpreter2/DVsmSeqContFrame.cpp index 7ffea82e..ad006def 100644 --- a/src/interpreter2/DVsmSeqContFrame.cpp +++ b/src/interpreter2/DVsmSeqContFrame.cpp @@ -41,7 +41,7 @@ namespace xo { DVsmSeqContFrame * DVsmSeqContFrame::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t From 8a9ddf4c55b68edd3212605295c570cc860aec2e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 16:54:46 -0400 Subject: [PATCH 120/131] refactor: void return type for Collector.forward_children() --- include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp | 2 +- include/xo/interpreter2/detail/IGCObject_DClosure.hpp | 2 +- .../interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp | 2 +- include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp | 2 +- .../xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp | 2 +- include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp | 2 +- .../xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp | 2 +- .../xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp | 2 +- .../interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp | 2 +- src/interpreter2/IGCObject_DClosure.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmApplyFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmDefContFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmSeqContFrame.cpp | 4 ++-- src/interpreter2/facet/IGCObject_DLocalEnv.cpp | 4 ++-- .../facet/IGCObject_DVirtualSchematikaMachine.cpp | 4 ++-- 18 files changed, 27 insertions(+), 27 deletions(-) diff --git a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp index 4cb21afa..131d57ae 100644 --- a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DVsmDefContFrame & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DVsmDefContFrame & self, obj gc) noexcept; + static void forward_children(DVsmDefContFrame & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp index 86becbdf..c0d7d22b 100644 --- a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DClosure & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DClosure & self, obj gc) noexcept; + static void forward_children(DClosure & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp index 01bef341..2a2e9034 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DVsmApplyClosureFrame & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DVsmApplyClosureFrame & self, obj gc) noexcept; + static void forward_children(DVsmApplyClosureFrame & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp index a3e0d31b..83d88686 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DVsmApplyFrame & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DVsmApplyFrame & self, obj gc) noexcept; + static void forward_children(DVsmApplyFrame & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp index 42c26b03..cd53aa9d 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DVsmEvalArgsFrame & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DVsmEvalArgsFrame & self, obj gc) noexcept; + static void forward_children(DVsmEvalArgsFrame & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp index 55064b27..8576aeda 100644 --- a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DLocalEnv & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DLocalEnv & self, obj gc) noexcept; + static void forward_children(DLocalEnv & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp index ab9a13c8..18297357 100644 --- a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DVsmIfElseContFrame & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DVsmIfElseContFrame & self, obj gc) noexcept; + static void forward_children(DVsmIfElseContFrame & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index d654d8a1..ca457e3d 100644 --- a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DVsmSeqContFrame & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DVsmSeqContFrame & self, obj gc) noexcept; + static void forward_children(DVsmSeqContFrame & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp index 71786a28..0a51165e 100644 --- a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DVirtualSchematikaMachine & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DVirtualSchematikaMachine & self, obj gc) noexcept; + static void forward_children(DVirtualSchematikaMachine & self, obj gc) noexcept; ///@} }; diff --git a/src/interpreter2/IGCObject_DClosure.cpp b/src/interpreter2/IGCObject_DClosure.cpp index 99e834b8..ac9f1932 100644 --- a/src/interpreter2/IGCObject_DClosure.cpp +++ b/src/interpreter2/IGCObject_DClosure.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DClosure::forward_children(DClosure & self, obj gc) noexcept -> size_type + IGCObject_DClosure::forward_children(DClosure & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp index a96ad2d7..2904c6be 100644 --- a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVsmApplyClosureFrame::forward_children(DVsmApplyClosureFrame & self, obj gc) noexcept -> size_type + IGCObject_DVsmApplyClosureFrame::forward_children(DVsmApplyClosureFrame & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp index 9666fdec..c8701e58 100644 --- a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVsmApplyFrame::forward_children(DVsmApplyFrame & self, obj gc) noexcept -> size_type + IGCObject_DVsmApplyFrame::forward_children(DVsmApplyFrame & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp index 2acd7b24..a574c84f 100644 --- a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVsmDefContFrame::forward_children(DVsmDefContFrame & self, obj gc) noexcept -> size_type + IGCObject_DVsmDefContFrame::forward_children(DVsmDefContFrame & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp index d1d6a0b6..072f0e49 100644 --- a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVsmEvalArgsFrame::forward_children(DVsmEvalArgsFrame & self, obj gc) noexcept -> size_type + IGCObject_DVsmEvalArgsFrame::forward_children(DVsmEvalArgsFrame & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp index 38f4881d..842199da 100644 --- a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVsmIfElseContFrame::forward_children(DVsmIfElseContFrame & self, obj gc) noexcept -> size_type + IGCObject_DVsmIfElseContFrame::forward_children(DVsmIfElseContFrame & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp index 3d57aaa1..fb504b96 100644 --- a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVsmSeqContFrame::forward_children(DVsmSeqContFrame & self, obj gc) noexcept -> size_type + IGCObject_DVsmSeqContFrame::forward_children(DVsmSeqContFrame & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp index ed9f18fd..dfa0cc30 100644 --- a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp +++ b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DLocalEnv::forward_children(DLocalEnv & self, obj gc) noexcept -> size_type + IGCObject_DLocalEnv::forward_children(DLocalEnv & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp index ddf77335..97168084 100644 --- a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVirtualSchematikaMachine::forward_children(DVirtualSchematikaMachine & self, obj gc) noexcept -> size_type + IGCObject_DVirtualSchematikaMachine::forward_children(DVirtualSchematikaMachine & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ From 8ba551bb1cd6a57e27b941ddb2cd43a7703e154a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 17:30:03 -0400 Subject: [PATCH 121/131] refactor: retire GCObject.shallow_size() Not needed. Rely on size stored in gc-owned object header --- .../xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp | 2 -- include/xo/interpreter2/detail/IGCObject_DClosure.hpp | 2 -- .../interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp | 2 -- include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp | 2 -- .../xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp | 2 -- include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp | 2 -- .../interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp | 2 -- .../xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp | 2 -- .../vsm/IGCObject_DVirtualSchematikaMachine.hpp | 2 -- src/interpreter2/IGCObject_DClosure.cpp | 6 ------ src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp | 6 ------ src/interpreter2/IGCObject_DVsmApplyFrame.cpp | 6 ------ src/interpreter2/IGCObject_DVsmDefContFrame.cpp | 6 ------ src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp | 6 ------ src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp | 6 ------ src/interpreter2/IGCObject_DVsmSeqContFrame.cpp | 6 ------ src/interpreter2/facet/IGCObject_DLocalEnv.cpp | 6 ------ .../facet/IGCObject_DVirtualSchematikaMachine.cpp | 6 ------ 18 files changed, 72 deletions(-) diff --git a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp index 131d57ae..7d082c38 100644 --- a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dvsmdefcontframe-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DVsmDefContFrame & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp index c0d7d22b..84502baa 100644 --- a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dclosure-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DClosure & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp index 2a2e9034..9a2e478d 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dvsmapplyclosureframe-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DVsmApplyClosureFrame & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp index 83d88686..9de1e8f3 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dvsmapplyframe-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DVsmApplyFrame & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp index cd53aa9d..9e2841a6 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dvsmevalargsframe-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DVsmEvalArgsFrame & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp index 8576aeda..e4de912e 100644 --- a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dlocalenv-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DLocalEnv & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp index 18297357..a3cede47 100644 --- a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dvsmifelsecontframe-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DVsmIfElseContFrame & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index ca457e3d..14367b50 100644 --- a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dvsmseqcontframe-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DVsmSeqContFrame & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp index 0a51165e..073e9fac 100644 --- a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dvirtualschematikamachine-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DVirtualSchematikaMachine & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/src/interpreter2/IGCObject_DClosure.cpp b/src/interpreter2/IGCObject_DClosure.cpp index ac9f1932..3f6af457 100644 --- a/src/interpreter2/IGCObject_DClosure.cpp +++ b/src/interpreter2/IGCObject_DClosure.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DClosure::shallow_size(const DClosure & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DClosure::shallow_move(DClosure & self, obj gc) noexcept -> Opaque { diff --git a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp index 2904c6be..cd0bed84 100644 --- a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DVsmApplyClosureFrame::shallow_size(const DVsmApplyClosureFrame & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DVsmApplyClosureFrame::shallow_move(DVsmApplyClosureFrame & self, obj gc) noexcept -> Opaque { diff --git a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp index c8701e58..0024df69 100644 --- a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DVsmApplyFrame::shallow_size(const DVsmApplyFrame & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DVsmApplyFrame::shallow_move(DVsmApplyFrame & self, obj gc) noexcept -> Opaque { diff --git a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp index a574c84f..e0cc2158 100644 --- a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DVsmDefContFrame::shallow_size(const DVsmDefContFrame & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DVsmDefContFrame::shallow_move(DVsmDefContFrame & self, obj gc) noexcept -> Opaque { diff --git a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp index 072f0e49..8107e7d9 100644 --- a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DVsmEvalArgsFrame::shallow_size(const DVsmEvalArgsFrame & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DVsmEvalArgsFrame::shallow_move(DVsmEvalArgsFrame & self, obj gc) noexcept -> Opaque { diff --git a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp index 842199da..7b95a521 100644 --- a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DVsmIfElseContFrame::shallow_size(const DVsmIfElseContFrame & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DVsmIfElseContFrame::shallow_move(DVsmIfElseContFrame & self, obj gc) noexcept -> Opaque { diff --git a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp index fb504b96..c9651507 100644 --- a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DVsmSeqContFrame::shallow_size(const DVsmSeqContFrame & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DVsmSeqContFrame::shallow_move(DVsmSeqContFrame & self, obj gc) noexcept -> Opaque { diff --git a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp index dfa0cc30..25b84b4e 100644 --- a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp +++ b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DLocalEnv::shallow_size(const DLocalEnv & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DLocalEnv::shallow_move(DLocalEnv & self, obj gc) noexcept -> Opaque { diff --git a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp index 97168084..8f071003 100644 --- a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DVirtualSchematikaMachine::shallow_size(const DVirtualSchematikaMachine & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DVirtualSchematikaMachine::shallow_move(DVirtualSchematikaMachine & self, obj gc) noexcept -> Opaque { From bc83df3f081725ec0d0d136696d81daf119edb3e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 18:01:25 -0400 Subject: [PATCH 122/131] refactor: retire GCObject.shallow_copy() Collector gets this info from gc-owned object header --- .../interpreter2/vsm/IGCObject_DLocalEnv.hpp | 67 ------------------- 1 file changed, 67 deletions(-) delete mode 100644 include/xo/interpreter2/vsm/IGCObject_DLocalEnv.hpp diff --git a/include/xo/interpreter2/vsm/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/vsm/IGCObject_DLocalEnv.hpp deleted file mode 100644 index 48b624d6..00000000 --- a/include/xo/interpreter2/vsm/IGCObject_DLocalEnv.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/** @file IGCObject_DLocalEnv.hpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IGCObject_DVirtualSchematikaMachine.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_repr.hpp.j2] - * 3. idl for facet methods - * [idl/IGCObject_DVirtualSchematikaMachine.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 From 7e583b1337bf34ba7a95b5ed2c1194b6dd81a791 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 5 Apr 2026 23:53:02 -0400 Subject: [PATCH 123/131] refactor: + narrower interface for gc pointer forwarding add AGCObjectVisitor, instead of requiring ACollector. --- include/xo/interpreter2/DClosure.hpp | 6 ++--- include/xo/interpreter2/DLocalEnv.hpp | 6 ++--- .../xo/interpreter2/DVsmApplyClosureFrame.hpp | 5 ++-- include/xo/interpreter2/DVsmApplyFrame.hpp | 6 ++--- include/xo/interpreter2/DVsmDefContFrame.hpp | 4 +-- include/xo/interpreter2/DVsmEvalArgsFrame.hpp | 6 ++--- .../xo/interpreter2/DVsmIfElseContFrame.hpp | 6 ++--- include/xo/interpreter2/DVsmSeqContFrame.hpp | 4 +-- .../define/IGCObject_DVsmDefContFrame.hpp | 7 +++-- .../detail/IGCObject_DClosure.hpp | 7 +++-- .../IGCObject_DVsmApplyClosureFrame.hpp | 7 +++-- .../detail/IGCObject_DVsmApplyFrame.hpp | 7 +++-- .../detail/IGCObject_DVsmEvalArgsFrame.hpp | 7 +++-- .../interpreter2/env/IGCObject_DLocalEnv.hpp | 7 +++-- .../ifelse/IGCObject_DVsmIfElseContFrame.hpp | 7 +++-- .../sequence/IGCObject_DVsmSeqContFrame.hpp | 7 +++-- .../vsm/DVirtualSchematikaMachine.hpp | 5 ++-- .../IGCObject_DVirtualSchematikaMachine.hpp | 7 +++-- src/interpreter2/DClosure.cpp | 24 +++-------------- src/interpreter2/DLocalEnv.cpp | 26 ++++++++----------- .../DVirtualSchematikaMachine.cpp | 22 +++++++--------- src/interpreter2/DVsmApplyClosureFrame.cpp | 16 +++--------- src/interpreter2/DVsmApplyFrame.cpp | 18 ++++--------- src/interpreter2/DVsmDefContFrame.cpp | 16 +++--------- src/interpreter2/DVsmEvalArgsFrame.cpp | 16 +++--------- src/interpreter2/DVsmIfElseContFrame.cpp | 16 +++--------- src/interpreter2/DVsmSeqContFrame.cpp | 16 +++--------- src/interpreter2/IGCObject_DClosure.cpp | 4 +-- .../IGCObject_DVsmApplyClosureFrame.cpp | 4 +-- src/interpreter2/IGCObject_DVsmApplyFrame.cpp | 4 +-- .../IGCObject_DVsmDefContFrame.cpp | 4 +-- .../IGCObject_DVsmEvalArgsFrame.cpp | 4 +-- .../IGCObject_DVsmIfElseContFrame.cpp | 4 +-- .../IGCObject_DVsmSeqContFrame.cpp | 4 +-- .../facet/IGCObject_DLocalEnv.cpp | 4 +-- .../IGCObject_DVirtualSchematikaMachine.cpp | 4 +-- 36 files changed, 138 insertions(+), 179 deletions(-) diff --git a/include/xo/interpreter2/DClosure.hpp b/include/xo/interpreter2/DClosure.hpp index e57f6a1a..4d24d72e 100644 --- a/include/xo/interpreter2/DClosure.hpp +++ b/include/xo/interpreter2/DClosure.hpp @@ -20,8 +20,9 @@ namespace xo { public: using ARuntimeContext = xo::scm::ARuntimeContext; using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; using size_type = std::int32_t; @@ -57,9 +58,8 @@ namespace xo { /** @defgroup scm-closure-gcobject-facet **/ ///@{ - std::size_t shallow_size() const noexcept; DClosure * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-closure-printable-facet **/ diff --git a/include/xo/interpreter2/DLocalEnv.hpp b/include/xo/interpreter2/DLocalEnv.hpp index 6ecd3eb6..5270dec1 100644 --- a/include/xo/interpreter2/DLocalEnv.hpp +++ b/include/xo/interpreter2/DLocalEnv.hpp @@ -17,8 +17,9 @@ namespace xo { public: using DArray = xo::scm::DArray; using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; using size_type = std::uint32_t; @@ -54,9 +55,8 @@ namespace xo { /** @defgroup scm-localenv-gcobject-facet **/ ///@{ - std::size_t shallow_size() const noexcept; DLocalEnv * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-localenv-printable-facet **/ diff --git a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp index ae422cb1..8dd30efb 100644 --- a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp @@ -19,8 +19,9 @@ namespace xo { class DVsmApplyClosureFrame { public: using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; public: @@ -41,7 +42,7 @@ namespace xo { /** gcobject facet **/ std::size_t shallow_size() const noexcept; DVsmApplyClosureFrame * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; /** pretty-printing support **/ bool pretty(const ppindentinfo & ppii) const; diff --git a/include/xo/interpreter2/DVsmApplyFrame.hpp b/include/xo/interpreter2/DVsmApplyFrame.hpp index 99093f37..d8e9ab79 100644 --- a/include/xo/interpreter2/DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyFrame.hpp @@ -15,8 +15,9 @@ namespace xo { public: using AProcedure = xo::scm::AProcedure; using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; public: @@ -37,9 +38,8 @@ namespace xo { void assign_fn(obj x) { this->fn_ = x; } - std::size_t shallow_size() const noexcept; DVsmApplyFrame * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; /** pretty-printing support **/ bool pretty(const ppindentinfo & ppii) const; diff --git a/include/xo/interpreter2/DVsmDefContFrame.hpp b/include/xo/interpreter2/DVsmDefContFrame.hpp index 0ad31cca..acdd8a90 100644 --- a/include/xo/interpreter2/DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/DVsmDefContFrame.hpp @@ -16,6 +16,7 @@ namespace xo { class DVsmDefContFrame { public: using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; using ppindentinfo = xo::print::ppindentinfo; @@ -50,9 +51,8 @@ namespace xo { /** @defgroup scm-vsmdefcontframe-gcobject-facet gcobject facet **/ ///@{ - std::size_t shallow_size() const noexcept; DVsmDefContFrame * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgrouop scm-vsmseqcontframe-printable-facet printable facet **/ diff --git a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp index a1903e94..ab7a4607 100644 --- a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp @@ -15,8 +15,9 @@ namespace xo { class DVsmEvalArgsFrame { public: using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; public: @@ -42,9 +43,8 @@ namespace xo { int32_t increment_arg() { return ++i_arg_; } - std::size_t shallow_size() const noexcept; DVsmEvalArgsFrame * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; bool pretty(const ppindentinfo & ppii) const; diff --git a/include/xo/interpreter2/DVsmIfElseContFrame.hpp b/include/xo/interpreter2/DVsmIfElseContFrame.hpp index 3c438e51..82c5ee31 100644 --- a/include/xo/interpreter2/DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/DVsmIfElseContFrame.hpp @@ -16,8 +16,9 @@ namespace xo { class DVsmIfElseContFrame { public: using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; + using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; public: @@ -50,9 +51,8 @@ namespace xo { /** @defgroup scm-vsmevalsequenceframe-gcobject-facet gcobject facet **/ ///@{ - std::size_t shallow_size() const noexcept; DVsmIfElseContFrame * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgrouop scm-vsmseqcontframe-printable-facet printable facet **/ diff --git a/include/xo/interpreter2/DVsmSeqContFrame.hpp b/include/xo/interpreter2/DVsmSeqContFrame.hpp index 959edfb0..65532996 100644 --- a/include/xo/interpreter2/DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/DVsmSeqContFrame.hpp @@ -18,6 +18,7 @@ namespace xo { using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using ppindentinfo = xo::print::ppindentinfo; public: @@ -55,9 +56,8 @@ namespace xo { /** @defgroup scm-vsmevalsequenceframe-gcobject-facet gcobject facet **/ ///@{ - std::size_t shallow_size() const noexcept; DVsmSeqContFrame * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgrouop scm-vsmseqcontframe-printable-facet printable facet **/ diff --git a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp index 7d082c38..85949311 100644 --- a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DVsmDefContFrame & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DVsmDefContFrame & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DVsmDefContFrame & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp index 84502baa..284199eb 100644 --- a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DClosure & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DClosure & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DClosure & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp index 9a2e478d..b6a92890 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DVsmApplyClosureFrame & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DVsmApplyClosureFrame & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DVsmApplyClosureFrame & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp index 9de1e8f3..85b3f614 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DVsmApplyFrame & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DVsmApplyFrame & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DVsmApplyFrame & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp index 9e2841a6..d62489c3 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DVsmEvalArgsFrame & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DVsmEvalArgsFrame & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DVsmEvalArgsFrame & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp index e4de912e..599829a9 100644 --- a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DLocalEnv & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DLocalEnv & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DLocalEnv & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp index a3cede47..c0c25c65 100644 --- a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DVsmIfElseContFrame & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DVsmIfElseContFrame & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DVsmIfElseContFrame & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index 14367b50..0c9fe148 100644 --- a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DVsmSeqContFrame & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DVsmSeqContFrame & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DVsmSeqContFrame & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp index fa9a6929..28343528 100644 --- a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp @@ -72,8 +72,9 @@ namespace xo { // will be DArenaVector> probably using Stack = void *; using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using AAllocator = xo::mm::AAllocator; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; using span_type = xo::mm::span; @@ -157,7 +158,7 @@ namespace xo { /** forward gc-aware child pointers **/ - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp index 073e9fac..3d72b7af 100644 --- a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DVirtualSchematikaMachine & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DVirtualSchematikaMachine & self, obj gc) noexcept; + /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. +Context: provides address of data pointer so it can be updated in place +when @p fn invokes garbage collector reentry point **/ + static void visit_gco_children(DVirtualSchematikaMachine & self, obj fn) noexcept; ///@} }; diff --git a/src/interpreter2/DClosure.cpp b/src/interpreter2/DClosure.cpp index 6b346463..ea8bcb15 100644 --- a/src/interpreter2/DClosure.cpp +++ b/src/interpreter2/DClosure.cpp @@ -64,32 +64,16 @@ namespace xo { return err; } - size_t - DClosure::shallow_size() const noexcept { - return sizeof(DClosure); - } - DClosure * DClosure::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - std::size_t - DClosure::forward_children(obj gc) noexcept + void + DClosure::visit_gco_children(obj gc) noexcept { - { - gc.forward_inplace(&lambda_); - //auto iface = xo::facet::impl_for(); - //gc.forward_inplace(&iface, (void **)(&lambda_)); - - } - { - gc.forward_inplace(&env_); - //auto iface = xo::facet::impl_for(); - //gc.forward_inplace(&iface, (void **)(&env_)); - } - - return this->shallow_size(); + gc.visit_child(&lambda_); + gc.visit_child(&env_); } // ----- printable facet ----- diff --git a/src/interpreter2/DLocalEnv.cpp b/src/interpreter2/DLocalEnv.cpp index 4124e280..3da6fd9b 100644 --- a/src/interpreter2/DLocalEnv.cpp +++ b/src/interpreter2/DLocalEnv.cpp @@ -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 gc) noexcept { return gc.std_move_for(this); } - std::size_t - DLocalEnv::forward_children(obj gc) noexcept + void + DLocalEnv::visit_gco_children(obj gc) noexcept { { - auto iface = xo::facet::impl_for(); - gc.forward_inplace(&iface, (void **)(&parent_)); + gc.visit_child(&parent_); + //auto iface = xo::facet::impl_for(); + //gc.forward_inplace(&iface, (void **)(&parent_)); } { - auto iface = xo::facet::impl_for(); - gc.forward_inplace(&iface, (void **)(&symtab_)); + gc.visit_child(&symtab_); + //auto iface = xo::facet::impl_for(); + //gc.forward_inplace(&iface, (void **)(&symtab_)); } { - auto iface = xo::facet::impl_for(); - gc.forward_inplace(&iface, (void **)(&args_)); + gc.visit_child(&args_); + //auto iface = xo::facet::impl_for(); + //gc.forward_inplace(&iface, (void **)(&args_)); } - - return shallow_size(); } // ----- printable facet ----- diff --git a/src/interpreter2/DVirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp index 06a4c23f..8f9d3967 100644 --- a/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -968,22 +968,20 @@ namespace xo { return nullptr; } - std::size_t - DVirtualSchematikaMachine::forward_children(obj gc) noexcept + void + DVirtualSchematikaMachine::visit_gco_children(obj 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 *>(&value_.value_ref())); + gc.visit_child(const_cast *>(&value_.value_ref())); } - - return this->shallow_size(); } } /*namespace scm*/ diff --git a/src/interpreter2/DVsmApplyClosureFrame.cpp b/src/interpreter2/DVsmApplyClosureFrame.cpp index 129d0d46..c17414b8 100644 --- a/src/interpreter2/DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/DVsmApplyClosureFrame.cpp @@ -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 gc) noexcept { return gc.std_move_for(this); } - std::size_t - DVsmApplyClosureFrame::forward_children(obj gc) noexcept + void + DVsmApplyClosureFrame::visit_gco_children(obj 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 diff --git a/src/interpreter2/DVsmApplyFrame.cpp b/src/interpreter2/DVsmApplyFrame.cpp index d388f9c4..1a9a946d 100644 --- a/src/interpreter2/DVsmApplyFrame.cpp +++ b/src/interpreter2/DVsmApplyFrame.cpp @@ -40,26 +40,18 @@ namespace xo { return result; } - std::size_t - DVsmApplyFrame::shallow_size() const noexcept - { - return sizeof(DVsmApplyFrame); - } - DVsmApplyFrame * DVsmApplyFrame::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - std::size_t - DVsmApplyFrame::forward_children(obj gc) noexcept + void + DVsmApplyFrame::visit_gco_children(obj 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 diff --git a/src/interpreter2/DVsmDefContFrame.cpp b/src/interpreter2/DVsmDefContFrame.cpp index 02094534..0014f1a3 100644 --- a/src/interpreter2/DVsmDefContFrame.cpp +++ b/src/interpreter2/DVsmDefContFrame.cpp @@ -31,25 +31,17 @@ namespace xo { // gcobject facet - std::size_t - DVsmDefContFrame::shallow_size() const noexcept - { - return sizeof(*this); - } - DVsmDefContFrame * DVsmDefContFrame::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - std::size_t - DVsmDefContFrame::forward_children(obj gc) noexcept + void + DVsmDefContFrame::visit_gco_children(obj 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 diff --git a/src/interpreter2/DVsmEvalArgsFrame.cpp b/src/interpreter2/DVsmEvalArgsFrame.cpp index 204bfb44..b796bb78 100644 --- a/src/interpreter2/DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/DVsmEvalArgsFrame.cpp @@ -41,25 +41,17 @@ namespace xo { return result; } - std::size_t - DVsmEvalArgsFrame::shallow_size() const noexcept - { - return sizeof(DVsmEvalArgsFrame); - } - DVsmEvalArgsFrame * DVsmEvalArgsFrame::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - std::size_t - DVsmEvalArgsFrame::forward_children(obj gc) noexcept + void + DVsmEvalArgsFrame::visit_gco_children(obj 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 diff --git a/src/interpreter2/DVsmIfElseContFrame.cpp b/src/interpreter2/DVsmIfElseContFrame.cpp index 511af900..d0edd976 100644 --- a/src/interpreter2/DVsmIfElseContFrame.cpp +++ b/src/interpreter2/DVsmIfElseContFrame.cpp @@ -29,25 +29,17 @@ namespace xo { // gcobject facet - std::size_t - DVsmIfElseContFrame::shallow_size() const noexcept - { - return sizeof(*this); - } - DVsmIfElseContFrame * DVsmIfElseContFrame::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - std::size_t - DVsmIfElseContFrame::forward_children(obj gc) noexcept + void + DVsmIfElseContFrame::visit_gco_children(obj 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 diff --git a/src/interpreter2/DVsmSeqContFrame.cpp b/src/interpreter2/DVsmSeqContFrame.cpp index ad006def..f9ef2f0b 100644 --- a/src/interpreter2/DVsmSeqContFrame.cpp +++ b/src/interpreter2/DVsmSeqContFrame.cpp @@ -32,25 +32,17 @@ namespace xo { // gcobject facet - std::size_t - DVsmSeqContFrame::shallow_size() const noexcept - { - return sizeof(*this); - } - DVsmSeqContFrame * DVsmSeqContFrame::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - std::size_t - DVsmSeqContFrame::forward_children(obj gc) noexcept + void + DVsmSeqContFrame::visit_gco_children(obj 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 diff --git a/src/interpreter2/IGCObject_DClosure.cpp b/src/interpreter2/IGCObject_DClosure.cpp index 3f6af457..889567bc 100644 --- a/src/interpreter2/IGCObject_DClosure.cpp +++ b/src/interpreter2/IGCObject_DClosure.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DClosure::forward_children(DClosure & self, obj gc) noexcept -> void + IGCObject_DClosure::visit_gco_children(DClosure & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp index cd0bed84..be67179b 100644 --- a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVsmApplyClosureFrame::forward_children(DVsmApplyClosureFrame & self, obj gc) noexcept -> void + IGCObject_DVsmApplyClosureFrame::visit_gco_children(DVsmApplyClosureFrame & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp index 0024df69..d3078821 100644 --- a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVsmApplyFrame::forward_children(DVsmApplyFrame & self, obj gc) noexcept -> void + IGCObject_DVsmApplyFrame::visit_gco_children(DVsmApplyFrame & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp index e0cc2158..b3de6d94 100644 --- a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVsmDefContFrame::forward_children(DVsmDefContFrame & self, obj gc) noexcept -> void + IGCObject_DVsmDefContFrame::visit_gco_children(DVsmDefContFrame & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp index 8107e7d9..edf1768b 100644 --- a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVsmEvalArgsFrame::forward_children(DVsmEvalArgsFrame & self, obj gc) noexcept -> void + IGCObject_DVsmEvalArgsFrame::visit_gco_children(DVsmEvalArgsFrame & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp index 7b95a521..6f73f5a8 100644 --- a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVsmIfElseContFrame::forward_children(DVsmIfElseContFrame & self, obj gc) noexcept -> void + IGCObject_DVsmIfElseContFrame::visit_gco_children(DVsmIfElseContFrame & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp index c9651507..437ac776 100644 --- a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVsmSeqContFrame::forward_children(DVsmSeqContFrame & self, obj gc) noexcept -> void + IGCObject_DVsmSeqContFrame::visit_gco_children(DVsmSeqContFrame & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp index 25b84b4e..2b8e4e93 100644 --- a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp +++ b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DLocalEnv::forward_children(DLocalEnv & self, obj gc) noexcept -> void + IGCObject_DLocalEnv::visit_gco_children(DLocalEnv & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp index 8f071003..7fa74f97 100644 --- a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVirtualSchematikaMachine::forward_children(DVirtualSchematikaMachine & self, obj gc) noexcept -> void + IGCObject_DVirtualSchematikaMachine::visit_gco_children(DVirtualSchematikaMachine & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ From ffa4d99583d483c6b13b28d892f2117cbdc4cfd7 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 6 Apr 2026 00:11:08 -0400 Subject: [PATCH 124/131] refactor: make shallow_move() available from AGCObjectVisitor --- include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp | 2 +- include/xo/interpreter2/detail/IGCObject_DClosure.hpp | 2 +- .../xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp | 2 +- include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp | 2 +- include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp | 2 +- include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp | 2 +- .../xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp | 2 +- include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp | 2 +- .../xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp index 85949311..8c95cf65 100644 --- a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DVsmDefContFrame & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp index 284199eb..a875406f 100644 --- a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DClosure & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp index b6a92890..ec79f34e 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DVsmApplyClosureFrame & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp index 85b3f614..da5dc97d 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DVsmApplyFrame & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp index d62489c3..d0faa515 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DVsmEvalArgsFrame & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp index 599829a9..cb5bdc49 100644 --- a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DLocalEnv & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp index c0c25c65..1fc589f7 100644 --- a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DVsmIfElseContFrame & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index 0c9fe148..c8e20628 100644 --- a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DVsmSeqContFrame & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp index 3d72b7af..55497fad 100644 --- a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DVirtualSchematikaMachine & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place From a312b5f20c4e589bbec0e92da0c61adeea8f2454 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 6 Apr 2026 15:21:48 -0400 Subject: [PATCH 125/131] refactor: use GCObjectVisitor api w/ gco_shallow_move --- include/xo/interpreter2/DClosure.hpp | 4 ++-- include/xo/interpreter2/DLocalEnv.hpp | 4 ++-- include/xo/interpreter2/DVsmApplyClosureFrame.hpp | 2 +- include/xo/interpreter2/DVsmApplyFrame.hpp | 4 ++-- include/xo/interpreter2/DVsmDefContFrame.hpp | 4 ++-- include/xo/interpreter2/DVsmEvalArgsFrame.hpp | 4 ++-- include/xo/interpreter2/DVsmIfElseContFrame.hpp | 4 ++-- include/xo/interpreter2/DVsmSeqContFrame.hpp | 12 ++++++------ .../define/IGCObject_DVsmDefContFrame.hpp | 5 +++-- .../xo/interpreter2/detail/IGCObject_DClosure.hpp | 5 +++-- .../detail/IGCObject_DVsmApplyClosureFrame.hpp | 5 +++-- .../interpreter2/detail/IGCObject_DVsmApplyFrame.hpp | 5 +++-- .../detail/IGCObject_DVsmEvalArgsFrame.hpp | 5 +++-- include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp | 5 +++-- .../ifelse/IGCObject_DVsmIfElseContFrame.hpp | 5 +++-- .../sequence/IGCObject_DVsmSeqContFrame.hpp | 5 +++-- .../interpreter2/vsm/DVirtualSchematikaMachine.hpp | 4 ++-- .../vsm/IGCObject_DVirtualSchematikaMachine.hpp | 5 +++-- src/interpreter2/DClosure.cpp | 2 +- src/interpreter2/DLocalEnv.cpp | 2 +- src/interpreter2/DVirtualSchematikaMachine.cpp | 5 ++++- src/interpreter2/DVsmApplyClosureFrame.cpp | 2 +- src/interpreter2/DVsmApplyFrame.cpp | 2 +- src/interpreter2/DVsmDefContFrame.cpp | 2 +- src/interpreter2/DVsmEvalArgsFrame.cpp | 2 +- src/interpreter2/DVsmIfElseContFrame.cpp | 2 +- src/interpreter2/DVsmSeqContFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DClosure.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmApplyFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmDefContFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmSeqContFrame.cpp | 4 ++-- src/interpreter2/facet/IGCObject_DLocalEnv.cpp | 4 ++-- .../facet/IGCObject_DVirtualSchematikaMachine.cpp | 4 ++-- 36 files changed, 79 insertions(+), 67 deletions(-) diff --git a/include/xo/interpreter2/DClosure.hpp b/include/xo/interpreter2/DClosure.hpp index 4d24d72e..8472cfc5 100644 --- a/include/xo/interpreter2/DClosure.hpp +++ b/include/xo/interpreter2/DClosure.hpp @@ -19,7 +19,7 @@ namespace xo { class DClosure { public: using ARuntimeContext = xo::scm::ARuntimeContext; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; @@ -58,7 +58,7 @@ namespace xo { /** @defgroup scm-closure-gcobject-facet **/ ///@{ - DClosure * shallow_move(obj gc) noexcept; + DClosure * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/DLocalEnv.hpp b/include/xo/interpreter2/DLocalEnv.hpp index 5270dec1..e60727b0 100644 --- a/include/xo/interpreter2/DLocalEnv.hpp +++ b/include/xo/interpreter2/DLocalEnv.hpp @@ -16,7 +16,7 @@ namespace xo { class DLocalEnv { public: using DArray = xo::scm::DArray; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; @@ -55,7 +55,7 @@ namespace xo { /** @defgroup scm-localenv-gcobject-facet **/ ///@{ - DLocalEnv * shallow_move(obj gc) noexcept; + DLocalEnv * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp index 8dd30efb..66cbf81a 100644 --- a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp @@ -41,7 +41,7 @@ namespace xo { /** gcobject facet **/ std::size_t shallow_size() const noexcept; - DVsmApplyClosureFrame * shallow_move(obj gc) noexcept; + DVsmApplyClosureFrame * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; /** pretty-printing support **/ diff --git a/include/xo/interpreter2/DVsmApplyFrame.hpp b/include/xo/interpreter2/DVsmApplyFrame.hpp index d8e9ab79..60a572aa 100644 --- a/include/xo/interpreter2/DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyFrame.hpp @@ -14,7 +14,7 @@ namespace xo { class DVsmApplyFrame { public: using AProcedure = xo::scm::AProcedure; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; @@ -38,7 +38,7 @@ namespace xo { void assign_fn(obj x) { this->fn_ = x; } - DVsmApplyFrame * shallow_move(obj gc) noexcept; + DVsmApplyFrame * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; /** pretty-printing support **/ diff --git a/include/xo/interpreter2/DVsmDefContFrame.hpp b/include/xo/interpreter2/DVsmDefContFrame.hpp index acdd8a90..79a9227c 100644 --- a/include/xo/interpreter2/DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/DVsmDefContFrame.hpp @@ -15,7 +15,7 @@ namespace xo { **/ class DVsmDefContFrame { public: - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; @@ -51,7 +51,7 @@ namespace xo { /** @defgroup scm-vsmdefcontframe-gcobject-facet gcobject facet **/ ///@{ - DVsmDefContFrame * shallow_move(obj gc) noexcept; + DVsmDefContFrame * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp index ab7a4607..34d74b9a 100644 --- a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp @@ -14,7 +14,7 @@ namespace xo { /** frame for executing an apply expression **/ class DVsmEvalArgsFrame { public: - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; @@ -43,7 +43,7 @@ namespace xo { int32_t increment_arg() { return ++i_arg_; } - DVsmEvalArgsFrame * shallow_move(obj gc) noexcept; + DVsmEvalArgsFrame * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; bool pretty(const ppindentinfo & ppii) const; diff --git a/include/xo/interpreter2/DVsmIfElseContFrame.hpp b/include/xo/interpreter2/DVsmIfElseContFrame.hpp index 82c5ee31..4d3176dc 100644 --- a/include/xo/interpreter2/DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/DVsmIfElseContFrame.hpp @@ -15,7 +15,7 @@ namespace xo { **/ class DVsmIfElseContFrame { public: - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; using AAllocator = xo::mm::AAllocator; @@ -51,7 +51,7 @@ namespace xo { /** @defgroup scm-vsmevalsequenceframe-gcobject-facet gcobject facet **/ ///@{ - DVsmIfElseContFrame * shallow_move(obj gc) noexcept; + DVsmIfElseContFrame * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/DVsmSeqContFrame.hpp b/include/xo/interpreter2/DVsmSeqContFrame.hpp index 65532996..6b141cc6 100644 --- a/include/xo/interpreter2/DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/DVsmSeqContFrame.hpp @@ -15,7 +15,7 @@ namespace xo { **/ class DVsmSeqContFrame { public: - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; @@ -32,10 +32,10 @@ namespace xo { /** create instance using memory from allocator @p mm **/ static DVsmSeqContFrame * make(obj mm, - obj parent, - VsmInstr cont, - DSequenceExpr * seq_expr, - uint32_t i_seq); + obj parent, + VsmInstr cont, + DSequenceExpr * seq_expr, + uint32_t i_seq); ///@} /** @defgroup scm-vsmevalsequenceframe-access-methods access methods **/ @@ -56,7 +56,7 @@ namespace xo { /** @defgroup scm-vsmevalsequenceframe-gcobject-facet gcobject facet **/ ///@{ - DVsmSeqContFrame * shallow_move(obj gc) noexcept; + DVsmSeqContFrame * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp index 8c95cf65..215515ac 100644 --- a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DVsmDefContFrame & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DVsmDefContFrame & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp index a875406f..6e6058dd 100644 --- a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DClosure & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DClosure & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp index ec79f34e..9a021127 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DVsmApplyClosureFrame & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DVsmApplyClosureFrame & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp index da5dc97d..2936f81e 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DVsmApplyFrame & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DVsmApplyFrame & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp index d0faa515..15a09267 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DVsmEvalArgsFrame & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DVsmEvalArgsFrame & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp index cb5bdc49..29484934 100644 --- a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DLocalEnv & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DLocalEnv & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp index 1fc589f7..6812b6a0 100644 --- a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DVsmIfElseContFrame & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DVsmIfElseContFrame & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index c8e20628..9b299d82 100644 --- a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DVsmSeqContFrame & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DVsmSeqContFrame & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp index 28343528..1b386aaa 100644 --- a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp @@ -71,7 +71,7 @@ namespace xo { public: // will be DArenaVector> probably using Stack = void *; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; @@ -154,7 +154,7 @@ namespace xo { /** shallow copy during gc cycle. Not implemented! Only intending to support * VSM as virtual root **/ - DVirtualSchematikaMachine * shallow_move(obj gc) noexcept; + DVirtualSchematikaMachine * gco_shallow_move(obj gc) noexcept; /** forward gc-aware child pointers **/ diff --git a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp index 55497fad..c7d1d1f7 100644 --- a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DVirtualSchematikaMachine & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DVirtualSchematikaMachine & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/src/interpreter2/DClosure.cpp b/src/interpreter2/DClosure.cpp index ea8bcb15..684eb5d0 100644 --- a/src/interpreter2/DClosure.cpp +++ b/src/interpreter2/DClosure.cpp @@ -65,7 +65,7 @@ namespace xo { } DClosure * - DClosure::shallow_move(obj gc) noexcept { + DClosure::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/interpreter2/DLocalEnv.cpp b/src/interpreter2/DLocalEnv.cpp index 3da6fd9b..e0fe0e79 100644 --- a/src/interpreter2/DLocalEnv.cpp +++ b/src/interpreter2/DLocalEnv.cpp @@ -92,7 +92,7 @@ namespace xo { } DLocalEnv * - DLocalEnv::shallow_move(obj gc) noexcept { + DLocalEnv::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/interpreter2/DVirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp index 8f9d3967..01c56698 100644 --- a/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -954,8 +954,11 @@ namespace xo { } DVirtualSchematikaMachine * - DVirtualSchematikaMachine::shallow_move(obj gc) noexcept + DVirtualSchematikaMachine::gco_shallow_move(obj gc) noexcept { + // need move-ctor on abox<..> + //return gc.std_move_for(this); + (void)gc; /** TODO: should be able to use gc.std_move_for(this) now diff --git a/src/interpreter2/DVsmApplyClosureFrame.cpp b/src/interpreter2/DVsmApplyClosureFrame.cpp index c17414b8..dbb1601c 100644 --- a/src/interpreter2/DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/DVsmApplyClosureFrame.cpp @@ -33,7 +33,7 @@ namespace xo { } DVsmApplyClosureFrame * - DVsmApplyClosureFrame::shallow_move(obj gc) noexcept + DVsmApplyClosureFrame::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/interpreter2/DVsmApplyFrame.cpp b/src/interpreter2/DVsmApplyFrame.cpp index 1a9a946d..19db4bdf 100644 --- a/src/interpreter2/DVsmApplyFrame.cpp +++ b/src/interpreter2/DVsmApplyFrame.cpp @@ -41,7 +41,7 @@ namespace xo { } DVsmApplyFrame * - DVsmApplyFrame::shallow_move(obj gc) noexcept + DVsmApplyFrame::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/interpreter2/DVsmDefContFrame.cpp b/src/interpreter2/DVsmDefContFrame.cpp index 0014f1a3..97b12ab0 100644 --- a/src/interpreter2/DVsmDefContFrame.cpp +++ b/src/interpreter2/DVsmDefContFrame.cpp @@ -32,7 +32,7 @@ namespace xo { // gcobject facet DVsmDefContFrame * - DVsmDefContFrame::shallow_move(obj gc) noexcept + DVsmDefContFrame::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/interpreter2/DVsmEvalArgsFrame.cpp b/src/interpreter2/DVsmEvalArgsFrame.cpp index b796bb78..42d44de5 100644 --- a/src/interpreter2/DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/DVsmEvalArgsFrame.cpp @@ -42,7 +42,7 @@ namespace xo { } DVsmEvalArgsFrame * - DVsmEvalArgsFrame::shallow_move(obj gc) noexcept + DVsmEvalArgsFrame::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/interpreter2/DVsmIfElseContFrame.cpp b/src/interpreter2/DVsmIfElseContFrame.cpp index d0edd976..a82206bc 100644 --- a/src/interpreter2/DVsmIfElseContFrame.cpp +++ b/src/interpreter2/DVsmIfElseContFrame.cpp @@ -30,7 +30,7 @@ namespace xo { // gcobject facet DVsmIfElseContFrame * - DVsmIfElseContFrame::shallow_move(obj gc) noexcept + DVsmIfElseContFrame::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/interpreter2/DVsmSeqContFrame.cpp b/src/interpreter2/DVsmSeqContFrame.cpp index f9ef2f0b..cb031b18 100644 --- a/src/interpreter2/DVsmSeqContFrame.cpp +++ b/src/interpreter2/DVsmSeqContFrame.cpp @@ -33,9 +33,9 @@ namespace xo { // gcobject facet DVsmSeqContFrame * - DVsmSeqContFrame::shallow_move(obj gc) noexcept + DVsmSeqContFrame::gco_shallow_move(obj gc) noexcept { - return gc.std_move_for(this); + return gc.std_move_for(this); } void diff --git a/src/interpreter2/IGCObject_DClosure.cpp b/src/interpreter2/IGCObject_DClosure.cpp index 889567bc..be0c9903 100644 --- a/src/interpreter2/IGCObject_DClosure.cpp +++ b/src/interpreter2/IGCObject_DClosure.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DClosure::shallow_move(DClosure & self, obj gc) noexcept -> Opaque + IGCObject_DClosure::gco_shallow_move(DClosure & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DClosure::visit_gco_children(DClosure & self, obj fn) noexcept -> void diff --git a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp index be67179b..5fcb724a 100644 --- a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DVsmApplyClosureFrame::shallow_move(DVsmApplyClosureFrame & self, obj gc) noexcept -> Opaque + IGCObject_DVsmApplyClosureFrame::gco_shallow_move(DVsmApplyClosureFrame & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DVsmApplyClosureFrame::visit_gco_children(DVsmApplyClosureFrame & self, obj fn) noexcept -> void diff --git a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp index d3078821..4e8adef7 100644 --- a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DVsmApplyFrame::shallow_move(DVsmApplyFrame & self, obj gc) noexcept -> Opaque + IGCObject_DVsmApplyFrame::gco_shallow_move(DVsmApplyFrame & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DVsmApplyFrame::visit_gco_children(DVsmApplyFrame & self, obj fn) noexcept -> void diff --git a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp index b3de6d94..60cb90d0 100644 --- a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DVsmDefContFrame::shallow_move(DVsmDefContFrame & self, obj gc) noexcept -> Opaque + IGCObject_DVsmDefContFrame::gco_shallow_move(DVsmDefContFrame & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DVsmDefContFrame::visit_gco_children(DVsmDefContFrame & self, obj fn) noexcept -> void diff --git a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp index edf1768b..c9697c90 100644 --- a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DVsmEvalArgsFrame::shallow_move(DVsmEvalArgsFrame & self, obj gc) noexcept -> Opaque + IGCObject_DVsmEvalArgsFrame::gco_shallow_move(DVsmEvalArgsFrame & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DVsmEvalArgsFrame::visit_gco_children(DVsmEvalArgsFrame & self, obj fn) noexcept -> void diff --git a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp index 6f73f5a8..d8fa856d 100644 --- a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DVsmIfElseContFrame::shallow_move(DVsmIfElseContFrame & self, obj gc) noexcept -> Opaque + IGCObject_DVsmIfElseContFrame::gco_shallow_move(DVsmIfElseContFrame & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DVsmIfElseContFrame::visit_gco_children(DVsmIfElseContFrame & self, obj fn) noexcept -> void diff --git a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp index 437ac776..aa004bce 100644 --- a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DVsmSeqContFrame::shallow_move(DVsmSeqContFrame & self, obj gc) noexcept -> Opaque + IGCObject_DVsmSeqContFrame::gco_shallow_move(DVsmSeqContFrame & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DVsmSeqContFrame::visit_gco_children(DVsmSeqContFrame & self, obj fn) noexcept -> void diff --git a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp index 2b8e4e93..eb107a81 100644 --- a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp +++ b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DLocalEnv::shallow_move(DLocalEnv & self, obj gc) noexcept -> Opaque + IGCObject_DLocalEnv::gco_shallow_move(DLocalEnv & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DLocalEnv::visit_gco_children(DLocalEnv & self, obj fn) noexcept -> void diff --git a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp index 7fa74f97..c894ec35 100644 --- a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DVirtualSchematikaMachine::shallow_move(DVirtualSchematikaMachine & self, obj gc) noexcept -> Opaque + IGCObject_DVirtualSchematikaMachine::gco_shallow_move(DVirtualSchematikaMachine & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DVirtualSchematikaMachine::visit_gco_children(DVirtualSchematikaMachine & self, obj fn) noexcept -> void From 895e8d7a345b977c1e66cd07b201446826b63e35 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 10 Apr 2026 01:10:03 -0400 Subject: [PATCH 126/131] xo-interpreter2 stack: + reason arg to visit_gco_children() Helps streamline DX1Collector in xo-gc/. Want both forward and verify entry points for the same representation. --- include/xo/interpreter2/DClosure.hpp | 4 ++-- include/xo/interpreter2/DLocalEnv.hpp | 4 ++-- .../xo/interpreter2/DVsmApplyClosureFrame.hpp | 3 ++- include/xo/interpreter2/DVsmApplyFrame.hpp | 4 ++-- include/xo/interpreter2/DVsmDefContFrame.hpp | 4 ++-- include/xo/interpreter2/DVsmEvalArgsFrame.hpp | 4 ++-- .../xo/interpreter2/DVsmIfElseContFrame.hpp | 4 ++-- include/xo/interpreter2/DVsmSeqContFrame.hpp | 6 +++--- .../define/IGCObject_DVsmDefContFrame.hpp | 3 ++- .../detail/IGCObject_DClosure.hpp | 3 ++- .../IGCObject_DVsmApplyClosureFrame.hpp | 3 ++- .../detail/IGCObject_DVsmApplyFrame.hpp | 3 ++- .../detail/IGCObject_DVsmEvalArgsFrame.hpp | 3 ++- .../interpreter2/env/IGCObject_DLocalEnv.hpp | 3 ++- .../ifelse/IGCObject_DVsmIfElseContFrame.hpp | 3 ++- .../sequence/IGCObject_DVsmSeqContFrame.hpp | 3 ++- .../vsm/DVirtualSchematikaMachine.hpp | 4 ++-- .../IGCObject_DVirtualSchematikaMachine.hpp | 3 ++- src/interpreter2/DClosure.cpp | 7 ++++--- src/interpreter2/DLocalEnv.cpp | 21 +++++-------------- .../DVirtualSchematikaMachine.cpp | 19 +++++++++-------- src/interpreter2/DVsmApplyClosureFrame.cpp | 7 ++++--- src/interpreter2/DVsmApplyFrame.cpp | 9 ++++---- src/interpreter2/DVsmDefContFrame.cpp | 7 ++++--- src/interpreter2/DVsmEvalArgsFrame.cpp | 7 ++++--- src/interpreter2/DVsmIfElseContFrame.cpp | 7 ++++--- src/interpreter2/DVsmSeqContFrame.cpp | 7 ++++--- src/interpreter2/IGCObject_DClosure.cpp | 4 ++-- .../IGCObject_DVsmApplyClosureFrame.cpp | 4 ++-- src/interpreter2/IGCObject_DVsmApplyFrame.cpp | 4 ++-- .../IGCObject_DVsmDefContFrame.cpp | 4 ++-- .../IGCObject_DVsmEvalArgsFrame.cpp | 4 ++-- .../IGCObject_DVsmIfElseContFrame.cpp | 4 ++-- .../IGCObject_DVsmSeqContFrame.cpp | 4 ++-- .../facet/IGCObject_DLocalEnv.cpp | 4 ++-- .../IGCObject_DVirtualSchematikaMachine.cpp | 4 ++-- 36 files changed, 99 insertions(+), 92 deletions(-) diff --git a/include/xo/interpreter2/DClosure.hpp b/include/xo/interpreter2/DClosure.hpp index 8472cfc5..8462d412 100644 --- a/include/xo/interpreter2/DClosure.hpp +++ b/include/xo/interpreter2/DClosure.hpp @@ -19,9 +19,9 @@ namespace xo { class DClosure { public: using ARuntimeContext = xo::scm::ARuntimeContext; - //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; using size_type = std::int32_t; @@ -59,7 +59,7 @@ namespace xo { ///@{ DClosure * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** @defgroup scm-closure-printable-facet **/ diff --git a/include/xo/interpreter2/DLocalEnv.hpp b/include/xo/interpreter2/DLocalEnv.hpp index e60727b0..4cbe3f7d 100644 --- a/include/xo/interpreter2/DLocalEnv.hpp +++ b/include/xo/interpreter2/DLocalEnv.hpp @@ -16,9 +16,9 @@ namespace xo { class DLocalEnv { public: using DArray = xo::scm::DArray; - //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; using size_type = std::uint32_t; @@ -56,7 +56,7 @@ namespace xo { ///@{ DLocalEnv * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** @defgroup scm-localenv-printable-facet **/ diff --git a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp index 66cbf81a..b13ed03a 100644 --- a/include/xo/interpreter2/DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyClosureFrame.hpp @@ -21,6 +21,7 @@ namespace xo { using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; @@ -42,7 +43,7 @@ namespace xo { /** gcobject facet **/ std::size_t shallow_size() const noexcept; DVsmApplyClosureFrame * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; /** pretty-printing support **/ bool pretty(const ppindentinfo & ppii) const; diff --git a/include/xo/interpreter2/DVsmApplyFrame.hpp b/include/xo/interpreter2/DVsmApplyFrame.hpp index 60a572aa..147b4857 100644 --- a/include/xo/interpreter2/DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/DVsmApplyFrame.hpp @@ -14,9 +14,9 @@ namespace xo { class DVsmApplyFrame { public: using AProcedure = xo::scm::AProcedure; - //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; @@ -39,7 +39,7 @@ namespace xo { void assign_fn(obj x) { this->fn_ = x; } DVsmApplyFrame * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; /** pretty-printing support **/ bool pretty(const ppindentinfo & ppii) const; diff --git a/include/xo/interpreter2/DVsmDefContFrame.hpp b/include/xo/interpreter2/DVsmDefContFrame.hpp index 79a9227c..3174a59f 100644 --- a/include/xo/interpreter2/DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/DVsmDefContFrame.hpp @@ -15,8 +15,8 @@ namespace xo { **/ class DVsmDefContFrame { public: - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; using ppindentinfo = xo::print::ppindentinfo; @@ -52,7 +52,7 @@ namespace xo { ///@{ DVsmDefContFrame * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** @defgrouop scm-vsmseqcontframe-printable-facet printable facet **/ diff --git a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp index 34d74b9a..bc556a9e 100644 --- a/include/xo/interpreter2/DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/DVsmEvalArgsFrame.hpp @@ -14,9 +14,9 @@ namespace xo { /** frame for executing an apply expression **/ class DVsmEvalArgsFrame { public: - //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; @@ -44,7 +44,7 @@ namespace xo { int32_t increment_arg() { return ++i_arg_; } DVsmEvalArgsFrame * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; bool pretty(const ppindentinfo & ppii) const; diff --git a/include/xo/interpreter2/DVsmIfElseContFrame.hpp b/include/xo/interpreter2/DVsmIfElseContFrame.hpp index 4d3176dc..355e4214 100644 --- a/include/xo/interpreter2/DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/DVsmIfElseContFrame.hpp @@ -15,9 +15,9 @@ namespace xo { **/ class DVsmIfElseContFrame { public: - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; @@ -52,7 +52,7 @@ namespace xo { ///@{ DVsmIfElseContFrame * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** @defgrouop scm-vsmseqcontframe-printable-facet printable facet **/ diff --git a/include/xo/interpreter2/DVsmSeqContFrame.hpp b/include/xo/interpreter2/DVsmSeqContFrame.hpp index 6b141cc6..f4412843 100644 --- a/include/xo/interpreter2/DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/DVsmSeqContFrame.hpp @@ -15,10 +15,10 @@ namespace xo { **/ class DVsmSeqContFrame { public: - //using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; + using AAllocator = xo::mm::AAllocator; using ppindentinfo = xo::print::ppindentinfo; public: @@ -57,7 +57,7 @@ namespace xo { ///@{ DVsmSeqContFrame * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** @defgrouop scm-vsmseqcontframe-printable-facet printable facet **/ diff --git a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp index 215515ac..972cbbbd 100644 --- a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DVsmDefContFrame & self, obj fn) noexcept; + static void visit_gco_children(DVsmDefContFrame & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp index 6e6058dd..e7326396 100644 --- a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DClosure & self, obj fn) noexcept; + static void visit_gco_children(DClosure & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp index 9a021127..1113a679 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DVsmApplyClosureFrame & self, obj fn) noexcept; + static void visit_gco_children(DVsmApplyClosureFrame & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp index 2936f81e..469d3a0c 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DVsmApplyFrame & self, obj fn) noexcept; + static void visit_gco_children(DVsmApplyFrame & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp index 15a09267..0a3ce07f 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DVsmEvalArgsFrame & self, obj fn) noexcept; + static void visit_gco_children(DVsmEvalArgsFrame & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp index 29484934..84207c36 100644 --- a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DLocalEnv & self, obj fn) noexcept; + static void visit_gco_children(DLocalEnv & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp index 6812b6a0..ff3545a1 100644 --- a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DVsmIfElseContFrame & self, obj fn) noexcept; + static void visit_gco_children(DVsmIfElseContFrame & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index 9b299d82..907e3fb2 100644 --- a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DVsmSeqContFrame & self, obj fn) noexcept; + static void visit_gco_children(DVsmSeqContFrame & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp index 1b386aaa..2902840c 100644 --- a/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp @@ -71,9 +71,9 @@ namespace xo { public: // will be DArenaVector> probably using Stack = void *; - //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; using span_type = xo::mm::span; @@ -158,7 +158,7 @@ namespace xo { /** forward gc-aware child pointers **/ - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} diff --git a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp index c7d1d1f7..85faa8ee 100644 --- a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DVirtualSchematikaMachine & self, obj fn) noexcept; + static void visit_gco_children(DVirtualSchematikaMachine & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/src/interpreter2/DClosure.cpp b/src/interpreter2/DClosure.cpp index 684eb5d0..c7bb3140 100644 --- a/src/interpreter2/DClosure.cpp +++ b/src/interpreter2/DClosure.cpp @@ -70,10 +70,11 @@ namespace xo { } void - DClosure::visit_gco_children(obj gc) noexcept + DClosure::visit_gco_children(VisitReason reason, + obj gc) noexcept { - gc.visit_child(&lambda_); - gc.visit_child(&env_); + gc.visit_child(reason, &lambda_); + gc.visit_child(reason, &env_); } // ----- printable facet ----- diff --git a/src/interpreter2/DLocalEnv.cpp b/src/interpreter2/DLocalEnv.cpp index e0fe0e79..0e805d1b 100644 --- a/src/interpreter2/DLocalEnv.cpp +++ b/src/interpreter2/DLocalEnv.cpp @@ -97,23 +97,12 @@ namespace xo { } void - DLocalEnv::visit_gco_children(obj gc) noexcept + DLocalEnv::visit_gco_children(VisitReason reason, + obj gc) noexcept { - { - gc.visit_child(&parent_); - //auto iface = xo::facet::impl_for(); - //gc.forward_inplace(&iface, (void **)(&parent_)); - } - { - gc.visit_child(&symtab_); - //auto iface = xo::facet::impl_for(); - //gc.forward_inplace(&iface, (void **)(&symtab_)); - } - { - gc.visit_child(&args_); - //auto iface = xo::facet::impl_for(); - //gc.forward_inplace(&iface, (void **)(&args_)); - } + gc.visit_child(reason, &parent_); + gc.visit_child(reason, &symtab_); + gc.visit_child(reason, &args_); } // ----- printable facet ----- diff --git a/src/interpreter2/DVirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp index 01c56698..c7e864c6 100644 --- a/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -972,18 +972,19 @@ namespace xo { } void - DVirtualSchematikaMachine::visit_gco_children(obj gc) noexcept + DVirtualSchematikaMachine::visit_gco_children(VisitReason reason, + obj gc) noexcept { - reader_.visit_gco_children(gc); + reader_.visit_gco_children(reason, gc); - 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_); + gc.visit_child(reason, &stack_); + gc.visit_poly_child(reason, &expr_); + gc.visit_child(reason, &global_env_); + gc.visit_child(reason, &local_env_); + gc.visit_child(reason, &fn_); + gc.visit_child(reason, &args_); if (value_.is_value()) { - gc.visit_child(const_cast *>(&value_.value_ref())); + gc.visit_child(reason, const_cast *>(&value_.value_ref())); } } diff --git a/src/interpreter2/DVsmApplyClosureFrame.cpp b/src/interpreter2/DVsmApplyClosureFrame.cpp index dbb1601c..55199464 100644 --- a/src/interpreter2/DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/DVsmApplyClosureFrame.cpp @@ -39,10 +39,11 @@ namespace xo { } void - DVsmApplyClosureFrame::visit_gco_children(obj gc) noexcept + DVsmApplyClosureFrame::visit_gco_children(VisitReason reason, + obj gc) noexcept { - gc.visit_child(&stack_); - gc.visit_child(&local_env_); + gc.visit_child(reason, &stack_); + gc.visit_child(reason, &local_env_); } bool diff --git a/src/interpreter2/DVsmApplyFrame.cpp b/src/interpreter2/DVsmApplyFrame.cpp index 19db4bdf..591d8aef 100644 --- a/src/interpreter2/DVsmApplyFrame.cpp +++ b/src/interpreter2/DVsmApplyFrame.cpp @@ -47,11 +47,12 @@ namespace xo { } void - DVsmApplyFrame::visit_gco_children(obj gc) noexcept + DVsmApplyFrame::visit_gco_children(VisitReason reason, + obj gc) noexcept { - gc.visit_child(&parent_); - gc.visit_child(&fn_); - gc.visit_child(&args_); + gc.visit_child(reason, &parent_); + gc.visit_child(reason, &fn_); + gc.visit_child(reason, &args_); } bool diff --git a/src/interpreter2/DVsmDefContFrame.cpp b/src/interpreter2/DVsmDefContFrame.cpp index 97b12ab0..d8c52d10 100644 --- a/src/interpreter2/DVsmDefContFrame.cpp +++ b/src/interpreter2/DVsmDefContFrame.cpp @@ -38,10 +38,11 @@ namespace xo { } void - DVsmDefContFrame::visit_gco_children(obj gc) noexcept + DVsmDefContFrame::visit_gco_children(VisitReason reason, + obj gc) noexcept { - gc.visit_child(&parent_); - gc.visit_child(&def_expr_); + gc.visit_child(reason, &parent_); + gc.visit_child(reason, &def_expr_); } // printable facet diff --git a/src/interpreter2/DVsmEvalArgsFrame.cpp b/src/interpreter2/DVsmEvalArgsFrame.cpp index 42d44de5..b4e3f448 100644 --- a/src/interpreter2/DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/DVsmEvalArgsFrame.cpp @@ -48,10 +48,11 @@ namespace xo { } void - DVsmEvalArgsFrame::visit_gco_children(obj gc) noexcept + DVsmEvalArgsFrame::visit_gco_children(VisitReason reason, + obj gc) noexcept { - gc.visit_child(&parent_); - gc.visit_child(&apply_expr_); + gc.visit_child(reason, &parent_); + gc.visit_child(reason, &apply_expr_); } bool diff --git a/src/interpreter2/DVsmIfElseContFrame.cpp b/src/interpreter2/DVsmIfElseContFrame.cpp index a82206bc..f1f88952 100644 --- a/src/interpreter2/DVsmIfElseContFrame.cpp +++ b/src/interpreter2/DVsmIfElseContFrame.cpp @@ -36,10 +36,11 @@ namespace xo { } void - DVsmIfElseContFrame::visit_gco_children(obj gc) noexcept + DVsmIfElseContFrame::visit_gco_children(VisitReason reason, + obj gc) noexcept { - gc.visit_child(&parent_); - gc.visit_child(&ifelse_expr_); + gc.visit_child(reason, &parent_); + gc.visit_child(reason, &ifelse_expr_); } // printable facet diff --git a/src/interpreter2/DVsmSeqContFrame.cpp b/src/interpreter2/DVsmSeqContFrame.cpp index cb031b18..219342b5 100644 --- a/src/interpreter2/DVsmSeqContFrame.cpp +++ b/src/interpreter2/DVsmSeqContFrame.cpp @@ -39,10 +39,11 @@ namespace xo { } void - DVsmSeqContFrame::visit_gco_children(obj gc) noexcept + DVsmSeqContFrame::visit_gco_children(VisitReason reason, + obj gc) noexcept { - gc.visit_child(&parent_); - gc.visit_child(&seq_expr_); + gc.visit_child(reason, &parent_); + gc.visit_child(reason, &seq_expr_); } // printable facet diff --git a/src/interpreter2/IGCObject_DClosure.cpp b/src/interpreter2/IGCObject_DClosure.cpp index be0c9903..dc281fd4 100644 --- a/src/interpreter2/IGCObject_DClosure.cpp +++ b/src/interpreter2/IGCObject_DClosure.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DClosure::visit_gco_children(DClosure & self, obj fn) noexcept -> void + IGCObject_DClosure::visit_gco_children(DClosure & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp index 5fcb724a..e080c301 100644 --- a/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DVsmApplyClosureFrame::visit_gco_children(DVsmApplyClosureFrame & self, obj fn) noexcept -> void + IGCObject_DVsmApplyClosureFrame::visit_gco_children(DVsmApplyClosureFrame & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp index 4e8adef7..b0ce1838 100644 --- a/src/interpreter2/IGCObject_DVsmApplyFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmApplyFrame.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DVsmApplyFrame::visit_gco_children(DVsmApplyFrame & self, obj fn) noexcept -> void + IGCObject_DVsmApplyFrame::visit_gco_children(DVsmApplyFrame & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp index 60cb90d0..c0ed5412 100644 --- a/src/interpreter2/IGCObject_DVsmDefContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmDefContFrame.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DVsmDefContFrame::visit_gco_children(DVsmDefContFrame & self, obj fn) noexcept -> void + IGCObject_DVsmDefContFrame::visit_gco_children(DVsmDefContFrame & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp index c9697c90..0db77058 100644 --- a/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DVsmEvalArgsFrame::visit_gco_children(DVsmEvalArgsFrame & self, obj fn) noexcept -> void + IGCObject_DVsmEvalArgsFrame::visit_gco_children(DVsmEvalArgsFrame & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp index d8fa856d..3488e8c3 100644 --- a/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DVsmIfElseContFrame::visit_gco_children(DVsmIfElseContFrame & self, obj fn) noexcept -> void + IGCObject_DVsmIfElseContFrame::visit_gco_children(DVsmIfElseContFrame & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp index aa004bce..5293306f 100644 --- a/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp +++ b/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DVsmSeqContFrame::visit_gco_children(DVsmSeqContFrame & self, obj fn) noexcept -> void + IGCObject_DVsmSeqContFrame::visit_gco_children(DVsmSeqContFrame & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp index eb107a81..f086b07a 100644 --- a/src/interpreter2/facet/IGCObject_DLocalEnv.cpp +++ b/src/interpreter2/facet/IGCObject_DLocalEnv.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DLocalEnv::visit_gco_children(DLocalEnv & self, obj fn) noexcept -> void + IGCObject_DLocalEnv::visit_gco_children(DLocalEnv & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp index c894ec35..4b9d83bb 100644 --- a/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DVirtualSchematikaMachine::visit_gco_children(DVirtualSchematikaMachine & self, obj fn) noexcept -> void + IGCObject_DVirtualSchematikaMachine::visit_gco_children(DVirtualSchematikaMachine & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ From 1651ed1d436cea83d33163b6f064e4bcf8e7d05f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 28 Apr 2026 23:17:00 -0400 Subject: [PATCH 127/131] xo-object2: obj argument to DArray::push_back() --- src/interpreter2/DVirtualSchematikaMachine.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/interpreter2/DVirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp index c7e864c6..fc64e2e8 100644 --- a/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -561,8 +561,8 @@ namespace xo { auto apply = obj::from(expr_); // accumulate evaluated arguments here - DArray * args = DArray::empty(mm_.to_op(), - apply->n_args()); + DArray * args = DArray::_empty(mm_.to_op(), + apply->n_args()); // TODO: check function signature @@ -821,7 +821,9 @@ namespace xo { log && log(xtag("i_arg", i_arg), xtag("n_arg", args->size()), xtag("cap", args->capacity())); - args->push_back(value); + auto gc = mm_.to_op().to_facet(); + + args->push_back(gc, value); i_arg = evalargs_frame->increment_arg(); From a8397c78d78302050b3d3a13cf7424a7975a08cb Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 1 May 2026 19:54:26 -0400 Subject: [PATCH 128/131] refactor focusing on xo-alloc2/ xo-gc/ write-barrier ability to inform allocator of gco->gco mutation, via AAllocator i/face. --- include/xo/interpreter2/DLocalEnv.hpp | 3 ++- .../interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp | 2 +- src/interpreter2/DLocalEnv.cpp | 7 ++++--- src/interpreter2/DVirtualSchematikaMachine.cpp | 4 ++-- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/include/xo/interpreter2/DLocalEnv.hpp b/include/xo/interpreter2/DLocalEnv.hpp index 4cbe3f7d..a9253bbc 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 AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using VisitReason = xo::mm::VisitReason; @@ -49,7 +50,7 @@ namespace xo { obj lookup_value(Binding ix) const noexcept; /** assign value associated with binding @p ix to @p x **/ - void assign_value(Binding ix, obj x); + void assign_value(obj mm, Binding ix, obj x); ///@} /** @defgroup scm-localenv-gcobject-facet **/ diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index 907e3fb2..f45f9d0b 100644 --- a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -67,4 +67,4 @@ when @p fn invokes garbage collector reentry point **/ } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/src/interpreter2/DLocalEnv.cpp b/src/interpreter2/DLocalEnv.cpp index 0e805d1b..6877f971 100644 --- a/src/interpreter2/DLocalEnv.cpp +++ b/src/interpreter2/DLocalEnv.cpp @@ -63,7 +63,9 @@ namespace xo { } void - DLocalEnv::assign_value(Binding ix, obj x) + DLocalEnv::assign_value(obj mm, + Binding ix, + obj x) { scope log(XO_DEBUG(true)); @@ -79,8 +81,7 @@ namespace xo { auto j = ix.j_slot(); if (j < static_cast(env->n_vars())) { - log && log("STUB: need write barrier for GC here"); - (*(env->args_))[j] = x; + env->args_->assign_at(mm, j, x); } else { assert(false); } diff --git a/src/interpreter2/DVirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp index fc64e2e8..c8604e50 100644 --- a/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -821,9 +821,9 @@ namespace xo { log && log(xtag("i_arg", i_arg), xtag("n_arg", args->size()), xtag("cap", args->capacity())); - auto gc = mm_.to_op().to_facet(); + //auto gc = mm_.to_op().to_facet(); - args->push_back(gc, value); + args->push_back(mm_.to_op(), value); i_arg = evalargs_frame->increment_arg(); From 327dce3f78cd469676be1dcc2a8a5521f9c6473e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 2 May 2026 13:49:29 -0400 Subject: [PATCH 129/131] xo-gc stack: refactor + streamline. Retiring unused Collector typealiases. Fix #include topology. Fix/improve write barrier setup. --- include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp | 1 - include/xo/interpreter2/detail/IGCObject_DClosure.hpp | 1 - .../xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp | 1 - include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp | 1 - include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp | 1 - include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp | 1 - .../xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp | 1 - .../xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp | 3 +-- .../interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp | 1 - 9 files changed, 1 insertion(+), 10 deletions(-) diff --git a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp index 972cbbbd..ed1ba4c2 100644 --- a/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp +++ b/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp index e7326396..26985fd6 100644 --- a/include/xo/interpreter2/detail/IGCObject_DClosure.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp index 1113a679..3f3a452c 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp index 469d3a0c..0228f54e 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp index 0a3ce07f..0bdf0784 100644 --- a/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp +++ b/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp index 84207c36..ce5789bd 100644 --- a/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp +++ b/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp index ff3545a1..77accb20 100644 --- a/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp +++ b/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index f45f9d0b..d289f7ff 100644 --- a/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; @@ -67,4 +66,4 @@ when @p fn invokes garbage collector reentry point **/ } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp index 85faa8ee..62856b6a 100644 --- a/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp +++ b/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; From 1aa20227ca9446126e55527f972477750c17ef74 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 2 May 2026 13:58:22 -0400 Subject: [PATCH 130/131] tidy: drop stale ACollector comments --- src/interpreter2/DVirtualSchematikaMachine.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/interpreter2/DVirtualSchematikaMachine.cpp b/src/interpreter2/DVirtualSchematikaMachine.cpp index c8604e50..021a38ea 100644 --- a/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -75,7 +75,8 @@ namespace xo { // establish the set of types that mm_ will be able to collect - CollectorTypeRegistry::instance().install_types(retval.to_op().to_facet()); + CollectorTypeRegistry::instance().install_types + (retval.to_op().to_facet()); return retval; } @@ -821,8 +822,6 @@ namespace xo { log && log(xtag("i_arg", i_arg), xtag("n_arg", args->size()), xtag("cap", args->capacity())); - //auto gc = mm_.to_op().to_facet(); - args->push_back(mm_.to_op(), value); i_arg = evalargs_frame->increment_arg(); From bc5a2c3959aead2881c30fe8e87f71420a581bf2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 31 May 2026 00:12:29 -0400 Subject: [PATCH 131/131] xo-interpreter2: build: fix cmake nits [PKG][BUGFIX] --- CMakeLists.txt | 12 ------------ cmake/xo_interpreter2Config.cmake.in | 2 +- src/interpreter2/CMakeLists.txt | 5 +---- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 18463e9d..1ab36e49 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,7 +55,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmapplyframe FACET_PKG xo_alloc2 -# REPR VsmApplyFrame INPUT idl/IGCObject_DVsmApplyFrame.json5 ) @@ -63,7 +62,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmapplyframe FACET_PKG xo_printable2 -# REPR VsmApplyFrame INPUT idl/IPrintable_DVsmApplyFrame.json5 ) @@ -73,7 +71,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmevalargsframe FACET_PKG xo_alloc2 -# REPR VsmEvalArgsFrame INPUT idl/IGCObject_DVsmEvalArgsFrame.json5 ) @@ -81,7 +78,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmevalargsframe FACET_PKG xo_printable2 -# REPR DVsmEvalArgsFrame INPUT idl/IPrintable_DVsmEvalArgsFrame.json5 ) @@ -91,7 +87,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmapplyclosureframe FACET_PKG xo_alloc2 -# REPR VsmApplyClosureFrame INPUT idl/IGCObject_DVsmApplyClosureFrame.json5 ) @@ -99,7 +94,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmapplyclosureframe FACET_PKG xo_printable2 -# REPR DVsmApplyClosureFrame INPUT idl/IPrintable_DVsmApplyClosureFrame.json5 ) @@ -109,7 +103,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmifelsecontframe FACET_PKG xo_alloc2 -# REPR VsmIfElseContFrame INPUT idl/IGCObject_DVsmIfElseContFrame.json5 ) @@ -117,7 +110,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmifelsecontframe FACET_PKG xo_printable2 -# REPR VsmIfElseContFrame INPUT idl/IPrintable_DVsmIfElseContFrame.json5 ) @@ -127,7 +119,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-vsmseqcontframe FACET_PKG xo_alloc2 -# REPR VsmSeqContFrame INPUT idl/IGCObject_DVsmSeqContFrame.json5 ) @@ -135,7 +126,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-vsmseqcontframe FACET_PKG xo_printable2 -# REPR DVsmSeqContFrame INPUT idl/IPrintable_DVsmSeqContFrame.json5 ) @@ -154,7 +144,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-gcobject-closure FACET_PKG xo_alloc2 -# REPR Closure INPUT idl/IGCObject_DClosure.json5 ) @@ -162,7 +151,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-interpreter2-facetimpl-printable-closure FACET_PKG xo_printable2 -# REPR Closure INPUT idl/IPrintable_DClosure.json5 ) diff --git a/cmake/xo_interpreter2Config.cmake.in b/cmake/xo_interpreter2Config.cmake.in index 3310d075..f7a4d276 100644 --- a/cmake/xo_interpreter2Config.cmake.in +++ b/cmake/xo_interpreter2Config.cmake.in @@ -6,7 +6,7 @@ include(CMakeFindDependencyMacro) # must coordinate with xo_dependency() calls # in CMakeLists.txt # -find_dependency(xo_expression2) +find_dependency(xo_reader2) find_dependency(xo_gc) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") diff --git a/src/interpreter2/CMakeLists.txt b/src/interpreter2/CMakeLists.txt index 5f40b44f..37e9ebfe 100644 --- a/src/interpreter2/CMakeLists.txt +++ b/src/interpreter2/CMakeLists.txt @@ -52,7 +52,4 @@ xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 $ # note: deps here must also appear in cmake/xo_interpreter2Config.cmake.in xo_dependency(${SELF_LIB} xo_reader2) xo_dependency(${SELF_LIB} xo_gc) -#xo_dependency(${SELF_LIB} reflect) -#xo_dependency(${SELF_LIB} xo_printable2) -#xo_dependency(${SELF_LIB} xo_flatstring) -#xo_dependency(${SELF_LIB} indentlog) +