From 884a6074d795b930caa67eec9a2138a9f48ed952 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 14:41:28 -0500 Subject: [PATCH 01/10] xo-numeric: streamline setup --- include/xo/numeric/SetupNumeric.hpp | 25 +++ .../xo/numeric/numeric_register_facets.hpp | 16 -- .../numeric/numeric_register_primitives.hpp | 22 --- src/numeric/CMakeLists.txt | 3 +- src/numeric/SetupNumeric.cpp | 159 ++++++++++++++++++ src/numeric/init_numeric.cpp | 11 +- src/numeric/numeric_register_facets.cpp | 93 ---------- src/numeric/numeric_register_primitives.cpp | 102 ----------- 8 files changed, 190 insertions(+), 241 deletions(-) create mode 100644 include/xo/numeric/SetupNumeric.hpp delete mode 100644 include/xo/numeric/numeric_register_facets.hpp delete mode 100644 include/xo/numeric/numeric_register_primitives.hpp create mode 100644 src/numeric/SetupNumeric.cpp delete mode 100644 src/numeric/numeric_register_facets.cpp delete mode 100644 src/numeric/numeric_register_primitives.cpp diff --git a/include/xo/numeric/SetupNumeric.hpp b/include/xo/numeric/SetupNumeric.hpp new file mode 100644 index 00000000..b6fecd1f --- /dev/null +++ b/include/xo/numeric/SetupNumeric.hpp @@ -0,0 +1,25 @@ +/** @file SetupNumeric.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "PrimitiveRegistry.hpp" +#include + +namespace xo { + namespace scm { + /** Setup numeric facet dispatch **/ + struct SetupNumeric { + public: + static bool register_facets(); + /** Register primitive factories with primitive registry **/ + static bool register_primitives(obj rcx, + InstallSink sink, + InstallFlags flags); + }; + } +} + +/* end SetupNumeric.hpp */ diff --git a/include/xo/numeric/numeric_register_facets.hpp b/include/xo/numeric/numeric_register_facets.hpp deleted file mode 100644 index 7beeb10e..00000000 --- a/include/xo/numeric/numeric_register_facets.hpp +++ /dev/null @@ -1,16 +0,0 @@ -/** @file numeric_register_facets.hpp - * - * @author Roland Conybeare, Feb 2026 - **/ - -#pragma once - -namespace xo { - namespace scm { - /** Setup numeric facet dispatch **/ - bool numeric_register_facets(); - - } -} - -/* end numeric_register_facets.hpp */ diff --git a/include/xo/numeric/numeric_register_primitives.hpp b/include/xo/numeric/numeric_register_primitives.hpp deleted file mode 100644 index 5c68a51d..00000000 --- a/include/xo/numeric/numeric_register_primitives.hpp +++ /dev/null @@ -1,22 +0,0 @@ -/** @file numeric_register_primitives.hpp - * - * @author Roland Conybeare, Mar 2026 - **/ - -#pragma once - -#include "PrimitiveRegistry.hpp" -#include - -namespace xo { - namespace scm { - /** Register primitive factories with primitive registry **/ - bool numeric_register_primitives(obj rcx, - //obj mm, - //StringTable * stbl, - InstallSink sink, - InstallFlags flags); - } -} - -/* end numeric_register_primitives.hpp */ diff --git a/src/numeric/CMakeLists.txt b/src/numeric/CMakeLists.txt index ca7dd6d5..256f9ad5 100644 --- a/src/numeric/CMakeLists.txt +++ b/src/numeric/CMakeLists.txt @@ -3,8 +3,7 @@ set(SELF_LIB xo_numeric) set(SELF_SRCS init_numeric.cpp - numeric_register_facets.cpp - numeric_register_primitives.cpp + SetupNumeric.cpp NumericPrimitives.cpp NumericDispatch.cpp INumeric_Any.cpp diff --git a/src/numeric/SetupNumeric.cpp b/src/numeric/SetupNumeric.cpp new file mode 100644 index 00000000..c5920505 --- /dev/null +++ b/src/numeric/SetupNumeric.cpp @@ -0,0 +1,159 @@ +/** @file SetupNumeric.cpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#include "SetupNumeric.hpp" +#include "NumericDispatch.hpp" +#include "Numeric.hpp" +#include "NumericPrimitives.hpp" +#include "NumericDispatch.hpp" + +#include "FloatIntegerOps.hpp" +#include "FloatOps.hpp" +#include "float/INumeric_DFloat.hpp" + +#include "IntegerOps.hpp" +#include "integer/INumeric_DInteger.hpp" + +#include + +#include +#include + +#include +#include +#include + +namespace xo { + using xo::mm::AAllocator; + using xo::facet::FacetRegistry; + using xo::reflect::typeseq; + + namespace scm { + bool + SetupNumeric::register_facets() + { + scope log(XO_DEBUG(true)); + + FacetRegistry::register_impl(); + + NumericDispatch::instance().register_impl + (&FloatOps::multiply, + &FloatOps::divide, + &FloatOps::add, + &FloatOps::subtract, + &FloatOps::cmp_equal, + &FloatOps::cmp_notequal, + &FloatOps::cmp_less, + &FloatOps::cmp_lessequal, + &FloatOps::cmp_greater, + &FloatOps::cmp_greatequal); + + NumericDispatch::instance().register_impl + (&FloatIntegerOps::multiply, + &FloatIntegerOps::divide, + &FloatIntegerOps::add, + &FloatIntegerOps::subtract, + &FloatIntegerOps::cmp_equal, + &FloatIntegerOps::cmp_notequal, + &FloatIntegerOps::cmp_less, + &FloatIntegerOps::cmp_lessequal, + &FloatIntegerOps::cmp_greater, + &FloatIntegerOps::cmp_greatequal); + + NumericDispatch::instance().register_impl + (&IntegerFloatOps::multiply, + &IntegerFloatOps::divide, + &IntegerFloatOps::add, + &IntegerFloatOps::subtract, + &IntegerFloatOps::cmp_equal, + &IntegerFloatOps::cmp_notequal, + &IntegerFloatOps::cmp_less, + &IntegerFloatOps::cmp_lessequal, + &IntegerFloatOps::cmp_greater, + &IntegerFloatOps::cmp_greatequal); + + NumericDispatch::instance().register_impl + (&IntegerOps::multiply, + &IntegerOps::divide, + &IntegerOps::add, + &IntegerOps::subtract, + &IntegerOps::cmp_equal, + &IntegerOps::cmp_notequal, + &IntegerOps::cmp_less, + &IntegerOps::cmp_lessequal, + &IntegerOps::cmp_greater, + &IntegerOps::cmp_greatequal); + + log && log(xtag("ANumeric.tseq", typeseq::id())); + + return true; + } + + namespace { + bool install_aux(InstallSink sink, + DPrimitive_gco_2_gco_gco * pm, + InstallFlags flags) + { + if (flags != InstallFlags::f_none) { + return sink(pm->name(), + pm->fn_td(), + obj(pm), + flags); + } else { + return true; + } + } + } + + bool + SetupNumeric::register_primitives(obj rcx, + InstallSink sink, + InstallFlags flags) + { + obj mm = rcx.allocator(); + StringTable * stbl = rcx.stringtable(); + + scope log(XO_DEBUG(true)); + + bool ok = true; + + ok = ok & install_aux(sink, + NumericPrimitives::make_multiply_pm(mm, stbl), + flags & InstallFlags::f_essential); + ok = ok & install_aux(sink, + NumericPrimitives::make_divide_pm(mm, stbl), + flags & InstallFlags::f_essential); + ok = ok & install_aux(sink, + NumericPrimitives::make_add_pm(mm, stbl), + flags & InstallFlags::f_essential); + ok = ok & install_aux(sink, + NumericPrimitives::make_subtract_pm(mm, stbl), + flags & InstallFlags::f_essential); + + ok = ok & install_aux(sink, + NumericPrimitives::make_cmpeq_pm(mm, stbl), + flags & InstallFlags::f_essential); + ok = ok & install_aux(sink, + NumericPrimitives::make_cmpne_pm(mm, stbl), + flags & InstallFlags::f_essential); + ok = ok & install_aux(sink, + NumericPrimitives::make_cmplt_pm(mm, stbl), + flags & InstallFlags::f_essential); + ok = ok & install_aux(sink, + NumericPrimitives::make_cmple_pm(mm, stbl), + flags & InstallFlags::f_essential); + ok = ok & install_aux(sink, + NumericPrimitives::make_cmpgt_pm(mm, stbl), + flags & InstallFlags::f_essential); + ok = ok & install_aux(sink, + NumericPrimitives::make_cmpge_pm(mm, stbl), + flags & InstallFlags::f_essential); + + return ok; + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end SetupNumeric.cpp */ diff --git a/src/numeric/init_numeric.cpp b/src/numeric/init_numeric.cpp index faa678a0..86105ec6 100644 --- a/src/numeric/init_numeric.cpp +++ b/src/numeric/init_numeric.cpp @@ -4,22 +4,21 @@ **/ #include "init_numeric.hpp" +#include "SetupNumeric.hpp" #include #include "Subsystem.hpp" -#include "numeric_register_facets.hpp" -#include "numeric_register_primitives.hpp" namespace xo { - using xo::scm::numeric_register_facets; - using xo::scm::numeric_register_primitives; + using xo::scm::SetupNumeric; + //using xo::scm::numeric_register_primitives; using xo::scm::PrimitiveRegistry; void InitSubsys::init() { - numeric_register_facets(); + SetupNumeric::register_facets(); - PrimitiveRegistry::instance().register_primitives(&numeric_register_primitives); + PrimitiveRegistry::instance().register_primitives(&SetupNumeric::register_primitives); } diff --git a/src/numeric/numeric_register_facets.cpp b/src/numeric/numeric_register_facets.cpp deleted file mode 100644 index 7ef2555a..00000000 --- a/src/numeric/numeric_register_facets.cpp +++ /dev/null @@ -1,93 +0,0 @@ -/** @file numeric_register_facets.cpp - * - * @author Roland Conybeare, Feb 2026 - **/ - -#include "numeric_register_facets.hpp" -#include "NumericDispatch.hpp" -#include "Numeric.hpp" - -#include "FloatIntegerOps.hpp" -#include "FloatOps.hpp" -#include "float/INumeric_DFloat.hpp" - -#include "IntegerOps.hpp" -#include "integer/INumeric_DInteger.hpp" - -#include -#include - -#include -#include -#include - -namespace xo { - using xo::facet::FacetRegistry; - using xo::reflect::typeseq; - - namespace scm { - - bool - numeric_register_facets() - { - scope log(XO_DEBUG(true)); - - FacetRegistry::register_impl(); - - NumericDispatch::instance().register_impl - (&FloatOps::multiply, - &FloatOps::divide, - &FloatOps::add, - &FloatOps::subtract, - &FloatOps::cmp_equal, - &FloatOps::cmp_notequal, - &FloatOps::cmp_less, - &FloatOps::cmp_lessequal, - &FloatOps::cmp_greater, - &FloatOps::cmp_greatequal); - - NumericDispatch::instance().register_impl - (&FloatIntegerOps::multiply, - &FloatIntegerOps::divide, - &FloatIntegerOps::add, - &FloatIntegerOps::subtract, - &FloatIntegerOps::cmp_equal, - &FloatIntegerOps::cmp_notequal, - &FloatIntegerOps::cmp_less, - &FloatIntegerOps::cmp_lessequal, - &FloatIntegerOps::cmp_greater, - &FloatIntegerOps::cmp_greatequal); - - NumericDispatch::instance().register_impl - (&IntegerFloatOps::multiply, - &IntegerFloatOps::divide, - &IntegerFloatOps::add, - &IntegerFloatOps::subtract, - &IntegerFloatOps::cmp_equal, - &IntegerFloatOps::cmp_notequal, - &IntegerFloatOps::cmp_less, - &IntegerFloatOps::cmp_lessequal, - &IntegerFloatOps::cmp_greater, - &IntegerFloatOps::cmp_greatequal); - - NumericDispatch::instance().register_impl - (&IntegerOps::multiply, - &IntegerOps::divide, - &IntegerOps::add, - &IntegerOps::subtract, - &IntegerOps::cmp_equal, - &IntegerOps::cmp_notequal, - &IntegerOps::cmp_less, - &IntegerOps::cmp_lessequal, - &IntegerOps::cmp_greater, - &IntegerOps::cmp_greatequal); - - log && log(xtag("ANumeric.tseq", typeseq::id())); - - return true; - } - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end numeric_register_facets.cpp */ diff --git a/src/numeric/numeric_register_primitives.cpp b/src/numeric/numeric_register_primitives.cpp deleted file mode 100644 index 08cb0fc9..00000000 --- a/src/numeric/numeric_register_primitives.cpp +++ /dev/null @@ -1,102 +0,0 @@ -/** @file numeric_register_primitives.cpp - * - * @author Roland Conybeare, Mar 2026 - **/ - -#include "numeric_register_primitives.hpp" -#include "NumericPrimitives.hpp" -#include "NumericDispatch.hpp" -#include -#include - -namespace xo { - using xo::mm::AAllocator; - using xo::scope; - - namespace scm { - namespace { - bool install_aux(InstallSink sink, - DPrimitive_gco_2_gco_gco * pm, - InstallFlags flags) - { - if (flags != InstallFlags::f_none) { - return sink(pm->name(), - pm->fn_td(), - obj(pm), - flags); - } else { - return true; - } - } - -#ifdef OBSOLETE - bool install_aux(InstallSink sink, - obj mm, - std::string_view name, - obj (*impl)(obj rcx, - obj x, - obj y), - InstallFlags flags) - { - if (flags != InstallFlags::f_none) { - auto pm - = DPrimitive_gco_2_gco_gco::_make(mm, name, impl); - - return install_aux(sink, pm, flags); - } else { - return true; - } - } -#endif - } - - bool - numeric_register_primitives(obj rcx, - //obj mm, StringTable * stbl, - InstallSink sink, InstallFlags flags) - { - obj mm = rcx.allocator(); - StringTable * stbl = rcx.stringtable(); - - scope log(XO_DEBUG(true)); - - bool ok = true; - - ok = ok & install_aux(sink, - NumericPrimitives::make_multiply_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_divide_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_add_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_subtract_pm(mm, stbl), - flags & InstallFlags::f_essential); - - ok = ok & install_aux(sink, - NumericPrimitives::make_cmpeq_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_cmpne_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_cmplt_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_cmple_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_cmpgt_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_cmpge_pm(mm, stbl), - flags & InstallFlags::f_essential); - - return ok; - } - } -} /*namespace xo*/ - -/* end numeric_register_primitives.cpp */ From f4d00d9e17bfdca1c22b8537407b0cf5d107922a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 20:18:52 -0500 Subject: [PATCH 02/10] xo-interpreter2: streamline pm setup --- src/numeric/SetupNumeric.cpp | 87 +++++++++++++++++------------------- 1 file changed, 40 insertions(+), 47 deletions(-) diff --git a/src/numeric/SetupNumeric.cpp b/src/numeric/SetupNumeric.cpp index c5920505..75a1f1de 100644 --- a/src/numeric/SetupNumeric.cpp +++ b/src/numeric/SetupNumeric.cpp @@ -91,22 +91,6 @@ namespace xo { return true; } - namespace { - bool install_aux(InstallSink sink, - DPrimitive_gco_2_gco_gco * pm, - InstallFlags flags) - { - if (flags != InstallFlags::f_none) { - return sink(pm->name(), - pm->fn_td(), - obj(pm), - flags); - } else { - return true; - } - } - } - bool SetupNumeric::register_primitives(obj rcx, InstallSink sink, @@ -119,37 +103,46 @@ namespace xo { bool ok = true; - ok = ok & install_aux(sink, - NumericPrimitives::make_multiply_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_divide_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_add_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_subtract_pm(mm, stbl), - flags & InstallFlags::f_essential); - - ok = ok & install_aux(sink, - NumericPrimitives::make_cmpeq_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_cmpne_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_cmplt_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_cmple_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_cmpgt_pm(mm, stbl), - flags & InstallFlags::f_essential); - ok = ok & install_aux(sink, - NumericPrimitives::make_cmpge_pm(mm, stbl), - flags & InstallFlags::f_essential); + ok = ok & (PrimitiveRegistry::install_aux + (sink, + NumericPrimitives::make_multiply_pm(mm, stbl), + flags & InstallFlags::f_essential)); + ok = ok & (PrimitiveRegistry::install_aux + (sink, + NumericPrimitives::make_divide_pm(mm, stbl), + flags & InstallFlags::f_essential)); + ok = ok & (PrimitiveRegistry::install_aux + (sink, + NumericPrimitives::make_add_pm(mm, stbl), + flags & InstallFlags::f_essential)); + ok = ok & (PrimitiveRegistry::install_aux + (sink, + NumericPrimitives::make_subtract_pm(mm, stbl), + flags & InstallFlags::f_essential)); + ok = ok & (PrimitiveRegistry::install_aux + (sink, + NumericPrimitives::make_cmpeq_pm(mm, stbl), + flags & InstallFlags::f_essential)); + ok = ok & (PrimitiveRegistry::install_aux + (sink, + NumericPrimitives::make_cmpne_pm(mm, stbl), + flags & InstallFlags::f_essential)); + ok = ok & (PrimitiveRegistry::install_aux + (sink, + NumericPrimitives::make_cmplt_pm(mm, stbl), + flags & InstallFlags::f_essential)); + ok = ok & (PrimitiveRegistry::install_aux + (sink, + NumericPrimitives::make_cmple_pm(mm, stbl), + flags & InstallFlags::f_essential)); + ok = ok & (PrimitiveRegistry::install_aux + (sink, + NumericPrimitives::make_cmpgt_pm(mm, stbl), + flags & InstallFlags::f_essential)); + ok = ok & (PrimitiveRegistry::install_aux + (sink, + NumericPrimitives::make_cmpge_pm(mm, stbl), + flags & InstallFlags::f_essential)); return ok; } From 335c04a834609b65921be385854a4cfb29f6d45e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Mar 2026 22:01:28 -0400 Subject: [PATCH 03/10] xo-numeric: cosmetic: add comments to label essential primitives --- src/numeric/SetupNumeric.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/numeric/SetupNumeric.cpp b/src/numeric/SetupNumeric.cpp index 75a1f1de..d61d6edc 100644 --- a/src/numeric/SetupNumeric.cpp +++ b/src/numeric/SetupNumeric.cpp @@ -103,42 +103,52 @@ namespace xo { bool ok = true; + /* "_mul" */ ok = ok & (PrimitiveRegistry::install_aux (sink, NumericPrimitives::make_multiply_pm(mm, stbl), flags & InstallFlags::f_essential)); + /* "_div" */ ok = ok & (PrimitiveRegistry::install_aux (sink, NumericPrimitives::make_divide_pm(mm, stbl), flags & InstallFlags::f_essential)); + /* "_add" */ ok = ok & (PrimitiveRegistry::install_aux (sink, NumericPrimitives::make_add_pm(mm, stbl), flags & InstallFlags::f_essential)); + /* "_sub" */ ok = ok & (PrimitiveRegistry::install_aux (sink, NumericPrimitives::make_subtract_pm(mm, stbl), flags & InstallFlags::f_essential)); + /* "_cmpeq" */ ok = ok & (PrimitiveRegistry::install_aux (sink, NumericPrimitives::make_cmpeq_pm(mm, stbl), flags & InstallFlags::f_essential)); + /* "_cmpne" */ ok = ok & (PrimitiveRegistry::install_aux (sink, NumericPrimitives::make_cmpne_pm(mm, stbl), flags & InstallFlags::f_essential)); + /* "_cmplt" */ ok = ok & (PrimitiveRegistry::install_aux (sink, NumericPrimitives::make_cmplt_pm(mm, stbl), flags & InstallFlags::f_essential)); + /* "_cmple" */ ok = ok & (PrimitiveRegistry::install_aux (sink, NumericPrimitives::make_cmple_pm(mm, stbl), flags & InstallFlags::f_essential)); + /* "_cmpgt" */ ok = ok & (PrimitiveRegistry::install_aux (sink, NumericPrimitives::make_cmpgt_pm(mm, stbl), flags & InstallFlags::f_essential)); + /* "_cmpge" */ ok = ok & (PrimitiveRegistry::install_aux (sink, NumericPrimitives::make_cmpge_pm(mm, stbl), From b3fbddcf3ea2ebe770b8893945669eae7f096009 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Mar 2026 22:16:24 -0400 Subject: [PATCH 04/10] xo-numeric: cosmetic: drop debug --- src/numeric/SetupNumeric.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/numeric/SetupNumeric.cpp b/src/numeric/SetupNumeric.cpp index d61d6edc..58254fc2 100644 --- a/src/numeric/SetupNumeric.cpp +++ b/src/numeric/SetupNumeric.cpp @@ -99,7 +99,7 @@ namespace xo { obj mm = rcx.allocator(); StringTable * stbl = rcx.stringtable(); - scope log(XO_DEBUG(true)); + scope log(XO_DEBUG(false)); bool ok = true; From 4601e824bc7d7614316d967a889571b7318e713a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 25 Mar 2026 17:11:46 -0400 Subject: [PATCH 05/10] xo-reader2 stack: refactor for ssm file location --- src/numeric/NumericPrimitives.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/numeric/NumericPrimitives.cpp b/src/numeric/NumericPrimitives.cpp index decc8d60..8515e9d4 100644 --- a/src/numeric/NumericPrimitives.cpp +++ b/src/numeric/NumericPrimitives.cpp @@ -24,10 +24,14 @@ namespace xo { // // e.g. f64 x f64 -> f64 +#ifdef NOPE auto numeric_ty = DAtomicType::make(mm, Metatype::t_numeric()); // #op+: numeric x numeric -> numeric auto pm_ty = obj (DFunctionType::_make(mm, numeric_ty, numeric_ty, numeric_ty)); +#endif + + auto pm_ty = obj(); return DPrimitive_gco_2_gco_gco::_make(mm, "_mul", pm_ty, &NumericDispatch::multiply); From d288c4ff1efa676276bc866772d352024c252b03 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 25 Mar 2026 17:52:39 -0400 Subject: [PATCH 06/10] xo-reader2 stack: constants for operator primitive names --- include/xo/numeric/NumericPrimitives.hpp | 25 ++++++++++++++++++++++++ src/numeric/NumericPrimitives.cpp | 20 +++++++++---------- 2 files changed, 35 insertions(+), 10 deletions(-) diff --git a/include/xo/numeric/NumericPrimitives.hpp b/include/xo/numeric/NumericPrimitives.hpp index aec3ae84..51c614f1 100644 --- a/include/xo/numeric/NumericPrimitives.hpp +++ b/include/xo/numeric/NumericPrimitives.hpp @@ -17,31 +17,56 @@ namespace xo { using AAllocator = xo::mm::AAllocator; public: + /** name for multiply primitive. Used for op* **/ + static constexpr const char * c_multiply_pm_name = "_mul"; /** polymorphic (in both arguments1) multiply **/ static DPrimitive_gco_2_gco_gco * make_multiply_pm(obj mm, StringTable * stbl); + + /** name for divide primitives. Used for op/ **/ + static constexpr const char * c_divide_pm_name = "_div"; /** polymorphic (in both arguments) divide **/ static DPrimitive_gco_2_gco_gco * make_divide_pm(obj mm, StringTable * stbl); + + /** name for add primitives. Used for op+ **/ + static constexpr const char * c_add_pm_name = "_add"; /** polymorphic (in both arguments) add **/ static DPrimitive_gco_2_gco_gco * make_add_pm(obj mm, StringTable * stbl); + + /** name for sub primitives. Used for op- **/ + static constexpr const char * c_sub_pm_name = "_sub"; /** polymorphic (in both arguments) subtract **/ static DPrimitive_gco_2_gco_gco * make_subtract_pm(obj mm, StringTable * stbl); + /** name for equality-comparison primitive. Used for op== **/ + static constexpr const char * c_cmpeq_pm_name = "_cmpeq"; /** polymorphic (in both arguments) compare (==) **/ static DPrimitive_gco_2_gco_gco * make_cmpeq_pm(obj mm, StringTable * stbl); + + /** name for inequality-comparison prmitive. Used for op!= **/ + static constexpr const char * c_cmpne_pm_name = "_cmpne"; /** polymorphic (in both arguments) compare (!=) **/ static DPrimitive_gco_2_gco_gco * make_cmpne_pm(obj mm, StringTable * stbl); + + /** name for less-comparison primitive. Used for op< **/ + static constexpr const char * c_cmplt_pm_name = "_cmplt"; /** polymorphic (in both arguments) compare (<) **/ static DPrimitive_gco_2_gco_gco * make_cmplt_pm(obj mm, StringTable * stbl); + + /** name for lesser-or-equal-comparison primitive. Used for op<= **/ + static constexpr const char * c_cmple_pm_name = "_cmple"; /** polymorphic (in both arguments) compare (<=) **/ static DPrimitive_gco_2_gco_gco * make_cmple_pm(obj mm, StringTable * stbl); + + /** name for greater-comparison primitive. Used for op> **/ + static constexpr const char * c_cmpgt_pm_name = "_cmpgt"; /** polymorphic (in both arguments) compare (>) **/ static DPrimitive_gco_2_gco_gco * make_cmpgt_pm(obj mm, StringTable * stbl); diff --git a/src/numeric/NumericPrimitives.cpp b/src/numeric/NumericPrimitives.cpp index 8515e9d4..0104f4cb 100644 --- a/src/numeric/NumericPrimitives.cpp +++ b/src/numeric/NumericPrimitives.cpp @@ -33,7 +33,7 @@ namespace xo { auto pm_ty = obj(); - return DPrimitive_gco_2_gco_gco::_make(mm, "_mul", pm_ty, + return DPrimitive_gco_2_gco_gco::_make(mm, c_multiply_pm_name, pm_ty, &NumericDispatch::multiply); } @@ -48,7 +48,7 @@ namespace xo { auto pm_ty = obj (DFunctionType::_make(mm, numeric_ty, numeric_ty, numeric_ty)); - return DPrimitive_gco_2_gco_gco::_make(mm, "_div", pm_ty, + return DPrimitive_gco_2_gco_gco::_make(mm, c_divide_pm_name, pm_ty, &NumericDispatch::divide); } @@ -63,7 +63,7 @@ namespace xo { auto pm_ty = obj (DFunctionType::_make(mm, numeric_ty, numeric_ty, numeric_ty)); - return DPrimitive_gco_2_gco_gco::_make(mm, "_add", pm_ty, + return DPrimitive_gco_2_gco_gco::_make(mm, c_add_pm_name, pm_ty, &NumericDispatch::add); } @@ -78,7 +78,7 @@ namespace xo { auto pm_ty = obj (DFunctionType::_make(mm, numeric_ty, numeric_ty, numeric_ty)); - return DPrimitive_gco_2_gco_gco::_make(mm, "_sub", pm_ty, + return DPrimitive_gco_2_gco_gco::_make(mm, c_sub_pm_name, pm_ty, &NumericDispatch::subtract); } @@ -94,7 +94,7 @@ namespace xo { auto pm_ty = obj (DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty)); - return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpeq", pm_ty, + return DPrimitive_gco_2_gco_gco::_make(mm, c_cmpeq_pm_name, pm_ty, &NumericDispatch::cmp_equal); } @@ -110,7 +110,7 @@ namespace xo { auto pm_ty = obj (DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty)); - return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpne", pm_ty, + return DPrimitive_gco_2_gco_gco::_make(mm, c_cmpne_pm_name, pm_ty, &NumericDispatch::cmp_notequal); } @@ -126,7 +126,7 @@ namespace xo { auto pm_ty = obj (DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty)); - return DPrimitive_gco_2_gco_gco::_make(mm, "_cmplt", pm_ty, + return DPrimitive_gco_2_gco_gco::_make(mm, c_cmplt_pm_name, pm_ty, &NumericDispatch::cmp_less); } @@ -142,7 +142,7 @@ namespace xo { auto pm_ty = obj (DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty)); - return DPrimitive_gco_2_gco_gco::_make(mm, "_cmple", pm_ty, + return DPrimitive_gco_2_gco_gco::_make(mm, c_cmple_pm_name, pm_ty, &NumericDispatch::cmp_lessequal); } @@ -158,7 +158,7 @@ namespace xo { auto pm_ty = obj (DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty)); - return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpgt", pm_ty, + return DPrimitive_gco_2_gco_gco::_make(mm, c_cmpgt_pm_name, pm_ty, &NumericDispatch::cmp_greater); } @@ -174,7 +174,7 @@ namespace xo { auto pm_ty = obj (DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty)); - return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpge", pm_ty, + return DPrimitive_gco_2_gco_gco::_make(mm, c_cmpge_pm_name, pm_ty, &NumericDispatch::cmp_greatequal); } From 9e88672ad4b78ec92c7b8d2a1ec0c50cfda51c62 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 25 Mar 2026 19:31:59 -0400 Subject: [PATCH 07/10] xo-interpreter2 stack: VSM as AGCObject for virtual root --- include/xo/numeric/NumericPrimitives.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/xo/numeric/NumericPrimitives.hpp b/include/xo/numeric/NumericPrimitives.hpp index 51c614f1..a1e047f0 100644 --- a/include/xo/numeric/NumericPrimitives.hpp +++ b/include/xo/numeric/NumericPrimitives.hpp @@ -70,6 +70,9 @@ namespace xo { /** polymorphic (in both arguments) compare (>) **/ static DPrimitive_gco_2_gco_gco * make_cmpgt_pm(obj mm, StringTable * stbl); + + /** name for greater-or-equal-comparison primitive. Used for op>= **/ + static constexpr const char * c_cmpge_pm_name = "_cmpge"; /** polymorphic (in both arguments) compare (>=) **/ static DPrimitive_gco_2_gco_gco * make_cmpge_pm(obj mm, StringTable * stbl); From 5950a45483ecf26931b2df1bf05925efb4d16186 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 28 Mar 2026 09:45:36 -0400 Subject: [PATCH 08/10] xo-numeric: restore numeric function type --- src/numeric/NumericPrimitives.cpp | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/numeric/NumericPrimitives.cpp b/src/numeric/NumericPrimitives.cpp index 0104f4cb..9697cc9b 100644 --- a/src/numeric/NumericPrimitives.cpp +++ b/src/numeric/NumericPrimitives.cpp @@ -24,14 +24,10 @@ namespace xo { // // e.g. f64 x f64 -> f64 -#ifdef NOPE auto numeric_ty = DAtomicType::make(mm, Metatype::t_numeric()); // #op+: numeric x numeric -> numeric auto pm_ty = obj (DFunctionType::_make(mm, numeric_ty, numeric_ty, numeric_ty)); -#endif - - auto pm_ty = obj(); return DPrimitive_gco_2_gco_gco::_make(mm, c_multiply_pm_name, pm_ty, &NumericDispatch::multiply); From 4dc673916796a985d3e1ef16395f8528e31583d2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 16:33:35 -0400 Subject: [PATCH 09/10] refactor: rename shallow_copy -> shallow_move + streamline Use RCollector.std_copy_for where appropriate --- include/xo/numeric/detail/ANumeric.hpp | 5 +++++ include/xo/numeric/detail/RNumeric.hpp | 1 + 2 files changed, 6 insertions(+) diff --git a/include/xo/numeric/detail/ANumeric.hpp b/include/xo/numeric/detail/ANumeric.hpp index bda27456..7c8e0c99 100644 --- a/include/xo/numeric/detail/ANumeric.hpp +++ b/include/xo/numeric/detail/ANumeric.hpp @@ -42,6 +42,11 @@ public: /** @defgroup scm-numeric-methods **/ ///@{ // const methods + /** An uninitialized ANumeric instance will have zero vtable pointer (per {linux,osx} abi). + * Use case for this is narrow. We go to some lengths to avoid null vtable pointers. For example + * obj will have non-null vtable (via IFacet_Any) with all methods terminating. + **/ + bool _has_null_vptr() const noexcept { return *reinterpret_cast(this) == nullptr; } /** RTTI: unique id# for actual runtime data representation **/ virtual typeseq _typeseq() const noexcept = 0; /** destroy instance @p d; calls c++ dtor only for actual runtime type; does not recover memory **/ diff --git a/include/xo/numeric/detail/RNumeric.hpp b/include/xo/numeric/detail/RNumeric.hpp index 86cac666..35a704ec 100644 --- a/include/xo/numeric/detail/RNumeric.hpp +++ b/include/xo/numeric/detail/RNumeric.hpp @@ -46,6 +46,7 @@ public: ///@{ // explicit injected content + static obj multiply(obj lhs, obj rhs); // builtin methods typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); } From 5f2de0ad5a9ad31ebb222fc2f8bd046d14f3d149 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 2 May 2026 13:49:29 -0400 Subject: [PATCH 10/10] xo-gc stack: refactor + streamline. Retiring unused Collector typealiases. Fix #include topology. Fix/improve write barrier setup. --- include/xo/numeric/detail/INumeric_Xfer.hpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/include/xo/numeric/detail/INumeric_Xfer.hpp b/include/xo/numeric/detail/INumeric_Xfer.hpp index c9cd2473..bca62e2f 100644 --- a/include/xo/numeric/detail/INumeric_Xfer.hpp +++ b/include/xo/numeric/detail/INumeric_Xfer.hpp @@ -9,10 +9,18 @@ * [iface_facet_any.hpp.j2] * 3. idl for facet methods * [idl/Numeric.json5] + * + * variables: + * {facet_hpp_fname} -> Numeric.hpp + * {impl_hpp_subdir} -> detail + * {facet_ns1} -> xo + * {facet_detail_subdir} -> detail + * {abstract_facet_fname} -> ANumeric.hpp **/ #pragma once +#include "ANumeric.hpp" namespace xo { namespace scm {