From 7f4b4e7cbd0b9e0f6edd8ecdbd9b11fb92d462cf Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 6 Jun 2026 22:13:05 -0400 Subject: [PATCH] git subrepo clone (merge) git@github.com:Rconybea/xo-interpreter2.git xo-interpreter2 subrepo: subdir: "xo-interpreter2" merged: "e4c6ff57" upstream: origin: "git@github.com:Rconybea/xo-interpreter2.git" branch: "main" commit: "e4c6ff57" git-subrepo: version: "0.4.9" origin: "???" commit: "???" --- xo-interpreter2/.gitrepo | 12 + xo-interpreter2/CMakeLists.txt | 198 ++++ xo-interpreter2/README.md | 1 + .../cmake/xo-bootstrap-macros.cmake | 33 + .../cmake/xo_interpreter2Config.cmake.in | 14 + xo-interpreter2/idl/IGCObject_DClosure.json5 | 18 + xo-interpreter2/idl/IGCObject_DLocalEnv.json5 | 18 + .../IGCObject_DVirtualSchematikaMachine.json5 | 18 + .../idl/IGCObject_DVsmApplyClosureFrame.json5 | 18 + .../idl/IGCObject_DVsmApplyFrame.json5 | 18 + .../idl/IGCObject_DVsmDefContFrame.json5 | 18 + .../idl/IGCObject_DVsmEvalArgsFrame.json5 | 18 + .../idl/IGCObject_DVsmIfElseContFrame.json5 | 18 + .../idl/IGCObject_DVsmSeqContFrame.json5 | 18 + xo-interpreter2/idl/IPrintable_DClosure.json5 | 16 + .../idl/IPrintable_DLocalEnv.json5 | 16 + .../IPrintable_DVsmApplyClosureFrame.json5 | 16 + .../idl/IPrintable_DVsmApplyFrame.json5 | 16 + .../idl/IPrintable_DVsmDefContFrame.json5 | 16 + .../idl/IPrintable_DVsmEvalArgsFrame.json5 | 16 + .../idl/IPrintable_DVsmIfElseContFrame.json5 | 16 + .../idl/IPrintable_DVsmSeqContFrame.json5 | 16 + xo-interpreter2/idl/IProcedure_DClosure.json5 | 19 + .../idl/IRuntimeContext_DVsmRcx.json5 | 18 + .../include/xo/interpreter2/.gitkeep | 0 .../include/xo/interpreter2/Closure.hpp | 13 + .../include/xo/interpreter2/DApplyFrame.hpp | 20 + .../include/xo/interpreter2/DClosure.hpp | 84 ++ .../include/xo/interpreter2/DLocalEnv.hpp | 84 ++ .../xo/interpreter2/DVsmApplyClosureFrame.hpp | 64 ++ .../xo/interpreter2/DVsmApplyFrame.hpp | 69 ++ .../xo/interpreter2/DVsmDefContFrame.hpp | 82 ++ .../xo/interpreter2/DVsmEvalArgsFrame.hpp | 67 ++ .../xo/interpreter2/DVsmIfElseContFrame.hpp | 82 ++ .../include/xo/interpreter2/DVsmRcx.hpp | 44 + .../xo/interpreter2/DVsmSeqContFrame.hpp | 89 ++ .../include/xo/interpreter2/LocalEnv.hpp | 12 + .../xo/interpreter2/SetupInterpreter2.hpp | 27 + .../interpreter2/VirtualSchematikaMachine.hpp | 11 + .../xo/interpreter2/VsmApplyClosureFrame.hpp | 12 + .../include/xo/interpreter2/VsmApplyFrame.hpp | 12 + .../include/xo/interpreter2/VsmConfig.hpp | 74 ++ .../xo/interpreter2/VsmDefContFrame.hpp | 12 + .../xo/interpreter2/VsmEvalArgsFrame.hpp | 12 + .../include/xo/interpreter2/VsmFrame.hpp | 36 + .../xo/interpreter2/VsmIfElseContFrame.hpp | 12 + .../include/xo/interpreter2/VsmInstr.hpp | 63 ++ .../include/xo/interpreter2/VsmOpcode.hpp | 67 ++ .../include/xo/interpreter2/VsmPrimitives.hpp | 28 + .../include/xo/interpreter2/VsmRcx.hpp | 11 + .../xo/interpreter2/VsmSeqContFrame.hpp | 12 + .../define/IGCObject_DVsmDefContFrame.hpp | 69 ++ .../define/IPrintable_DVsmDefContFrame.hpp | 62 ++ .../detail/IGCObject_DClosure.hpp | 69 ++ .../IGCObject_DVsmApplyClosureFrame.hpp | 69 ++ .../detail/IGCObject_DVsmApplyFrame.hpp | 69 ++ .../detail/IGCObject_DVsmEvalArgsFrame.hpp | 69 ++ .../detail/IPrintable_DClosure.hpp | 62 ++ .../detail/IPrintable_DLocalEnv.hpp | 62 ++ .../IPrintable_DVsmApplyClosureFrame.hpp | 62 ++ .../detail/IPrintable_DVsmApplyFrame.hpp | 62 ++ .../detail/IPrintable_DVsmEvalArgsFrame.hpp | 62 ++ .../detail/IProcedure_DClosure.hpp | 67 ++ .../detail/IRuntimeContext_DVsmRcx.hpp | 69 ++ .../interpreter2/env/IGCObject_DLocalEnv.hpp | 69 ++ .../interpreter2/env/IPrintable_DLocalEnv.hpp | 62 ++ .../ifelse/IGCObject_DVsmIfElseContFrame.hpp | 69 ++ .../ifelse/IPrintable_DVsmIfElseContFrame.hpp | 62 ++ .../xo/interpreter2/init_interpreter2.hpp | 21 + .../sequence/IGCObject_DVsmSeqContFrame.hpp | 69 ++ .../sequence/IPrintable_DVsmSeqContFrame.hpp | 62 ++ .../vsm/DVirtualSchematikaMachine.hpp | 350 ++++++ .../IGCObject_DVirtualSchematikaMachine.hpp | 69 ++ .../src/interpreter2/CMakeLists.txt | 55 + xo-interpreter2/src/interpreter2/DClosure.cpp | 101 ++ .../src/interpreter2/DLocalEnv.cpp | 128 +++ .../DVirtualSchematikaMachine.cpp | 995 ++++++++++++++++++ .../interpreter2/DVsmApplyClosureFrame.cpp | 61 ++ .../src/interpreter2/DVsmApplyFrame.cpp | 70 ++ .../src/interpreter2/DVsmDefContFrame.cpp | 61 ++ .../src/interpreter2/DVsmEvalArgsFrame.cpp | 69 ++ .../src/interpreter2/DVsmIfElseContFrame.cpp | 59 ++ xo-interpreter2/src/interpreter2/DVsmRcx.cpp | 51 + .../src/interpreter2/DVsmSeqContFrame.cpp | 63 ++ .../src/interpreter2/IGCObject_DClosure.cpp | 32 + .../IGCObject_DVsmApplyClosureFrame.cpp | 32 + .../interpreter2/IGCObject_DVsmApplyFrame.cpp | 32 + .../IGCObject_DVsmDefContFrame.cpp | 32 + .../IGCObject_DVsmEvalArgsFrame.cpp | 32 + .../IGCObject_DVsmIfElseContFrame.cpp | 32 + .../IGCObject_DVsmSeqContFrame.cpp | 32 + .../src/interpreter2/IPrintable_DClosure.cpp | 28 + .../src/interpreter2/IPrintable_DLocalEnv.cpp | 28 + .../IPrintable_DVsmApplyClosureFrame.cpp | 28 + .../IPrintable_DVsmApplyFrame.cpp | 28 + .../IPrintable_DVsmDefContFrame.cpp | 28 + .../IPrintable_DVsmEvalArgsFrame.cpp | 28 + .../IPrintable_DVsmIfElseContFrame.cpp | 28 + .../IPrintable_DVsmSeqContFrame.cpp | 28 + .../interpreter2/IRuntimeContext_DVsmRcx.cpp | 52 + .../src/interpreter2/SetupInterpreter2.cpp | 146 +++ .../src/interpreter2/VsmApplyFrame.cpp | 0 xo-interpreter2/src/interpreter2/VsmInstr.cpp | 59 ++ .../src/interpreter2/VsmPrimitives.cpp | 62 ++ .../facet/IGCObject_DLocalEnv.cpp | 32 + .../IGCObject_DVirtualSchematikaMachine.cpp | 32 + .../src/interpreter2/init_interpreter2.cpp | 44 + xo-interpreter2/src/skrepl/CMakeLists.txt | 13 + xo-interpreter2/src/skrepl/skreplxx.cpp | 260 +++++ xo-interpreter2/utest/CMakeLists.txt | 11 + .../utest/VirtualSchematikaMachine.test.cpp | 557 ++++++++++ .../utest/interpreter2_utest_main.cpp | 32 + 112 files changed, 6831 insertions(+) create mode 100644 xo-interpreter2/.gitrepo create mode 100644 xo-interpreter2/CMakeLists.txt create mode 100644 xo-interpreter2/README.md create mode 100644 xo-interpreter2/cmake/xo-bootstrap-macros.cmake create mode 100644 xo-interpreter2/cmake/xo_interpreter2Config.cmake.in create mode 100644 xo-interpreter2/idl/IGCObject_DClosure.json5 create mode 100644 xo-interpreter2/idl/IGCObject_DLocalEnv.json5 create mode 100644 xo-interpreter2/idl/IGCObject_DVirtualSchematikaMachine.json5 create mode 100644 xo-interpreter2/idl/IGCObject_DVsmApplyClosureFrame.json5 create mode 100644 xo-interpreter2/idl/IGCObject_DVsmApplyFrame.json5 create mode 100644 xo-interpreter2/idl/IGCObject_DVsmDefContFrame.json5 create mode 100644 xo-interpreter2/idl/IGCObject_DVsmEvalArgsFrame.json5 create mode 100644 xo-interpreter2/idl/IGCObject_DVsmIfElseContFrame.json5 create mode 100644 xo-interpreter2/idl/IGCObject_DVsmSeqContFrame.json5 create mode 100644 xo-interpreter2/idl/IPrintable_DClosure.json5 create mode 100644 xo-interpreter2/idl/IPrintable_DLocalEnv.json5 create mode 100644 xo-interpreter2/idl/IPrintable_DVsmApplyClosureFrame.json5 create mode 100644 xo-interpreter2/idl/IPrintable_DVsmApplyFrame.json5 create mode 100644 xo-interpreter2/idl/IPrintable_DVsmDefContFrame.json5 create mode 100644 xo-interpreter2/idl/IPrintable_DVsmEvalArgsFrame.json5 create mode 100644 xo-interpreter2/idl/IPrintable_DVsmIfElseContFrame.json5 create mode 100644 xo-interpreter2/idl/IPrintable_DVsmSeqContFrame.json5 create mode 100644 xo-interpreter2/idl/IProcedure_DClosure.json5 create mode 100644 xo-interpreter2/idl/IRuntimeContext_DVsmRcx.json5 create mode 100644 xo-interpreter2/include/xo/interpreter2/.gitkeep create mode 100644 xo-interpreter2/include/xo/interpreter2/Closure.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/DApplyFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/DClosure.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/DLocalEnv.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/DVsmApplyClosureFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/DVsmApplyFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/DVsmDefContFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/DVsmEvalArgsFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/DVsmIfElseContFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/DVsmRcx.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/DVsmSeqContFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/LocalEnv.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/SetupInterpreter2.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/VirtualSchematikaMachine.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/VsmApplyClosureFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/VsmApplyFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/VsmConfig.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/VsmDefContFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/VsmEvalArgsFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/VsmFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/VsmIfElseContFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/VsmInstr.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/VsmOpcode.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/VsmPrimitives.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/VsmRcx.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/VsmSeqContFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/define/IPrintable_DVsmDefContFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DClosure.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DClosure.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DLocalEnv.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DVsmApplyClosureFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DVsmApplyFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DVsmEvalArgsFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/detail/IProcedure_DClosure.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/env/IPrintable_DLocalEnv.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/ifelse/IPrintable_DVsmIfElseContFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/init_interpreter2.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/sequence/IPrintable_DVsmSeqContFrame.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp create mode 100644 xo-interpreter2/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp create mode 100644 xo-interpreter2/src/interpreter2/CMakeLists.txt create mode 100644 xo-interpreter2/src/interpreter2/DClosure.cpp create mode 100644 xo-interpreter2/src/interpreter2/DLocalEnv.cpp create mode 100644 xo-interpreter2/src/interpreter2/DVirtualSchematikaMachine.cpp create mode 100644 xo-interpreter2/src/interpreter2/DVsmApplyClosureFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/DVsmApplyFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/DVsmDefContFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/DVsmEvalArgsFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/DVsmIfElseContFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/DVsmRcx.cpp create mode 100644 xo-interpreter2/src/interpreter2/DVsmSeqContFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/IGCObject_DClosure.cpp create mode 100644 xo-interpreter2/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/IGCObject_DVsmApplyFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/IGCObject_DVsmDefContFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/IPrintable_DClosure.cpp create mode 100644 xo-interpreter2/src/interpreter2/IPrintable_DLocalEnv.cpp create mode 100644 xo-interpreter2/src/interpreter2/IPrintable_DVsmApplyClosureFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/IPrintable_DVsmApplyFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/IPrintable_DVsmDefContFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/IPrintable_DVsmEvalArgsFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/IPrintable_DVsmIfElseContFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/IPrintable_DVsmSeqContFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/IRuntimeContext_DVsmRcx.cpp create mode 100644 xo-interpreter2/src/interpreter2/SetupInterpreter2.cpp create mode 100644 xo-interpreter2/src/interpreter2/VsmApplyFrame.cpp create mode 100644 xo-interpreter2/src/interpreter2/VsmInstr.cpp create mode 100644 xo-interpreter2/src/interpreter2/VsmPrimitives.cpp create mode 100644 xo-interpreter2/src/interpreter2/facet/IGCObject_DLocalEnv.cpp create mode 100644 xo-interpreter2/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp create mode 100644 xo-interpreter2/src/interpreter2/init_interpreter2.cpp create mode 100644 xo-interpreter2/src/skrepl/CMakeLists.txt create mode 100644 xo-interpreter2/src/skrepl/skreplxx.cpp create mode 100644 xo-interpreter2/utest/CMakeLists.txt create mode 100644 xo-interpreter2/utest/VirtualSchematikaMachine.test.cpp create mode 100644 xo-interpreter2/utest/interpreter2_utest_main.cpp diff --git a/xo-interpreter2/.gitrepo b/xo-interpreter2/.gitrepo new file mode 100644 index 00000000..b3fabe36 --- /dev/null +++ b/xo-interpreter2/.gitrepo @@ -0,0 +1,12 @@ +; DO NOT EDIT (unless you know what you are doing) +; +; This subdirectory is a git "subrepo", and this file is maintained by the +; git-subrepo command. See https://github.com/ingydotnet/git-subrepo#readme +; +[subrepo] + remote = git@github.com:Rconybea/xo-interpreter2.git + branch = main + commit = e4c6ff5739a2a97d2c470630da63541196a1cc08 + parent = d11f6ca5977b1f6b79b201652ce37e631f6d48ba + method = merge + cmdver = 0.4.9 diff --git a/xo-interpreter2/CMakeLists.txt b/xo-interpreter2/CMakeLists.txt new file mode 100644 index 00000000..1ab36e49 --- /dev/null +++ b/xo-interpreter2/CMakeLists.txt @@ -0,0 +1,198 @@ +# 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(src/interpreter2) +add_subdirectory(src/skrepl) +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 + 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 + INPUT idl/IPrintable_DVsmDefContFrame.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-gcobject-vsmapplyframe + FACET_PKG xo_alloc2 + INPUT idl/IGCObject_DVsmApplyFrame.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-printable-vsmapplyframe + FACET_PKG xo_printable2 + INPUT idl/IPrintable_DVsmApplyFrame.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-gcobject-vsmevalargsframe + FACET_PKG xo_alloc2 + INPUT idl/IGCObject_DVsmEvalArgsFrame.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-printable-vsmevalargsframe + FACET_PKG xo_printable2 + INPUT idl/IPrintable_DVsmEvalArgsFrame.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-gcobject-vsmapplyclosureframe + FACET_PKG xo_alloc2 + INPUT idl/IGCObject_DVsmApplyClosureFrame.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-printable-vsmapplyclosureframe + FACET_PKG xo_printable2 + INPUT idl/IPrintable_DVsmApplyClosureFrame.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-gcobject-vsmifelsecontframe + FACET_PKG xo_alloc2 + INPUT idl/IGCObject_DVsmIfElseContFrame.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-printable-vsmifelsecontframe + FACET_PKG xo_printable2 + INPUT idl/IPrintable_DVsmIfElseContFrame.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-gcobject-vsmseqcontframe + FACET_PKG xo_alloc2 + INPUT idl/IGCObject_DVsmSeqContFrame.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-printable-vsmseqcontframe + FACET_PKG xo_printable2 + INPUT idl/IPrintable_DVsmSeqContFrame.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +# +#xo_add_genfacetimpl( +# TARGET xo-interpreter2-facetimpl-procedure-closure +# FACET_PKG xo_procedure2 +# REPR Closure +# INPUT idl/IProcedure_DClosure.json5 +#) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-gcobject-closure + FACET_PKG xo_alloc2 + INPUT idl/IGCObject_DClosure.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-printable-closure + FACET_PKG xo_printable2 + INPUT idl/IPrintable_DClosure.json5 +) + +# ---------------------------------------------------------------- + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-gcobject-localenv + FACET_PKG xo_alloc2 + INPUT idl/IGCObject_DLocalEnv.json5 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-printable-localenv + FACET_PKG xo_printable2 + INPUT idl/IPrintable_DLocalEnv.json5 +) + +# ---------------------------------------------------------------- + +xo_add_genfacetimpl( + TARGET xo-interpreter2-facetimpl-runtimecontext-vsmrcx + FACET_PKG xo_procedure2 + INPUT idl/IRuntimeContext_DVsmRcx.json5 + ) + +# ---------------------------------------------------------------- + +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) + +# ---------------------------------------------------------------- +# 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/xo-interpreter2/README.md b/xo-interpreter2/README.md new file mode 100644 index 00000000..f667e82d --- /dev/null +++ b/xo-interpreter2/README.md @@ -0,0 +1 @@ +# xo-interpreter2 diff --git a/xo-interpreter2/cmake/xo-bootstrap-macros.cmake b/xo-interpreter2/cmake/xo-bootstrap-macros.cmake new file mode 100644 index 00000000..2cf387e5 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/cmake/xo_interpreter2Config.cmake.in b/xo-interpreter2/cmake/xo_interpreter2Config.cmake.in new file mode 100644 index 00000000..f7a4d276 --- /dev/null +++ b/xo-interpreter2/cmake/xo_interpreter2Config.cmake.in @@ -0,0 +1,14 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +# note: changes to find_dependency() calls here +# must coordinate with xo_dependency() calls +# in CMakeLists.txt +# +find_dependency(xo_reader2) +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@") diff --git a/xo-interpreter2/idl/IGCObject_DClosure.json5 b/xo-interpreter2/idl/IGCObject_DClosure.json5 new file mode 100644 index 00000000..944ee2f4 --- /dev/null +++ b/xo-interpreter2/idl/IGCObject_DClosure.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", + 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/xo-interpreter2/idl/IGCObject_DLocalEnv.json5 b/xo-interpreter2/idl/IGCObject_DLocalEnv.json5 new file mode 100644 index 00000000..a4a252a4 --- /dev/null +++ b/xo-interpreter2/idl/IGCObject_DLocalEnv.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2/facet", + 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 LocalEnv", + using_doxygen: true, + repr: "DLocalEnv", + doc: [ "implement AGCObject for DLocalEnv" ], +} diff --git a/xo-interpreter2/idl/IGCObject_DVirtualSchematikaMachine.json5 b/xo-interpreter2/idl/IGCObject_DVirtualSchematikaMachine.json5 new file mode 100644 index 00000000..50275848 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/idl/IGCObject_DVsmApplyClosureFrame.json5 b/xo-interpreter2/idl/IGCObject_DVsmApplyClosureFrame.json5 new file mode 100644 index 00000000..bfdb8c96 --- /dev/null +++ b/xo-interpreter2/idl/IGCObject_DVsmApplyClosureFrame.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", + 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/xo-interpreter2/idl/IGCObject_DVsmApplyFrame.json5 b/xo-interpreter2/idl/IGCObject_DVsmApplyFrame.json5 new file mode 100644 index 00000000..4bb09a61 --- /dev/null +++ b/xo-interpreter2/idl/IGCObject_DVsmApplyFrame.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", + 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/xo-interpreter2/idl/IGCObject_DVsmDefContFrame.json5 b/xo-interpreter2/idl/IGCObject_DVsmDefContFrame.json5 new file mode 100644 index 00000000..faaee199 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/idl/IGCObject_DVsmEvalArgsFrame.json5 b/xo-interpreter2/idl/IGCObject_DVsmEvalArgsFrame.json5 new file mode 100644 index 00000000..90781d9c --- /dev/null +++ b/xo-interpreter2/idl/IGCObject_DVsmEvalArgsFrame.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", + 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/xo-interpreter2/idl/IGCObject_DVsmIfElseContFrame.json5 b/xo-interpreter2/idl/IGCObject_DVsmIfElseContFrame.json5 new file mode 100644 index 00000000..29e980ae --- /dev/null +++ b/xo-interpreter2/idl/IGCObject_DVsmIfElseContFrame.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "ifelse", + 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/xo-interpreter2/idl/IGCObject_DVsmSeqContFrame.json5 b/xo-interpreter2/idl/IGCObject_DVsmSeqContFrame.json5 new file mode 100644 index 00000000..5e8fcc25 --- /dev/null +++ b/xo-interpreter2/idl/IGCObject_DVsmSeqContFrame.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "sequence", + 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/xo-interpreter2/idl/IPrintable_DClosure.json5 b/xo-interpreter2/idl/IPrintable_DClosure.json5 new file mode 100644 index 00000000..2a1e2db9 --- /dev/null +++ b/xo-interpreter2/idl/IPrintable_DClosure.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", + 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/xo-interpreter2/idl/IPrintable_DLocalEnv.json5 b/xo-interpreter2/idl/IPrintable_DLocalEnv.json5 new file mode 100644 index 00000000..dfc6a644 --- /dev/null +++ b/xo-interpreter2/idl/IPrintable_DLocalEnv.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 DLocalEnv", + using_doxygen: true, + repr: "DLocalEnv", + doc: [ "implement APrintable for DLocalEnv" ], +} diff --git a/xo-interpreter2/idl/IPrintable_DVsmApplyClosureFrame.json5 b/xo-interpreter2/idl/IPrintable_DVsmApplyClosureFrame.json5 new file mode 100644 index 00000000..45927399 --- /dev/null +++ b/xo-interpreter2/idl/IPrintable_DVsmApplyClosureFrame.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", + 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/xo-interpreter2/idl/IPrintable_DVsmApplyFrame.json5 b/xo-interpreter2/idl/IPrintable_DVsmApplyFrame.json5 new file mode 100644 index 00000000..bef2fb62 --- /dev/null +++ b/xo-interpreter2/idl/IPrintable_DVsmApplyFrame.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", + 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/xo-interpreter2/idl/IPrintable_DVsmDefContFrame.json5 b/xo-interpreter2/idl/IPrintable_DVsmDefContFrame.json5 new file mode 100644 index 00000000..58410fd6 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/idl/IPrintable_DVsmEvalArgsFrame.json5 b/xo-interpreter2/idl/IPrintable_DVsmEvalArgsFrame.json5 new file mode 100644 index 00000000..c43c5160 --- /dev/null +++ b/xo-interpreter2/idl/IPrintable_DVsmEvalArgsFrame.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", + 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/xo-interpreter2/idl/IPrintable_DVsmIfElseContFrame.json5 b/xo-interpreter2/idl/IPrintable_DVsmIfElseContFrame.json5 new file mode 100644 index 00000000..6490d444 --- /dev/null +++ b/xo-interpreter2/idl/IPrintable_DVsmIfElseContFrame.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "ifelse", + 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/xo-interpreter2/idl/IPrintable_DVsmSeqContFrame.json5 b/xo-interpreter2/idl/IPrintable_DVsmSeqContFrame.json5 new file mode 100644 index 00000000..7b8e7ddd --- /dev/null +++ b/xo-interpreter2/idl/IPrintable_DVsmSeqContFrame.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "sequence", + 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/xo-interpreter2/idl/IProcedure_DClosure.json5 b/xo-interpreter2/idl/IProcedure_DClosure.json5 new file mode 100644 index 00000000..eec40c0c --- /dev/null +++ b/xo-interpreter2/idl/IProcedure_DClosure.json5 @@ -0,0 +1,19 @@ +{ + mode: "implementation", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", + 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/xo-interpreter2/idl/IRuntimeContext_DVsmRcx.json5 b/xo-interpreter2/idl/IRuntimeContext_DVsmRcx.json5 new file mode 100644 index 00000000..b52517ee --- /dev/null +++ b/xo-interpreter2/idl/IRuntimeContext_DVsmRcx.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/interpreter2", + output_hpp_dir: "include/xo/interpreter2", + output_impl_subdir: "detail", + 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/xo-interpreter2/include/xo/interpreter2/.gitkeep b/xo-interpreter2/include/xo/interpreter2/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/xo-interpreter2/include/xo/interpreter2/Closure.hpp b/xo-interpreter2/include/xo/interpreter2/Closure.hpp new file mode 100644 index 00000000..dc9272fe --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/Closure.hpp @@ -0,0 +1,13 @@ +/** @file Closure.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DClosure.hpp" +//#include "detail/IProcedure_DClosure.hpp" +#include "detail/IGCObject_DClosure.hpp" +#include "detail/IPrintable_DClosure.hpp" + +/* end Closure.hpp */ diff --git a/xo-interpreter2/include/xo/interpreter2/DApplyFrame.hpp b/xo-interpreter2/include/xo/interpreter2/DApplyFrame.hpp new file mode 100644 index 00000000..d1c81c2b --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/DClosure.hpp b/xo-interpreter2/include/xo/interpreter2/DClosure.hpp new file mode 100644 index 00000000..8462d412 --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/DClosure.hpp @@ -0,0 +1,84 @@ +/** @file DClosure.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "LocalEnv.hpp" +#include +#include + +namespace xo { + namespace scm { + + /** @brief runtime representation for a procedure + * + * Maintains lambda + captured lexical context + **/ + class DClosure { + public: + using ARuntimeContext = xo::scm::ARuntimeContext; + 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; + + 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); + + /** @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 **/ + ///@{ + + DClosure * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + ///@} + /** @defgroup scm-closure-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + 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/xo-interpreter2/include/xo/interpreter2/DLocalEnv.hpp b/xo-interpreter2/include/xo/interpreter2/DLocalEnv.hpp new file mode 100644 index 00000000..a9253bbc --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/DLocalEnv.hpp @@ -0,0 +1,84 @@ +/** @file DLocalEnv.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include +#include + +namespace xo { + namespace scm { + + /** @brief runtime bindings for arguments to a lambda + **/ + 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; + + public: + /** @defgroup scm-localenv-constructors constructors **/ + ///@{ + + /** create instance with parent @p p for variables in @p symtab **/ + DLocalEnv(DLocalEnv * parent, + DLocalSymtab * symtab, + DArray * args); + + static DLocalEnv * _make(obj mm, + DLocalEnv * parent, + DLocalSymtab * symtab, + DArray * args); + + ///@} + /** @defgroup scm-localenv-methods methods **/ + ///@{ + + DLocalEnv * parent() const noexcept { return parent_; } + 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; + + /** assign value associated with binding @p ix to @p x **/ + void assign_value(obj mm, Binding ix, obj x); + + ///@} + /** @defgroup scm-localenv-gcobject-facet **/ + ///@{ + + DLocalEnv * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + ///@} + /** @defgroup scm-localenv-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const noexcept; + + ///@} + + 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/xo-interpreter2/include/xo/interpreter2/DVsmApplyClosureFrame.hpp b/xo-interpreter2/include/xo/interpreter2/DVsmApplyClosureFrame.hpp new file mode 100644 index 00000000..b13ed03a --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/DVsmApplyClosureFrame.hpp @@ -0,0 +1,64 @@ +/** @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 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: + DVsmApplyClosureFrame(obj stack, + VsmInstr cont, + DLocalEnv * env); + + /** create instance, using memory from @p mm **/ + static DVsmApplyClosureFrame * make(obj mm, + obj parent, + VsmInstr cont, + DLocalEnv * env); + + obj parent() 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 * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, 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/xo-interpreter2/include/xo/interpreter2/DVsmApplyFrame.hpp b/xo-interpreter2/include/xo/interpreter2/DVsmApplyFrame.hpp new file mode 100644 index 00000000..147b4857 --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/DVsmApplyFrame.hpp @@ -0,0 +1,69 @@ +/** @file DVsmApplyFrame.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "VsmInstr.hpp" +#include +#include + +namespace xo { + namespace scm { + class DVsmApplyFrame { + public: + using AProcedure = xo::scm::AProcedure; + 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: + DVsmApplyFrame(obj old_parent, + VsmInstr old_cont, + DArray * args); + + /** create instance using memory from @p mm **/ + static DVsmApplyFrame * make(obj mm, + obj old_parent, + 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_; } + + void assign_fn(obj x) { this->fn_ = x; } + + DVsmApplyFrame * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + /** pretty-printing support **/ + 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; + * don't know correct value until we evaluate + * expression in head position. + * + * Must exhibit either: + * 1. AProcedure facet (runs natively) + * 2. AVsmProcedure facet (requires schematika runtime) + **/ + obj fn_; + /** evaluated arguments (to target procedure) **/ + DArray * args_; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmApplyFrame.hpp */ diff --git a/xo-interpreter2/include/xo/interpreter2/DVsmDefContFrame.hpp b/xo-interpreter2/include/xo/interpreter2/DVsmDefContFrame.hpp new file mode 100644 index 00000000..3174a59f --- /dev/null +++ b/xo-interpreter2/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 AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; + 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 **/ + ///@{ + + DVsmDefContFrame * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, 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/xo-interpreter2/include/xo/interpreter2/DVsmEvalArgsFrame.hpp b/xo-interpreter2/include/xo/interpreter2/DVsmEvalArgsFrame.hpp new file mode 100644 index 00000000..bc556a9e --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/DVsmEvalArgsFrame.hpp @@ -0,0 +1,67 @@ +/** @file DVsmEvalArgsFrame.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "VsmApplyFrame.hpp" +#include + +namespace xo { + namespace scm { + + /** frame for executing an apply expression **/ + class DVsmEvalArgsFrame { + public: + 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: + /** see picture in VirtualSchematikaMachine._do_eval_apply_op() + * + * old_parent = [apply frame] + * old_cont = [xfer to called function] + * + **/ + DVsmEvalArgsFrame(DVsmApplyFrame * parent, + VsmInstr cont, + DApplyExpr * apply_expr); + + static DVsmEvalArgsFrame * make(obj mm, + DVsmApplyFrame * apply_frame, + VsmInstr old_cont, + 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_; } + + DVsmEvalArgsFrame * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; + + 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 **/ + DApplyExpr * apply_expr_ = nullptr; + + /** next argument to be evaluated. -1 means function head **/ + int32_t i_arg_ = -1; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmEvalArgsFrame.hpp */ diff --git a/xo-interpreter2/include/xo/interpreter2/DVsmIfElseContFrame.hpp b/xo-interpreter2/include/xo/interpreter2/DVsmIfElseContFrame.hpp new file mode 100644 index 00000000..355e4214 --- /dev/null +++ b/xo-interpreter2/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 AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using AGCObject = xo::mm::AGCObject; + using VisitReason = xo::mm::VisitReason; + using AAllocator = xo::mm::AAllocator; + 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 **/ + ///@{ + + DVsmIfElseContFrame * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, 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/xo-interpreter2/include/xo/interpreter2/DVsmRcx.hpp b/xo-interpreter2/include/xo/interpreter2/DVsmRcx.hpp new file mode 100644 index 00000000..a8c8c524 --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/DVsmRcx.hpp @@ -0,0 +1,44 @@ +/** @file DVsmRcx.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include +#include +#include + +namespace xo { + namespace scm { + // see xo-interpreter/ VirtualSchematikaMachine.hpp + class DVirtualSchematikaMachine; + + /** @brief Runtime context for schematika interpreter + * + * Provides allocator + **/ + class DVsmRcx { + public: + using StringTable = xo::scm::StringTable; + using AAllocator = xo::mm::AAllocator; + using ACollector = xo::mm::ACollector; + using MemorySizeVisitor = xo::mm::MemorySizeVisitor; + + public: + DVsmRcx(DVirtualSchematikaMachine * 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; + + private: + /** schematika interpreter **/ + DVirtualSchematikaMachine * vsm_ = nullptr;; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmRcx.hpp */ diff --git a/xo-interpreter2/include/xo/interpreter2/DVsmSeqContFrame.hpp b/xo-interpreter2/include/xo/interpreter2/DVsmSeqContFrame.hpp new file mode 100644 index 00000000..f4412843 --- /dev/null +++ b/xo-interpreter2/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 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: + /** @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 **/ + ///@{ + + DVsmSeqContFrame * gco_shallow_move(obj gc) noexcept; + void visit_gco_children(VisitReason reason, 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/xo-interpreter2/include/xo/interpreter2/LocalEnv.hpp b/xo-interpreter2/include/xo/interpreter2/LocalEnv.hpp new file mode 100644 index 00000000..b1b302fd --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/LocalEnv.hpp @@ -0,0 +1,12 @@ +/** @file LocalEnv.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DLocalEnv.hpp" +#include "env/IGCObject_DLocalEnv.hpp" +#include "detail/IPrintable_DLocalEnv.hpp" + +/* end LocalEnv.hpp */ diff --git a/xo-interpreter2/include/xo/interpreter2/SetupInterpreter2.hpp b/xo-interpreter2/include/xo/interpreter2/SetupInterpreter2.hpp new file mode 100644 index 00000000..be751bda --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/VirtualSchematikaMachine.hpp b/xo-interpreter2/include/xo/interpreter2/VirtualSchematikaMachine.hpp new file mode 100644 index 00000000..ee16d1e7 --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/VirtualSchematikaMachine.hpp @@ -0,0 +1,11 @@ +/** @file VirtualSchematikaMachine.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "vsm/DVirtualSchematikaMachine.hpp" +#include "vsm/IGCObject_DVirtualSchematikaMachine.hpp" + +/* end VirtualSchematikaMachine.hpp */ diff --git a/xo-interpreter2/include/xo/interpreter2/VsmApplyClosureFrame.hpp b/xo-interpreter2/include/xo/interpreter2/VsmApplyClosureFrame.hpp new file mode 100644 index 00000000..09b68d09 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/VsmApplyFrame.hpp b/xo-interpreter2/include/xo/interpreter2/VsmApplyFrame.hpp new file mode 100644 index 00000000..5ed121ba --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/VsmConfig.hpp b/xo-interpreter2/include/xo/interpreter2/VsmConfig.hpp new file mode 100644 index 00000000..ff211609 --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/VsmConfig.hpp @@ -0,0 +1,74 @@ +/** @file VsmConfig.hpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include +#include +#include + +namespace xo { + namespace scm { + /** Configuration for virtual schematika machine + **/ + struct VsmConfig { + using X1CollectorConfig = xo::mm::X1CollectorConfig; + using ArenaConfig = xo::mm::ArenaConfig; + + VsmConfig() = default; + + VsmConfig with_debug_flag(bool x) const { + VsmConfig retval = *this; + retval.debug_flag_ = x; + return retval; + } + + VsmConfig with_parser_debug_flag(bool x) const { + VsmConfig retval = *this; + retval.rdr_config_.parser_debug_flag_ = x; + 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; + + /** 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_ = std_x1_config(); + /** 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 + **/ + ArenaConfig error_config_ = ArenaConfig().with_name("error-reserve").with_size(64*1024); + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VsmConfig.hpp */ diff --git a/xo-interpreter2/include/xo/interpreter2/VsmDefContFrame.hpp b/xo-interpreter2/include/xo/interpreter2/VsmDefContFrame.hpp new file mode 100644 index 00000000..5ea2bad6 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/VsmEvalArgsFrame.hpp b/xo-interpreter2/include/xo/interpreter2/VsmEvalArgsFrame.hpp new file mode 100644 index 00000000..8c45b25e --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/VsmFrame.hpp b/xo-interpreter2/include/xo/interpreter2/VsmFrame.hpp new file mode 100644 index 00000000..52a30761 --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/VsmFrame.hpp @@ -0,0 +1,36 @@ +/** @file VsmFrame.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "VsmInstr.hpp" +#include +#include + +namespace xo { + namespace scm { + class VsmFrame { + public: + using AGCObject = xo::mm::AGCObject; + + public: + VsmFrame(obj parent, + VsmInstr cont) : parent_{parent}, cont_{cont} {} + + //obj parent() const noexcept { return parent_; } + obj parent() const noexcept { return parent_; } + VsmInstr cont() const noexcept { return cont_; } + + protected: + /** saved VSM stack; restore when this frame consumed **/ + obj parent_; + /** saved continuation; restore when this frame consumed **/ + VsmInstr cont_; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VsmFrame.hpp */ diff --git a/xo-interpreter2/include/xo/interpreter2/VsmIfElseContFrame.hpp b/xo-interpreter2/include/xo/interpreter2/VsmIfElseContFrame.hpp new file mode 100644 index 00000000..a0494ddf --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/VsmInstr.hpp b/xo-interpreter2/include/xo/interpreter2/VsmInstr.hpp new file mode 100644 index 00000000..2417757f --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/VsmInstr.hpp @@ -0,0 +1,63 @@ +/** @file VsmInstr.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "VsmOpcode.hpp" + +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 **/ + 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; + + 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(); + return os; + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VsmInstr.hpp */ diff --git a/xo-interpreter2/include/xo/interpreter2/VsmOpcode.hpp b/xo-interpreter2/include/xo/interpreter2/VsmOpcode.hpp new file mode 100644 index 00000000..161b352e --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/VsmOpcode.hpp @@ -0,0 +1,67 @@ +/** @file VsmOpcode.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include +#include + +namespace xo { + namespace scm { + /** Opcode for a virtual schematika expression; + * 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 **/ + 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, + + /** 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 + **/ + apply_cont, + + /** continuation to act on a branch **/ + ifelse_cont, + + /** Loop over elements of a SequenceExpr **/ + seq_cont, + + /** sentinel, counts number of opcodes **/ + N, + }; + + 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*/ + +/* end VsmOpcode.hpp */ diff --git a/xo-interpreter2/include/xo/interpreter2/VsmPrimitives.hpp b/xo-interpreter2/include/xo/interpreter2/VsmPrimitives.hpp new file mode 100644 index 00000000..9690d03e --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/VsmPrimitives.hpp @@ -0,0 +1,28 @@ +/** @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, + StringTable * stbl); + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VsmPrimitives.hpp */ diff --git a/xo-interpreter2/include/xo/interpreter2/VsmRcx.hpp b/xo-interpreter2/include/xo/interpreter2/VsmRcx.hpp new file mode 100644 index 00000000..c0f015eb --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/VsmSeqContFrame.hpp b/xo-interpreter2/include/xo/interpreter2/VsmSeqContFrame.hpp new file mode 100644 index 00000000..96e8d053 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp b/xo-interpreter2/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp new file mode 100644 index 00000000..ed1ba4c2 --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/define/IGCObject_DVsmDefContFrame.hpp @@ -0,0 +1,69 @@ +/** @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 AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dvsmdefcontframe-methods **/ + ///@{ + // const methods + + // non-const methods + /** 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 **/ + static void visit_gco_children(DVsmDefContFrame & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-interpreter2/include/xo/interpreter2/define/IPrintable_DVsmDefContFrame.hpp b/xo-interpreter2/include/xo/interpreter2/define/IPrintable_DVsmDefContFrame.hpp new file mode 100644 index 00000000..46ab4ee7 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DClosure.hpp b/xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DClosure.hpp new file mode 100644 index 00000000..26985fd6 --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DClosure.hpp @@ -0,0 +1,69 @@ +/** @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 AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dclosure-methods **/ + ///@{ + // const methods + + // non-const methods + /** 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 **/ + static void visit_gco_children(DClosure & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp b/xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp new file mode 100644 index 00000000..3f3a452c --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DVsmApplyClosureFrame.hpp @@ -0,0 +1,69 @@ +/** @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 AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dvsmapplyclosureframe-methods **/ + ///@{ + // const methods + + // non-const methods + /** 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 **/ + static void visit_gco_children(DVsmApplyClosureFrame & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp b/xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp new file mode 100644 index 00000000..0228f54e --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DVsmApplyFrame.hpp @@ -0,0 +1,69 @@ +/** @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 AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dvsmapplyframe-methods **/ + ///@{ + // const methods + + // non-const methods + /** 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 **/ + static void visit_gco_children(DVsmApplyFrame & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp b/xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp new file mode 100644 index 00000000..0bdf0784 --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/detail/IGCObject_DVsmEvalArgsFrame.hpp @@ -0,0 +1,69 @@ +/** @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 AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dvsmevalargsframe-methods **/ + ///@{ + // const methods + + // non-const methods + /** 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 **/ + static void visit_gco_children(DVsmEvalArgsFrame & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DClosure.hpp b/xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DClosure.hpp new file mode 100644 index 00000000..6cc91cf1 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DLocalEnv.hpp b/xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DLocalEnv.hpp new file mode 100644 index 00000000..c0ddb7f8 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DVsmApplyClosureFrame.hpp b/xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DVsmApplyClosureFrame.hpp new file mode 100644 index 00000000..f2e5a072 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DVsmApplyFrame.hpp b/xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DVsmApplyFrame.hpp new file mode 100644 index 00000000..af1a4e02 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DVsmEvalArgsFrame.hpp b/xo-interpreter2/include/xo/interpreter2/detail/IPrintable_DVsmEvalArgsFrame.hpp new file mode 100644 index 00000000..1c06f71e --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/detail/IProcedure_DClosure.hpp b/xo-interpreter2/include/xo/interpreter2/detail/IProcedure_DClosure.hpp new file mode 100644 index 00000000..2c966a50 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp b/xo-interpreter2/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp new file mode 100644 index 00000000..d87596e6 --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/detail/IRuntimeContext_DVsmRcx.hpp @@ -0,0 +1,69 @@ +/** @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 ACollector = xo::scm::ARuntimeContext::ACollector; + using MemorySizeVisitor = xo::scm::ARuntimeContext::MemorySizeVisitor; + 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; + /** 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 **/ + static void visit_pools(const DVsmRcx & self, MemorySizeVisitor visitor); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-interpreter2/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp b/xo-interpreter2/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp new file mode 100644 index 00000000..ce5789bd --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/env/IGCObject_DLocalEnv.hpp @@ -0,0 +1,69 @@ +/** @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 AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dlocalenv-methods **/ + ///@{ + // const methods + + // non-const methods + /** 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 **/ + static void visit_gco_children(DLocalEnv & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-interpreter2/include/xo/interpreter2/env/IPrintable_DLocalEnv.hpp b/xo-interpreter2/include/xo/interpreter2/env/IPrintable_DLocalEnv.hpp new file mode 100644 index 00000000..c0ddb7f8 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp b/xo-interpreter2/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp new file mode 100644 index 00000000..77accb20 --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/ifelse/IGCObject_DVsmIfElseContFrame.hpp @@ -0,0 +1,69 @@ +/** @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 AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dvsmifelsecontframe-methods **/ + ///@{ + // const methods + + // non-const methods + /** 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 **/ + static void visit_gco_children(DVsmIfElseContFrame & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-interpreter2/include/xo/interpreter2/ifelse/IPrintable_DVsmIfElseContFrame.hpp b/xo-interpreter2/include/xo/interpreter2/ifelse/IPrintable_DVsmIfElseContFrame.hpp new file mode 100644 index 00000000..5f0e5a7b --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/init_interpreter2.hpp b/xo-interpreter2/include/xo/interpreter2/init_interpreter2.hpp new file mode 100644 index 00000000..87e93438 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/xo-interpreter2/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp new file mode 100644 index 00000000..d289f7ff --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -0,0 +1,69 @@ +/** @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 AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dvsmseqcontframe-methods **/ + ///@{ + // const methods + + // non-const methods + /** 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 **/ + static void visit_gco_children(DVsmSeqContFrame & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-interpreter2/include/xo/interpreter2/sequence/IPrintable_DVsmSeqContFrame.hpp b/xo-interpreter2/include/xo/interpreter2/sequence/IPrintable_DVsmSeqContFrame.hpp new file mode 100644 index 00000000..0fb46c45 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp b/xo-interpreter2/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp new file mode 100644 index 00000000..2902840c --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/vsm/DVirtualSchematikaMachine.hpp @@ -0,0 +1,350 @@ +/** @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 { + /** 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} {} + + bool is_value() const { return result_; } + bool is_error() const; + + const obj * value() const { return &result_; } + const obj & value_ref() const { return result_; } + + /** result of evaluating first expression encountered in input **/ + obj result_; + }; + + /** 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) : 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_; + }; + + /** @class VirtualSchematikaMachine + * @brief virtual machine for schematika + **/ + class DVirtualSchematikaMachine { + public: + // will be DArenaVector> probably + using Stack = void *; + 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; + + 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 + **/ + const 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 * gco_shallow_move(obj gc) noexcept; + + /** forward gc-aware child pointers + **/ + void visit_gco_children(VisitReason reason, 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_; + + /** 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. + **/ + obj aux_mm_; + + /** allocator (likely DX1Collector or similar) for + * expressions and values. Schemaatika reader will use this also. + * + * Allocations must represent a type that supports GCObject. + **/ + 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/xo-interpreter2/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp b/xo-interpreter2/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp new file mode 100644 index 00000000..62856b6a --- /dev/null +++ b/xo-interpreter2/include/xo/interpreter2/vsm/IGCObject_DVirtualSchematikaMachine.hpp @@ -0,0 +1,69 @@ +/** @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 AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dvirtualschematikamachine-methods **/ + ///@{ + // const methods + + // non-const methods + /** 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 **/ + static void visit_gco_children(DVirtualSchematikaMachine & self, VisitReason reason, obj fn) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/xo-interpreter2/src/interpreter2/CMakeLists.txt b/xo-interpreter2/src/interpreter2/CMakeLists.txt new file mode 100644 index 00000000..37e9ebfe --- /dev/null +++ b/xo-interpreter2/src/interpreter2/CMakeLists.txt @@ -0,0 +1,55 @@ +# interpreter2/CMakeLists.txt + +set(SELF_LIB xo_interpreter2) +set(SELF_SRCS + init_interpreter2.cpp + SetupInterpreter2.cpp + + VsmPrimitives.cpp + + DVirtualSchematikaMachine.cpp + facet/IGCObject_DVirtualSchematikaMachine.cpp + + DVsmDefContFrame.cpp + IGCObject_DVsmDefContFrame.cpp + IPrintable_DVsmDefContFrame.cpp + + DVsmEvalArgsFrame.cpp + IGCObject_DVsmEvalArgsFrame.cpp + IPrintable_DVsmEvalArgsFrame.cpp + + DVsmApplyFrame.cpp + IGCObject_DVsmApplyFrame.cpp + IPrintable_DVsmApplyFrame.cpp + + DVsmApplyClosureFrame.cpp + IGCObject_DVsmApplyClosureFrame.cpp + IPrintable_DVsmApplyClosureFrame.cpp + + DVsmIfElseContFrame.cpp + IGCObject_DVsmIfElseContFrame.cpp + IPrintable_DVsmIfElseContFrame.cpp + + DVsmSeqContFrame.cpp + IGCObject_DVsmSeqContFrame.cpp + IPrintable_DVsmSeqContFrame.cpp + + DClosure.cpp + IGCObject_DClosure.cpp + IPrintable_DClosure.cpp + + DLocalEnv.cpp + facet/IGCObject_DLocalEnv.cpp + IPrintable_DLocalEnv.cpp + + DVsmRcx.cpp + IRuntimeContext_DVsmRcx.cpp + + VsmInstr.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_reader2) +xo_dependency(${SELF_LIB} xo_gc) + diff --git a/xo-interpreter2/src/interpreter2/DClosure.cpp b/xo-interpreter2/src/interpreter2/DClosure.cpp new file mode 100644 index 00000000..c7bb3140 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/DClosure.cpp @@ -0,0 +1,101 @@ +/** @file DClosure.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "Closure.hpp" +#include "LambdaExpr.hpp" +#include "LocalEnv.hpp" +#include "VsmRcx.hpp" +#include +#include +#include +#include + +namespace xo { + using xo::mm::AGCObject; + using xo::print::APrintable; + + 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); + } + + obj + 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)); + + auto vsm_rcx + = obj::from(rcx); + + log && log(xtag("vsm_rcx.data", (void*)vsm_rcx.data())); + + auto err_mm + = vsm_rcx->error_allocator(); + + auto err + = DRuntimeError::make(err_mm, + "DClosure::apply_nocheck", + "not implemented"); + return err; + } + + DClosure * + DClosure::gco_shallow_move(obj gc) noexcept { + return gc.std_move_for(this); + } + + void + DClosure::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + gc.visit_child(reason, &lambda_); + gc.visit_child(reason, &env_); + } + + // ----- 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*/ + +/* end DClosure.cpp */ diff --git a/xo-interpreter2/src/interpreter2/DLocalEnv.cpp b/xo-interpreter2/src/interpreter2/DLocalEnv.cpp new file mode 100644 index 00000000..6877f971 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/DLocalEnv.cpp @@ -0,0 +1,128 @@ +/** @file DLocalEnv.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "LocalEnv.hpp" +#include +#include +#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(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->n_vars())) { + return (*(env->args_))[j]; + } else { + assert(false); + } + } else { + assert(false); + } + + /* something terribly wrong if control here */ + return obj(); + } + + void + DLocalEnv::assign_value(obj mm, + Binding ix, + obj x) + { + scope log(XO_DEBUG(true)); + + 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->n_vars())) { + env->args_->assign_at(mm, j, x); + } else { + assert(false); + } + } else { + assert(false); + } + + /* something terribly wrong if control here */ + } + + DLocalEnv * + DLocalEnv::gco_shallow_move(obj gc) noexcept { + return gc.std_move_for(this); + } + + void + DLocalEnv::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + gc.visit_child(reason, &parent_); + gc.visit_child(reason, &symtab_); + gc.visit_child(reason, &args_); + } + + // ----- 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*/ + +/* end DLocalEnv.cpp */ diff --git a/xo-interpreter2/src/interpreter2/DVirtualSchematikaMachine.cpp b/xo-interpreter2/src/interpreter2/DVirtualSchematikaMachine.cpp new file mode 100644 index 00000000..021a38ea --- /dev/null +++ b/xo-interpreter2/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -0,0 +1,995 @@ +/** @file VirtualSchematikaMachine.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#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" +#include "VsmApplyClosureFrame.hpp" +#include "VsmIfElseContFrame.hpp" +#include "VsmSeqContFrame.hpp" +#include "VsmRcx.hpp" +#include "Closure.hpp" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +namespace xo { + using xo::scm::DDictionary; + 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; + 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; + using std::cout; + + namespace scm { + + bool + VsmResult::is_error() const + { + return (*this->value() && obj::from(*(this->value()))); + } + + 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) + // + DVirtualSchematikaMachine::DVirtualSchematikaMachine(const VsmConfig & config, + obj aux_mm) + : config_{config}, + self_vroot_{obj(this)}, + aux_mm_{aux_mm}, + mm_(vsm_make_gc(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_); + assert(arena); + + this->error_mm_.adopt(obj(arena)); + } + + this->global_env_ + = obj(reader_.global_env()); + + // 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 * + DVirtualSchematikaMachine::_make(obj mm, + const VsmConfig & config, + obj aux_mm) + { + 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 + DVirtualSchematikaMachine::allocator() const noexcept + { + return mm_.to_op(); + } + + obj + DVirtualSchematikaMachine::error_allocator() const noexcept + { + return error_mm_.to_op(); + } + + StringTable * + DVirtualSchematikaMachine::stringtable() noexcept + { + return reader_.stringtable(); + } + + bool + DVirtualSchematikaMachine::is_at_toplevel() const noexcept + { + return reader_.is_at_toplevel(); + } + + void + DVirtualSchematikaMachine::visit_pools(const MemorySizeVisitor & visitor) const + { + aux_mm_.visit_pools(visitor); + mm_.visit_pools(visitor); + error_mm_.visit_pools(visitor); + reader_.visit_pools(visitor); + } + + void + DVirtualSchematikaMachine::begin_interactive_session() + { + reader_.begin_interactive_session(); + } + + void + DVirtualSchematikaMachine::begin_batch_session() + { + reader_.begin_batch_session(); + } + + VsmResultExt + DVirtualSchematikaMachine::read_eval_print(span_type input, bool eof) + { + if (input.empty()) { + return VsmResultExt(); + } + + reader_.reset_result(); + + auto [expr, remaining, tk_error] + = reader_.read_expr(input, eof); + + if (!expr) { + if (tk_error.is_error()) { + // tokenizer error -> convert to runtime error + + 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)); + + this->value_ = VsmResult(error); + + { + obj error_pr + = FacetRegistry::instance().variant(error); + + ppconfig ppc; + ppstate_standalone pps(&cout, 0, &ppc); + pps.prettyn(error_pr); + } + + return VsmResultExt(value_, remaining); + } else { + // incomplete input + return VsmResultExt(VsmResult(), remaining); + } + } + + // here: have obtained complete input expression + + const VsmResult & evalresult = this->start_eval(expr); + + if (evalresult.is_error()) { + // TODO: print error here + + return VsmResultExt(evalresult, remaining); + } + + assert(evalresult.is_value()); + + obj value = evalresult.result_; + + assert(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); + } + + return VsmResultExt(evalresult, remaining); + } + + const VsmResult & + DVirtualSchematikaMachine::start_eval(obj expr) + { + this->pc_ = VsmInstr::c_eval; + this->expr_ = expr; + this->value_ = VsmResult(obj()); + this->cont_ = VsmInstr::c_halt; + + this->run(); + + return value_; + } + + void + DVirtualSchematikaMachine::run() + { + while (this->execute_one()) + ; + } + + bool + DVirtualSchematikaMachine::execute_one() + { + scope log(XO_DEBUG(config_.debug_flag_)); + + log && log(xtag("pc", pc_), + xtag("cont", cont_)); + + auto expr_pr = expr_.to_facet(); + 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)); + + switch (pc_.opcode()) { + case vsm_opcode::sentinel: + case vsm_opcode::halt: + case vsm_opcode::N: + 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; + case vsm_opcode::def_cont: + _do_def_cont_op(); + break; + 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; + } + + return true; + } + + void + DVirtualSchematikaMachine::_do_eval_op() + { + switch(expr_.extype()) { + case exprtype::invalid: + case exprtype::N: + break; + case exprtype::constant: + _do_eval_constant_op(); + break; + case exprtype::define: + _do_eval_define_op(); + break; + case exprtype::lambda: + _do_eval_lambda_op(); + break; + case exprtype::variable: + _do_eval_variable_op(); + break; + case exprtype::varref: + _do_eval_varref_op(); + break; + case exprtype::apply: + _do_eval_apply_op(); + break; + case exprtype::ifexpr: + _do_eval_if_else_op(); + break; + case exprtype::sequence: + _do_eval_sequence_op(); + break; + } + } + + void + DVirtualSchematikaMachine::_do_eval_constant_op() + { + auto expr + = obj::from(expr_); + + this->value_ = VsmResult(expr.data()->value()); + + this->pc_ = this->cont_; + this->cont_ = VsmInstr::c_sentinel; + } + + void + DVirtualSchematikaMachine::_do_eval_define_op() + { + scope log(XO_DEBUG(true)); + + auto def_expr + = obj::from(expr_); + + if (local_env_) { + // nested defines implemented by rewriting, + // so this branch should be unreachable + + assert(false); + } else { + // 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; + } + } + + void + DVirtualSchematikaMachine::_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 + DVirtualSchematikaMachine::_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) + // + + // 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_.data()); + + this->value_ + = VsmResult(obj(obj(closure))); + + this->pc_ = this->cont_; + this->cont_ = VsmInstr::c_sentinel; + } + + void + DVirtualSchematikaMachine::_do_eval_variable_op() + { + // not implemented + assert(false); + } + + void + DVirtualSchematikaMachine::_do_eval_varref_op() + { + auto var = obj::from(expr_); + + Binding b = var->path(); + + obj value; + + if (b.is_local() && local_env_) { + value = local_env_->lookup_value(b); + } else if (b.is_global()) { + value = global_env_->lookup_value(b); + } + + if (value) { + this->value_ = VsmResult(value); + + this->pc_ = this->cont_; + this->cont_ = VsmInstr::c_sentinel; + return; + } + + // no local or global 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; + this->cont_ = VsmInstr::c_sentinel; + } + + void + DVirtualSchematikaMachine::_do_eval_apply_op() + { + // ApplyExpr in expr_ register + + // assuming bump allocator: + // + // 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_); + + // accumulate evaluated arguments here + DArray * args = DArray::_empty(mm_.to_op(), + apply->n_args()); + + // TODO: check function signature + + 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, apply.data())); + + this->stack_ = evalargs_frame; + + // Setup evaluation of first argument. No new stack for this. + + this->expr_ = apply->fn(); + this->pc_ = VsmInstr::c_eval; + this->cont_ = VsmInstr::c_evalargs; + } + + void + DVirtualSchematikaMachine::_do_eval_if_else_op() + { + // 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->expr_ = ifelse_expr->test(); + this->pc_ = VsmInstr::c_eval; + this->cont_ = VsmInstr::c_ifelse_cont; + } + + void + DVirtualSchematikaMachine::_do_eval_sequence_op() + { + // stack: + // + // 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->expr_ = (*seq_expr.data())[0]; + this->pc_ = VsmInstr::c_eval; + this->cont_ = VsmInstr::c_seq_cont; + } + + void + DVirtualSchematikaMachine::_do_apply_op() + { + // rcx_ : runtime context + // fn_ : function to call + // args_ : array of arguments + + // TODO: check argument types + + auto closure = obj::from(fn_); + + if (closure) { + _do_call_closure_op(); + return; + } else { + _do_call_primitive_op(); + return; + } + } + + void + DVirtualSchematikaMachine::_do_call_closure_op() + { + // We need to preserve registers while evaluating + // lambda body + + auto closure = obj::from(fn_); + + assert(closure); + + // 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_apply_cont) { + // 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_.data())); + + // push frame w/ saved vsm registers + this->stack_ = frame; + this->cont_ = VsmInstr::c_apply_cont; + } + + auto lambda = closure->lambda(); + + auto local_env + = DLocalEnv::_make(mm_.to_op(), + local_env_.data(), + lambda->local_symtab(), + args_.data()); + + this->local_env_ = obj(local_env); + this->expr_ = lambda->body_expr(); + this->pc_ = VsmInstr::c_eval; + // cont_ already established + } + + void + DVirtualSchematikaMachine::_do_call_primitive_op() + { + auto fn = fn_.to_facet(); + + this->value_ = VsmResult(fn.apply_nocheck(rcx_.to_op(), args_.data())); + this->pc_ = cont_; + this->cont_ = VsmInstr::c_sentinel; + } + + void + DVirtualSchematikaMachine::_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; + this->cont_ = VsmInstr::c_sentinel; + 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) { + 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); + + i_arg = evalargs_frame->increment_arg(); + + // now i_arg is 0 -> evaluate that argument + + if (i_arg >= static_cast(apply_expr->n_args())) { + // corner case: function with 0 arguments + + this->fn_ = apply_frame->fn(); // = value; + this->args_ = obj(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. + + 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(mm_.to_op(), 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_ = obj(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_ = VsmInstr::c_evalargs; + + return; + } + } + + // not implemented + assert(false); + } + + void + DVirtualSchematikaMachine::_do_apply_cont_op() + { + // see DVsmApplyClosureFrame + + auto frame = obj::from(stack_); + + assert(frame); + + this->stack_ = frame->parent(); + this->local_env_ = obj(frame->local_env()); + this->pc_ = frame->cont(); + this->cont_ = VsmInstr::c_sentinel; + } + + void + DVirtualSchematikaMachine::_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->expr_ = next_expr; + this->pc_ = VsmInstr::c_eval; + this->cont_ = frame->cont(); + } 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; + this->cont_ = VsmInstr::c_sentinel; + } + } + + void + DVirtualSchematikaMachine::_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(); + this->cont_ = VsmInstr::c_sentinel; + + return; + } else { + frame->incr_i_seq(); + + this->expr_ = (*seq_expr)[i_seq]; + this->pc_ = VsmInstr::c_eval; + this->cont_ = VsmInstr::c_seq_cont; + + return; + } + } + + std::size_t + DVirtualSchematikaMachine::shallow_size() const noexcept + { + return sizeof(DVirtualSchematikaMachine); + } + + DVirtualSchematikaMachine * + 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 + * that shallow_move uses move construction. + * DVirtualSchematikaMachine is (or can be made) moveable. + **/ + + assert(false); + + return nullptr; + } + + void + DVirtualSchematikaMachine::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + reader_.visit_gco_children(reason, gc); + + 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(reason, const_cast *>(&value_.value_ref())); + } + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVirtualSchematikaMachine.cpp */ diff --git a/xo-interpreter2/src/interpreter2/DVsmApplyClosureFrame.cpp b/xo-interpreter2/src/interpreter2/DVsmApplyClosureFrame.cpp new file mode 100644 index 00000000..55199464 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/DVsmApplyClosureFrame.cpp @@ -0,0 +1,61 @@ +/** @file DVsmApplyClosureFrame.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DVsmApplyClosureFrame.hpp" +#include "LocalEnv.hpp" + +namespace xo { + using xo::mm::AGCObject; + using xo::reflect::typeseq; + + namespace scm { + + DVsmApplyClosureFrame::DVsmApplyClosureFrame(obj stack, + VsmInstr cont, + DLocalEnv * local_env) + : stack_{stack}, + cont_{cont}, + 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); + } + + DVsmApplyClosureFrame * + DVsmApplyClosureFrame::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DVsmApplyClosureFrame::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + gc.visit_child(reason, &stack_); + gc.visit_child(reason, &local_env_); + } + + 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/xo-interpreter2/src/interpreter2/DVsmApplyFrame.cpp b/xo-interpreter2/src/interpreter2/DVsmApplyFrame.cpp new file mode 100644 index 00000000..591d8aef --- /dev/null +++ b/xo-interpreter2/src/interpreter2/DVsmApplyFrame.cpp @@ -0,0 +1,70 @@ +/** @file DVsmApplyFrame.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DVsmApplyFrame.hpp" +#include +#include + +namespace xo { + using xo::facet::typeseq; + + namespace scm { + + DVsmApplyFrame::DVsmApplyFrame(obj old_parent, + VsmInstr old_cont, + DArray * args) + : parent_{old_parent}, + cont_{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; + } + + DVsmApplyFrame * + DVsmApplyFrame::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DVsmApplyFrame::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + gc.visit_child(reason, &parent_); + gc.visit_child(reason, &fn_); + gc.visit_child(reason, &args_); + } + + 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/xo-interpreter2/src/interpreter2/DVsmDefContFrame.cpp b/xo-interpreter2/src/interpreter2/DVsmDefContFrame.cpp new file mode 100644 index 00000000..d8c52d10 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/DVsmDefContFrame.cpp @@ -0,0 +1,61 @@ +/** @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 + + DVsmDefContFrame * + DVsmDefContFrame::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DVsmDefContFrame::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + gc.visit_child(reason, &parent_); + gc.visit_child(reason, &def_expr_); + } + + // 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/xo-interpreter2/src/interpreter2/DVsmEvalArgsFrame.cpp b/xo-interpreter2/src/interpreter2/DVsmEvalArgsFrame.cpp new file mode 100644 index 00000000..b4e3f448 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/DVsmEvalArgsFrame.cpp @@ -0,0 +1,69 @@ +/** @file DVsmEvalArgsFrame.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DVsmEvalArgsFrame.hpp" +#include +#include + +namespace xo { + using xo::facet::typeseq; + using xo::print::ppindentinfo; + + namespace scm { + + // ----- VsmEvalArgsFrame ----- + + DVsmEvalArgsFrame::DVsmEvalArgsFrame(DVsmApplyFrame * parent, + VsmInstr cont, + DApplyExpr * apply_expr) + : parent_{parent}, + cont_{cont}, + apply_expr_{apply_expr} + {} + + DVsmEvalArgsFrame * + DVsmEvalArgsFrame::make(obj mm, + DVsmApplyFrame * apply_frame, + VsmInstr cont, + DApplyExpr * apply_expr) + { + DVsmEvalArgsFrame * result = nullptr; + + void * mem = mm.alloc(typeseq::id(), + sizeof(DVsmEvalArgsFrame)); + + result = new (mem) DVsmEvalArgsFrame(apply_frame, cont, apply_expr); + + assert(result); + + return result; + } + + DVsmEvalArgsFrame * + DVsmEvalArgsFrame::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DVsmEvalArgsFrame::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + gc.visit_child(reason, &parent_); + gc.visit_child(reason, &apply_expr_); + } + + 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/xo-interpreter2/src/interpreter2/DVsmIfElseContFrame.cpp b/xo-interpreter2/src/interpreter2/DVsmIfElseContFrame.cpp new file mode 100644 index 00000000..f1f88952 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/DVsmIfElseContFrame.cpp @@ -0,0 +1,59 @@ +/** @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 + + DVsmIfElseContFrame * + DVsmIfElseContFrame::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DVsmIfElseContFrame::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + gc.visit_child(reason, &parent_); + gc.visit_child(reason, &ifelse_expr_); + } + + // 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/xo-interpreter2/src/interpreter2/DVsmRcx.cpp b/xo-interpreter2/src/interpreter2/DVsmRcx.cpp new file mode 100644 index 00000000..c083d2c5 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/DVsmRcx.cpp @@ -0,0 +1,51 @@ +/** @file DVsmRcx.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DVsmRcx.hpp" +#include "VirtualSchematikaMachine.hpp" +#include + +namespace xo { + using xo::mm::AAllocator; + using xo::mm::ACollector; + + namespace scm { + + DVsmRcx::DVsmRcx(DVirtualSchematikaMachine * vsm) : vsm_{vsm} {} + + obj + DVsmRcx::allocator() const noexcept + { + return vsm_->allocator(); + } + + obj + DVsmRcx::collector() const noexcept + { + return vsm_->allocator().try_to_facet(); + } + + obj + DVsmRcx::error_allocator() const noexcept + { + return vsm_->error_allocator(); + } + + StringTable * + DVsmRcx::stringtable() const noexcept + { + return vsm_->stringtable(); + } + + void + DVsmRcx::visit_pools(const MemorySizeVisitor & visitor) const + { + vsm_->visit_pools(visitor); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVsmRcx.cpp */ diff --git a/xo-interpreter2/src/interpreter2/DVsmSeqContFrame.cpp b/xo-interpreter2/src/interpreter2/DVsmSeqContFrame.cpp new file mode 100644 index 00000000..219342b5 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/DVsmSeqContFrame.cpp @@ -0,0 +1,63 @@ +/** @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 + + DVsmSeqContFrame * + DVsmSeqContFrame::gco_shallow_move(obj gc) noexcept + { + return gc.std_move_for(this); + } + + void + DVsmSeqContFrame::visit_gco_children(VisitReason reason, + obj gc) noexcept + { + gc.visit_child(reason, &parent_); + gc.visit_child(reason, &seq_expr_); + } + + // 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/xo-interpreter2/src/interpreter2/IGCObject_DClosure.cpp b/xo-interpreter2/src/interpreter2/IGCObject_DClosure.cpp new file mode 100644 index 00000000..dc281fd4 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/IGCObject_DClosure.cpp @@ -0,0 +1,32 @@ +/** @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::gco_shallow_move(DClosure & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DClosure::visit_gco_children(DClosure & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DClosure.cpp */ diff --git a/xo-interpreter2/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp b/xo-interpreter2/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp new file mode 100644 index 00000000..e080c301 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/IGCObject_DVsmApplyClosureFrame.cpp @@ -0,0 +1,32 @@ +/** @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::gco_shallow_move(DVsmApplyClosureFrame & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DVsmApplyClosureFrame::visit_gco_children(DVsmApplyClosureFrame & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVsmApplyClosureFrame.cpp */ diff --git a/xo-interpreter2/src/interpreter2/IGCObject_DVsmApplyFrame.cpp b/xo-interpreter2/src/interpreter2/IGCObject_DVsmApplyFrame.cpp new file mode 100644 index 00000000..b0ce1838 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/IGCObject_DVsmApplyFrame.cpp @@ -0,0 +1,32 @@ +/** @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::gco_shallow_move(DVsmApplyFrame & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DVsmApplyFrame::visit_gco_children(DVsmApplyFrame & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVsmApplyFrame.cpp */ diff --git a/xo-interpreter2/src/interpreter2/IGCObject_DVsmDefContFrame.cpp b/xo-interpreter2/src/interpreter2/IGCObject_DVsmDefContFrame.cpp new file mode 100644 index 00000000..c0ed5412 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/IGCObject_DVsmDefContFrame.cpp @@ -0,0 +1,32 @@ +/** @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::gco_shallow_move(DVsmDefContFrame & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DVsmDefContFrame::visit_gco_children(DVsmDefContFrame & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVsmDefContFrame.cpp */ diff --git a/xo-interpreter2/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp b/xo-interpreter2/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp new file mode 100644 index 00000000..0db77058 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/IGCObject_DVsmEvalArgsFrame.cpp @@ -0,0 +1,32 @@ +/** @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::gco_shallow_move(DVsmEvalArgsFrame & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DVsmEvalArgsFrame::visit_gco_children(DVsmEvalArgsFrame & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVsmEvalArgsFrame.cpp */ diff --git a/xo-interpreter2/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp b/xo-interpreter2/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp new file mode 100644 index 00000000..3488e8c3 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/IGCObject_DVsmIfElseContFrame.cpp @@ -0,0 +1,32 @@ +/** @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::gco_shallow_move(DVsmIfElseContFrame & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DVsmIfElseContFrame::visit_gco_children(DVsmIfElseContFrame & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVsmIfElseContFrame.cpp */ diff --git a/xo-interpreter2/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp b/xo-interpreter2/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp new file mode 100644 index 00000000..5293306f --- /dev/null +++ b/xo-interpreter2/src/interpreter2/IGCObject_DVsmSeqContFrame.cpp @@ -0,0 +1,32 @@ +/** @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::gco_shallow_move(DVsmSeqContFrame & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DVsmSeqContFrame::visit_gco_children(DVsmSeqContFrame & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVsmSeqContFrame.cpp */ diff --git a/xo-interpreter2/src/interpreter2/IPrintable_DClosure.cpp b/xo-interpreter2/src/interpreter2/IPrintable_DClosure.cpp new file mode 100644 index 00000000..e9c599fb --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/src/interpreter2/IPrintable_DLocalEnv.cpp b/xo-interpreter2/src/interpreter2/IPrintable_DLocalEnv.cpp new file mode 100644 index 00000000..6fe745b2 --- /dev/null +++ b/xo-interpreter2/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 "env/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/xo-interpreter2/src/interpreter2/IPrintable_DVsmApplyClosureFrame.cpp b/xo-interpreter2/src/interpreter2/IPrintable_DVsmApplyClosureFrame.cpp new file mode 100644 index 00000000..36b89a10 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/src/interpreter2/IPrintable_DVsmApplyFrame.cpp b/xo-interpreter2/src/interpreter2/IPrintable_DVsmApplyFrame.cpp new file mode 100644 index 00000000..5faa360f --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/src/interpreter2/IPrintable_DVsmDefContFrame.cpp b/xo-interpreter2/src/interpreter2/IPrintable_DVsmDefContFrame.cpp new file mode 100644 index 00000000..f73b7dd6 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/src/interpreter2/IPrintable_DVsmEvalArgsFrame.cpp b/xo-interpreter2/src/interpreter2/IPrintable_DVsmEvalArgsFrame.cpp new file mode 100644 index 00000000..25d81800 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/src/interpreter2/IPrintable_DVsmIfElseContFrame.cpp b/xo-interpreter2/src/interpreter2/IPrintable_DVsmIfElseContFrame.cpp new file mode 100644 index 00000000..e8afc908 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/src/interpreter2/IPrintable_DVsmSeqContFrame.cpp b/xo-interpreter2/src/interpreter2/IPrintable_DVsmSeqContFrame.cpp new file mode 100644 index 00000000..74801873 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/src/interpreter2/IRuntimeContext_DVsmRcx.cpp b/xo-interpreter2/src/interpreter2/IRuntimeContext_DVsmRcx.cpp new file mode 100644 index 00000000..b2259c75 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/IRuntimeContext_DVsmRcx.cpp @@ -0,0 +1,52 @@ +/** @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(); + } + + auto + IRuntimeContext_DVsmRcx::collector(const DVsmRcx & self) noexcept -> obj + { + 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 * + { + return self.stringtable(); + } + + auto + IRuntimeContext_DVsmRcx::visit_pools(const DVsmRcx & self, MemorySizeVisitor visitor) -> void + { + self.visit_pools(visitor); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IRuntimeContext_DVsmRcx.cpp */ diff --git a/xo-interpreter2/src/interpreter2/SetupInterpreter2.cpp b/xo-interpreter2/src/interpreter2/SetupInterpreter2.cpp new file mode 100644 index 00000000..6af697bd --- /dev/null +++ b/xo-interpreter2/src/interpreter2/SetupInterpreter2.cpp @@ -0,0 +1,146 @@ +/** @file SetupInterpreter2.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "SetupInterpreter2.hpp" +#include "VsmPrimitives.hpp" +#include "DPrimitive_gco_2_gco_gco.hpp" +#include "VsmDefContFrame.hpp" +#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" +#include "GlobalEnv.hpp" +#include "LocalEnv.hpp" +#include "VsmRcx.hpp" + +#include +#include +#include +#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 { + bool + SetupInterpreter2::register_facets() + { + scope log(XO_DEBUG(true)); + + // VsmStqackFrame + // +- VsmApplyFrame + // +- VsmEvalArgsFrame + // +- VsmApplyClosureFrame + // +- VsmDefContFrame + // +- VsmIfElseContFrame + // \- VsmSeqContFrame + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + // LocalEnv (see xo-reader2/ for GlobalEnv) + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + // Procedure + // \- Primitive_gco_2_gco_gco + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + // Closure + +// FacetRegistry::register_impl(); // if/when provided + FacetRegistry::register_impl(); + 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("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())); + + 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()); + ok &= gc.install_type(impl_for()); + + ok &= gc.install_type(impl_for()); + + 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*/ + +/* end SetupInterpreter2.cpp */ diff --git a/xo-interpreter2/src/interpreter2/VsmApplyFrame.cpp b/xo-interpreter2/src/interpreter2/VsmApplyFrame.cpp new file mode 100644 index 00000000..e69de29b diff --git a/xo-interpreter2/src/interpreter2/VsmInstr.cpp b/xo-interpreter2/src/interpreter2/VsmInstr.cpp new file mode 100644 index 00000000..852b6332 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/VsmInstr.cpp @@ -0,0 +1,59 @@ +/** @file VsmInstr.cpp +* + * @author Roland Conybeare, Feb 2026 + **/ + +#include "VsmInstr.hpp" + +namespace xo { + namespace scm { + const char * + 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"; + case vsm_opcode::N: + break; + } + + return "opcode?"; + } + + VsmInstr + VsmInstr::c_sentinel = VsmInstr(vsm_opcode::sentinel); + + VsmInstr + VsmInstr::c_halt = VsmInstr(vsm_opcode::halt); + + VsmInstr + VsmInstr::c_eval = VsmInstr(vsm_opcode::eval); + + VsmInstr + VsmInstr::c_apply = VsmInstr(vsm_opcode::apply); + + 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*/ +} /*namespace xo*/ + +/* end VsmInstr.cpp */ diff --git a/xo-interpreter2/src/interpreter2/VsmPrimitives.cpp b/xo-interpreter2/src/interpreter2/VsmPrimitives.cpp new file mode 100644 index 00000000..aebb5866 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/VsmPrimitives.cpp @@ -0,0 +1,62 @@ +/** @file VsmPrimitives.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "VsmPrimitives.hpp" +#include +#include +#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, + 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); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end VsmPrimitives.cpp */ diff --git a/xo-interpreter2/src/interpreter2/facet/IGCObject_DLocalEnv.cpp b/xo-interpreter2/src/interpreter2/facet/IGCObject_DLocalEnv.cpp new file mode 100644 index 00000000..f086b07a --- /dev/null +++ b/xo-interpreter2/src/interpreter2/facet/IGCObject_DLocalEnv.cpp @@ -0,0 +1,32 @@ +/** @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 "env/IGCObject_DLocalEnv.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DLocalEnv::gco_shallow_move(DLocalEnv & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DLocalEnv::visit_gco_children(DLocalEnv & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DLocalEnv.cpp */ diff --git a/xo-interpreter2/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp b/xo-interpreter2/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp new file mode 100644 index 00000000..4b9d83bb --- /dev/null +++ b/xo-interpreter2/src/interpreter2/facet/IGCObject_DVirtualSchematikaMachine.cpp @@ -0,0 +1,32 @@ +/** @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::gco_shallow_move(DVirtualSchematikaMachine & self, obj gc) noexcept -> Opaque + { + return self.gco_shallow_move(gc); + } + auto + IGCObject_DVirtualSchematikaMachine::visit_gco_children(DVirtualSchematikaMachine & self, VisitReason reason, obj fn) noexcept -> void + { + self.visit_gco_children(reason, fn); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVirtualSchematikaMachine.cpp */ diff --git a/xo-interpreter2/src/interpreter2/init_interpreter2.cpp b/xo-interpreter2/src/interpreter2/init_interpreter2.cpp new file mode 100644 index 00000000..56630794 --- /dev/null +++ b/xo-interpreter2/src/interpreter2/init_interpreter2.cpp @@ -0,0 +1,44 @@ +/** @file init_interpreter2.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_interpreter2.hpp" +#include "SetupInterpreter2.hpp" + +#include +#include +#include + +namespace xo { + using xo::scm::SetupInterpreter2; + using xo::scm::PrimitiveRegistry; + using xo::mm::CollectorTypeRegistry; + + void + InitSubsys::init() + { + SetupInterpreter2::register_facets(); + CollectorTypeRegistry::instance().register_types(&SetupInterpreter2::register_types); + PrimitiveRegistry::instance().register_primitives(&SetupInterpreter2::register_primitives); + } + + InitEvidence + InitSubsys::require() + { + scope log(XO_DEBUG(true)); + + InitEvidence retval; + + /* direct subsystem deps for xo-interpreter2/ */ + retval ^= InitSubsys::require(); + 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/xo-interpreter2/src/skrepl/CMakeLists.txt b/xo-interpreter2/src/skrepl/CMakeLists.txt new file mode 100644 index 00000000..b5511114 --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/src/skrepl/skreplxx.cpp b/xo-interpreter2/src/skrepl/skreplxx.cpp new file mode 100644 index 00000000..a4f86857 --- /dev/null +++ b/xo-interpreter2/src/skrepl/skreplxx.cpp @@ -0,0 +1,260 @@ +/** @file skreplxx.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include +#include +#include +#include +#include +#include +#ifdef __APPLE__ +#include // for STDIN_FILENO on OSX +#endif + +namespace xo { + using xo::scm::DVirtualSchematikaMachine; + 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(32 * 1024), + 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; + //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 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 = DVirtualSchematikaMachine::span_type; + + App(const AppConfig & cfg = AppConfig()) + : repl_config_{cfg.repl_config_}, + app_arena_{cfg.app_arena_config_}, + vsm_config_{cfg.vsm_config_} + { + 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); + void _stop(); + + 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 **/ + VsmConfig vsm_config_; + abox vsm_; + }; + + void + App::run() + { + this->_init(); + this->_start(); + this->_repl(); + } + + void + App::_init() + { + // 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_.adopt(DVirtualSchematikaMachine::make(obj(&app_arena_), + vsm_config_, + obj(&app_arena_))); + } + + 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 loop: 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_error(); + } + + void + App::_stop() + { + vsm_._drop(); + } + +} /*namespace xo*/ + +int +main (int argc, char * argv[]) +{ + using xo::AppConfig; + using xo::App; + + AppConfig cfg; + // [cmdline options here] + + cfg.vsm_config_.x1_config_.debug_flag_ = true; + + App app(cfg); + + app.run(); +} /*main*/ + +/* end skreplxx.cpp */ diff --git a/xo-interpreter2/utest/CMakeLists.txt b/xo-interpreter2/utest/CMakeLists.txt new file mode 100644 index 00000000..e45cffaa --- /dev/null +++ b/xo-interpreter2/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/xo-interpreter2/utest/VirtualSchematikaMachine.test.cpp b/xo-interpreter2/utest/VirtualSchematikaMachine.test.cpp new file mode 100644 index 00000000..aabda3a3 --- /dev/null +++ b/xo-interpreter2/utest/VirtualSchematikaMachine.test.cpp @@ -0,0 +1,557 @@ +/** @file VirtualSchematikaMachine.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +namespace xo { + using xo::scm::DVirtualSchematikaMachine; + using xo::scm::VsmConfig; + using xo::scm::VsmResultExt; + using xo::scm::DClosure; + 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; +// 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 xo::facet::TypeRegistry; + using xo::reflect::typeseq; + using span_type = xo::scm::DVirtualSchematikaMachine::span_type; + using Catch::Matchers::WithinAbs; + + 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_.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) { + *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); + TypeRegistry::instance().visit_pools(visitor); + FacetRegistry::instance().visit_pools(visitor); + vsm_->visit_pools(visitor); + + return true; + } + + /** @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) + { + 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()); + REQUIRE(res.value()); + + log && log(xtag("res.tseq", res.value()->_typeseq()), + xtag("res.type", TypeRegistry::id2name(res.value()->_typeseq()))); + + REQUIRE(verify_result(res)); + + if (must_exhaust) { + REQUIRE(res.remaining_.size() == 1); + REQUIRE(*res.remaining_.lo() == '\n'); + } else { + REQUIRE(res.remaining_.size() > 1); + } + + return res.remaining_; + } + + 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), xtag("input", input)); + bool eof_flag = false; + bool must_exhaust = true; + + INFO(xtag("input", input)); + + VsmFixture vsm_fixture(testname, debug_flag, cfg); + + 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, + 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_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)); + + bool must_exhaust = (i + 1 == verify_fns.size()); + + remaining + = vsm_fixture.read_eval_verify(debug_flag, + remaining, + verify_fns[i], + must_exhaust, eof_flag); + } + + log && vsm_fixture.log_memory_layout(&log); + } + + TEST_CASE("VirtualSchematikaMachine-ctor", "[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); + + log && vsm_fixture.log_memory_layout(&log); + } + + TEST_CASE("VirtualSchematikaMachine-const1", "[interpreter2][VSM]") + { + const auto & testname = Catch::getResultCapture().getCurrentTestName(); + constexpr bool c_debug_flag = false; + + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(x._typeseq() == typeseq::id()); + REQUIRE_THAT(x.data()->value(), WithinAbs(3.141592635, 1e-6)); + + return true; + }; + + 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; + + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(x._typeseq() == typeseq::id()); + REQUIRE(x.data()->value() == 1011); + + return true; + }; + + 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; + + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(x._typeseq() == typeseq::id()); + REQUIRE(x.data()->value() == 1.570796325); + + return true; + }; + + 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; + + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(x.data()->value() == 6.2831853); + + return true; + }; + + 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; + + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(x.data()->value() == true); + + return true; + }; + + 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; + + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(strcmp(x.data()->chars(), "equal") == 0); + + return true; + }; + + 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; + + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + + REQUIRE(x); + + return true; + }; + + 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; + + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(x->value() == 195); + + return true; + }; + + 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; + + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(strcmp(x->chars(), "foo") == 0); + + return true; + }; + + 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; + + 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; + + 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; + + 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; + + 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; + + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(x->value() == 4.5); + + return true; + }; + + 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; + + auto verify_fn = [](const VsmResultExt & res) { + 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); + + return true; + }; + + 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; + + auto verify_fn = [](const VsmResultExt & res) { + 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); + + return true; + }; + + 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; + + auto verify_fn = [](const VsmResultExt & res) { + auto x = obj::from(*res.value()); + + REQUIRE(x); + REQUIRE(x->value() == true); + + return true; + }; + + 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*/ + +/* end SchematikaParser.test.cpp */ diff --git a/xo-interpreter2/utest/interpreter2_utest_main.cpp b/xo-interpreter2/utest/interpreter2_utest_main.cpp new file mode 100644 index 00000000..ca898beb --- /dev/null +++ b/xo-interpreter2/utest/interpreter2_utest_main.cpp @@ -0,0 +1,32 @@ +/** @file interpreter2_utest_main.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include +#include + +#define CATCH_CONFIG_RUNNER +#include "catch2/catch.hpp" + +int +main(int argc, char* argv[]) +{ + using xo::facet::FacetRegistry; + using xo::Subsystem; + + // initialize facet registry + FacetRegistry::instance(1024); + + // 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 */