From 7778c7f1c99b277f8ad1a5a7e935e85b3528fabd Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 10 Jan 2026 12:39:09 -0500 Subject: [PATCH 001/128] + xo-tokenizer2 xo-reader2 xo-expression2 xo-interpreter2 2nd gen schematika interpreter using fomo --- CMakeLists.txt | 41 +++++++++++++++++++++++++++++ README.md | 1 - cmake/xo-bootstrap-macros.cmake | 33 +++++++++++++++++++++++ cmake/xo_expression2Config.cmake.in | 12 +++++++++ include/xo/expression2/.gitkeep | 0 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 CMakeLists.txt delete mode 100644 README.md create mode 100644 cmake/xo-bootstrap-macros.cmake create mode 100644 cmake/xo_expression2Config.cmake.in create mode 100644 include/xo/expression2/.gitkeep diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..1ecb48b3 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,41 @@ +# xo-expression2/CMakeLists.txt + +cmake_minimum_required(VERSION 3.10) + +project(xo_expression2 VERSION 1.0) +enable_language(CXX) + +include(GNUInstallDirs) +include(cmake/xo-bootstrap-macros.cmake) + +xo_cxx_toplevel_options3() + +# ---------------------------------------------------------------- +# c++ settings + +# one-time project-specific c++ flags. usually empty +set(PROJECT_CXX_FLAGS "") +add_definitions(${PROJECT_CXX_FLAGS}) + +# ---------------------------------------------------------------- +# output targets + +#add_subdirectory(utest) + +# ---------------------------------------------------------------- +# header-only library + +set(SELF_LIB xo_expression2) +xo_add_headeronly_library(${SELF_LIB}) +xo_install_library4(${SELF_LIB} ${PROJECT_NAME}Targets) +xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) + +# ---------------------------------------------------------------- +# input dependencies +# +# NOTE: dependency set here must be kept consistent with +# xo-expression2/cmake/xo_expression2Config.cmake.in + +#xo_headeronly_dependency(${SELF_LIB} xo_flatstring) + +# end CMakeLists.txt diff --git a/README.md b/README.md deleted file mode 100644 index a4dd3522..00000000 --- a/README.md +++ /dev/null @@ -1 +0,0 @@ -# xo-expression2 diff --git a/cmake/xo-bootstrap-macros.cmake b/cmake/xo-bootstrap-macros.cmake new file mode 100644 index 00000000..2cf387e5 --- /dev/null +++ b/cmake/xo-bootstrap-macros.cmake @@ -0,0 +1,33 @@ +# ---------------------------------------------------------------- +# for example: +# $ PREFIX=/usr/local # for example +# $ cmake -DCMAKE_MODULE_PATH=prefix -DCMAKE_INSTALL_PREFIX=$PREFIX -B .build +# +# will get +# CMAKE_MODULE_PATH +# from xo-cmake-config --cmake-module-path +# +# and expect .cmake macros in +# CMAKE_MODULE_PATH/xo_macros/xo_cxx.cmake +# ---------------------------------------------------------------- + +find_program(XO_CMAKE_CONFIG_EXECUTABLE NAMES xo-cmake-config REQUIRED) + +if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL "prefix")) + message(FATAL "could not find xo-cmake-config executable") +endif() + +if (NOT XO_SUBMODULE_BUILD) + if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix)) + # default to typical install location for xo-project-macros + execute_process(COMMAND ${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH) + message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + endif() +endif() + +# needs to have been installed somewhere on CMAKE_MODULE_PATH, +# (e.g. from xo-cmake with the same value for CMAKE_INSTALL_PREFIX) +# +include(xo_macros/xo_cxx) + +xo_cxx_bootstrap_message() diff --git a/cmake/xo_expression2Config.cmake.in b/cmake/xo_expression2Config.cmake.in new file mode 100644 index 00000000..b5c3cd5c --- /dev/null +++ b/cmake/xo_expression2Config.cmake.in @@ -0,0 +1,12 @@ +@PACKAGE_INIT@ + +include(CMakeFindDependencyMacro) + +# note: changes to find_dependency() calls here +# must coordinate with xo_dependency() calls +# in CMakeLists.txt +# +#find_dependency(xo_flatstring) + +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +check_required_components("@PROJECT_NAME@") diff --git a/include/xo/expression2/.gitkeep b/include/xo/expression2/.gitkeep new file mode 100644 index 00000000..e69de29b From ceb75e83c4f4f968e7fea816b105224db82bdfc8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 12 Jan 2026 21:50:17 -0500 Subject: [PATCH 002/128] xo-expression2: + Expression facet --- CMakeLists.txt | 15 +++- cmake/xo_expression2Config.cmake.in | 6 +- idl/Expression.json5 | 48 ++++++++++ include/xo/expression2/DConstant.hpp | 37 ++++++++ include/xo/expression2/Expression.hpp | 21 +++++ include/xo/expression2/TypeRef.hpp | 60 +++++++++++++ include/xo/expression2/detail/AExpression.hpp | 72 +++++++++++++++ .../xo/expression2/detail/IExpression_Any.hpp | 87 +++++++++++++++++++ .../expression2/detail/IExpression_Xfer.hpp | 86 ++++++++++++++++++ include/xo/expression2/detail/RExpression.hpp | 81 +++++++++++++++++ src/expression2/CMakeLists.txt | 16 ++++ src/expression2/IExpression_Any.cpp | 38 ++++++++ src/expression2/TypeRef.cpp | 60 +++++++++++++ .../expression2_register_facets.cpp | 11 +++ 14 files changed, 634 insertions(+), 4 deletions(-) create mode 100644 idl/Expression.json5 create mode 100644 include/xo/expression2/DConstant.hpp create mode 100644 include/xo/expression2/Expression.hpp create mode 100644 include/xo/expression2/TypeRef.hpp create mode 100644 include/xo/expression2/detail/AExpression.hpp create mode 100644 include/xo/expression2/detail/IExpression_Any.hpp create mode 100644 include/xo/expression2/detail/IExpression_Xfer.hpp create mode 100644 include/xo/expression2/detail/RExpression.hpp create mode 100644 src/expression2/CMakeLists.txt create mode 100644 src/expression2/IExpression_Any.cpp create mode 100644 src/expression2/TypeRef.cpp create mode 100644 src/expression2/expression2_register_facets.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 1ecb48b3..3adeccfa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,12 +22,21 @@ add_definitions(${PROJECT_CXX_FLAGS}) #add_subdirectory(utest) +# note: manual target; generated code committed to git +xo_add_genfacet( + TARGET xo-expression2-facet-expression + FACET Expression + INPUT idl/Expression.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 + ) + # ---------------------------------------------------------------- # header-only library -set(SELF_LIB xo_expression2) -xo_add_headeronly_library(${SELF_LIB}) -xo_install_library4(${SELF_LIB} ${PROJECT_NAME}Targets) +add_subdirectory(src/expression2) + xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) # ---------------------------------------------------------------- diff --git a/cmake/xo_expression2Config.cmake.in b/cmake/xo_expression2Config.cmake.in index b5c3cd5c..ee1852c8 100644 --- a/cmake/xo_expression2Config.cmake.in +++ b/cmake/xo_expression2Config.cmake.in @@ -6,7 +6,11 @@ include(CMakeFindDependencyMacro) # must coordinate with xo_dependency() calls # in CMakeLists.txt # -#find_dependency(xo_flatstring) +find_dependency(xo_gc) +find_dependency(reflect) +find_dependency(xo_printable2) +find_dependency(xo_flatstring) +find_dependency(indentlog) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") check_required_components("@PROJECT_NAME@") diff --git a/idl/Expression.json5 b/idl/Expression.json5 new file mode 100644 index 00000000..9daca006 --- /dev/null +++ b/idl/Expression.json5 @@ -0,0 +1,48 @@ +{ + mode: "facet", + includes: ["\"TypeRef.hpp\""], + namespace1: "xo", + namespace2: "scm", + facet: "Expression", + detail_subdir: "detail", + brief: "a schematika expression", + using_doxygen: true, + doc: [ + "Representation for executable Schematika expressions" + ], + types: [], + const_methods: [ + { + name: "typeref", + doc: ["placeholder for type giving possible values for this expression"], + return_type: "TypeRef", + args: [], + const: true, + noexcept: true, + attributes: [], + }, + { + name: "valuetype", + doc: ["type giving possible values for this expression. Maybe null before typecheck"], + return_type: "TypeDescr", + args: [], + const: true, + noexcept: true, + attributes: [], + }, + ], + nonconst_methods: [ + { + name: "assign_valuetype", + doc: ["assing to valuetype member. Useful when scaffolding expressions"], + return_type: "void", + args: [ + // void assign_valuetype(TypeDescr td) + {type: "TypeDescr", name: "td"}, + ], + const: false, + noexcept: true, + attributes: [], + } + ], +} diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp new file mode 100644 index 00000000..b7cc5cce --- /dev/null +++ b/include/xo/expression2/DConstant.hpp @@ -0,0 +1,37 @@ +/** @file DConstant.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include + +namespace xo { + namespace scm { + /** @class DConstant + * @brief Schematika expression respresenting a literal constant + **/ + struct DConstant { + public: + using TypeDescr = xo::reflect::TypeDescr; + + public: + DConstant(TypeDescr td, void * value); + + TypeDescr value_td() const { return value_td; } + + TypeRef typeref() const noexcept; + TypeDescr valuetype() const noexcept; + void assign_valuetype(TypeDescr td) noexcept; + + private: + /** type for value of this expression **/ + TypeRef type_ref_; + /** type description for destination *value_ **/ + TypeDescr valuetype_; + /** literal value **/ + void * value_; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DConstant.hpp */ diff --git a/include/xo/expression2/Expression.hpp b/include/xo/expression2/Expression.hpp new file mode 100644 index 00000000..311b627d --- /dev/null +++ b/include/xo/expression2/Expression.hpp @@ -0,0 +1,21 @@ +/** @file Expression.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Expression.json5] + * 2. jinja2 template for facet .hpp file: + * [facet.hpp.j2] + * 3. idl for facet methods + * [idl/Expression.json5] + **/ + +#pragma once + +#include "detail/AExpression.hpp" +#include "detail/IExpression_Any.hpp" +#include "detail/IExpression_Xfer.hpp" +#include "detail/RExpression.hpp" + +/* end Expression.hpp */ \ No newline at end of file diff --git a/include/xo/expression2/TypeRef.hpp b/include/xo/expression2/TypeRef.hpp new file mode 100644 index 00000000..8ee08716 --- /dev/null +++ b/include/xo/expression2/TypeRef.hpp @@ -0,0 +1,60 @@ +/** @file TypeRef.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include +#include + +namespace xo { + namespace scm { + /** @class TypeRef + * @brief name and (when established) resolution for type associate with an expression + * + * Type inference / unification operates on + * @ref xo::scm::TypeBlueprint instances. See also! + **/ + class TypeRef { + public: + using TypeDescr = xo::reflect::TypeDescr; + using type_var = flatstring<20>; + using prefix_type = flatstring<8>; + + public: + TypeRef() = default; + TypeRef(const type_var & id, TypeDescr td); + + /** if @p td is non-null + * -> type is already resolved + * + * if type is not determined (i.e. @p td is nullptr): + * -> generate and store type variable name. + **/ + static TypeRef dwim(prefix_type prefix, TypeDescr td); + + /** generate a unique type-variable name, + * that begins with @p prefix + **/ + static type_var generate_unique(prefix_type prefix); + + const type_var & id() const noexcept { return id_; } + TypeDescr td() const noexcept { return td_; } + + /** true iff type at this location has been resolved **/ + bool is_concrete() const noexcept; + + private: + /** unique (probably generated) name for type at this location **/ + type_var id_; + /** Description for concrete type, once resolved. + * May be null when this TypeRef created, + * but expected to be immutable once established. + **/ + TypeDescr td_; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end TypeRef.hpp */ diff --git a/include/xo/expression2/detail/AExpression.hpp b/include/xo/expression2/detail/AExpression.hpp new file mode 100644 index 00000000..942c940b --- /dev/null +++ b/include/xo/expression2/detail/AExpression.hpp @@ -0,0 +1,72 @@ +/** @file AExpression.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Expression.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [abstract_facet.hpp.j2] + * 3. idl for facet methods + * [idl/Expression.json5] + **/ + +#pragma once + +// includes (via {facet_includes}) +#include "TypeRef.hpp" +#include +#include +#include + +namespace xo { +namespace scm { + +using Copaque = const void *; +using Opaque = void *; + +/** +Representation for executable Schematika expressions +**/ +class AExpression { +public: + /** @defgroup scm-expression-type-traits **/ + ///@{ + // types + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + ///@} + + /** @defgroup scm-expression-methods **/ + ///@{ + // const methods + /** RTTI: unique id# for actual runtime data representation **/ + virtual typeseq _typeseq() const noexcept = 0; + /** placeholder for type giving possible values for this expression **/ + virtual TypeRef typeref(Copaque data) const noexcept = 0; + /** type giving possible values for this expression. Maybe null before typecheck **/ + virtual TypeDescr valuetype(Copaque data) const noexcept = 0; + + // nonconst methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + virtual void assign_valuetype(Opaque data, TypeDescr td) noexcept = 0; + ///@} +}; /*AExpression*/ + +/** Implementation IExpression_DRepr of AExpression for state DRepr + * should provide a specialization: + * + * template <> + * struct xo::facet::FacetImplementation { + * using Impltype = IExpression_DRepr; + * }; + * + * then IExpression_ImplType --> IExpression_DRepr + **/ +template +using IExpression_ImplType = xo::facet::FacetImplType; + +} /*namespace scm*/ +} /*namespace xo*/ + +/* */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IExpression_Any.hpp b/include/xo/expression2/detail/IExpression_Any.hpp new file mode 100644 index 00000000..0fac3289 --- /dev/null +++ b/include/xo/expression2/detail/IExpression_Any.hpp @@ -0,0 +1,87 @@ +/** @file IExpression_Any.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Expression.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Expression.json5] + **/ + +#pragma once + +#include "AExpression.hpp" +#include + +namespace xo { namespace scm { class IExpression_Any; } } + +namespace xo { +namespace facet { + +template <> +struct FacetImplementation +{ + using ImplType = xo::scm::IExpression_Any; +}; + +} +} + +namespace xo { +namespace scm { + + /** @class IExpression_Any + * @brief AExpression implementation for empty variant instance + **/ + class IExpression_Any : public AExpression { + public: + /** @defgroup scm-expression-any-type-traits **/ + ///@{ + + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + + ///@} + /** @defgroup scm-expression-any-methods **/ + ///@{ + + const AExpression * iface() const { return std::launder(this); } + + // from AExpression + + // const methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + [[noreturn]] TypeRef typeref(Copaque) const noexcept override { _fatal(); } + [[noreturn]] TypeDescr valuetype(Copaque) const noexcept override { _fatal(); } + + // nonconst methods + [[noreturn]] void assign_valuetype(Opaque, TypeDescr) noexcept override { _fatal(); } + + ///@} + + private: + /** @defgraoup scm-expression-any-private-methods **/ + ///@{ + + [[noreturn]] static void _fatal(); + + ///@} + + public: + /** @defgroup scm-expression-any-member-vars **/ + ///@{ + + static typeseq s_typeseq; + static bool _valid; + + ///@} + }; + +} /*namespace scm */ +} /*namespace xo */ + +/* IExpression_Any.hpp */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IExpression_Xfer.hpp b/include/xo/expression2/detail/IExpression_Xfer.hpp new file mode 100644 index 00000000..55abfd05 --- /dev/null +++ b/include/xo/expression2/detail/IExpression_Xfer.hpp @@ -0,0 +1,86 @@ +/** @file IExpression_Xfer.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Expression.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Expression.json5] + **/ + +#pragma once + +#include "TypeRef.hpp" + +namespace xo { +namespace scm { + /** @class IExpression_Xfer + **/ + template + class IExpression_Xfer : public AExpression { + public: + /** @defgroup scm-expression-xfer-type-traits **/ + ///@{ + /** actual implementation (not generated; often delegates to DRepr) **/ + using Impl = IExpression_DRepr; + /** integer identifying a type **/ + using typeseq = AExpression::typeseq; + ///@} + + /** @defgroup scm-expression-xfer-methods **/ + ///@{ + + static const DRepr & _dcast(Copaque d) { return *(const DRepr *)d; } + static DRepr & _dcast(Opaque d) { return *(DRepr *)d; } + + // from AExpression + + // const methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + TypeRef typeref(Copaque data) const noexcept override { + return I::typeref(_dcast(data)); + } + TypeDescr valuetype(Copaque data) const noexcept override { + return I::valuetype(_dcast(data)); + } + + // non-const methods + void assign_valuetype(Opaque data, TypeDescr td) noexcept override { + return I::assign_valuetype(_dcast(data), td); + } + + ///@} + + private: + using I = Impl; + + public: + /** @defgroup scm-expression-xfer-member-vars **/ + ///@{ + + /** typeseq for template parameter DRepr **/ + static typeseq s_typeseq; + /** true iff satisfies facet implementation **/ + static bool _valid; + + ///@} + }; + + template + xo::facet::typeseq + IExpression_Xfer::s_typeseq + = xo::facet::typeseq::id(); + + template + bool + IExpression_Xfer::_valid + = xo::facet::valid_facet_implementation(); + +} /*namespace scm */ +} /*namespace xo*/ + +/* end IExpression_Xfer.hpp */ \ No newline at end of file diff --git a/include/xo/expression2/detail/RExpression.hpp b/include/xo/expression2/detail/RExpression.hpp new file mode 100644 index 00000000..e9b431e3 --- /dev/null +++ b/include/xo/expression2/detail/RExpression.hpp @@ -0,0 +1,81 @@ +/** @file RExpression.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Expression.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Expression.json5] + **/ + +#pragma once + +#include "AExpression.hpp" + +namespace xo { +namespace scm { + +/** @class RExpression + **/ +template +class RExpression : public Object { +private: + using O = Object; + +public: + /** @defgroup scm-expression-router-type-traits **/ + ///@{ + using ObjectType = Object; + using DataPtr = Object::DataPtr; + using typeseq = xo::reflect::typeseq; + ///@} + + /** @defgroup scm-expression-router-ctors **/ + ///@{ + RExpression() {} + RExpression(Object::DataPtr data) : Object{std::move(data)} {} + + ///@} + /** @defgroup scm-expression-router-methods **/ + ///@{ + + // const methods + typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); } + TypeRef typeref() const noexcept override { + return O::iface()->typeref(O::data()); + } + TypeDescr valuetype() const noexcept override { + return O::iface()->valuetype(O::data()); + } + + // non-const methods + // << do something for non-const methods >> + // + + ///@} + /** @defgroup scm-expression-member-vars **/ + ///@{ + + static bool _valid; + + ///@} +}; + +template +bool +RExpression::_valid = xo::facet::valid_object_router(); + +} /*namespace scm*/ +} /*namespace xo*/ + +namespace xo { namespace facet { + template + struct RoutingFor { + using RoutingType = xo::scm::RExpression; + }; +} } + +/* end RExpression.hpp */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt new file mode 100644 index 00000000..c0c794ff --- /dev/null +++ b/src/expression2/CMakeLists.txt @@ -0,0 +1,16 @@ +# expression2/CMakeLists.txt + +set(SELF_LIB xo_expression2) +set(SELF_SRCS + TypeRef.cpp + #IExpression_Any.cpp + expression2_register_facets.cpp + ) + +xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) +# note: deps here must also appear in cmake/xo_expression2Config.cmake.in +xo_dependency(${SELF_LIB} xo_gc) +xo_dependency(${SELF_LIB} reflect) +xo_dependency(${SELF_LIB} xo_printable2) +xo_dependency(${SELF_LIB} xo_flatstring) +xo_dependency(${SELF_LIB} indentlog) diff --git a/src/expression2/IExpression_Any.cpp b/src/expression2/IExpression_Any.cpp new file mode 100644 index 00000000..a27a68bc --- /dev/null +++ b/src/expression2/IExpression_Any.cpp @@ -0,0 +1,38 @@ +/** @file IExpression_Any.cpp + * + **/ + +#include "detail/IExpression_Any.hpp" +#include + +namespace xo { +namespace scm { + +using xo::facet::DVariantPlaceholder; +using xo::facet::typeseq; +using xo::facet::valid_facet_implementation; + +void +IExpression_Any::_fatal() +{ + /* control here on uninitialized IAllocator_Any. + * Initialized instance will have specific implementation type + */ + std::cerr << "fatal" + << ": attempt to call uninitialized" + << " IExpression_Any method" + << std::endl; + std::terminate(); +} + +typeseq +IExpression_Any::s_typeseq = typeseq::id(); + +bool +IExpression_Any::_valid + = valid_facet_implementation(); + +} /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_Any.cpp */ \ No newline at end of file diff --git a/src/expression2/TypeRef.cpp b/src/expression2/TypeRef.cpp new file mode 100644 index 00000000..2ceb6132 --- /dev/null +++ b/src/expression2/TypeRef.cpp @@ -0,0 +1,60 @@ +/** @file TypeRef.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "TypeRef.hpp" + +namespace xo { + namespace scm { + TypeRef::TypeRef(const type_var & id, TypeDescr td) + : id_{id}, td_{td} + {} + + TypeRef + TypeRef::dwim(prefix_type prefix, TypeDescr td) + { + if (td) { + /* type already resolved + * -> we don't need a type variable name + */ + type_var null; + return TypeRef(null, td); + } else { + /* type is not resolved yet. + * -> give it a unique name, + * to seed unification + */ + return TypeRef(generate_unique(prefix), td); + } + } + + auto + TypeRef::generate_unique(prefix_type prefix) -> type_var + { + static uint32_t s_counter = 0; + + s_counter = (1 + s_counter) % 1000000000; + + char buf[type_var::fixed_capacity]; + int n = snprintf(buf, sizeof(buf), "%s:%u", prefix.c_str(), s_counter); + (void)n;; + + assert(n < static_cast(type_var::fixed_capacity)); + + // not necessary, but to remove all doubt. + buf [sizeof(buf) - 1] = '\0'; + + return type_var(buf); + } + + bool + TypeRef::is_concrete() const noexcept + { + return (td_ != nullptr); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end TypeRef.cpp */ diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp new file mode 100644 index 00000000..49edb80c --- /dev/null +++ b/src/expression2/expression2_register_facets.cpp @@ -0,0 +1,11 @@ +/** @file expression2_register_facets.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +namespace xo { + namespace scm { + } +} /*namesapce xo*/ + +/* end expression2_register_facets.cpp */ From 3cbbe5ab63d242484b84ca0bc694dcf0e9a114ed Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 13 Jan 2026 01:40:48 -0500 Subject: [PATCH 003/128] + xo-interpreter2 scaffold for constant expression [WIP] --- cmake/xo_expression2Config.cmake.in | 1 + idl/Expression.json5 | 23 ++++- include/xo/expression2/DConstant.hpp | 37 +++++--- include/xo/expression2/Expression.hpp | 2 +- include/xo/expression2/TypeRef.hpp | 10 ++- include/xo/expression2/detail/AExpression.hpp | 8 +- .../xo/expression2/detail/IExpression_Any.hpp | 4 +- .../expression2/detail/IExpression_Xfer.hpp | 8 +- include/xo/expression2/detail/RExpression.hpp | 10 ++- include/xo/expression2/exprtype.hpp | 84 +++++++++++++++++++ src/expression2/CMakeLists.txt | 2 + src/expression2/DConstant.cpp | 53 ++++++++++++ src/expression2/TypeRef.cpp | 14 +++- 13 files changed, 232 insertions(+), 24 deletions(-) create mode 100644 include/xo/expression2/exprtype.hpp create mode 100644 src/expression2/DConstant.cpp diff --git a/cmake/xo_expression2Config.cmake.in b/cmake/xo_expression2Config.cmake.in index ee1852c8..d48c29a4 100644 --- a/cmake/xo_expression2Config.cmake.in +++ b/cmake/xo_expression2Config.cmake.in @@ -8,6 +8,7 @@ include(CMakeFindDependencyMacro) # find_dependency(xo_gc) find_dependency(reflect) +find_dependency(xo_object2) find_dependency(xo_printable2) find_dependency(xo_flatstring) find_dependency(indentlog) diff --git a/idl/Expression.json5 b/idl/Expression.json5 index 9daca006..f156dffe 100644 --- a/idl/Expression.json5 +++ b/idl/Expression.json5 @@ -1,6 +1,9 @@ { mode: "facet", - includes: ["\"TypeRef.hpp\""], + includes: [ "\"TypeRef.hpp\"", + "\"exprtype.hpp\"", + ""], + namespace1: "xo", namespace2: "scm", facet: "Expression", @@ -10,8 +13,24 @@ doc: [ "Representation for executable Schematika expressions" ], - types: [], + types: [ + // using TypeDescr = xo::reflect::TypeDescr; + { + name: "TypeDescr", + doc: ["struct describing a type"], + definition: "xo::reflect::TypeDescr" + }, + ], const_methods: [ + { + name: "extype", + doc: ["expression type (constant | apply | ..)"], + return_type: "exprtype", + args: [], + const: true, + noexcept: true, + attributes: [], + }, { name: "typeref", doc: ["placeholder for type giving possible values for this expression"], diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp index b7cc5cce..29776912 100644 --- a/include/xo/expression2/DConstant.hpp +++ b/include/xo/expression2/DConstant.hpp @@ -3,7 +3,10 @@ * @author Roland Conybeare, Jan 2026 **/ -#include +#include "TypeRef.hpp" +#include "exprtype.hpp" +#include +#include namespace xo { namespace scm { @@ -12,24 +15,36 @@ namespace xo { **/ struct DConstant { public: + using TaggedPtr = xo::reflect::TaggedPtr; using TypeDescr = xo::reflect::TypeDescr; + using AGCObject = xo::mm::AGCObject; + using typeseq = xo::reflect::typeseq; public: - DConstant(TypeDescr td, void * value); + explicit DConstant(obj value) noexcept; - TypeDescr value_td() const { return value_td; } + bool is_resolved() const noexcept { return typeref_.is_resolved(); } - TypeRef typeref() const noexcept; - TypeDescr valuetype() const noexcept; - void assign_valuetype(TypeDescr td) noexcept; + exprtype extype() const noexcept { return exprtype::constant; } + TypeDescr value_td() const noexcept { return typeref_.td(); } + TaggedPtr value_tp() const noexcept { return TaggedPtr(typeref_.td(), value_.data()); } + + TypeRef typeref() const noexcept { return typeref_; } + TypeDescr valuetype() const noexcept { return typeref_.td(); } + obj value() const noexcept { return value_; } + + void assign_valuetype(TypeDescr td) noexcept { typeref_.resolve(td); } private: - /** type for value of this expression **/ - TypeRef type_ref_; - /** type description for destination *value_ **/ - TypeDescr valuetype_; + static TypeDescr _lookup_td(typeseq tseq); + + private: + /** type for value of this expression + * or unification breadcrumb before unification + **/ + TypeRef typeref_; /** literal value **/ - void * value_; + obj value_; }; } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/expression2/Expression.hpp b/include/xo/expression2/Expression.hpp index 311b627d..c6960c07 100644 --- a/include/xo/expression2/Expression.hpp +++ b/include/xo/expression2/Expression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for facet .hpp file: diff --git a/include/xo/expression2/TypeRef.hpp b/include/xo/expression2/TypeRef.hpp index 8ee08716..cd789d23 100644 --- a/include/xo/expression2/TypeRef.hpp +++ b/include/xo/expression2/TypeRef.hpp @@ -26,6 +26,11 @@ namespace xo { TypeRef() = default; TypeRef(const type_var & id, TypeDescr td); + /** trivial typeref, where already resolved. + * Require: @p td non-null + **/ + static TypeRef resolved(TypeDescr td); + /** if @p td is non-null * -> type is already resolved * @@ -43,7 +48,10 @@ namespace xo { TypeDescr td() const noexcept { return td_; } /** true iff type at this location has been resolved **/ - bool is_concrete() const noexcept; + bool is_resolved() const noexcept; + + /** resolve TypeRef by supplying final type-description **/ + void resolve(TypeDescr td) noexcept { td_ = td; } private: /** unique (probably generated) name for type at this location **/ diff --git a/include/xo/expression2/detail/AExpression.hpp b/include/xo/expression2/detail/AExpression.hpp index 942c940b..ae53af05 100644 --- a/include/xo/expression2/detail/AExpression.hpp +++ b/include/xo/expression2/detail/AExpression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -15,6 +15,8 @@ // includes (via {facet_includes}) #include "TypeRef.hpp" +#include "exprtype.hpp" +#include #include #include #include @@ -35,6 +37,8 @@ public: // types /** integer identifying a type **/ using typeseq = xo::facet::typeseq; + /** struct describing a type **/ + using TypeDescr = xo::reflect::TypeDescr; ///@} /** @defgroup scm-expression-methods **/ @@ -42,6 +46,8 @@ public: // const methods /** RTTI: unique id# for actual runtime data representation **/ virtual typeseq _typeseq() const noexcept = 0; + /** expression type (constant | apply | ..) **/ + virtual exprtype extype(Copaque data) const noexcept = 0; /** placeholder for type giving possible values for this expression **/ virtual TypeRef typeref(Copaque data) const noexcept = 0; /** type giving possible values for this expression. Maybe null before typecheck **/ diff --git a/include/xo/expression2/detail/IExpression_Any.hpp b/include/xo/expression2/detail/IExpression_Any.hpp index 0fac3289..e76cc3a6 100644 --- a/include/xo/expression2/detail/IExpression_Any.hpp +++ b/include/xo/expression2/detail/IExpression_Any.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -44,6 +44,7 @@ namespace scm { /** integer identifying a type **/ using typeseq = xo::facet::typeseq; + using TypeDescr = AExpression::TypeDescr; ///@} /** @defgroup scm-expression-any-methods **/ @@ -55,6 +56,7 @@ namespace scm { // const methods typeseq _typeseq() const noexcept override { return s_typeseq; } + [[noreturn]] exprtype extype(Copaque) const noexcept override { _fatal(); } [[noreturn]] TypeRef typeref(Copaque) const noexcept override { _fatal(); } [[noreturn]] TypeDescr valuetype(Copaque) const noexcept override { _fatal(); } diff --git a/include/xo/expression2/detail/IExpression_Xfer.hpp b/include/xo/expression2/detail/IExpression_Xfer.hpp index 55abfd05..9f7356bc 100644 --- a/include/xo/expression2/detail/IExpression_Xfer.hpp +++ b/include/xo/expression2/detail/IExpression_Xfer.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -14,6 +14,8 @@ #pragma once #include "TypeRef.hpp" +#include "exprtype.hpp" +#include namespace xo { namespace scm { @@ -28,6 +30,7 @@ namespace scm { using Impl = IExpression_DRepr; /** integer identifying a type **/ using typeseq = AExpression::typeseq; + using TypeDescr = AExpression::TypeDescr; ///@} /** @defgroup scm-expression-xfer-methods **/ @@ -40,6 +43,9 @@ namespace scm { // const methods typeseq _typeseq() const noexcept override { return s_typeseq; } + exprtype extype(Copaque data) const noexcept override { + return I::extype(_dcast(data)); + } TypeRef typeref(Copaque data) const noexcept override { return I::typeref(_dcast(data)); } diff --git a/include/xo/expression2/detail/RExpression.hpp b/include/xo/expression2/detail/RExpression.hpp index e9b431e3..9afd711f 100644 --- a/include/xo/expression2/detail/RExpression.hpp +++ b/include/xo/expression2/detail/RExpression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -31,6 +31,7 @@ public: using ObjectType = Object; using DataPtr = Object::DataPtr; using typeseq = xo::reflect::typeseq; + using TypeDescr = AExpression::TypeDescr; ///@} /** @defgroup scm-expression-router-ctors **/ @@ -44,10 +45,13 @@ public: // const methods typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); } - TypeRef typeref() const noexcept override { + exprtype extype() const noexcept { + return O::iface()->extype(O::data()); + } + TypeRef typeref() const noexcept { return O::iface()->typeref(O::data()); } - TypeDescr valuetype() const noexcept override { + TypeDescr valuetype() const noexcept { return O::iface()->valuetype(O::data()); } diff --git a/include/xo/expression2/exprtype.hpp b/include/xo/expression2/exprtype.hpp new file mode 100644 index 00000000..cf66d39e --- /dev/null +++ b/include/xo/expression2/exprtype.hpp @@ -0,0 +1,84 @@ +/** @file exprtype.hpp + * + * Author: Roland Conybeare + **/ + +#pragma once + +#include +//#include + +namespace xo { + namespace scm { + /** @enum exprtype + * @brief enum to identify subclasses of xo::scm::Expression. + * + **/ + enum class exprtype { + /** sentinel value **/ + invalid = -1, + + /** literal constant. must satisfy both standard_layout_type + trivial **/ + constant, +#ifdef NOT_YET + /** a literal constant that refers to a linkable named function **/ + primitive, + /** variable/function definition **/ + define, + /** variable assignment **/ + assign, + /** function call **/ + apply, + /** function definition **/ + lambda, + /** variable reference **/ + variable, + /** if-then-else **/ + ifexpr, + /** sequence **/ + sequence, + /** type conversion **/ + convert, +#endif + + /** not an expression. comes last, counts entries **/ + N + }; + + inline const char * + expr2str(exprtype x) + { + switch(x) { + case exprtype::invalid: return "?exprtype"; + case exprtype::constant: return "constant"; +#ifdef NOT_YET + case exprtype::primitive: return "primitive"; + case exprtype::define: return "define"; + case exprtype::assign: return "assign"; + case exprtype::apply: return "apply"; + case exprtype::lambda: return "lambda"; + case exprtype::variable: return "variable"; + case exprtype::ifexpr: return "if_expr"; + case exprtype::sequence: return "sequence"; + case exprtype::convert: return "convert"; +#endif + default: break; + } + + return "???exprtype???"; + } + + /** @brief number of built-in expression types, repr convenient for array sizing **/ + static constexpr std::size_t n_exprtype = static_cast(exprtype::N); + + inline std::ostream & + operator<<(std::ostream & os, + exprtype x) + { + os << expr2str(x); + return os; + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end exprtype.hpp */ diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index c0c794ff..b91033c7 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -2,6 +2,7 @@ set(SELF_LIB xo_expression2) set(SELF_SRCS + DConstant.cpp TypeRef.cpp #IExpression_Any.cpp expression2_register_facets.cpp @@ -11,6 +12,7 @@ xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 $ # note: deps here must also appear in cmake/xo_expression2Config.cmake.in xo_dependency(${SELF_LIB} xo_gc) xo_dependency(${SELF_LIB} reflect) +xo_dependency(${SELF_LIB} xo_object2) xo_dependency(${SELF_LIB} xo_printable2) xo_dependency(${SELF_LIB} xo_flatstring) xo_dependency(${SELF_LIB} indentlog) diff --git a/src/expression2/DConstant.cpp b/src/expression2/DConstant.cpp new file mode 100644 index 00000000..fcb38f54 --- /dev/null +++ b/src/expression2/DConstant.cpp @@ -0,0 +1,53 @@ +/** @file DConstant.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DConstant.hpp" +#include "TypeDescr.hpp" +#include +#include +#include +#include + +namespace xo { + using xo::scm::DFloat; + using xo::scm::DInteger; + using xo::reflect::Reflect; + using xo::reflect::TypeDescr; + using xo::reflect::typeseq; + + namespace scm { + DConstant::DConstant(obj value) noexcept + : + //typeref_{TypeRef::resolved(td)}, + value_{value} + { + // todo: use ObjectConverter here + + auto tseq = value_._typeseq(); + + TypeDescr td = this->_lookup_td(tseq); + + if (td) { + typeref_ = TypeRef::resolved(td); + } + } + + TypeDescr + DConstant::_lookup_td(typeseq tseq) + { + if (tseq == typeseq::id()) { + /* double */ + return Reflect::require(); + } else if (tseq == typeseq::id()) { + /* long */ + return Reflect::require(); + } + + return nullptr; + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DConstant.cpp */ diff --git a/src/expression2/TypeRef.cpp b/src/expression2/TypeRef.cpp index 2ceb6132..7b187ecd 100644 --- a/src/expression2/TypeRef.cpp +++ b/src/expression2/TypeRef.cpp @@ -11,6 +11,15 @@ namespace xo { : id_{id}, td_{td} {} + TypeRef + TypeRef::resolved(TypeDescr td) + { + assert(td); + + type_var null; + return TypeRef(null, td); + } + TypeRef TypeRef::dwim(prefix_type prefix, TypeDescr td) { @@ -18,8 +27,7 @@ namespace xo { /* type already resolved * -> we don't need a type variable name */ - type_var null; - return TypeRef(null, td); + return TypeRef::resolved(td); } else { /* type is not resolved yet. * -> give it a unique name, @@ -49,7 +57,7 @@ namespace xo { } bool - TypeRef::is_concrete() const noexcept + TypeRef::is_resolved() const noexcept { return (td_ != nullptr); } From 9e9a76344cd4993e4b789da34ac51ab4e7efa2cf Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 14 Jan 2026 00:09:45 -0500 Subject: [PATCH 004/128] xo-expression2: + IExpression_DConstant --- CMakeLists.txt | 12 ++++ idl/IExpression_DConstant.json5 | 11 ++++ include/xo/expression2/DConstant.hpp | 2 + .../xo/expression2/IExpression_DConstant.hpp | 63 +++++++++++++++++++ src/expression2/CMakeLists.txt | 3 +- src/expression2/IExpression_DConstant.cpp | 45 +++++++++++++ 6 files changed, 135 insertions(+), 1 deletion(-) create mode 100644 idl/IExpression_DConstant.json5 create mode 100644 include/xo/expression2/IExpression_DConstant.hpp create mode 100644 src/expression2/IExpression_DConstant.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 3adeccfa..df5a0c56 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,18 @@ xo_add_genfacet( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-constant + FACET_PKG xo_expression2 + FACET Expression + REPR Constant + INPUT idl/IExpression_DConstant.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + # ---------------------------------------------------------------- # header-only library diff --git a/idl/IExpression_DConstant.json5 b/idl/IExpression_DConstant.json5 new file mode 100644 index 00000000..89842432 --- /dev/null +++ b/idl/IExpression_DConstant.json5 @@ -0,0 +1,11 @@ +{ + mode: "implementation", + includes: [ "\"Expression.hpp\"" ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DConstant state", + using_doxygen: true, + repr: "DConstant", + doc: ["doc for something or other IExpression+DConstant" ], +} diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp index 29776912..9d2014b9 100644 --- a/include/xo/expression2/DConstant.hpp +++ b/include/xo/expression2/DConstant.hpp @@ -3,6 +3,8 @@ * @author Roland Conybeare, Jan 2026 **/ +#pragma once + #include "TypeRef.hpp" #include "exprtype.hpp" #include diff --git a/include/xo/expression2/IExpression_DConstant.hpp b/include/xo/expression2/IExpression_DConstant.hpp new file mode 100644 index 00000000..b08d8814 --- /dev/null +++ b/include/xo/expression2/IExpression_DConstant.hpp @@ -0,0 +1,63 @@ +/** @file IExpression_DConstant.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DConstant.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DConstant.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "DConstant.hpp" + +namespace xo { namespace scm { class IExpression_DConstant; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DConstant + **/ + class IExpression_DConstant { + public: + /** @defgroup scm-expression-dconstant-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + ///@} + /** @defgroup scm-expression-dconstant-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DConstant & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DConstant & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DConstant & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DConstant & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index b91033c7..956d405a 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -4,7 +4,8 @@ set(SELF_LIB xo_expression2) set(SELF_SRCS DConstant.cpp TypeRef.cpp - #IExpression_Any.cpp + IExpression_Any.cpp + IExpression_DConstant.cpp expression2_register_facets.cpp ) diff --git a/src/expression2/IExpression_DConstant.cpp b/src/expression2/IExpression_DConstant.cpp new file mode 100644 index 00000000..39f8135c --- /dev/null +++ b/src/expression2/IExpression_DConstant.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DConstant.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DConstant.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DConstant.json5] +**/ + +#include "IExpression_DConstant.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DConstant::extype(const DConstant & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DConstant::typeref(const DConstant & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DConstant::valuetype(const DConstant & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DConstant::assign_valuetype(DConstant & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DConstant.cpp */ \ No newline at end of file From 41efdda5f6f46ecdab2dd7ec5dad2e8850063d51 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 15 Jan 2026 20:52:09 -0500 Subject: [PATCH 005/128] xo-expression2: + StringTable + utest [WIP] [FAILING] --- CMakeLists.txt | 2 +- include/xo/expression2/StringTable.hpp | 56 +++++++++ src/expression2/CMakeLists.txt | 1 + src/expression2/StringTable.cpp | 135 +++++++++++++++++++++ utest/CMakeLists.txt | 11 ++ utest/StringTable.test.cpp | 160 +++++++++++++++++++++++++ utest/expression2_utest_main.cpp | 6 + 7 files changed, 370 insertions(+), 1 deletion(-) create mode 100644 include/xo/expression2/StringTable.hpp create mode 100644 src/expression2/StringTable.cpp create mode 100644 utest/CMakeLists.txt create mode 100644 utest/StringTable.test.cpp create mode 100644 utest/expression2_utest_main.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index df5a0c56..0c6419c8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,7 @@ add_definitions(${PROJECT_CXX_FLAGS}) # ---------------------------------------------------------------- # output targets -#add_subdirectory(utest) +add_subdirectory(utest) # note: manual target; generated code committed to git xo_add_genfacet( diff --git a/include/xo/expression2/StringTable.hpp b/include/xo/expression2/StringTable.hpp new file mode 100644 index 00000000..9413a01a --- /dev/null +++ b/include/xo/expression2/StringTable.hpp @@ -0,0 +1,56 @@ +/** @file StringTable.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include +#include +#include +#include + +namespace xo { + namespace scm { + + /** @class StringTable + * @brief table containing a set of interned strings + * + * A table of strings referenced in schematika expressions + **/ + class StringTable { + public: + using DArena = xo::mm::DArena; + using StringMap = xo::map::DArenaHashMap; + using size_type = StringMap::size_type; + + public: + StringTable(size_type hint_max_capacity, + bool debug_flag = false); + + /** lookup interned string; nullptr if not present **/ + const DString * lookup(std::string_view key) const; + + /** return unique string with contents @p key. Idempotent! **/ + const DString * intern(std::string_view key); + + /** verify StringTable invariants. + * Act on failure according to policy @p p + **/ + bool verify_ok(verify_policy p = verify_policy::throw_only()) const; + + private: + /** allocate string storage in this arena; use DString to represent each string. + * Can't use DArenaVector b/c DString has variable size + **/ + DArena strings_; + /** map_[s] points to arena strings, i.e. members of @ref strings_ **/ + StringMap map_; + }; + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end StringTable.hpp */ diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 956d405a..79dcecd0 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -6,6 +6,7 @@ set(SELF_SRCS TypeRef.cpp IExpression_Any.cpp IExpression_DConstant.cpp + StringTable.cpp expression2_register_facets.cpp ) diff --git a/src/expression2/StringTable.cpp b/src/expression2/StringTable.cpp new file mode 100644 index 00000000..73acf273 --- /dev/null +++ b/src/expression2/StringTable.cpp @@ -0,0 +1,135 @@ +/** @file StringTable.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include "StringTable.hpp" +#include +#include + +namespace xo { + using xo::mm::ArenaConfig; + using xo::mm::AAllocator; + using xo::facet::with_facet; + using xo::facet::obj; + + namespace scm { + StringTable::StringTable(size_type hint_max_capacity, + bool debug_flag) + : strings_{DArena::map(ArenaConfig{.name_ = "strings", + .size_ = hint_max_capacity})}, + map_{hint_max_capacity} + { + (void)debug_flag; + } + + const DString * + StringTable::lookup(std::string_view key) const + { + auto ix = map_.find(key); + + if (ix != map_.end()) + return ix->second; + + return nullptr; + } + + const DString * + StringTable::intern(std::string_view key) + { + // 1a. lookup key in map_. + // 1b. if present, return existing DString* + + auto ix = map_.find(key); + + if (ix != map_.end()) + return ix->second; + + // 2. otherwise need to add. + // + // 2d. return key2 address + + // 2a. allocate DString copy 'interned' of key in strings_ + auto mm = with_facet::mkobj(&strings_); + DString * interned = DString::from_view(mm, key); + + assert(interned); + if (interned) { + // 2b. make string_view from *interned + std::string_view interned_key = std::string_view(*interned); + + // interned_key has same lifetime as StringTable, + // we can use it in map_ + + // 2c. store address of 'interned' in map_ + auto & slot = this->map_[interned_key]; + + slot = interned; + + return slot; + } + + return nullptr; + } + + bool + StringTable::verify_ok(verify_policy policy) const + { + using xo::scope; + using xo::xtag; + + constexpr const char * c_self = "StringTable::verify_ok"; + scope log(XO_DEBUG(false)); + + /* ST1: underlying hash map passes its invariants */ + if (!map_.verify_ok(policy)) { + return policy.report_error(log, + c_self, ": map_.verify_ok failed"); + } + + /* ST2: for each entry, key points to value's string data */ + for (const auto & kv : map_) { + const std::string_view & key = kv.first; + const DString * value = kv.second; + + /* ST2.1: value is not null */ + if (value == nullptr) { + return policy.report_error(log, + c_self, ": null value in map", + xtag("key", key)); + } + + /* ST2.2: value lies within strings_ arena */ + if (!strings_.contains(value)) { + return policy.report_error(log, + c_self, ": value not in strings_ arena", + xtag("key", key), + xtag("value", (void*)value)); + } + + /* ST2.3: key.data() points to value's chars */ + if (key.data() != value->chars()) { + return policy.report_error(log, + c_self, ": key.data() != value->chars()", + xtag("key", key), + xtag("key.data()", (void*)key.data()), + xtag("value->chars()", (void*)value->chars())); + } + + /* ST2.4: key.size() == value->size() */ + if (key.size() != value->size()) { + return policy.report_error(log, + c_self, ": key.size() != value->size()", + xtag("key", key), + xtag("key.size()", key.size()), + xtag("value->size()", value->size())); + } + } + + return true; + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end StringTable.cpp */ diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt new file mode 100644 index 00000000..e43fd217 --- /dev/null +++ b/utest/CMakeLists.txt @@ -0,0 +1,11 @@ +# built unittest xo-expression2/utest + +set(UTEST_EXE utest.expression2) +set(UTEST_SRCS + expression2_utest_main.cpp + StringTable.test.cpp +) + +xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) +xo_self_dependency(${UTEST_EXE} xo_expression2) +xo_external_target_dependency(${UTEST_EXE} Catch2 Catch2::Catch2) diff --git a/utest/StringTable.test.cpp b/utest/StringTable.test.cpp new file mode 100644 index 00000000..ef928f77 --- /dev/null +++ b/utest/StringTable.test.cpp @@ -0,0 +1,160 @@ +/** @file StringTable.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include +#include +#include + +namespace xo { + using xo::scm::StringTable; + using xo::scm::DString; + + namespace ut { + TEST_CASE("StringTable-lookup-empty", "[expression2][StringTable]") + { + StringTable table(1024); + + // lookup on empty table returns nullptr + REQUIRE(table.lookup("foo") == nullptr); + REQUIRE(table.lookup("") == nullptr); + } + + TEST_CASE("StringTable-intern", "[expression2][StringTable]") + { + StringTable table(1024); + + const DString * s1 = table.intern("hello"); + + REQUIRE(s1 != nullptr); + REQUIRE(std::strcmp(s1->chars(), "hello") == 0); + REQUIRE(s1->size() == 5); + } + + TEST_CASE("StringTable-intern-idempotent", "[expression2][StringTable]") + { + StringTable table(1024); + + const DString * s1 = table.intern("hello"); + const DString * s2 = table.intern("hello"); + + // same key returns same pointer + REQUIRE(s1 != nullptr); + REQUIRE(s2 != nullptr); + REQUIRE(s1 == s2); + } + + TEST_CASE("StringTable-lookup-after-intern", "[expression2][StringTable]") + { + StringTable table(1024); + + REQUIRE(table.lookup("hello") == nullptr); + + const DString * s1 = table.intern("hello"); + + const DString * s2 = table.lookup("hello"); + + REQUIRE(s2 != nullptr); + REQUIRE(s1 == s2); + } + + TEST_CASE("StringTable-multiple-strings", "[expression2][StringTable]") + { + StringTable table(1024); + + const DString * s1 = table.intern("apple"); + const DString * s2 = table.intern("banana"); + const DString * s3 = table.intern("cherry"); + + // all different pointers + REQUIRE(s1 != s2); + REQUIRE(s2 != s3); + REQUIRE(s1 != s3); + + // correct contents + REQUIRE(std::strcmp(s1->chars(), "apple") == 0); + REQUIRE(std::strcmp(s2->chars(), "banana") == 0); + REQUIRE(std::strcmp(s3->chars(), "cherry") == 0); + + // lookup still works + REQUIRE(table.lookup("apple") == s1); + REQUIRE(table.lookup("banana") == s2); + REQUIRE(table.lookup("cherry") == s3); + REQUIRE(table.lookup("date") == nullptr); + } + + TEST_CASE("StringTable-intern-empty-string", "[expression2][StringTable]") + { + StringTable table(1024); + + const DString * s1 = table.intern(""); + + REQUIRE(s1 != nullptr); + REQUIRE(s1->size() == 0); + REQUIRE(s1->chars()[0] == '\0'); + + // idempotent for empty string too + const DString * s2 = table.intern(""); + REQUIRE(s1 == s2); + } + + TEST_CASE("StringTable-verify_ok", "[expression2][StringTable]") + { + StringTable table(4096); + + { + INFO("1. empty table"); + + // empty table passes verify_ok + REQUIRE(table.verify_ok()); + } + + // after interning strings, still passes + { + INFO("2. intern(hello)"); + + table.intern("hello"); + REQUIRE(table.verify_ok()); + } + + { + INFO("3. intern(world)"); + + table.intern("world"); + REQUIRE(table.verify_ok()); + } + + { + INFO("4. intern(foo)"); + + table.intern("foo"); + REQUIRE(table.verify_ok()); + } + + { + INFO("5. intern(bar)"); + + table.intern("bar"); + REQUIRE(table.verify_ok()); + } + + // idempotent intern doesn't break invariants + { + INFO("6. intern(hello)"); + + table.intern("hello"); + REQUIRE(table.verify_ok()); + } + + { + INFO("7. intern(world)"); + + table.intern("world"); + REQUIRE(table.verify_ok()); + } + } + } /*namespace ut*/ +} /*namespace xo*/ + +/* end StringTable.test.cpp */ diff --git a/utest/expression2_utest_main.cpp b/utest/expression2_utest_main.cpp new file mode 100644 index 00000000..e13405df --- /dev/null +++ b/utest/expression2_utest_main.cpp @@ -0,0 +1,6 @@ +/* file expression2_utest_main.cpp */ + +#define CATCH_CONFIG_MAIN +#include "catch2/catch.hpp" + +/* end expression2_utest_main.cpp */ From 0ae4b1528f2b15ac7dbbfdbed09a2c94f9b80c68 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 16 Jan 2026 13:05:58 -0500 Subject: [PATCH 006/128] xo-expression2: + DUniqueString, use in StringTable --- include/xo/expression2/DUniqueString.hpp | 138 +++++++++++++++++++++++ include/xo/expression2/StringTable.hpp | 8 +- src/expression2/CMakeLists.txt | 1 + src/expression2/DUniqueString.cpp | 95 ++++++++++++++++ src/expression2/StringTable.cpp | 10 +- utest/StringTable.test.cpp | 23 ++-- 6 files changed, 255 insertions(+), 20 deletions(-) create mode 100644 include/xo/expression2/DUniqueString.hpp create mode 100644 src/expression2/DUniqueString.cpp diff --git a/include/xo/expression2/DUniqueString.hpp b/include/xo/expression2/DUniqueString.hpp new file mode 100644 index 00000000..32a26726 --- /dev/null +++ b/include/xo/expression2/DUniqueString.hpp @@ -0,0 +1,138 @@ +/** @file DUniqueString.hpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include + +namespace xo { + namespace scm { + /** @class DUniqueString + * @brief unique immutable string + * + * A DUniqueString is an immutable string stored in a shared StringTable. + * Follows that DUniqueStrings at different memory locations + * have different contents. + * + * DUniqueString instances will be created by StringTable (see also). + * Application code will not allocate them directly. + * + * Needs to be gc-aware so that collector knows what to do when it encounters + * a obj with a DUnqiueString data pointer; such instances + * will not be allocated from GC memory + **/ + class DUniqueString { + public: + using AAllocator = xo::mm::AAllocator; + using ACollector = xo::mm::ACollector; + using size_type = DString::size_type; + + /* Memory model for a DUniqueString allocated via xo allocator + * + * 0 8 16 20 24 24+z + * v v v v v v + * +---------------+-+-------------+-------+-------+-----------+ + * | header |u| padding | cap | size | text... \0| + * +---------------+-+-------------+-------+-------+-----------+ + * + * Legend + * header 8 byte allocation header + * u 1 byte DUniqueString placholder (c++ insists) + * padding 7 bytes allocator-imposed padding to 8-byte alignment + * cap 4 bytes DString.capacity + * size 4 bytes DString.size + * text z bytes DString.size bytes of text (including null) + * In practice followed by padding to 8 byte + * alignment + */ + + /** @defgroup duniquestring-ctors constructors **/ + ///@{ + + /** not copyable **/ + DUniqueString(const DUniqueString &) = delete; + + ///@} + /** @defgroup duniquestring-methods methods **/ + ///@{ + + size_type size() const noexcept { return _text()->size(); } + const char * chars() const noexcept { return _text()->chars(); } + + /** compare unique strings: return n with {n<0, n=0, n>0} + * when @p lhs lexicographically {before, at, after} @p rhs + **/ + static int compare(const DUniqueString & lhs, const DUniqueString & rhs) { + if (&lhs == &rhs) + return 0; + + return DString::compare(*(lhs._text()), *(rhs._text())); + } + + std::size_t hash() const noexcept { return _text()->hash(); } + operator std::string_view() const noexcept { return std::string_view(*_text()); } + + ///@} + /** @defgroup duniquestring-gcobject-methods gcobject facet methods **/ + ///@{ + + std::size_t shallow_size() const noexcept; + + /** clone unique string, using memory from allocator @p mm. **/ + DUniqueString * shallow_copy(obj mm) const noexcept; + + /** fixup child pointers (trivial for DUniqueString, no gc-owned children **/ + std::size_t forward_children(obj gc) noexcept; + + ///@} + + private: + /** @defgroup duniquestring-impl-methods implementation methods **/ + ///@{ + + /** default ctor **/ + DUniqueString() = default; + + /** DString containing actual string content immediately follows DUniqueString + * in memory; part of same alloc + **/ + const DString * _text() const noexcept; + + //explicit DUniqueString(const DString * text) : text_{text} {} + + /** create instance using memory from @p mm, + * with string contents copied from @p sv + **/ + static DUniqueString * from_view(obj mm, + std::string_view sv); + + ///@} + + friend class StringTable; + + private: +#ifdef NOPE + /** interned string. Note stringtable memory distinct from gc memory, + * so gc will not (and should not) traverse this pointer. + **/ + const DString * text_ = nullptr; +#endif + }; + + /* since unique: just compare addresses */ + inline bool operator==(const DUniqueString & lhs, const DUniqueString & rhs) { + return (&lhs == &rhs); + } + + /* since unique: just compare addresses **/ + inline bool operator!=(const DUniqueString & lhs, const DUniqueString & rhs) { + return (&lhs != &rhs); + } + + inline bool operator<=(const DUniqueString & lhs, const DUniqueString & rhs) { + return (DUniqueString::compare(lhs, rhs) <= 0); + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end UniqueString.hpp */ diff --git a/include/xo/expression2/StringTable.hpp b/include/xo/expression2/StringTable.hpp index 9413a01a..54b0a826 100644 --- a/include/xo/expression2/StringTable.hpp +++ b/include/xo/expression2/StringTable.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include "DUniqueString.hpp" #include #include #include @@ -22,7 +22,7 @@ namespace xo { public: using DArena = xo::mm::DArena; using StringMap = xo::map::DArenaHashMap; + DUniqueString*>; using size_type = StringMap::size_type; public: @@ -30,10 +30,10 @@ namespace xo { bool debug_flag = false); /** lookup interned string; nullptr if not present **/ - const DString * lookup(std::string_view key) const; + const DUniqueString * lookup(std::string_view key) const; /** return unique string with contents @p key. Idempotent! **/ - const DString * intern(std::string_view key); + const DUniqueString * intern(std::string_view key); /** verify StringTable invariants. * Act on failure according to policy @p p diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 79dcecd0..41700e9c 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -7,6 +7,7 @@ set(SELF_SRCS IExpression_Any.cpp IExpression_DConstant.cpp StringTable.cpp + DUniqueString.cpp expression2_register_facets.cpp ) diff --git a/src/expression2/DUniqueString.cpp b/src/expression2/DUniqueString.cpp new file mode 100644 index 00000000..3e534b9c --- /dev/null +++ b/src/expression2/DUniqueString.cpp @@ -0,0 +1,95 @@ +/** @file DUniqueString.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DUniqueString.hpp" +#include +#include + +namespace xo { + using xo::mm::padding; + using xo::facet::typeseq; + + namespace scm { + const DString * + DUniqueString::_text() const noexcept + { + // location of paired DString is chosen + // by allocator (DArena, probably). + // + // In general allocator alignment more conservative + // than C++ alignment + // + // Remmebr also: although DUniqueString has zero members, + // C++ requires it to behave asif size at least 1 byte + // for iterator consistency + // (e.g. because c++ would support iterating over + // std::vector) + // + size_t offset = padding::with_padding(sizeof(*this)); + assert(offset > 0); + + return (const DString *)(((std::byte *)this) + offset); + } + + DUniqueString * + DUniqueString::from_view(obj mm, + std::string_view sv) + { + scope log(XO_DEBUG(false)); + + /** fine point: choosing to allocate DUniqueString ahead of DString, + * so it comes first in bump allocator + **/ + + void * mem = mm.super_alloc(typeseq::id(), + sizeof(DUniqueString)); + DUniqueString * result = new (mem) DUniqueString(); + + /** allocated in memory immediate following @p result. + * This optimization saves us one pointer (8 bytes) in DUniqueString + * itself, plus one allocation header (8 bytes) for 16 bytes total + **/ + DString * text = DString::from_view_suballoc(mm, sv); + + log && log(xtag("result", result), xtag("result.text", result->_text()), xtag("text", text)); + + assert(text); + assert(text == result->_text()); + + /** must finish super-allocation before next alloc **/ + mm.sub_alloc(0, true); + + return result; + } + + size_t + DUniqueString::shallow_size() const noexcept + { + return sizeof(DUniqueString); + } + + DUniqueString * + DUniqueString::shallow_copy(obj mm) const noexcept + { + // well-posed, but not expected to be used. + assert(false); + + DUniqueString * copy = (DUniqueString *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + size_t + DUniqueString::forward_children(obj) noexcept + { + return shallow_size(); + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DUniqueString.cpp */ diff --git a/src/expression2/StringTable.cpp b/src/expression2/StringTable.cpp index 73acf273..ae48eea9 100644 --- a/src/expression2/StringTable.cpp +++ b/src/expression2/StringTable.cpp @@ -23,7 +23,7 @@ namespace xo { (void)debug_flag; } - const DString * + const DUniqueString * StringTable::lookup(std::string_view key) const { auto ix = map_.find(key); @@ -34,7 +34,7 @@ namespace xo { return nullptr; } - const DString * + const DUniqueString * StringTable::intern(std::string_view key) { // 1a. lookup key in map_. @@ -49,9 +49,9 @@ namespace xo { // // 2d. return key2 address - // 2a. allocate DString copy 'interned' of key in strings_ + // 2a. allocate DUniqueString copy 'interned' of key in strings_ auto mm = with_facet::mkobj(&strings_); - DString * interned = DString::from_view(mm, key); + DUniqueString * interned = DUniqueString::from_view(mm, key); assert(interned); if (interned) { @@ -90,7 +90,7 @@ namespace xo { /* ST2: for each entry, key points to value's string data */ for (const auto & kv : map_) { const std::string_view & key = kv.first; - const DString * value = kv.second; + const DUniqueString * value = kv.second; /* ST2.1: value is not null */ if (value == nullptr) { diff --git a/utest/StringTable.test.cpp b/utest/StringTable.test.cpp index ef928f77..66163c22 100644 --- a/utest/StringTable.test.cpp +++ b/utest/StringTable.test.cpp @@ -9,7 +9,8 @@ namespace xo { using xo::scm::StringTable; - using xo::scm::DString; + using xo::scm::DUniqueString; + //using xo::scm::DString; namespace ut { TEST_CASE("StringTable-lookup-empty", "[expression2][StringTable]") @@ -25,7 +26,7 @@ namespace xo { { StringTable table(1024); - const DString * s1 = table.intern("hello"); + const DUniqueString * s1 = table.intern("hello"); REQUIRE(s1 != nullptr); REQUIRE(std::strcmp(s1->chars(), "hello") == 0); @@ -36,8 +37,8 @@ namespace xo { { StringTable table(1024); - const DString * s1 = table.intern("hello"); - const DString * s2 = table.intern("hello"); + const DUniqueString * s1 = table.intern("hello"); + const DUniqueString * s2 = table.intern("hello"); // same key returns same pointer REQUIRE(s1 != nullptr); @@ -51,9 +52,9 @@ namespace xo { REQUIRE(table.lookup("hello") == nullptr); - const DString * s1 = table.intern("hello"); + const DUniqueString * s1 = table.intern("hello"); - const DString * s2 = table.lookup("hello"); + const DUniqueString * s2 = table.lookup("hello"); REQUIRE(s2 != nullptr); REQUIRE(s1 == s2); @@ -63,9 +64,9 @@ namespace xo { { StringTable table(1024); - const DString * s1 = table.intern("apple"); - const DString * s2 = table.intern("banana"); - const DString * s3 = table.intern("cherry"); + const DUniqueString * s1 = table.intern("apple"); + const DUniqueString * s2 = table.intern("banana"); + const DUniqueString * s3 = table.intern("cherry"); // all different pointers REQUIRE(s1 != s2); @@ -88,14 +89,14 @@ namespace xo { { StringTable table(1024); - const DString * s1 = table.intern(""); + const DUniqueString * s1 = table.intern(""); REQUIRE(s1 != nullptr); REQUIRE(s1->size() == 0); REQUIRE(s1->chars()[0] == '\0'); // idempotent for empty string too - const DString * s2 = table.intern(""); + const DUniqueString * s2 = table.intern(""); REQUIRE(s1 == s2); } From aae8a3e8642e94978cb64ebd4bde960687297db3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 16 Jan 2026 13:34:22 -0500 Subject: [PATCH 007/128] xo-expression2: + IGCObject_DUniqueString + facet/type registration --- CMakeLists.txt | 12 ++++ idl/IGCObject_DUniqueString.json5 | 15 +++++ .../detail/IGCObject_DUniqueString.hpp | 67 +++++++++++++++++++ .../expression2_register_facets.hpp | 17 +++++ .../expression2_register_types.hpp | 17 +++++ src/expression2/IGCObject_DUniqueString.cpp | 39 +++++++++++ .../expression2_register_facets.cpp | 26 ++++++- .../expression2_register_types.cpp | 37 ++++++++++ 8 files changed, 227 insertions(+), 3 deletions(-) create mode 100644 idl/IGCObject_DUniqueString.json5 create mode 100644 include/xo/expression2/detail/IGCObject_DUniqueString.hpp create mode 100644 include/xo/expression2/expression2_register_facets.hpp create mode 100644 include/xo/expression2/expression2_register_types.hpp create mode 100644 src/expression2/IGCObject_DUniqueString.cpp create mode 100644 src/expression2/expression2_register_types.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 0c6419c8..415b920d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-uniquestring + FACET_PKG xo_gc + FACET GCObject + REPR UniqueString + INPUT idl/IGCObject_DUniqueString.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + # ---------------------------------------------------------------- # header-only library diff --git a/idl/IGCObject_DUniqueString.json5 b/idl/IGCObject_DUniqueString.json5 new file mode 100644 index 00000000..8cf516b2 --- /dev/null +++ b/idl/IGCObject_DUniqueString.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DUniqueString", + using_doxygen: true, + repr: "DUniqueString", + doc: [ "implement AGCObject for DUniqueString" ], +} diff --git a/include/xo/expression2/detail/IGCObject_DUniqueString.hpp b/include/xo/expression2/detail/IGCObject_DUniqueString.hpp new file mode 100644 index 00000000..b971daea --- /dev/null +++ b/include/xo/expression2/detail/IGCObject_DUniqueString.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DUniqueString.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DUniqueString.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DUniqueString.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DUniqueString.hpp" + +namespace xo { namespace scm { class IGCObject_DUniqueString; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DUniqueString + **/ + class IGCObject_DUniqueString { + public: + /** @defgroup scm-gcobject-duniquestring-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-duniquestring-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DUniqueString & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DUniqueString & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DUniqueString & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/expression2_register_facets.hpp b/include/xo/expression2/expression2_register_facets.hpp new file mode 100644 index 00000000..95feeea5 --- /dev/null +++ b/include/xo/expression2/expression2_register_facets.hpp @@ -0,0 +1,17 @@ +/** @file expression2_register_facets.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + /** Register expression2 (facet,impl) combinations with FacetRegistry **/ + bool expression2_register_facets(); + } +} + +/* end expression2_register_facets.hpp */ diff --git a/include/xo/expression2/expression2_register_types.hpp b/include/xo/expression2/expression2_register_types.hpp new file mode 100644 index 00000000..6c7cc959 --- /dev/null +++ b/include/xo/expression2/expression2_register_types.hpp @@ -0,0 +1,17 @@ +/** @file expression2_register_types.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + /** Register expression2 (facet,impl) combinations with FacetRegistry **/ + bool expression2_register_types(obj gc); + } +} + +/* end expression2_register_types.hpp */ diff --git a/src/expression2/IGCObject_DUniqueString.cpp b/src/expression2/IGCObject_DUniqueString.cpp new file mode 100644 index 00000000..b13b3f79 --- /dev/null +++ b/src/expression2/IGCObject_DUniqueString.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DUniqueString.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DUniqueString.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DUniqueString.json5] +**/ + +#include "detail/IGCObject_DUniqueString.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DUniqueString::shallow_size(const DUniqueString & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DUniqueString::shallow_copy(const DUniqueString & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DUniqueString::forward_children(DUniqueString & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DUniqueString.cpp */ \ No newline at end of file diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 49edb80c..56ac85ae 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -1,11 +1,31 @@ /** @file expression2_register_facets.cpp -* + * * @author Roland Conybeare, Jan 2026 **/ +#include "expression2_register_facets.hpp" + +#include + +#include +#include +#include + namespace xo { + using xo::mm::AGCObject; + using xo::facet::FacetRegistry; + namespace scm { - } -} /*namesapce xo*/ + bool + expression2_register_facets() + { + scope log(XO_DEBUG(true)); + + FacetRegistry::register_impl(); + + return true; + } + } /*namespace scm*/ +} /*namespace xo*/ /* end expression2_register_facets.cpp */ diff --git a/src/expression2/expression2_register_types.cpp b/src/expression2/expression2_register_types.cpp new file mode 100644 index 00000000..2b8aadcf --- /dev/null +++ b/src/expression2/expression2_register_types.cpp @@ -0,0 +1,37 @@ +/** @file expression2_register_types.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "expression2_register_types.hpp" + +#include "detail/IGCObject_DUniqueString.hpp" + +//#include "detail/IPrintable_DUniqueString.hpp" + +//#include +#include + +namespace xo { + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::facet::impl_for; + using xo::facet::typeseq; + using xo::scope; + + namespace scm { + bool + expression2_register_types(obj gc) + { + scope log(XO_DEBUG(true)); + + bool ok = true; + + ok &= gc.install_type(impl_for()); + + return ok; + } + } +} /*namespace xo*/ + +/* end expression2_register_types.cpp */ From 23383d7e69d722cfde268eb23cf3b215b44921b6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 16 Jan 2026 16:10:00 -0500 Subject: [PATCH 008/128] xo-gc: + CollectorTypeRegistry for streamlined init --- cmake/xo_expression2Config.cmake.in | 1 + include/xo/expression2/init_expression2.hpp | 21 +++++++++++ src/expression2/CMakeLists.txt | 4 ++ src/expression2/init_expression2.cpp | 41 +++++++++++++++++++++ utest/expression2_utest_main.cpp | 20 +++++++++- 5 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 include/xo/expression2/init_expression2.hpp create mode 100644 src/expression2/init_expression2.cpp diff --git a/cmake/xo_expression2Config.cmake.in b/cmake/xo_expression2Config.cmake.in index d48c29a4..c8cfbcad 100644 --- a/cmake/xo_expression2Config.cmake.in +++ b/cmake/xo_expression2Config.cmake.in @@ -11,6 +11,7 @@ find_dependency(reflect) find_dependency(xo_object2) find_dependency(xo_printable2) find_dependency(xo_flatstring) +find_dependency(cmake) find_dependency(indentlog) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") diff --git a/include/xo/expression2/init_expression2.hpp b/include/xo/expression2/init_expression2.hpp new file mode 100644 index 00000000..c5e290a8 --- /dev/null +++ b/include/xo/expression2/init_expression2.hpp @@ -0,0 +1,21 @@ +/** @file init_expression2.hpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include + +namespace xo { + /* tag to represent the xo-expression2/ subsystem within ordered initialization */ + enum S_expression2_tag {}; + + template <> + struct InitSubsys { + static void init(); + static InitEvidence require(); + }; +} /*namespace xo*/ + +/* end init_expression2.hpp */ diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 41700e9c..8ddedb9c 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -2,13 +2,16 @@ set(SELF_LIB xo_expression2) set(SELF_SRCS + init_expression2.cpp DConstant.cpp TypeRef.cpp IExpression_Any.cpp IExpression_DConstant.cpp StringTable.cpp DUniqueString.cpp + IGCObject_DUniqueString.cpp expression2_register_facets.cpp + expression2_register_types.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) @@ -18,4 +21,5 @@ xo_dependency(${SELF_LIB} reflect) xo_dependency(${SELF_LIB} xo_object2) xo_dependency(${SELF_LIB} xo_printable2) xo_dependency(${SELF_LIB} xo_flatstring) +xo_dependency(${SELF_LIB} subsys) xo_dependency(${SELF_LIB} indentlog) diff --git a/src/expression2/init_expression2.cpp b/src/expression2/init_expression2.cpp new file mode 100644 index 00000000..e975ef99 --- /dev/null +++ b/src/expression2/init_expression2.cpp @@ -0,0 +1,41 @@ +/** @file init_expression2.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_expression2.hpp" +#include "expression2_register_facets.hpp" +#include "expression2_register_types.hpp" + +#include +#include + +namespace xo { + using xo::scm::expression2_register_facets; + using xo::scm::expression2_register_types; + using xo::mm::CollectorTypeRegistry; + + void + InitSubsys::init() + { + expression2_register_facets(); + + CollectorTypeRegistry::instance().register_types(&expression2_register_types); + } + + InitEvidence + InitSubsys::require() + { + InitEvidence retval; + + /* direct subsystem deps for xo-object2/ */ + retval ^= InitSubsys::require(); + + /* xo-expression2/'s own initialization code */ + retval ^= Subsystem::provide("expression2", &init); + + return retval; + } +} /*namespace xo*/ + +/* end init_expression2.cpp */ diff --git a/utest/expression2_utest_main.cpp b/utest/expression2_utest_main.cpp index e13405df..004d2598 100644 --- a/utest/expression2_utest_main.cpp +++ b/utest/expression2_utest_main.cpp @@ -1,6 +1,24 @@ /* file expression2_utest_main.cpp */ -#define CATCH_CONFIG_MAIN +#include + +#define CATCH_CONFIG_RUNNER #include "catch2/catch.hpp" +int +main(int argc, char* argv[]) +{ + using xo::Subsystem; + + // Your custom initialization code here + Subsystem::initialize_all(); + + // Run Catch2's test session + int result = Catch::Session().run(argc, argv); + + // cleanup here, if any + + return result; +} + /* end expression2_utest_main.cpp */ From 9b0ba471bd643f24072071e0fada29813838586c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 16 Jan 2026 17:02:10 -0500 Subject: [PATCH 009/128] xo-expression2: + X1Collector test for DUniqueString --- include/xo/expression2/DUniqueString.hpp | 2 + .../expression2_register_facets.cpp | 3 + utest/CMakeLists.txt | 1 + utest/X1Collector.test.cpp | 115 ++++++++++++++++++ 4 files changed, 121 insertions(+) create mode 100644 utest/X1Collector.test.cpp diff --git a/include/xo/expression2/DUniqueString.hpp b/include/xo/expression2/DUniqueString.hpp index 32a26726..4d7dc0fd 100644 --- a/include/xo/expression2/DUniqueString.hpp +++ b/include/xo/expression2/DUniqueString.hpp @@ -3,6 +3,8 @@ * @author Roland Conybeare, Jan 2026 **/ +#pragma once + #include namespace xo { diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 56ac85ae..6a0f9c80 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -14,6 +14,7 @@ namespace xo { using xo::mm::AGCObject; using xo::facet::FacetRegistry; + using xo::facet::typeseq; namespace scm { bool @@ -23,6 +24,8 @@ namespace xo { FacetRegistry::register_impl(); + log && log(xtag("DUniqueString.tseq", typeseq::id())); + return true; } } /*namespace scm*/ diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index e43fd217..2b8bceec 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -4,6 +4,7 @@ set(UTEST_EXE utest.expression2) set(UTEST_SRCS expression2_utest_main.cpp StringTable.test.cpp + X1Collector.test.cpp ) xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp new file mode 100644 index 00000000..a664f9a2 --- /dev/null +++ b/utest/X1Collector.test.cpp @@ -0,0 +1,115 @@ +/** @file X1Collector.test.cpp + * + * Minimal collector test for DUniqueString + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_expression2.hpp" +#include "StringTable.hpp" +#include "detail/IGCObject_DUniqueString.hpp" + +#include +#include +#include +#include + +#include +#include + +#include +#include + +#include + +#include + +#include + +namespace ut { + using xo::S_expression2_tag; + using xo::scm::StringTable; + using xo::scm::DUniqueString; + using xo::scm::DFloat; + using xo::scm::DInteger; + using xo::scm::DList; + using xo::scm::DString; + using xo::mm::CollectorTypeRegistry; + using xo::mm::AAllocator; + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::mm::DX1Collector; + using xo::mm::CollectorConfig; + using xo::mm::ArenaConfig; + using xo::facet::with_facet; + using xo::facet::typeseq; + using xo::InitEvidence; + using xo::InitSubsys; + + // Ensure subsystem initialized before tests + static InitEvidence s_init = InitSubsys::require(); + + TEST_CASE("x1_duniquestring", "[gc][x1][expression2]") + { + REQUIRE(s_init.evidence()); + + // Create collector + CollectorConfig cfg{ + .name_ = "x1_duniquestring_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{1024, 1024}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + + auto gc_o = with_facet::mkobj(&gc); + auto c_o = with_facet::mkobj(&gc); + + // Install types from CollectorTypeRegistry + bool ok = CollectorTypeRegistry::instance().install_types(c_o); + REQUIRE(ok); + + // Verify types from object2 are installed + ok = c_o.is_type_installed(typeseq::id()); + REQUIRE(ok); + ok = c_o.is_type_installed(typeseq::id()); + REQUIRE(ok); + ok = c_o.is_type_installed(typeseq::id()); + REQUIRE(ok); + ok = c_o.is_type_installed(typeseq::id()); + REQUIRE(ok); + + // Verify DUniqueString from expression2 is installed + ok = c_o.is_type_installed(typeseq::id()); + REQUIRE(ok); + + // Create DUniqueString via StringTable + StringTable table(1024); + const DUniqueString * ustr = table.intern("hello"); + REQUIRE(ustr != nullptr); + REQUIRE(ustr->size() == 5); + + // Wrap as obj + // Note: const_cast is safe here since DUniqueString is immutable by design, + // and we're only wrapping for facet access, not modification + auto ustr_o = with_facet::mkobj(const_cast(ustr)); + REQUIRE(ustr_o.iface() != nullptr); + REQUIRE(ustr_o.data() != nullptr); + + // verify unique string contents + REQUIRE(strcmp(ustr_o.data()->chars(), "hello") == 0); + + // Add as gc root + c_o.add_gc_root(&ustr_o); + + // Verify string content accessible through wrapped object + REQUIRE(ustr_o.data()->size() == 5); + REQUIRE(std::strcmp(ustr_o.data()->chars(), "hello") == 0); + } +} + +/* end X1Collector.test.cpp */ From cb4b5f37691ebce03665893fb1d7e005406845e2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 16 Jan 2026 17:11:50 -0500 Subject: [PATCH 010/128] xo-expression2: + DUniqueString.pretty() --- include/xo/expression2/DUniqueString.hpp | 7 +++++++ src/expression2/DUniqueString.cpp | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/include/xo/expression2/DUniqueString.hpp b/include/xo/expression2/DUniqueString.hpp index 4d7dc0fd..46fdfa1e 100644 --- a/include/xo/expression2/DUniqueString.hpp +++ b/include/xo/expression2/DUniqueString.hpp @@ -28,6 +28,7 @@ namespace xo { using AAllocator = xo::mm::AAllocator; using ACollector = xo::mm::ACollector; using size_type = DString::size_type; + using ppindentinfo = xo::print::ppindentinfo; /* Memory model for a DUniqueString allocated via xo allocator * @@ -74,6 +75,12 @@ namespace xo { std::size_t hash() const noexcept { return _text()->hash(); } operator std::string_view() const noexcept { return std::string_view(*_text()); } + ///@} + /** @defgroup duniquestring-printable-methods printable facet methods **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + ///@} /** @defgroup duniquestring-gcobject-methods gcobject facet methods **/ ///@{ diff --git a/src/expression2/DUniqueString.cpp b/src/expression2/DUniqueString.cpp index 3e534b9c..d0a4b0a0 100644 --- a/src/expression2/DUniqueString.cpp +++ b/src/expression2/DUniqueString.cpp @@ -33,6 +33,12 @@ namespace xo { return (const DString *)(((std::byte *)this) + offset); } + bool + DUniqueString::pretty(const ppindentinfo & ppii) const + { + return _text()->pretty(ppii); + } + DUniqueString * DUniqueString::from_view(obj mm, std::string_view sv) From ef6a1d139d0226327cc448f3c57e59472e09954b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 16 Jan 2026 17:21:58 -0500 Subject: [PATCH 011/128] xo-expression2: + IPrintable_DUniqueString facetimpl --- CMakeLists.txt | 12 ++++ idl/IPrintable_DUniqueString.json5 | 13 ++++ .../detail/IPrintable_DUniqueString.hpp | 62 +++++++++++++++++++ src/expression2/CMakeLists.txt | 1 + src/expression2/IPrintable_DUniqueString.cpp | 28 +++++++++ .../expression2_register_facets.cpp | 4 ++ 6 files changed, 120 insertions(+) create mode 100644 idl/IPrintable_DUniqueString.json5 create mode 100644 include/xo/expression2/detail/IPrintable_DUniqueString.hpp create mode 100644 src/expression2/IPrintable_DUniqueString.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 415b920d..00897d60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-uniquestring + FACET_PKG xo_printable2 + FACET Printable + REPR DUniqueString + INPUT idl/IPrintable_DUniqueString.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + # ---------------------------------------------------------------- # header-only library diff --git a/idl/IPrintable_DUniqueString.json5 b/idl/IPrintable_DUniqueString.json5 new file mode 100644 index 00000000..540f7b71 --- /dev/null +++ b/idl/IPrintable_DUniqueString.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DUniqueString", + using_doxygen: true, + repr: "DUniqueString", + doc: [ "implement APrintable for DUniqueString" ], +} diff --git a/include/xo/expression2/detail/IPrintable_DUniqueString.hpp b/include/xo/expression2/detail/IPrintable_DUniqueString.hpp new file mode 100644 index 00000000..34c9da79 --- /dev/null +++ b/include/xo/expression2/detail/IPrintable_DUniqueString.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DUniqueString.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DUniqueString.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DUniqueString.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DUniqueString.hpp" + +namespace xo { namespace scm { class IPrintable_DUniqueString; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DUniqueString + **/ + class IPrintable_DUniqueString { + public: + /** @defgroup scm-printable-duniquestring-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-duniquestring-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DUniqueString & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 8ddedb9c..bf54ab6a 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -10,6 +10,7 @@ set(SELF_SRCS StringTable.cpp DUniqueString.cpp IGCObject_DUniqueString.cpp + IPrintable_DUniqueString.cpp expression2_register_facets.cpp expression2_register_types.cpp ) diff --git a/src/expression2/IPrintable_DUniqueString.cpp b/src/expression2/IPrintable_DUniqueString.cpp new file mode 100644 index 00000000..a7b92af8 --- /dev/null +++ b/src/expression2/IPrintable_DUniqueString.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DUniqueString.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DUniqueString.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DUniqueString.json5] +**/ + +#include "detail/IPrintable_DUniqueString.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DUniqueString::pretty(const DUniqueString & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DUniqueString.cpp */ \ No newline at end of file diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 6a0f9c80..2d728bd3 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -6,13 +6,16 @@ #include "expression2_register_facets.hpp" #include +#include #include +#include #include #include namespace xo { using xo::mm::AGCObject; + using xo::print::APrintable; using xo::facet::FacetRegistry; using xo::facet::typeseq; @@ -23,6 +26,7 @@ namespace xo { scope log(XO_DEBUG(true)); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); log && log(xtag("DUniqueString.tseq", typeseq::id())); From 5870e72a4b603cca4a7c00ab8558356ac437abc3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 16 Jan 2026 19:04:08 -0500 Subject: [PATCH 012/128] xo-expression2: symtab scaffold [WIP] [COSMETIC] --- idl/ASymbolTable.json5 | 41 +++++++++++++++++++ include/xo/expression2/DLocalSymtab.hpp | 54 +++++++++++++++++++++++++ 2 files changed, 95 insertions(+) create mode 100644 idl/ASymbolTable.json5 create mode 100644 include/xo/expression2/DLocalSymtab.hpp diff --git a/idl/ASymbolTable.json5 b/idl/ASymbolTable.json5 new file mode 100644 index 00000000..ca10ef91 --- /dev/null +++ b/idl/ASymbolTable.json5 @@ -0,0 +1,41 @@ +{ + mode: "facet", + includes: [ ], + + namespace1: "xo", + namespace2: "scm", + facet: "SymbolTable", + detail_subdir: "symtab", + brief: "symbol table derived from a set of schematika expressions", + using_doxygen: true, + doc: [ + "Map symbols to schematika expression. Output of schematika parser" + ], + types: [ + // { name: string, doc: [ string ], definition: string }, + ], + const_methods: [ + { + name: "is_global_symtab", + doc: ["true iff this is toplevel (global) symbol table."], + return_type: "bool", + args: [], + const: true, + noexcept: true, + attributes: [], + }, + { + name: "lookup_binding_unint", + doc: ["report ingredients needed to address variable at runtime."], + return_type: "Binding", + args: [ + {type: "DString*", name: "sym"}, + ], + const: true, + noexcept: true, + attributes: [], + }, + ], + nonconst_methods: [ + ], +} diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp new file mode 100644 index 00000000..b8d583bf --- /dev/null +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -0,0 +1,54 @@ +/** @file DLocalSymtab.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "TypeRef.hpp" +#include "exprtype.hpp" +#include +#include + +namespace xo { + namespace scm { + /** @class DLocalSymtab + * @brief Schematika expression respresenting a literal constant + **/ + struct DLocalSymtab { + public: + using TaggedPtr = xo::reflect::TaggedPtr; + using TypeDescr = xo::reflect::TypeDescr; + using AGCObject = xo::mm::AGCObject; + using typeseq = xo::reflect::typeseq; + + public: + explicit DLocalSymtab(obj value) noexcept; + + bool is_resolved() const noexcept { return typeref_.is_resolved(); } + + exprtype extype() const noexcept { return exprtype::constant; } + TypeDescr value_td() const noexcept { return typeref_.td(); } + TaggedPtr value_tp() const noexcept { return TaggedPtr(typeref_.td(), value_.data()); } + + TypeRef typeref() const noexcept { return typeref_; } + TypeDescr valuetype() const noexcept { return typeref_.td(); } + obj value() const noexcept { return value_; } + + void assign_valuetype(TypeDescr td) noexcept { typeref_.resolve(td); } + + private: + static TypeDescr _lookup_td(typeseq tseq); + + private: + /** type for value of this expression + * or unification breadcrumb before unification + **/ + TypeRef typeref_; + /** literal value **/ + obj value_; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DLocalSymtab.hpp */ From 33c4e2dc0a8d630f91e3359bd6f92ce2e7342447 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 16 Jan 2026 20:47:54 -0500 Subject: [PATCH 013/128] xo-expression2: DUniqueSring: fix copy during hypothetical GC --- include/xo/expression2/DUniqueString.hpp | 8 +++++++- src/expression2/DUniqueString.cpp | 18 ++++++++++++++---- 2 files changed, 21 insertions(+), 5 deletions(-) diff --git a/include/xo/expression2/DUniqueString.hpp b/include/xo/expression2/DUniqueString.hpp index 46fdfa1e..08fcde86 100644 --- a/include/xo/expression2/DUniqueString.hpp +++ b/include/xo/expression2/DUniqueString.hpp @@ -59,6 +59,10 @@ namespace xo { /** @defgroup duniquestring-methods methods **/ ///@{ + /** Available storage for this instance. + * For completeness' sake since uniquestring not modifiable + **/ + size_type capacity() const noexcept { return _text()->capacity(); } size_type size() const noexcept { return _text()->size(); } const char * chars() const noexcept { return _text()->chars(); } @@ -74,6 +78,8 @@ namespace xo { std::size_t hash() const noexcept { return _text()->hash(); } operator std::string_view() const noexcept { return std::string_view(*_text()); } + /** not assignable **/ + DUniqueString & operator=(const DUniqueString &) = delete; ///@} /** @defgroup duniquestring-printable-methods printable facet methods **/ @@ -105,7 +111,7 @@ namespace xo { /** DString containing actual string content immediately follows DUniqueString * in memory; part of same alloc **/ - const DString * _text() const noexcept; + DString * _text() const noexcept; //explicit DUniqueString(const DString * text) : text_{text} {} diff --git a/src/expression2/DUniqueString.cpp b/src/expression2/DUniqueString.cpp index d0a4b0a0..c0fa26db 100644 --- a/src/expression2/DUniqueString.cpp +++ b/src/expression2/DUniqueString.cpp @@ -6,13 +6,14 @@ #include "DUniqueString.hpp" #include #include +#include namespace xo { using xo::mm::padding; using xo::facet::typeseq; namespace scm { - const DString * + DString * DUniqueString::_text() const noexcept { // location of paired DString is chosen @@ -30,7 +31,7 @@ namespace xo { size_t offset = padding::with_padding(sizeof(*this)); assert(offset > 0); - return (const DString *)(((std::byte *)this) + offset); + return (DString *)(((std::byte *)this) + offset); } bool @@ -84,8 +85,17 @@ namespace xo { DUniqueString * copy = (DUniqueString *)mm.alloc_copy((std::byte *)this); - if (copy) - *copy = *this; + if (copy) { + // Copy assignment not implemented in general + // *copy = *this; + // in this case *copy already has the same size as *this + + assert(size() <= capacity()); + + strncpy(copy->_text()->data(), + this->_text()->chars(), + this->size()); + } return copy; } From a23307aabb560c00955f0a7b8df81775c3cb202f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 17 Jan 2026 01:05:59 -0500 Subject: [PATCH 014/128] xo-expression2: + DVariable --- include/xo/expression2/DVariable.hpp | 56 ++++++++++++++++++++++++++++ src/expression2/CMakeLists.txt | 1 + src/expression2/DVariable.cpp | 19 ++++++++++ 3 files changed, 76 insertions(+) create mode 100644 include/xo/expression2/DVariable.hpp create mode 100644 src/expression2/DVariable.cpp diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp new file mode 100644 index 00000000..036d88ce --- /dev/null +++ b/include/xo/expression2/DVariable.hpp @@ -0,0 +1,56 @@ +/** @file DVariable.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "DUniqueString.hpp" +#include "Binding.hpp" +#include "TypeRef.hpp" +#include "exprtype.hpp" +#include + +namespace xo { + namespace scm { + + /** @class DVariable* + * @brief syntax for a variable reference + **/ + class DVariable { + public: + using TypeDescr = xo::reflect::TypeDescr; + + public: + DVariable(const DUniqueString & name, const TypeRef & typeref, Binding path) + : name_{name}, typeref_{typeref}, path_{path} {} + + const DUniqueString & name() const { return name_; } + Binding path() const { return path_; } + + /** @defgroup scm-variable-expression-facet**/ + ///@{ + + exprtype extype() const noexcept { return exprtype::variable; } + TypeRef typeref() const noexcept { return typeref_; } + TypeDescr valuetype() const noexcept { return typeref_.td(); }; + void assign_valuetype(TypeDescr td) noexcept; + + ///@} + + private: + /** symbol name **/ + const DUniqueString & name_; + /** variable value always has type consistent + * with this description + **/ + TypeRef typeref_; + /** at runtime: navigate environemnt via this path to get + * runtime memory location for this variable + **/ + Binding path_; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVariable.hpp */ diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index bf54ab6a..6b897535 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -4,6 +4,7 @@ set(SELF_LIB xo_expression2) set(SELF_SRCS init_expression2.cpp DConstant.cpp + DVariable.cpp TypeRef.cpp IExpression_Any.cpp IExpression_DConstant.cpp diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp new file mode 100644 index 00000000..f589da7b --- /dev/null +++ b/src/expression2/DVariable.cpp @@ -0,0 +1,19 @@ +/** @file DVariable.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DVariable.hpp" +#include "exprtype.hpp" + +namespace xo { + namespace scm { + void + DVariable::assign_valuetype(TypeDescr td) noexcept + { + typeref_.resolve(td); + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVariable.cpp */ From 37b0ea3c3e656498b8b51636e2930c560fcb365d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 17 Jan 2026 01:09:02 -0500 Subject: [PATCH 015/128] xo-expression2: + SymbolTable facet --- idl/SymbolTable.json5 | 59 +++++++++++++ include/xo/expression2/SymbolTable.hpp | 22 +++++ .../xo/expression2/symtab/ASymbolTable.hpp | 75 ++++++++++++++++ .../expression2/symtab/ISymbolTable_Any.hpp | 86 +++++++++++++++++++ .../expression2/symtab/ISymbolTable_Xfer.hpp | 84 ++++++++++++++++++ .../xo/expression2/symtab/RSymbolTable.hpp | 82 ++++++++++++++++++ src/expression2/CMakeLists.txt | 8 ++ src/expression2/ISymbolTable_Any.cpp | 41 +++++++++ 8 files changed, 457 insertions(+) create mode 100644 idl/SymbolTable.json5 create mode 100644 include/xo/expression2/SymbolTable.hpp create mode 100644 include/xo/expression2/symtab/ASymbolTable.hpp create mode 100644 include/xo/expression2/symtab/ISymbolTable_Any.hpp create mode 100644 include/xo/expression2/symtab/ISymbolTable_Xfer.hpp create mode 100644 include/xo/expression2/symtab/RSymbolTable.hpp create mode 100644 src/expression2/ISymbolTable_Any.cpp diff --git a/idl/SymbolTable.json5 b/idl/SymbolTable.json5 new file mode 100644 index 00000000..3d91a3d7 --- /dev/null +++ b/idl/SymbolTable.json5 @@ -0,0 +1,59 @@ +{ + mode: "facet", + includes: [ + "\"Binding.hpp\"", + "\"DUniqueString.hpp\"" + ], + // extra includes in SymbolTable.hpp, if any + user_hpp_includes: [], + namespace1: "xo", + namespace2: "scm", + // text after includes, before ASymbolTable + pretext: [ "// {pretext} here" ], + facet: "SymbolTable", + detail_subdir: "symtab", + brief: "symbol table derived from a set of schematika expressions", + using_doxygen: true, + doc: [ + "Map symbols to schematika expressions. Output of schematika parser" + ], + types: [ + // { name: string, doc: [ string ], definition: string }, + ], + const_methods: [ + + { + // bool is_global_symtab() const noexcept; + name: "is_global_symtab", + doc: ["true iff this is toplevel (global) symbol table."], + return_type: "bool", + args: [], + const: true, + noexcept: true, + attributes: [], + }, + + { + // Binding lookup_binding(const DUniqueString * sym) const noexcept; + name: "lookup_binding", + doc: ["report ingredients needed to address variable at runtime."], + return_type: "Binding", + args: [ + {type: "const DUniqueString *", name: "sym"}, + ], + const: true, + noexcept: true, + attributes: [], + }, + + // // + // obj lookup_var(const DUniqueString * sym) const noexcept; + + // // + // obj lookup_local(const DUniqueString * sym) const noexcept; + ], + nonconst_methods: [ + // // Variable gives both {name, type} + // void upsert_local(DVariable * target) = 0; + ], +} diff --git a/include/xo/expression2/SymbolTable.hpp b/include/xo/expression2/SymbolTable.hpp new file mode 100644 index 00000000..09fc04a8 --- /dev/null +++ b/include/xo/expression2/SymbolTable.hpp @@ -0,0 +1,22 @@ +/** @file SymbolTable.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/SymbolTable.json5] + * 2. jinja2 template for facet .hpp file: + * [facet.hpp.j2] + * 3. idl for facet methods + * [idl/SymbolTable.json5] + **/ + +#pragma once + +#include "symtab/ASymbolTable.hpp" +#include "symtab/ISymbolTable_Any.hpp" +#include "symtab/ISymbolTable_Xfer.hpp" +#include "symtab/RSymbolTable.hpp" + + +/* end SymbolTable.hpp */ \ No newline at end of file diff --git a/include/xo/expression2/symtab/ASymbolTable.hpp b/include/xo/expression2/symtab/ASymbolTable.hpp new file mode 100644 index 00000000..36d4c812 --- /dev/null +++ b/include/xo/expression2/symtab/ASymbolTable.hpp @@ -0,0 +1,75 @@ +/** @file ASymbolTable.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/SymbolTable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [abstract_facet.hpp.j2] + * 3. idl for facet methods + * [idl/SymbolTable.json5] + **/ + +#pragma once + +// includes (via {facet_includes}) +#include "Binding.hpp" +#include "DUniqueString.hpp" +#include +#include +#include + +// {pretext} here + +namespace xo { +namespace scm { + +using Copaque = const void *; +using Opaque = void *; + +/** +Map symbols to schematika expressions. Output of schematika parser +**/ +class ASymbolTable { +public: + /** @defgroup scm-symboltable-type-traits **/ + ///@{ + // types + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + using Copaque = const void *; + using Opaque = void *; + ///@} + + /** @defgroup scm-symboltable-methods **/ + ///@{ + // const methods + /** RTTI: unique id# for actual runtime data representation **/ + virtual typeseq _typeseq() const noexcept = 0; + /** true iff this is toplevel (global) symbol table. **/ + virtual bool is_global_symtab(Copaque data) const noexcept = 0; + /** report ingredients needed to address variable at runtime. **/ + virtual Binding lookup_binding(Copaque data, const DUniqueString * sym) const noexcept = 0; + + // nonconst methods + ///@} +}; /*ASymbolTable*/ + +/** Implementation ISymbolTable_DRepr of ASymbolTable for state DRepr + * should provide a specialization: + * + * template <> + * struct xo::facet::FacetImplementation { + * using Impltype = ISymbolTable_DRepr; + * }; + * + * then ISymbolTable_ImplType --> ISymbolTable_DRepr + **/ +template +using ISymbolTable_ImplType = xo::facet::FacetImplType; + +} /*namespace scm*/ +} /*namespace xo*/ + +/* ASymbolTable.hpp */ \ No newline at end of file diff --git a/include/xo/expression2/symtab/ISymbolTable_Any.hpp b/include/xo/expression2/symtab/ISymbolTable_Any.hpp new file mode 100644 index 00000000..6a119832 --- /dev/null +++ b/include/xo/expression2/symtab/ISymbolTable_Any.hpp @@ -0,0 +1,86 @@ +/** @file ISymbolTable_Any.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/SymbolTable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/SymbolTable.json5] + **/ + +#pragma once + +#include "ASymbolTable.hpp" +#include + +namespace xo { namespace scm { class ISymbolTable_Any; } } + +namespace xo { +namespace facet { + +template <> +struct FacetImplementation +{ + using ImplType = xo::scm::ISymbolTable_Any; +}; + +} +} + +namespace xo { +namespace scm { + + /** @class ISymbolTable_Any + * @brief ASymbolTable implementation for empty variant instance + **/ + class ISymbolTable_Any : public ASymbolTable { + public: + /** @defgroup scm-symboltable-any-type-traits **/ + ///@{ + + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + + ///@} + /** @defgroup scm-symboltable-any-methods **/ + ///@{ + + const ASymbolTable * iface() const { return std::launder(this); } + + // from ASymbolTable + + // const methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + [[noreturn]] bool is_global_symtab(Copaque) const noexcept override { _fatal(); } + [[noreturn]] Binding lookup_binding(Copaque, const DUniqueString *) const noexcept override { _fatal(); } + + // nonconst methods + + ///@} + + private: + /** @defgraoup scm-symboltable-any-private-methods **/ + ///@{ + + [[noreturn]] static void _fatal(); + + ///@} + + public: + /** @defgroup scm-symboltable-any-member-vars **/ + ///@{ + + static typeseq s_typeseq; + static bool _valid; + + ///@} + }; + +} /*namespace scm */ +} /*namespace xo */ + +/* ISymbolTable_Any.hpp */ \ No newline at end of file diff --git a/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp b/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp new file mode 100644 index 00000000..2333bb05 --- /dev/null +++ b/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp @@ -0,0 +1,84 @@ +/** @file ISymbolTable_Xfer.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/SymbolTable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/SymbolTable.json5] + **/ + +#pragma once + +#include "Binding.hpp" +#include "DUniqueString.hpp" + +namespace xo { +namespace scm { + /** @class ISymbolTable_Xfer + **/ + template + class ISymbolTable_Xfer : public ASymbolTable { + public: + /** @defgroup scm-symboltable-xfer-type-traits **/ + ///@{ + /** actual implementation (not generated; often delegates to DRepr) **/ + using Impl = ISymbolTable_DRepr; + /** integer identifying a type **/ + using typeseq = ASymbolTable::typeseq; + ///@} + + /** @defgroup scm-symboltable-xfer-methods **/ + ///@{ + + static const DRepr & _dcast(Copaque d) { return *(const DRepr *)d; } + static DRepr & _dcast(Opaque d) { return *(DRepr *)d; } + + // from ASymbolTable + + // const methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + bool is_global_symtab(Copaque data) const noexcept override { + return I::is_global_symtab(_dcast(data)); + } + Binding lookup_binding(Copaque data, const DUniqueString * sym) const noexcept override { + return I::lookup_binding(_dcast(data), sym); + } + + // non-const methods + + ///@} + + private: + using I = Impl; + + public: + /** @defgroup scm-symboltable-xfer-member-vars **/ + ///@{ + + /** typeseq for template parameter DRepr **/ + static typeseq s_typeseq; + /** true iff satisfies facet implementation **/ + static bool _valid; + + ///@} + }; + + template + xo::facet::typeseq + ISymbolTable_Xfer::s_typeseq + = xo::facet::typeseq::id(); + + template + bool + ISymbolTable_Xfer::_valid + = xo::facet::valid_facet_implementation(); + +} /*namespace scm */ +} /*namespace xo*/ + +/* end ISymbolTable_Xfer.hpp */ \ No newline at end of file diff --git a/include/xo/expression2/symtab/RSymbolTable.hpp b/include/xo/expression2/symtab/RSymbolTable.hpp new file mode 100644 index 00000000..c72503cc --- /dev/null +++ b/include/xo/expression2/symtab/RSymbolTable.hpp @@ -0,0 +1,82 @@ +/** @file RSymbolTable.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/SymbolTable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/SymbolTable.json5] + **/ + +#pragma once + +#include "ASymbolTable.hpp" + +namespace xo { +namespace scm { + +/** @class RSymbolTable + **/ +template +class RSymbolTable : public Object { +private: + using O = Object; + +public: + /** @defgroup scm-symboltable-router-type-traits **/ + ///@{ + using ObjectType = Object; + using DataPtr = Object::DataPtr; + using typeseq = xo::reflect::typeseq; + ///@} + + /** @defgroup scm-symboltable-router-ctors **/ + ///@{ + RSymbolTable() {} + RSymbolTable(Object::DataPtr data) : Object{std::move(data)} {} + RSymbolTable(const ASymbolTable * iface, void * data) + requires std::is_same_v + : Object(iface, data) {} + + ///@} + /** @defgroup scm-symboltable-router-methods **/ + ///@{ + + // const methods + typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); } + bool is_global_symtab() const noexcept { + return O::iface()->is_global_symtab(O::data()); + } + Binding lookup_binding(const DUniqueString * sym) const noexcept { + return O::iface()->lookup_binding(O::data(), sym); + } + + // non-const methods (still const in router!) + + ///@} + /** @defgroup scm-symboltable-member-vars **/ + ///@{ + + static bool _valid; + + ///@} +}; + +template +bool +RSymbolTable::_valid = xo::facet::valid_object_router(); + +} /*namespace scm*/ +} /*namespace xo*/ + +namespace xo { namespace facet { + template + struct RoutingFor { + using RoutingType = xo::scm::RSymbolTable; + }; +} } + +/* end RSymbolTable.hpp */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 6b897535..e7de9253 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -3,15 +3,23 @@ set(SELF_LIB xo_expression2) set(SELF_SRCS init_expression2.cpp + DConstant.cpp DVariable.cpp + TypeRef.cpp + IExpression_Any.cpp IExpression_DConstant.cpp + + ISymbolTable_Any.cpp + StringTable.cpp + DUniqueString.cpp IGCObject_DUniqueString.cpp IPrintable_DUniqueString.cpp + expression2_register_facets.cpp expression2_register_types.cpp ) diff --git a/src/expression2/ISymbolTable_Any.cpp b/src/expression2/ISymbolTable_Any.cpp new file mode 100644 index 00000000..7c811253 --- /dev/null +++ b/src/expression2/ISymbolTable_Any.cpp @@ -0,0 +1,41 @@ +/** @file ISymbolTable_Any.cpp + * + **/ + +#include "symtab/ISymbolTable_Any.hpp" +#include + +namespace xo { +namespace scm { + +using xo::facet::DVariantPlaceholder; +using xo::facet::typeseq; +using xo::facet::valid_facet_implementation; + +void +ISymbolTable_Any::_fatal() +{ + /* control here on uninitialized IAllocator_Any. + * Initialized instance will have specific implementation type + */ + std::cerr << "fatal" + << ": attempt to call uninitialized" + << " ISymbolTable_Any method" + << std::endl; + std::terminate(); +} + +typeseq +ISymbolTable_Any::s_typeseq = typeseq::id(); + +bool +ISymbolTable_Any::_valid + = valid_facet_implementation(); + +// nonconst methods + + +} /*namespace scm*/ +} /*namespace xo*/ + +/* end ISymbolTable_Any.cpp */ \ No newline at end of file From 28fc36adeb86b5fe2282a86f1d8871694baa1124 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 17 Jan 2026 01:09:25 -0500 Subject: [PATCH 016/128] xo-expression2: nit --- idl/ASymbolTable.json5 | 41 ----------------------------------------- 1 file changed, 41 deletions(-) delete mode 100644 idl/ASymbolTable.json5 diff --git a/idl/ASymbolTable.json5 b/idl/ASymbolTable.json5 deleted file mode 100644 index ca10ef91..00000000 --- a/idl/ASymbolTable.json5 +++ /dev/null @@ -1,41 +0,0 @@ -{ - mode: "facet", - includes: [ ], - - namespace1: "xo", - namespace2: "scm", - facet: "SymbolTable", - detail_subdir: "symtab", - brief: "symbol table derived from a set of schematika expressions", - using_doxygen: true, - doc: [ - "Map symbols to schematika expression. Output of schematika parser" - ], - types: [ - // { name: string, doc: [ string ], definition: string }, - ], - const_methods: [ - { - name: "is_global_symtab", - doc: ["true iff this is toplevel (global) symbol table."], - return_type: "bool", - args: [], - const: true, - noexcept: true, - attributes: [], - }, - { - name: "lookup_binding_unint", - doc: ["report ingredients needed to address variable at runtime."], - return_type: "Binding", - args: [ - {type: "DString*", name: "sym"}, - ], - const: true, - noexcept: true, - attributes: [], - }, - ], - nonconst_methods: [ - ], -} From d6b29241fdabb648ccd446d2abb7391eabe5d396 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 17 Jan 2026 01:10:33 -0500 Subject: [PATCH 017/128] xo-expression2: + Binding etc --- include/xo/expression2/Binding.hpp | 46 ++++++++++++++++++++++++ include/xo/expression2/DUniqueString.hpp | 2 +- include/xo/expression2/TypeRef.hpp | 3 +- 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 include/xo/expression2/Binding.hpp diff --git a/include/xo/expression2/Binding.hpp b/include/xo/expression2/Binding.hpp new file mode 100644 index 00000000..455c1538 --- /dev/null +++ b/include/xo/expression2/Binding.hpp @@ -0,0 +1,46 @@ +/** @file Binding.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + class Binding { + public: + static constexpr int32_t s_link_sentinel = -2; + static constexpr int32_t s_link_global = -1; + + public: + Binding(int32_t i_link, int32_t j_slot) + : i_link_{i_link}, j_slot_{j_slot} {} + + /** global bindings are located by symbol name **/ + static Binding global() { return Binding(s_link_global, 0); } + static Binding local(int32_t j_slot) { return Binding(0, j_slot); } + + bool is_global() const { return i_link_ == s_link_global; } + + int32_t i_link() const noexcept { return i_link_; } + int32_t j_slot() const noexcept { return j_slot_; } + + private: + /** + * >= 0: number of parent links to traverse + * to a fixed-size frame + * -1: resolve globally + **/ + int32_t i_link_ = s_link_sentinel; + /** if @ref i_link_ >= 0, frame offset + * (in 'variables' not bytes). + * ignored if @ref i_link_ is global + **/ + int32_t j_slot_ = -1; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* Binding.hpp */ diff --git a/include/xo/expression2/DUniqueString.hpp b/include/xo/expression2/DUniqueString.hpp index 08fcde86..30655b45 100644 --- a/include/xo/expression2/DUniqueString.hpp +++ b/include/xo/expression2/DUniqueString.hpp @@ -40,7 +40,7 @@ namespace xo { * * Legend * header 8 byte allocation header - * u 1 byte DUniqueString placholder (c++ insists) + * u 1 byte DUniqueString placeholder (c++ insists) * padding 7 bytes allocator-imposed padding to 8-byte alignment * cap 4 bytes DString.capacity * size 4 bytes DString.size diff --git a/include/xo/expression2/TypeRef.hpp b/include/xo/expression2/TypeRef.hpp index cd789d23..01401d28 100644 --- a/include/xo/expression2/TypeRef.hpp +++ b/include/xo/expression2/TypeRef.hpp @@ -11,7 +11,8 @@ namespace xo { namespace scm { /** @class TypeRef - * @brief name and (when established) resolution for type associate with an expression + * @brief name and (when established) resolution for type + * associated with an expression * * Type inference / unification operates on * @ref xo::scm::TypeBlueprint instances. See also! From b8e0452730bc7c41ca80e14d9f7e7b71ec8a8c00 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 17 Jan 2026 01:11:24 -0500 Subject: [PATCH 018/128] xo-expression: genfacet for SymbolTable --- CMakeLists.txt | 10 ++++++++++ include/xo/expression2/detail/AExpression.hpp | 2 +- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 00897d60..a0aad4e9 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,6 +22,16 @@ add_definitions(${PROJECT_CXX_FLAGS}) add_subdirectory(utest) +# note: manual target; generated code committed to git +xo_add_genfacet( + TARGET xo-expression2-facet-symboltable + FACET SymbolTable + INPUT idl/SymbolTable.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 + ) + # note: manual target; generated code committed to git xo_add_genfacet( TARGET xo-expression2-facet-expression diff --git a/include/xo/expression2/detail/AExpression.hpp b/include/xo/expression2/detail/AExpression.hpp index ae53af05..18b7823f 100644 --- a/include/xo/expression2/detail/AExpression.hpp +++ b/include/xo/expression2/detail/AExpression.hpp @@ -75,4 +75,4 @@ using IExpression_ImplType = xo::facet::FacetImplType; } /*namespace scm*/ } /*namespace xo*/ -/* */ \ No newline at end of file +/* */ From b3215da3601105f79ba9761b6b9c4f542bbec0e3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 17 Jan 2026 01:11:50 -0500 Subject: [PATCH 019/128] xo-expression2: scaffold variable eval in VSM --- include/xo/expression2/exprtype.hpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/xo/expression2/exprtype.hpp b/include/xo/expression2/exprtype.hpp index cf66d39e..0d5e8299 100644 --- a/include/xo/expression2/exprtype.hpp +++ b/include/xo/expression2/exprtype.hpp @@ -31,8 +31,10 @@ namespace xo { apply, /** function definition **/ lambda, +#endif /** variable reference **/ variable, +#ifdef NOT_YET /** if-then-else **/ ifexpr, /** sequence **/ From f38c90db91f0d9cde1929bbe5507686f03770bf6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 17 Jan 2026 01:24:04 -0500 Subject: [PATCH 020/128] xo-expression2: + IExpression_DVariable --- CMakeLists.txt | 12 ++++ idl/Expression.json5 | 5 +- idl/IExpression_DConstant.json5 | 1 + idl/IExpression_DVariable.json5 | 12 ++++ include/xo/expression2/DLocalSymtab.hpp | 49 +++++++------- include/xo/expression2/Expression.hpp | 1 + include/xo/expression2/detail/AExpression.hpp | 6 +- .../xo/expression2/detail/IExpression_Any.hpp | 2 +- .../detail/IExpression_DVariable.hpp | 66 +++++++++++++++++++ include/xo/expression2/detail/RExpression.hpp | 10 ++- src/expression2/CMakeLists.txt | 1 + src/expression2/IExpression_Any.cpp | 9 +++ src/expression2/IExpression_DVariable.cpp | 45 +++++++++++++ 13 files changed, 187 insertions(+), 32 deletions(-) create mode 100644 idl/IExpression_DVariable.json5 create mode 100644 include/xo/expression2/detail/IExpression_DVariable.hpp create mode 100644 src/expression2/IExpression_DVariable.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index a0aad4e9..28982fba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -54,6 +54,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-variable + FACET_PKG xo_expression2 + FACET Expression + REPR Variable + INPUT idl/IExpression_DVariable.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-uniquestring diff --git a/idl/Expression.json5 b/idl/Expression.json5 index f156dffe..f2f7d44a 100644 --- a/idl/Expression.json5 +++ b/idl/Expression.json5 @@ -3,9 +3,12 @@ includes: [ "\"TypeRef.hpp\"", "\"exprtype.hpp\"", ""], - + // extra includes in Expression.hpp, if any + user_hpp_includes: [], namespace1: "xo", namespace2: "scm", + // text after includes, before AExpression + pretext: [ "// {pretext} here" ], facet: "Expression", detail_subdir: "detail", brief: "a schematika expression", diff --git a/idl/IExpression_DConstant.json5 b/idl/IExpression_DConstant.json5 index 89842432..d7628f81 100644 --- a/idl/IExpression_DConstant.json5 +++ b/idl/IExpression_DConstant.json5 @@ -1,6 +1,7 @@ { mode: "implementation", includes: [ "\"Expression.hpp\"" ], + local_types: [ ], namespace1: "xo", namespace2: "scm", facet_idl: "idl/Expression.json5", diff --git a/idl/IExpression_DVariable.json5 b/idl/IExpression_DVariable.json5 new file mode 100644 index 00000000..6e7993d3 --- /dev/null +++ b/idl/IExpression_DVariable.json5 @@ -0,0 +1,12 @@ +{ + mode: "implementation", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DVariable state", + using_doxygen: true, + repr: "DVariable", + doc: ["doc for IExpression+DVariable" ], +} diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index b8d583bf..b60b6570 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -5,48 +5,45 @@ #pragma once -#include "TypeRef.hpp" -#include "exprtype.hpp" -#include -#include +#include "Binding.hpp" +#include "DUniqueString.hpp" +//#include "exprtype.hpp" +//#include +//#include namespace xo { namespace scm { /** @class DLocalSymtab - * @brief Schematika expression respresenting a literal constant + * @brief symbol table for a local stack frame **/ struct DLocalSymtab { public: - using TaggedPtr = xo::reflect::TaggedPtr; - using TypeDescr = xo::reflect::TypeDescr; - using AGCObject = xo::mm::AGCObject; - using typeseq = xo::reflect::typeseq; +// using TaggedPtr = xo::reflect::TaggedPtr; +// using TypeDescr = xo::reflect::TypeDescr; +// using AGCObject = xo::mm::AGCObject; +// using typeseq = xo::reflect::typeseq; + + struct Slot { + // obj var_; + Binding binding_; + }; public: - explicit DLocalSymtab(obj value) noexcept; +// explicit DLocalSymtab(obj value) noexcept; - bool is_resolved() const noexcept { return typeref_.is_resolved(); } + /** @defgroup xo-expression2-symboltable-facet symboltable facet**/ + ///@{ - exprtype extype() const noexcept { return exprtype::constant; } - TypeDescr value_td() const noexcept { return typeref_.td(); } - TaggedPtr value_tp() const noexcept { return TaggedPtr(typeref_.td(), value_.data()); } + /** true for global symbol table **/ + bool is_global_symtab() const noexcept { return false; } - TypeRef typeref() const noexcept { return typeref_; } - TypeDescr valuetype() const noexcept { return typeref_.td(); } - obj value() const noexcept { return value_; } + /** lookup binding for variable @p sym **/ + Binding lookup_binding(const DUniqueString * sym) const noexcept; - void assign_valuetype(TypeDescr td) noexcept { typeref_.resolve(td); } + ///@} private: - static TypeDescr _lookup_td(typeseq tseq); - private: - /** type for value of this expression - * or unification breadcrumb before unification - **/ - TypeRef typeref_; - /** literal value **/ - obj value_; }; } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/expression2/Expression.hpp b/include/xo/expression2/Expression.hpp index c6960c07..60e8a402 100644 --- a/include/xo/expression2/Expression.hpp +++ b/include/xo/expression2/Expression.hpp @@ -18,4 +18,5 @@ #include "detail/IExpression_Xfer.hpp" #include "detail/RExpression.hpp" + /* end Expression.hpp */ \ No newline at end of file diff --git a/include/xo/expression2/detail/AExpression.hpp b/include/xo/expression2/detail/AExpression.hpp index 18b7823f..10375114 100644 --- a/include/xo/expression2/detail/AExpression.hpp +++ b/include/xo/expression2/detail/AExpression.hpp @@ -21,6 +21,8 @@ #include #include +// {pretext} here + namespace xo { namespace scm { @@ -37,6 +39,8 @@ public: // types /** integer identifying a type **/ using typeseq = xo::facet::typeseq; + using Copaque = const void *; + using Opaque = void *; /** struct describing a type **/ using TypeDescr = xo::reflect::TypeDescr; ///@} @@ -75,4 +79,4 @@ using IExpression_ImplType = xo::facet::FacetImplType; } /*namespace scm*/ } /*namespace xo*/ -/* */ +/* AExpression.hpp */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IExpression_Any.hpp b/include/xo/expression2/detail/IExpression_Any.hpp index e76cc3a6..c92c2c4a 100644 --- a/include/xo/expression2/detail/IExpression_Any.hpp +++ b/include/xo/expression2/detail/IExpression_Any.hpp @@ -61,7 +61,7 @@ namespace scm { [[noreturn]] TypeDescr valuetype(Copaque) const noexcept override { _fatal(); } // nonconst methods - [[noreturn]] void assign_valuetype(Opaque, TypeDescr) noexcept override { _fatal(); } + [[noreturn]] void assign_valuetype(Opaque, TypeDescr) noexcept override; ///@} diff --git a/include/xo/expression2/detail/IExpression_DVariable.hpp b/include/xo/expression2/detail/IExpression_DVariable.hpp new file mode 100644 index 00000000..95b1becb --- /dev/null +++ b/include/xo/expression2/detail/IExpression_DVariable.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DVariable.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DVariable.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DVariable.hpp" + +namespace xo { namespace scm { class IExpression_DVariable; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DVariable + **/ + class IExpression_DVariable { + public: + /** @defgroup scm-expression-dvariable-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-dvariable-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DVariable & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DVariable & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DVariable & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DVariable & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/RExpression.hpp b/include/xo/expression2/detail/RExpression.hpp index 9afd711f..caf69fe0 100644 --- a/include/xo/expression2/detail/RExpression.hpp +++ b/include/xo/expression2/detail/RExpression.hpp @@ -38,6 +38,9 @@ public: ///@{ RExpression() {} RExpression(Object::DataPtr data) : Object{std::move(data)} {} + RExpression(const AExpression * iface, void * data) + requires std::is_same_v + : Object(iface, data) {} ///@} /** @defgroup scm-expression-router-methods **/ @@ -55,9 +58,10 @@ public: return O::iface()->valuetype(O::data()); } - // non-const methods - // << do something for non-const methods >> - // + // non-const methods (still const in router!) + void assign_valuetype(TypeDescr td) noexcept { + return O::iface()->assign_valuetype(O::data(), td); + } ///@} /** @defgroup scm-expression-member-vars **/ diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index e7de9253..9194bfa5 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -11,6 +11,7 @@ set(SELF_SRCS IExpression_Any.cpp IExpression_DConstant.cpp + IExpression_DVariable.cpp ISymbolTable_Any.cpp diff --git a/src/expression2/IExpression_Any.cpp b/src/expression2/IExpression_Any.cpp index a27a68bc..7f60e5af 100644 --- a/src/expression2/IExpression_Any.cpp +++ b/src/expression2/IExpression_Any.cpp @@ -32,6 +32,15 @@ bool IExpression_Any::_valid = valid_facet_implementation(); +// nonconst methods + +auto +IExpression_Any::assign_valuetype(Opaque, TypeDescr) noexcept -> void +{ + _fatal(); +} + + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/expression2/IExpression_DVariable.cpp b/src/expression2/IExpression_DVariable.cpp new file mode 100644 index 00000000..ca657c36 --- /dev/null +++ b/src/expression2/IExpression_DVariable.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DVariable.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DVariable.json5] +**/ + +#include "detail/IExpression_DVariable.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DVariable::extype(const DVariable & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DVariable::typeref(const DVariable & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DVariable::valuetype(const DVariable & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DVariable::assign_valuetype(DVariable & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DVariable.cpp */ \ No newline at end of file From f0e7a186a87799847944991c6e1ad65850b6999d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 18 Jan 2026 17:59:46 -0500 Subject: [PATCH 021/128] xo-reader2 scaffold (fomo+arena version of xo-reader/) [WIP] --- CMakeLists.txt | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 28982fba..fe5cd540 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -91,18 +91,13 @@ xo_add_genfacetimpl( ) # ---------------------------------------------------------------- -# header-only library +# shared library add_subdirectory(src/expression2) +# ---------------------------------------------------------------- +# cmake helper (for external xo-expression2 users) + xo_export_cmake_config(${PROJECT_NAME} ${PROJECT_VERSION} ${PROJECT_NAME}Targets) -# ---------------------------------------------------------------- -# input dependencies -# -# NOTE: dependency set here must be kept consistent with -# xo-expression2/cmake/xo_expression2Config.cmake.in - -#xo_headeronly_dependency(${SELF_LIB} xo_flatstring) - # end CMakeLists.txt From da0d7369461986df09c51944bb74b17d1ce339fc Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 19 Jan 2026 21:25:30 -0500 Subject: [PATCH 022/128] xo-reader2 xo-expresion2: work on define-expressions [WIP] --- CMakeLists.txt | 16 ++++ idl/IExpression_DDefineExpr.json5 | 12 +++ include/xo/expression2/Binding.hpp | 2 + include/xo/expression2/DDefineExpr.hpp | 75 +++++++++++++++++++ include/xo/expression2/DGlobalSymtab.hpp | 39 ++++++++++ include/xo/expression2/DVariable.hpp | 26 ++++++- .../detail/IExpression_DDefineExpr.hpp | 66 ++++++++++++++++ include/xo/expression2/exprtype.hpp | 4 + src/expression2/CMakeLists.txt | 5 ++ src/expression2/DDefineExpr.cpp | 71 ++++++++++++++++++ src/expression2/DGlobalSymtab.cpp | 27 +++++++ src/expression2/DLocalSymtab.cpp | 25 +++++++ src/expression2/DVariable.cpp | 22 ++++++ src/expression2/IExpression_DDefineExpr.cpp | 45 +++++++++++ 14 files changed, 431 insertions(+), 4 deletions(-) create mode 100644 idl/IExpression_DDefineExpr.json5 create mode 100644 include/xo/expression2/DDefineExpr.hpp create mode 100644 include/xo/expression2/DGlobalSymtab.hpp create mode 100644 include/xo/expression2/detail/IExpression_DDefineExpr.hpp create mode 100644 src/expression2/DDefineExpr.cpp create mode 100644 src/expression2/DGlobalSymtab.cpp create mode 100644 src/expression2/DLocalSymtab.cpp create mode 100644 src/expression2/IExpression_DDefineExpr.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index fe5cd540..678e5eca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,6 +32,8 @@ xo_add_genfacet( OUTPUT_CPP_DIR src/expression2 ) +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacet( TARGET xo-expression2-facet-expression @@ -66,6 +68,20 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-defineexpr + FACET_PKG xo_expression2 + FACET Expression + REPR DefineExpr + INPUT idl/IExpression_DDefineExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-uniquestring diff --git a/idl/IExpression_DDefineExpr.json5 b/idl/IExpression_DDefineExpr.json5 new file mode 100644 index 00000000..ff35d6d6 --- /dev/null +++ b/idl/IExpression_DDefineExpr.json5 @@ -0,0 +1,12 @@ +{ + mode: "implementation", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DDefineExpr state", + using_doxygen: true, + repr: "DDefineExpr", + doc: ["doc for IExpression+DDefineExpr" ], +} diff --git a/include/xo/expression2/Binding.hpp b/include/xo/expression2/Binding.hpp index 455c1538..5f0f7e27 100644 --- a/include/xo/expression2/Binding.hpp +++ b/include/xo/expression2/Binding.hpp @@ -15,6 +15,7 @@ namespace xo { static constexpr int32_t s_link_global = -1; public: + Binding() : i_link_{-2}, j_slot_{-1} {} Binding(int32_t i_link, int32_t j_slot) : i_link_{i_link}, j_slot_{j_slot} {} @@ -32,6 +33,7 @@ namespace xo { * >= 0: number of parent links to traverse * to a fixed-size frame * -1: resolve globally + * -2: sentinel (binding info not computed) **/ int32_t i_link_ = s_link_sentinel; /** if @ref i_link_ >= 0, frame offset diff --git a/include/xo/expression2/DDefineExpr.hpp b/include/xo/expression2/DDefineExpr.hpp new file mode 100644 index 00000000..94a37197 --- /dev/null +++ b/include/xo/expression2/DDefineExpr.hpp @@ -0,0 +1,75 @@ +/** @file DDefineExpr.hpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "Expression.hpp" +#include "DVariable.hpp" +#include + +namespace xo { + namespace scm { + class DUniqueString; // see DUniqueString.hpp + + /** @class DDefineExpr + * @brief an expression that introduces a variable. + * + * Variable may optionally be declared with a type, + * and may come with an expression specifying an initial value + **/ + class DDefineExpr { + public: + using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; + + public: + /** create instance: define-expr using memory from @p mm + * with lhs name @p lhs_name and rhs expression @p rhs_expr + **/ + static DDefineExpr * make(obj mm, + const DUniqueString * lhs_name, + obj rhs_expr); + /** create empty skeleton. Rely on this for parsing + **/ + static DDefineExpr * make_empty(obj mm); + + DVariable * lhs() const { return lhs_var_; } + obj rhs() const noexcept { return rhs_; } + + const DUniqueString * name() const noexcept; + + void assign_lhs_name(const DUniqueString * name); + /** CONCESSION. will use DUniqueString* once we have StringTable **/ + void assign_lhs_name(std::string_view name); + + /** @defgroup scm-defineexpr-expression-facet **/ + ///@{ + + exprtype extype() const noexcept { return exprtype::define; } + TypeRef typeref() const noexcept { return lhs_var_->typeref(); } + TypeDescr valuetype() const noexcept { return lhs_var_->typeref().td(); } + void assign_valuetype(TypeDescr td) noexcept; + + ///@} + + private: + DDefineExpr(DVariable * lhs_var, + obj rhs); + + private: + /** variable being defined by this expression. + **/ + DVariable * lhs_var_ = nullptr; + + /** expression for initial value of this expression + **/ + obj rhs_; + + // std::set free_var_set_; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DDefineExpr.hpp */ diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp new file mode 100644 index 00000000..bb668ff3 --- /dev/null +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -0,0 +1,39 @@ +/** @file DGlobalSymtab.hpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "Binding.hpp" + +namespace xo { + namespace scm { + class DUniqueString; + + /** @class DGlobalSymtab + * @brief symbol table for toplevel environment + **/ + struct DGlobalSymtab { + public: + + + public: + /** @defgroup xo-expression2-symboltable-facet symboltable facet**/ + ///@{ + + /** true for global symbol table **/ + bool is_global_symtab() const noexcept { return true; } + + /** lookup binding for variable @p sym **/ + Binding lookup_binding(const DUniqueString * sym) const noexcept; + + ///@} + + private: + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DGlobalSymtab.hpp */ diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp index 036d88ce..2208852e 100644 --- a/include/xo/expression2/DVariable.hpp +++ b/include/xo/expression2/DVariable.hpp @@ -19,15 +19,33 @@ namespace xo { **/ class DVariable { public: + using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; public: - DVariable(const DUniqueString & name, const TypeRef & typeref, Binding path) - : name_{name}, typeref_{typeref}, path_{path} {} + /** create instance + * @p mm memory allocator + * @p name variable name + * @p typeref type information for legal values + * (possibly just placeholder when relying on inference) + * @p path binding path to runtime value. + * This may be computed after parsing; + * mnust be resolved before execution. + **/ + static DVariable * make(obj mm, + const DUniqueString * name, + const TypeRef & typeref, + Binding path = Binding()); - const DUniqueString & name() const { return name_; } + DVariable(const DUniqueString * name, + const TypeRef & typeref, + Binding path); + + const DUniqueString * name() const { return name_; } Binding path() const { return path_; } + void assign_name(const DUniqueString * name) { this->name_ = name; } + /** @defgroup scm-variable-expression-facet**/ ///@{ @@ -40,7 +58,7 @@ namespace xo { private: /** symbol name **/ - const DUniqueString & name_; + const DUniqueString * name_; /** variable value always has type consistent * with this description **/ diff --git a/include/xo/expression2/detail/IExpression_DDefineExpr.hpp b/include/xo/expression2/detail/IExpression_DDefineExpr.hpp new file mode 100644 index 00000000..3ac7fd49 --- /dev/null +++ b/include/xo/expression2/detail/IExpression_DDefineExpr.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DDefineExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DDefineExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DDefineExpr.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DDefineExpr.hpp" + +namespace xo { namespace scm { class IExpression_DDefineExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DDefineExpr + **/ + class IExpression_DDefineExpr { + public: + /** @defgroup scm-expression-ddefineexpr-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-ddefineexpr-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DDefineExpr & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DDefineExpr & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DDefineExpr & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DDefineExpr & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/exprtype.hpp b/include/xo/expression2/exprtype.hpp index 0d5e8299..d64a1191 100644 --- a/include/xo/expression2/exprtype.hpp +++ b/include/xo/expression2/exprtype.hpp @@ -23,8 +23,10 @@ namespace xo { #ifdef NOT_YET /** a literal constant that refers to a linkable named function **/ primitive, +#endif /** variable/function definition **/ define, +#ifdef NOT_YET /** variable assignment **/ assign, /** function call **/ @@ -55,7 +57,9 @@ namespace xo { case exprtype::constant: return "constant"; #ifdef NOT_YET case exprtype::primitive: return "primitive"; +#endif case exprtype::define: return "define"; +#ifdef NOT_YET case exprtype::assign: return "assign"; case exprtype::apply: return "apply"; case exprtype::lambda: return "lambda"; diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 9194bfa5..0fcd6541 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -6,12 +6,17 @@ set(SELF_SRCS DConstant.cpp DVariable.cpp + DDefineExpr.cpp TypeRef.cpp IExpression_Any.cpp IExpression_DConstant.cpp IExpression_DVariable.cpp + IExpression_DDefineExpr.cpp + + DLocalSymtab.cpp + DGlobalSymtab.cpp ISymbolTable_Any.cpp diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp new file mode 100644 index 00000000..14d1c52e --- /dev/null +++ b/src/expression2/DDefineExpr.cpp @@ -0,0 +1,71 @@ +/** @file DDefineExpr.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DDefineExpr.hpp" +#include + +namespace xo { + using xo::facet::typeseq; + + namespace scm { + + DDefineExpr::DDefineExpr(DVariable * lhs_var, + obj rhs) + : lhs_var_{lhs_var}, rhs_{rhs} + {} + + DDefineExpr * + DDefineExpr::make(obj mm, + const DUniqueString * lhs_name, + obj rhs_expr) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DDefineExpr)); + + auto lhs_var = DVariable::make(mm, + lhs_name, + rhs_expr.typeref()); + + return new (mem) DDefineExpr(lhs_var, rhs_expr); + } + + DDefineExpr * + DDefineExpr::make_empty(obj mm) + { + return make(mm, + nullptr /*lhs_name*/, + obj() /*rhs_expr*/); + } + + const DUniqueString * + DDefineExpr::name() const noexcept + { + return lhs_var_->name(); + } + + void + DDefineExpr::assign_lhs_name(const DUniqueString * name) + { + lhs_var_->assign_name(name); + } + + void + DDefineExpr::assign_lhs_name(std::string_view name) + { + scope log(XO_DEBUG(true), "bogus impl - will require unique string"); + log && log(xtag("name", name)); + + //lhs_var_->assign_name(name); + } + + void + DDefineExpr::assign_valuetype(TypeDescr td) noexcept + { + lhs_var_->assign_valuetype(td); + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DDefineExpr.cpp */ diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp new file mode 100644 index 00000000..c11761d9 --- /dev/null +++ b/src/expression2/DGlobalSymtab.cpp @@ -0,0 +1,27 @@ +/** @file DGlobalSymtab.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DGlobalSymtab.hpp" +#include "DUniqueString.hpp" +#include + +namespace xo { + namespace scm { + + Binding + DGlobalSymtab::lookup_binding(const DUniqueString * sym) const noexcept + { + (void)sym; + + scope log(XO_DEBUG(true), "stub"); + log && log(xtag("sym", std::string_view(*sym))); + + return Binding(); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DGlobalSymtab.cpp */ diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp new file mode 100644 index 00000000..febd1463 --- /dev/null +++ b/src/expression2/DLocalSymtab.cpp @@ -0,0 +1,25 @@ +/** @file DLocalSymtab.cpp +* + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DLocalSymtab.hpp" +#include "DUniqueString.hpp" +#include + +namespace xo { + namespace scm { + + Binding + DLocalSymtab::lookup_binding(const DUniqueString * sym) const noexcept + { + scope log(XO_DEBUG(true), "stub impl"); + log && log(xtag("sym", std::string_view(*sym))); + + return Binding(); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DLocalSymtab.cpp */ diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index f589da7b..d27c71ef 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -7,12 +7,34 @@ #include "exprtype.hpp" namespace xo { + using xo::facet::typeseq; + namespace scm { + + DVariable * + DVariable::make(obj mm, + const DUniqueString * name, + const TypeRef & typeref, + Binding path) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DVariable)); + + return new (mem) DVariable(name, typeref, path); + } + + DVariable::DVariable(const DUniqueString * name, + const TypeRef & typeref, + Binding path) + : name_{name}, typeref_{typeref}, path_{path} + {} + void DVariable::assign_valuetype(TypeDescr td) noexcept { typeref_.resolve(td); } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/expression2/IExpression_DDefineExpr.cpp b/src/expression2/IExpression_DDefineExpr.cpp new file mode 100644 index 00000000..3222eabd --- /dev/null +++ b/src/expression2/IExpression_DDefineExpr.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DDefineExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DDefineExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DDefineExpr.json5] +**/ + +#include "detail/IExpression_DDefineExpr.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DDefineExpr::extype(const DDefineExpr & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DDefineExpr::typeref(const DDefineExpr & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DDefineExpr::valuetype(const DDefineExpr & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DDefineExpr::assign_valuetype(DDefineExpr & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DDefineExpr.cpp */ \ No newline at end of file From 5dc510694c8b6f7cafb90d940b85656b26215de8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 19 Jan 2026 23:18:30 -0500 Subject: [PATCH 023/128] xo-reader2: bugfix in DDefineExpr --- src/expression2/DDefineExpr.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index 14d1c52e..ada633f6 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -24,9 +24,13 @@ namespace xo { void * mem = mm.alloc(typeseq::id(), sizeof(DDefineExpr)); + TypeRef rhs_tref; + if (rhs_expr) + rhs_tref = rhs_expr.typeref(); + auto lhs_var = DVariable::make(mm, lhs_name, - rhs_expr.typeref()); + rhs_tref); return new (mem) DDefineExpr(lhs_var, rhs_expr); } From 864a850825f562c704603f4f7c7bd9cab681549a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 20 Jan 2026 00:08:51 -0500 Subject: [PATCH 024/128] xo-reader2: intern for DDefineExpr lhs symbol --- include/xo/expression2/DDefineExpr.hpp | 22 ++++++++++++++++------ src/expression2/DDefineExpr.cpp | 9 --------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/include/xo/expression2/DDefineExpr.hpp b/include/xo/expression2/DDefineExpr.hpp index 94a37197..618e4161 100644 --- a/include/xo/expression2/DDefineExpr.hpp +++ b/include/xo/expression2/DDefineExpr.hpp @@ -25,6 +25,9 @@ namespace xo { using TypeDescr = xo::reflect::TypeDescr; public: + /** @defgroup scm-defineexpr-constructors **/ + ///@{ + /** create instance: define-expr using memory from @p mm * with lhs name @p lhs_name and rhs expression @p rhs_expr **/ @@ -35,14 +38,20 @@ namespace xo { **/ static DDefineExpr * make_empty(obj mm); + DDefineExpr(DVariable * lhs_var, + obj rhs); + + ///@} + /** @defgroup scm-definexpr-access-methods **/ + ///@{ + DVariable * lhs() const { return lhs_var_; } obj rhs() const noexcept { return rhs_; } - const DUniqueString * name() const noexcept; void assign_lhs_name(const DUniqueString * name); - /** CONCESSION. will use DUniqueString* once we have StringTable **/ - void assign_lhs_name(std::string_view name); + + ///@} /** @defgroup scm-defineexpr-expression-facet **/ ///@{ @@ -55,10 +64,9 @@ namespace xo { ///@} private: - DDefineExpr(DVariable * lhs_var, - obj rhs); + /** @defgrouop scm-defineexpr-instance-vars **/ + ///@{ - private: /** variable being defined by this expression. **/ DVariable * lhs_var_ = nullptr; @@ -68,6 +76,8 @@ namespace xo { obj rhs_; // std::set free_var_set_; + + ///@} }; } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index ada633f6..a5609246 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -55,15 +55,6 @@ namespace xo { lhs_var_->assign_name(name); } - void - DDefineExpr::assign_lhs_name(std::string_view name) - { - scope log(XO_DEBUG(true), "bogus impl - will require unique string"); - log && log(xtag("name", name)); - - //lhs_var_->assign_name(name); - } - void DDefineExpr::assign_valuetype(TypeDescr td) noexcept { From 807513a556b9c963509e107b34829b4627e6638d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 20 Jan 2026 15:06:58 -0500 Subject: [PATCH 025/128] xo-reader2 xo-expression2: pprint for DDefineExpr + DVariable --- CMakeLists.txt | 28 +++++++++ idl/IPrintable_DDefineExpr.json5 | 13 ++++ idl/IPrintable_DVariable.json5 | 13 ++++ include/xo/expression2/DDefineExpr.hpp | 8 +++ include/xo/expression2/DVariable.hpp | 10 ++- .../detail/IExpression_DVariable.hpp | 4 +- .../detail/IPrintable_DDefineExpr.hpp | 62 +++++++++++++++++++ .../detail/IPrintable_DVariable.hpp | 62 +++++++++++++++++++ src/expression2/CMakeLists.txt | 4 ++ src/expression2/DDefineExpr.cpp | 29 +++++++++ src/expression2/DVariable.cpp | 13 ++++ src/expression2/IPrintable_DDefineExpr.cpp | 28 +++++++++ src/expression2/IPrintable_DVariable.cpp | 28 +++++++++ .../expression2_register_facets.cpp | 12 ++++ 14 files changed, 311 insertions(+), 3 deletions(-) create mode 100644 idl/IPrintable_DDefineExpr.json5 create mode 100644 idl/IPrintable_DVariable.json5 create mode 100644 include/xo/expression2/detail/IPrintable_DDefineExpr.hpp create mode 100644 include/xo/expression2/detail/IPrintable_DVariable.hpp create mode 100644 src/expression2/IPrintable_DDefineExpr.cpp create mode 100644 src/expression2/IPrintable_DVariable.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 678e5eca..3de04758 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -56,6 +56,8 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-variable @@ -68,6 +70,20 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-variable + FACET_PKG xo_printable2 + FACET Printable + REPR Variable + INPUT idl/IPrintable_DVariable.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-defineexpr @@ -80,6 +96,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-defineexpr + FACET_PKG xo_printable2 + FACET Printable + REPR DefineExpr + INPUT idl/IPrintable_DDefineExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + # ---------------------------------------------------------------- # note: manual target; generated code committed to git diff --git a/idl/IPrintable_DDefineExpr.json5 b/idl/IPrintable_DDefineExpr.json5 new file mode 100644 index 00000000..351f8caf --- /dev/null +++ b/idl/IPrintable_DDefineExpr.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DDefineExpr", + using_doxygen: true, + repr: "DDefineExpr", + doc: [ "implement APrintable for DDefineExpr" ], +} diff --git a/idl/IPrintable_DVariable.json5 b/idl/IPrintable_DVariable.json5 new file mode 100644 index 00000000..52c301b2 --- /dev/null +++ b/idl/IPrintable_DVariable.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DVariable", + using_doxygen: true, + repr: "DVariable", + doc: [ "implement APrintable for DVariable" ], +} diff --git a/include/xo/expression2/DDefineExpr.hpp b/include/xo/expression2/DDefineExpr.hpp index 618e4161..59826aa2 100644 --- a/include/xo/expression2/DDefineExpr.hpp +++ b/include/xo/expression2/DDefineExpr.hpp @@ -8,6 +8,7 @@ #include "Expression.hpp" #include "DVariable.hpp" #include +#include namespace xo { namespace scm { @@ -21,6 +22,7 @@ namespace xo { **/ class DDefineExpr { public: + using ppindentinfo = xo::print::ppindentinfo; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -62,6 +64,12 @@ namespace xo { void assign_valuetype(TypeDescr td) noexcept; ///@} + /** @defgroup scm-defineexpr-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} private: /** @defgrouop scm-defineexpr-instance-vars **/ diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp index 2208852e..ae362bf1 100644 --- a/include/xo/expression2/DVariable.hpp +++ b/include/xo/expression2/DVariable.hpp @@ -10,6 +10,7 @@ #include "TypeRef.hpp" #include "exprtype.hpp" #include +#include namespace xo { namespace scm { @@ -19,6 +20,7 @@ namespace xo { **/ class DVariable { public: + using ppindentinfo = xo::print::ppindentinfo; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -46,7 +48,7 @@ namespace xo { void assign_name(const DUniqueString * name) { this->name_ = name; } - /** @defgroup scm-variable-expression-facet**/ + /** @defgroup scm-variable-expression-facet **/ ///@{ exprtype extype() const noexcept { return exprtype::variable; } @@ -55,6 +57,12 @@ namespace xo { void assign_valuetype(TypeDescr td) noexcept; ///@} + /** @defgroup scm-variable-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} private: /** symbol name **/ diff --git a/include/xo/expression2/detail/IExpression_DVariable.hpp b/include/xo/expression2/detail/IExpression_DVariable.hpp index 95b1becb..b4186f55 100644 --- a/include/xo/expression2/detail/IExpression_DVariable.hpp +++ b/include/xo/expression2/detail/IExpression_DVariable.hpp @@ -55,7 +55,7 @@ namespace xo { static TypeDescr valuetype(const DVariable & self) noexcept; // non-const methods - /** assing to valuetype member. Useful when scaffolding expressions **/ + /** assign to valuetype member. Useful when scaffolding expressions **/ static void assign_valuetype(DVariable & self, TypeDescr td) noexcept; ///@} }; @@ -63,4 +63,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp b/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp new file mode 100644 index 00000000..6d727d86 --- /dev/null +++ b/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DDefineExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DDefineExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DDefineExpr.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DDefineExpr.hpp" + +namespace xo { namespace scm { class IPrintable_DDefineExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DDefineExpr + **/ + class IPrintable_DDefineExpr { + public: + /** @defgroup scm-printable-ddefineexpr-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-ddefineexpr-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DDefineExpr & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IPrintable_DVariable.hpp b/include/xo/expression2/detail/IPrintable_DVariable.hpp new file mode 100644 index 00000000..6e97451b --- /dev/null +++ b/include/xo/expression2/detail/IPrintable_DVariable.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DVariable.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVariable.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DVariable.hpp" + +namespace xo { namespace scm { class IPrintable_DVariable; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DVariable + **/ + class IPrintable_DVariable { + public: + /** @defgroup scm-printable-dvariable-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dvariable-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DVariable & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 0fcd6541..f2dfe7e7 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -12,8 +12,12 @@ set(SELF_SRCS IExpression_Any.cpp IExpression_DConstant.cpp + IExpression_DVariable.cpp + IPrintable_DVariable.cpp + IExpression_DDefineExpr.cpp + IPrintable_DDefineExpr.cpp DLocalSymtab.cpp DGlobalSymtab.cpp diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index a5609246..8afb90fe 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -4,9 +4,14 @@ **/ #include "DDefineExpr.hpp" +#include "detail/IPrintable_DVariable.hpp" +#include +#include #include namespace xo { + using xo::print::APrintable; + using xo::facet::FacetRegistry; using xo::facet::typeseq; namespace scm { @@ -60,6 +65,30 @@ namespace xo { { lhs_var_->assign_valuetype(td); } + + bool + DDefineExpr::pretty(const ppindentinfo & ppii) const + { + auto lhs = obj(lhs_var_); + auto rhs = FacetRegistry::instance().try_variant(rhs_); + + if (rhs_) { + assert(rhs); + + return ppii.pps()->pretty_struct + (ppii, + "DDefineExpr", + refrtag("lhs", lhs), + refrtag("rhs", rhs)); + } else { + return ppii.pps()->pretty_struct + (ppii, + "DDefineExpr", + refrtag("lhs", lhs)); + } + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index d27c71ef..4adbe841 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -35,6 +35,19 @@ namespace xo { typeref_.resolve(td); } + bool + DVariable::pretty(const ppindentinfo & ppii) const + { + auto name = (name_ + ? std::string_view(*name_) + : std::string_view("")); + + return ppii.pps()->pretty_struct + (ppii, + "DVariable", + refrtag("name", name)); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/expression2/IPrintable_DDefineExpr.cpp b/src/expression2/IPrintable_DDefineExpr.cpp new file mode 100644 index 00000000..e8c6a799 --- /dev/null +++ b/src/expression2/IPrintable_DDefineExpr.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DDefineExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DDefineExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DDefineExpr.json5] +**/ + +#include "detail/IPrintable_DDefineExpr.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DDefineExpr::pretty(const DDefineExpr & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DDefineExpr.cpp */ \ No newline at end of file diff --git a/src/expression2/IPrintable_DVariable.cpp b/src/expression2/IPrintable_DVariable.cpp new file mode 100644 index 00000000..75e673ae --- /dev/null +++ b/src/expression2/IPrintable_DVariable.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DVariable.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVariable.json5] +**/ + +#include "detail/IPrintable_DVariable.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DVariable::pretty(const DVariable & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DVariable.cpp */ \ No newline at end of file diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 2d728bd3..e6715769 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -8,6 +8,10 @@ #include #include +#include + +#include + #include #include #include @@ -28,7 +32,15 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); + log && log(xtag("DUniqueString.tseq", typeseq::id())); + log && log(xtag("DDefineExpr.tseq", typeseq::id())); + log && log(xtag("DVariable.tseq", typeseq::id())); + + log && log(xtag("AExpression.tqseq", typeseq::id())); return true; } From 7c076c70536f061848ba7b3366253fea2e96731e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 20 Jan 2026 16:44:28 -0500 Subject: [PATCH 026/128] xo-indentlog: tidy: cosmetic adj in cond.hpp --- src/expression2/DDefineExpr.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index 8afb90fe..83ee9188 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -85,7 +85,8 @@ namespace xo { return ppii.pps()->pretty_struct (ppii, "DDefineExpr", - refrtag("lhs", lhs)); + refrtag("lhs", lhs), + refrtag("rhs", "nullptr")); } } From 6caae2ff991e589a10a8b265367441385b64b0e0 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 20 Jan 2026 16:54:27 -0500 Subject: [PATCH 027/128] xo-reader2: streamline DDefineExpr printing using xo::print::cond --- src/expression2/DDefineExpr.cpp | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index 83ee9188..c8785415 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -8,6 +8,7 @@ #include #include #include +#include namespace xo { using xo::print::APrintable; @@ -73,21 +74,11 @@ namespace xo { auto rhs = FacetRegistry::instance().try_variant(rhs_); - if (rhs_) { - assert(rhs); - - return ppii.pps()->pretty_struct - (ppii, - "DDefineExpr", - refrtag("lhs", lhs), - refrtag("rhs", rhs)); - } else { - return ppii.pps()->pretty_struct - (ppii, - "DDefineExpr", - refrtag("lhs", lhs), - refrtag("rhs", "nullptr")); - } + return ppii.pps()->pretty_struct + (ppii, + "DDefineExpr", + refrtag("lhs", lhs), + refrtag("rhs", cond(rhs_, rhs, "nullptr"))); } } /*namespace scm*/ From 7fd1bd0a6ba163dff52ee866f8dc7de786b3f5d4 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 20 Jan 2026 22:12:17 -0500 Subject: [PATCH 028/128] xo-reader2: print TypeRef belonging to DVariabe --- include/xo/expression2/TypeRef.hpp | 17 +++++++++++++++++ src/expression2/DVariable.cpp | 6 +++++- src/expression2/TypeRef.cpp | 14 ++++++++++++++ 3 files changed, 36 insertions(+), 1 deletion(-) diff --git a/include/xo/expression2/TypeRef.hpp b/include/xo/expression2/TypeRef.hpp index 01401d28..7ec6e388 100644 --- a/include/xo/expression2/TypeRef.hpp +++ b/include/xo/expression2/TypeRef.hpp @@ -7,6 +7,7 @@ #include #include +#include namespace xo { namespace scm { @@ -22,6 +23,7 @@ namespace xo { using TypeDescr = xo::reflect::TypeDescr; using type_var = flatstring<20>; using prefix_type = flatstring<8>; + using ppindentinfo = xo::print::ppindentinfo; public: TypeRef() = default; @@ -54,6 +56,9 @@ namespace xo { /** resolve TypeRef by supplying final type-description **/ void resolve(TypeDescr td) noexcept { td_ = td; } + /** pretty-printer support **/ + bool pretty(const ppindentinfo & ppii) const; + private: /** unique (probably generated) name for type at this location **/ type_var id_; @@ -64,6 +69,18 @@ namespace xo { TypeDescr td_; }; } /*namespace scm*/ + + namespace print { + /** pretty printer in relies on this specialization + * to handle TypeRef instances + **/ + template <> + struct ppdetail { + static inline bool print_pretty(const ppindentinfo & ppii, const xo::scm::TypeRef x) { + return x.pretty(ppii); + } + }; + } } /*namespace xo*/ /* end TypeRef.hpp */ diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index 4adbe841..4550a102 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -5,6 +5,7 @@ #include "DVariable.hpp" #include "exprtype.hpp" +#include namespace xo { using xo::facet::typeseq; @@ -38,6 +39,8 @@ namespace xo { bool DVariable::pretty(const ppindentinfo & ppii) const { + using xo::print::quot; + auto name = (name_ ? std::string_view(*name_) : std::string_view("")); @@ -45,7 +48,8 @@ namespace xo { return ppii.pps()->pretty_struct (ppii, "DVariable", - refrtag("name", name)); + refrtag("name", quot(name)), + refrtag("typeref", typeref_)); } } /*namespace scm*/ diff --git a/src/expression2/TypeRef.cpp b/src/expression2/TypeRef.cpp index 7b187ecd..01cb043c 100644 --- a/src/expression2/TypeRef.cpp +++ b/src/expression2/TypeRef.cpp @@ -4,6 +4,8 @@ **/ #include "TypeRef.hpp" +#include +#include namespace xo { namespace scm { @@ -62,6 +64,18 @@ namespace xo { return (td_ != nullptr); } + bool + TypeRef::pretty(const ppindentinfo & ppii) const + { + using xo::print::quot; + + return ppii.pps()->pretty_struct + (ppii, + "TypeRef", + refrtag("id", quot(id_)), + refrtag("td", td_)); + } + } /*namespace scm*/ } /*namespace xo*/ From 5ad6934f2c65941555f76eb2f5d9ee19c25bc9b5 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 21 Jan 2026 12:14:35 -0500 Subject: [PATCH 029/128] xo-reader2: handle parsed typedescr + use in DDefineSsm --- include/xo/expression2/DDefineExpr.hpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/xo/expression2/DDefineExpr.hpp b/include/xo/expression2/DDefineExpr.hpp index 59826aa2..1056dbb7 100644 --- a/include/xo/expression2/DDefineExpr.hpp +++ b/include/xo/expression2/DDefineExpr.hpp @@ -51,10 +51,13 @@ namespace xo { obj rhs() const noexcept { return rhs_; } const DUniqueString * name() const noexcept; + ///@} + /** @defgroup scm-definexpr-bookkeeping-methods **/ + ///@{ + void assign_lhs_name(const DUniqueString * name); ///@} - /** @defgroup scm-defineexpr-expression-facet **/ ///@{ From a341ac1f069e1c284ba01503ee15c54bcbf4dd11 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 22 Jan 2026 15:18:35 -0500 Subject: [PATCH 030/128] xo-reader2: + on_f64_token() + handle in DDefineSsm+DProgressSsm --- CMakeLists.txt | 4 ++++ include/xo/expression2/DConstant.hpp | 8 ++++++++ include/xo/expression2/Expression.hpp | 2 +- include/xo/expression2/SymbolTable.hpp | 2 +- include/xo/expression2/detail/AExpression.hpp | 2 +- include/xo/expression2/detail/IExpression_Any.hpp | 2 +- .../expression2/{ => detail}/IExpression_DConstant.hpp | 5 ++++- .../xo/expression2/detail/IExpression_DVariable.hpp | 6 +++--- include/xo/expression2/detail/IExpression_Xfer.hpp | 2 +- include/xo/expression2/detail/RExpression.hpp | 2 +- include/xo/expression2/symtab/ASymbolTable.hpp | 2 +- include/xo/expression2/symtab/ISymbolTable_Any.hpp | 2 +- include/xo/expression2/symtab/ISymbolTable_Xfer.hpp | 2 +- include/xo/expression2/symtab/RSymbolTable.hpp | 2 +- src/expression2/DConstant.cpp | 10 ++++++++++ src/expression2/IExpression_DConstant.cpp | 2 +- src/expression2/IExpression_DVariable.cpp | 2 +- 17 files changed, 41 insertions(+), 16 deletions(-) rename include/xo/expression2/{ => detail}/IExpression_DConstant.hpp (91%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3de04758..f286f2ad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -134,6 +134,10 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# ---------------------------------------------------------------- + +xo_add_genfacet_all(xo-expression2-genfacet-all) + # ---------------------------------------------------------------- # shared library diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp index 9d2014b9..a73ea2df 100644 --- a/include/xo/expression2/DConstant.hpp +++ b/include/xo/expression2/DConstant.hpp @@ -19,12 +19,20 @@ namespace xo { public: using TaggedPtr = xo::reflect::TaggedPtr; using TypeDescr = xo::reflect::TypeDescr; + using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; using typeseq = xo::reflect::typeseq; public: explicit DConstant(obj value) noexcept; + /** create instance + * @p mm memory allocator + * @p value literal constant + **/ + static DConstant * make(obj mm, + obj value); + bool is_resolved() const noexcept { return typeref_.is_resolved(); } exprtype extype() const noexcept { return exprtype::constant; } diff --git a/include/xo/expression2/Expression.hpp b/include/xo/expression2/Expression.hpp index 60e8a402..df4161a1 100644 --- a/include/xo/expression2/Expression.hpp +++ b/include/xo/expression2/Expression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for facet .hpp file: diff --git a/include/xo/expression2/SymbolTable.hpp b/include/xo/expression2/SymbolTable.hpp index 09fc04a8..26576ed6 100644 --- a/include/xo/expression2/SymbolTable.hpp +++ b/include/xo/expression2/SymbolTable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for facet .hpp file: diff --git a/include/xo/expression2/detail/AExpression.hpp b/include/xo/expression2/detail/AExpression.hpp index 10375114..e080ece8 100644 --- a/include/xo/expression2/detail/AExpression.hpp +++ b/include/xo/expression2/detail/AExpression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_Any.hpp b/include/xo/expression2/detail/IExpression_Any.hpp index c92c2c4a..17545afb 100644 --- a/include/xo/expression2/detail/IExpression_Any.hpp +++ b/include/xo/expression2/detail/IExpression_Any.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/IExpression_DConstant.hpp b/include/xo/expression2/detail/IExpression_DConstant.hpp similarity index 91% rename from include/xo/expression2/IExpression_DConstant.hpp rename to include/xo/expression2/detail/IExpression_DConstant.hpp index b08d8814..61b92e12 100644 --- a/include/xo/expression2/IExpression_DConstant.hpp +++ b/include/xo/expression2/detail/IExpression_DConstant.hpp @@ -6,13 +6,14 @@ * arguments: * --input [idl/IExpression_DConstant.json5] * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] + * [iface_facet_repr.hpp.j2] * 3. idl for facet methods * [idl/IExpression_DConstant.json5] **/ #pragma once +#include "Expression.hpp" #include "Expression.hpp" #include "DConstant.hpp" @@ -40,6 +41,8 @@ namespace xo { /** @defgroup scm-expression-dconstant-type-traits **/ ///@{ using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; ///@} /** @defgroup scm-expression-dconstant-methods **/ ///@{ diff --git a/include/xo/expression2/detail/IExpression_DVariable.hpp b/include/xo/expression2/detail/IExpression_DVariable.hpp index b4186f55..6b9b702f 100644 --- a/include/xo/expression2/detail/IExpression_DVariable.hpp +++ b/include/xo/expression2/detail/IExpression_DVariable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -55,7 +55,7 @@ namespace xo { static TypeDescr valuetype(const DVariable & self) noexcept; // non-const methods - /** assign to valuetype member. Useful when scaffolding expressions **/ + /** assing to valuetype member. Useful when scaffolding expressions **/ static void assign_valuetype(DVariable & self, TypeDescr td) noexcept; ///@} }; @@ -63,4 +63,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IExpression_Xfer.hpp b/include/xo/expression2/detail/IExpression_Xfer.hpp index 9f7356bc..fac8c541 100644 --- a/include/xo/expression2/detail/IExpression_Xfer.hpp +++ b/include/xo/expression2/detail/IExpression_Xfer.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/RExpression.hpp b/include/xo/expression2/detail/RExpression.hpp index caf69fe0..4d717640 100644 --- a/include/xo/expression2/detail/RExpression.hpp +++ b/include/xo/expression2/detail/RExpression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/ASymbolTable.hpp b/include/xo/expression2/symtab/ASymbolTable.hpp index 36d4c812..f0c6e10f 100644 --- a/include/xo/expression2/symtab/ASymbolTable.hpp +++ b/include/xo/expression2/symtab/ASymbolTable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/ISymbolTable_Any.hpp b/include/xo/expression2/symtab/ISymbolTable_Any.hpp index 6a119832..b642adb7 100644 --- a/include/xo/expression2/symtab/ISymbolTable_Any.hpp +++ b/include/xo/expression2/symtab/ISymbolTable_Any.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp b/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp index 2333bb05..3d5f7221 100644 --- a/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp +++ b/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/RSymbolTable.hpp b/include/xo/expression2/symtab/RSymbolTable.hpp index c72503cc..600ea4f8 100644 --- a/include/xo/expression2/symtab/RSymbolTable.hpp +++ b/include/xo/expression2/symtab/RSymbolTable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/DConstant.cpp b/src/expression2/DConstant.cpp index fcb38f54..5bf98bfc 100644 --- a/src/expression2/DConstant.cpp +++ b/src/expression2/DConstant.cpp @@ -34,6 +34,16 @@ namespace xo { } } + DConstant * + DConstant::make(obj mm, + obj value) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DConstant)); + + return new (mem) DConstant(value); + } + TypeDescr DConstant::_lookup_td(typeseq tseq) { diff --git a/src/expression2/IExpression_DConstant.cpp b/src/expression2/IExpression_DConstant.cpp index 39f8135c..2d39c36d 100644 --- a/src/expression2/IExpression_DConstant.cpp +++ b/src/expression2/IExpression_DConstant.cpp @@ -11,7 +11,7 @@ * [idl/IExpression_DConstant.json5] **/ -#include "IExpression_DConstant.hpp" +#include "detail/IExpression_DConstant.hpp" namespace xo { namespace scm { diff --git a/src/expression2/IExpression_DVariable.cpp b/src/expression2/IExpression_DVariable.cpp index ca657c36..2b4a007b 100644 --- a/src/expression2/IExpression_DVariable.cpp +++ b/src/expression2/IExpression_DVariable.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: From c3907f45df292affceb7a8338fa8be33c6528509 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 22 Jan 2026 17:15:05 -0500 Subject: [PATCH 031/128] xo-reader2: + on_parsed_expression_with_semicolon + DefineSsm works --- include/xo/expression2/DDefineExpr.hpp | 1 + src/expression2/DDefineExpr.cpp | 5 +++++ 2 files changed, 6 insertions(+) diff --git a/include/xo/expression2/DDefineExpr.hpp b/include/xo/expression2/DDefineExpr.hpp index 1056dbb7..6b7716e3 100644 --- a/include/xo/expression2/DDefineExpr.hpp +++ b/include/xo/expression2/DDefineExpr.hpp @@ -56,6 +56,7 @@ namespace xo { ///@{ void assign_lhs_name(const DUniqueString * name); + void assign_rhs(obj rhs); ///@} /** @defgroup scm-defineexpr-expression-facet **/ diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index c8785415..e193c4d4 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -67,6 +67,11 @@ namespace xo { lhs_var_->assign_valuetype(td); } + void + DDefineExpr::assign_rhs(obj x) { + this->rhs_ = x; + } + bool DDefineExpr::pretty(const ppindentinfo & ppii) const { From 855cdb08b71cb86212ce6717b65b70233186287a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 22 Jan 2026 18:40:42 -0500 Subject: [PATCH 032/128] xo-reader2 xo-expression2: define example working and printing def foo : f64 = 3.141593; --- CMakeLists.txt | 14 +++++ idl/IPrintable_DConstant.json5 | 13 ++++ include/xo/expression2/DConstant.hpp | 3 + .../detail/IPrintable_DConstant.hpp | 62 +++++++++++++++++++ src/expression2/CMakeLists.txt | 2 + src/expression2/DConstant.cpp | 18 ++++++ src/expression2/DDefineExpr.cpp | 20 ++++-- src/expression2/IPrintable_DConstant.cpp | 28 +++++++++ .../expression2_register_facets.cpp | 18 +++++- 9 files changed, 172 insertions(+), 6 deletions(-) create mode 100644 idl/IPrintable_DConstant.json5 create mode 100644 include/xo/expression2/detail/IPrintable_DConstant.hpp create mode 100644 src/expression2/IPrintable_DConstant.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index f286f2ad..52e9d380 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -44,6 +44,8 @@ xo_add_genfacet( OUTPUT_CPP_DIR src/expression2 ) +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-constant @@ -56,6 +58,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-constant + FACET_PKG xo_printable2 + FACET Printable + REPR Constant + INPUT idl/IPrintable_DConstant.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + # ---------------------------------------------------------------- # note: manual target; generated code committed to git diff --git a/idl/IPrintable_DConstant.json5 b/idl/IPrintable_DConstant.json5 new file mode 100644 index 00000000..1d955d79 --- /dev/null +++ b/idl/IPrintable_DConstant.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DConstant", + using_doxygen: true, + repr: "DConstant", + doc: [ "implement APrintable for DConstant" ], +} diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp index a73ea2df..81561e68 100644 --- a/include/xo/expression2/DConstant.hpp +++ b/include/xo/expression2/DConstant.hpp @@ -22,6 +22,7 @@ namespace xo { using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; using typeseq = xo::reflect::typeseq; + using ppindentinfo = xo::print::ppindentinfo; public: explicit DConstant(obj value) noexcept; @@ -45,6 +46,8 @@ namespace xo { void assign_valuetype(TypeDescr td) noexcept { typeref_.resolve(td); } + bool pretty(const ppindentinfo & ppii) const; + private: static TypeDescr _lookup_td(typeseq tseq); diff --git a/include/xo/expression2/detail/IPrintable_DConstant.hpp b/include/xo/expression2/detail/IPrintable_DConstant.hpp new file mode 100644 index 00000000..a1e31382 --- /dev/null +++ b/include/xo/expression2/detail/IPrintable_DConstant.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DConstant.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DConstant.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DConstant.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DConstant.hpp" + +namespace xo { namespace scm { class IPrintable_DConstant; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DConstant + **/ + class IPrintable_DConstant { + public: + /** @defgroup scm-printable-dconstant-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dconstant-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DConstant & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index f2dfe7e7..17c34275 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -11,7 +11,9 @@ set(SELF_SRCS TypeRef.cpp IExpression_Any.cpp + IExpression_DConstant.cpp + IPrintable_DConstant.cpp IExpression_DVariable.cpp IPrintable_DVariable.cpp diff --git a/src/expression2/DConstant.cpp b/src/expression2/DConstant.cpp index 5bf98bfc..a0b255a6 100644 --- a/src/expression2/DConstant.cpp +++ b/src/expression2/DConstant.cpp @@ -7,12 +7,16 @@ #include "TypeDescr.hpp" #include #include +#include #include +#include #include namespace xo { using xo::scm::DFloat; using xo::scm::DInteger; + using xo::print::APrintable; + using xo::facet::FacetRegistry; using xo::reflect::Reflect; using xo::reflect::TypeDescr; using xo::reflect::typeseq; @@ -57,6 +61,20 @@ namespace xo { return nullptr; } + + bool + DConstant::pretty(const ppindentinfo & ppii) const + { + obj value + = FacetRegistry::instance().variant(value_); + + return ppii.pps()->pretty_struct + (ppii, + "DConstant", + refrtag("value_.tseq", value_._typeseq()), + refrtag("value.tseq", value._typeseq()), + refrtag("value", value)); + } } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index e193c4d4..47465c0e 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -79,11 +79,21 @@ namespace xo { auto rhs = FacetRegistry::instance().try_variant(rhs_); - return ppii.pps()->pretty_struct - (ppii, - "DDefineExpr", - refrtag("lhs", lhs), - refrtag("rhs", cond(rhs_, rhs, "nullptr"))); + // note: xo::print::cond() doesn't resolve the way we want here + + if (rhs) { + return ppii.pps()->pretty_struct + (ppii, + "DDefineExpr", + refrtag("lhs", lhs), + refrtag("rhs", rhs)); + } else { + return ppii.pps()->pretty_struct + (ppii, + "DDefineExpr", + refrtag("lhs", lhs)); + + } } } /*namespace scm*/ diff --git a/src/expression2/IPrintable_DConstant.cpp b/src/expression2/IPrintable_DConstant.cpp new file mode 100644 index 00000000..1bacfb9d --- /dev/null +++ b/src/expression2/IPrintable_DConstant.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DConstant.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DConstant.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DConstant.json5] +**/ + +#include "detail/IPrintable_DConstant.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DConstant::pretty(const DConstant & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DConstant.cpp */ \ No newline at end of file diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index e6715769..1854f3eb 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -8,10 +8,15 @@ #include #include +#include #include +#include #include +#include +#include + #include #include #include @@ -32,13 +37,24 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); - FacetRegistry::register_impl(); + // Expression + // +- Constant + // +- Variable + // \- DefineExpr + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + + FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + log && log(xtag("DUniqueString.tseq", typeseq::id())); log && log(xtag("DDefineExpr.tseq", typeseq::id())); log && log(xtag("DVariable.tseq", typeseq::id())); + log && log(xtag("DConstant.tseq", typeseq::id())); log && log(xtag("AExpression.tqseq", typeseq::id())); From 9a87b28f3fbf353188676006b4d79163a5e0db3e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 23 Jan 2026 16:34:33 -0500 Subject: [PATCH 033/128] xo-reader2: fix clearing result in SchematikaReader --- src/expression2/DConstant.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/expression2/DConstant.cpp b/src/expression2/DConstant.cpp index a0b255a6..f65ba013 100644 --- a/src/expression2/DConstant.cpp +++ b/src/expression2/DConstant.cpp @@ -65,15 +65,15 @@ namespace xo { bool DConstant::pretty(const ppindentinfo & ppii) const { - obj value + obj value_pr = FacetRegistry::instance().variant(value_); return ppii.pps()->pretty_struct (ppii, "DConstant", refrtag("value_.tseq", value_._typeseq()), - refrtag("value.tseq", value._typeseq()), - refrtag("value", value)); + refrtag("value.tseq", value_pr._typeseq()), + refrtag("value", value_pr)); } } /*namespace scm*/ } /*namespace xo*/ From 6c73d08e32f5302d5a692c8bc514663a8d9a0815 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 25 Jan 2026 13:14:26 -0500 Subject: [PATCH 034/128] xo-expression2: + DApplyExpr [WIP]. Builds, not used or tested --- include/xo/expression2/DApplyExpr.hpp | 64 ++++++++++++++++++ include/xo/expression2/DVariable.hpp | 2 +- include/xo/expression2/exprtype.hpp | 4 ++ src/expression2/CMakeLists.txt | 1 + src/expression2/DApplyExpr.cpp | 95 +++++++++++++++++++++++++++ 5 files changed, 165 insertions(+), 1 deletion(-) create mode 100644 include/xo/expression2/DApplyExpr.hpp create mode 100644 src/expression2/DApplyExpr.cpp diff --git a/include/xo/expression2/DApplyExpr.hpp b/include/xo/expression2/DApplyExpr.hpp new file mode 100644 index 00000000..882cf5cd --- /dev/null +++ b/include/xo/expression2/DApplyExpr.hpp @@ -0,0 +1,64 @@ +/** @file DApplyExpr.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "Expression.hpp" +#include "TypeRef.hpp" +#include "exprtype.hpp" +#include +#include +#include + +namespace xo { + namespace scm { + + /** @class DApplyExpr + * @brief syntax for a procedure/function call + **/ + class DApplyExpr { + public: + using TypeDescr = xo::reflect::TypeDescr; + using ppindentinfo = xo::print::ppindentinfo; + using size_type = std::size_t; + + public: + + obj fn() const noexcept { return fn_; } + const DArray * args() const noexcept { return args_; } + + size_type n_arg() const noexcept { return args_->size(); } + obj arg(size_type i) const; + + /** @defgroup scm-applyexpr-expression-facet **/ + ///@{ + + exprtype extype() const noexcept { return exprtype::apply; } + TypeRef typeref() const noexcept { return typeref_; } + TypeDescr valuetype() const noexcept { return typeref_.td(); } + void assign_valuetype(TypeDescr td) noexcept; + + ///@} + /** @defgroup scm-applyexpr-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + private: + /** expression value always has type consistent + * with this description + **/ + TypeRef typeref_; + /** expression for function/procedure to invoke **/ + obj fn_; + /** expression for each argument vector **/ + const DArray * args_; + }; + } +} + +/* end DApplyExpr.hpp */ diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp index ae362bf1..af2eddd5 100644 --- a/include/xo/expression2/DVariable.hpp +++ b/include/xo/expression2/DVariable.hpp @@ -15,7 +15,7 @@ namespace xo { namespace scm { - /** @class DVariable* + /** @class DVariable * @brief syntax for a variable reference **/ class DVariable { diff --git a/include/xo/expression2/exprtype.hpp b/include/xo/expression2/exprtype.hpp index d64a1191..df4e3be6 100644 --- a/include/xo/expression2/exprtype.hpp +++ b/include/xo/expression2/exprtype.hpp @@ -29,8 +29,10 @@ namespace xo { #ifdef NOT_YET /** variable assignment **/ assign, +#endif /** function call **/ apply, +#ifdef NOT_YET /** function definition **/ lambda, #endif @@ -61,7 +63,9 @@ namespace xo { case exprtype::define: return "define"; #ifdef NOT_YET case exprtype::assign: return "assign"; +#endif case exprtype::apply: return "apply"; +#ifdef NOT_YET case exprtype::lambda: return "lambda"; case exprtype::variable: return "variable"; case exprtype::ifexpr: return "if_expr"; diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 17c34275..9dea6457 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -7,6 +7,7 @@ set(SELF_SRCS DConstant.cpp DVariable.cpp DDefineExpr.cpp + DApplyExpr.cpp TypeRef.cpp diff --git a/src/expression2/DApplyExpr.cpp b/src/expression2/DApplyExpr.cpp new file mode 100644 index 00000000..0c0546f3 --- /dev/null +++ b/src/expression2/DApplyExpr.cpp @@ -0,0 +1,95 @@ +/** @file DApplyExpr.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DApplyExpr.hpp" +#include "Expression.hpp" +#include +#include + +namespace xo { + using xo::print::APrintable; + using xo::facet::FacetRegistry; + using xo::mm::AGCObject; + + namespace scm { + obj + DApplyExpr::arg(size_type i) const + { + if (i >= args_->size()) [[unlikely]] { + throw std::runtime_error(tostr("attempt to fetch argument i where [0..n) expected", + xtag("i", i), + xtag("n", args_->size()), + xtag("src", "DApplyExpr::arg"))); + } + + obj arg_i = args_->at(i); + + auto expr_i = FacetRegistry::instance().variant(arg_i); + + if (!expr_i) [[unlikely]] { + throw std::runtime_error(tostr("expected expression interface on argument i", + xtag("i", i), + xtag("arg[i]", arg_i))); + } + + return expr_i; + } + + void + DApplyExpr::assign_valuetype(TypeDescr td) noexcept { + typeref_.resolve(td); + } + + bool + DApplyExpr::pretty(const ppindentinfo & ppii) const { + using xo::print::ppstate; + + ppstate * pps = ppii.pps(); + + if (ppii.upto()) { + /* perhaps print on one line */ + if (!pps->print_upto(" fn + = FacetRegistry::instance().variant(fn_); + if (!pps->print_upto(refrtag("fn", fn))) + return false; + } + + for (size_t i_arg = 0, n_arg = this->n_arg(); i_arg < n_arg; ++i_arg) { + obj arg_i + = FacetRegistry::instance().variant(this->arg(i_arg)); + + if (!pps->print_upto(refrtag(concat("arg", 1+i_arg), arg_i))) + return false; + } + + return true; + } else { + pps->write(" fn + = FacetRegistry::instance().variant(fn_); + + pps->newline_indent(ppii.ci1()); + pps->pretty(refrtag("fn", fn)); + + for (size_t i_arg = 0, n_arg = this->n_arg(); i_arg < n_arg; ++i_arg) { + obj arg_i + = FacetRegistry::instance().variant(fn_); + + pps->newline_indent(ppii.ci1()); + pps->pretty(refrtag(concat("arg", 1+i_arg), arg_i)); + } + return false; + } + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DApplyExpr.cpp */ From 9eda9f7894e51c705c9a55f1ea1d8e71d1b91979 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 26 Jan 2026 13:42:42 -0500 Subject: [PATCH 035/128] xo-expression2 xo-procedure2: work on calling primitive for x*y --- CMakeLists.txt | 26 +++++++ idl/IExpression_DApplyExpr.json5 | 12 ++++ idl/IPrintable_DApplyExpr.json5 | 13 ++++ include/xo/expression2/DApplyExpr.hpp | 57 ++++++++++++++-- .../detail/IExpression_DApplyExpr.hpp | 66 ++++++++++++++++++ .../detail/IPrintable_DApplyExpr.hpp | 62 +++++++++++++++++ src/expression2/CMakeLists.txt | 3 + src/expression2/DApplyExpr.cpp | 67 ++++++++++++++----- src/expression2/IExpression_DApplyExpr.cpp | 45 +++++++++++++ src/expression2/IPrintable_DApplyExpr.cpp | 28 ++++++++ .../expression2_register_facets.cpp | 10 ++- 11 files changed, 365 insertions(+), 24 deletions(-) create mode 100644 idl/IExpression_DApplyExpr.json5 create mode 100644 idl/IPrintable_DApplyExpr.json5 create mode 100644 include/xo/expression2/detail/IExpression_DApplyExpr.hpp create mode 100644 include/xo/expression2/detail/IPrintable_DApplyExpr.hpp create mode 100644 src/expression2/IExpression_DApplyExpr.cpp create mode 100644 src/expression2/IPrintable_DApplyExpr.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 52e9d380..869f891d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -124,6 +124,32 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-applyexpr + FACET_PKG xo_expression2 + FACET Expression + REPR ApplyExpr + INPUT idl/IExpression_DApplyExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-applyexpr + FACET_PKG xo_printable2 + FACET Printable + REPR ApplyExpr + INPUT idl/IPrintable_DApplyExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-uniquestring diff --git a/idl/IExpression_DApplyExpr.json5 b/idl/IExpression_DApplyExpr.json5 new file mode 100644 index 00000000..6814547c --- /dev/null +++ b/idl/IExpression_DApplyExpr.json5 @@ -0,0 +1,12 @@ +{ + mode: "implementation", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DApplyExpr state", + using_doxygen: true, + repr: "DApplyExpr", + doc: ["doc for IExpression+DApplyExpr" ], +} diff --git a/idl/IPrintable_DApplyExpr.json5 b/idl/IPrintable_DApplyExpr.json5 new file mode 100644 index 00000000..fe743b0b --- /dev/null +++ b/idl/IPrintable_DApplyExpr.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DApplyExpr", + using_doxygen: true, + repr: "DApplyExpr", + doc: [ "implement APrintable for DApplyExpr" ], +} diff --git a/include/xo/expression2/DApplyExpr.hpp b/include/xo/expression2/DApplyExpr.hpp index 882cf5cd..8502c62a 100644 --- a/include/xo/expression2/DApplyExpr.hpp +++ b/include/xo/expression2/DApplyExpr.hpp @@ -20,18 +20,55 @@ namespace xo { **/ class DApplyExpr { public: + using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; using ppindentinfo = xo::print::ppindentinfo; - using size_type = std::size_t; + using size_type = std::uint32_t; public: + /** @defgroup scm-applyexpr-constructors **/ + ///@{ + + /** construct empty instance, but with argument expressions empty **/ + DApplyExpr(TypeRef typeref, + obj fn_expr, + size_type n_args); + + /** create apply for function with 2 arguments **/ + static obj make2(obj mm, + TypeRef typeref, + obj fn_expr, + obj arg1, + obj arg2); + + /** create apply for function with 2 arguments **/ + static DApplyExpr * _make2(obj mm, + TypeRef typeref, + obj fn_expr, + obj arg1, + obj arg2); + + /** scaffold incomplete instance. + * apply-expr using memory from @p mm. + * will construct instance with space for @p n_args arguments + * but expressions left empty. + * use @ref assign_arg for all arguments to complete. + **/ + static DApplyExpr * scaffold(obj mm, + TypeRef typeref, + obj fn_expr, + size_type n_args); + void assign_arg(size_type i_arg, obj expr); + + ///@} + /** @defgroup scm-applyexpr-access-methods **/ + ///@{ obj fn() const noexcept { return fn_; } - const DArray * args() const noexcept { return args_; } - - size_type n_arg() const noexcept { return args_->size(); } + size_type n_args() const noexcept { return n_args_; } obj arg(size_type i) const; + ///@} /** @defgroup scm-applyexpr-expression-facet **/ ///@{ @@ -40,6 +77,12 @@ namespace xo { TypeDescr valuetype() const noexcept { return typeref_.td(); } void assign_valuetype(TypeDescr td) noexcept; + ///@} + /** @defgroup scm-applyexpr-gcobject-facet **/ + ///@{ + + // shallow_copy() etc. + ///@} /** @defgroup scm-applyexpr-printable-facet **/ ///@{ @@ -55,8 +98,10 @@ namespace xo { TypeRef typeref_; /** expression for function/procedure to invoke **/ obj fn_; - /** expression for each argument vector **/ - const DArray * args_; + /** number of arguments (not counting @ref fn_ **/ + size_type n_args_ = 0; + /** args_[i] is expression for i'th argument to @ref fn_ **/ + obj args_[]; }; } } diff --git a/include/xo/expression2/detail/IExpression_DApplyExpr.hpp b/include/xo/expression2/detail/IExpression_DApplyExpr.hpp new file mode 100644 index 00000000..c8952199 --- /dev/null +++ b/include/xo/expression2/detail/IExpression_DApplyExpr.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DApplyExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DApplyExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DApplyExpr.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DApplyExpr.hpp" + +namespace xo { namespace scm { class IExpression_DApplyExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DApplyExpr + **/ + class IExpression_DApplyExpr { + public: + /** @defgroup scm-expression-dapplyexpr-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-dapplyexpr-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DApplyExpr & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DApplyExpr & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DApplyExpr & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DApplyExpr & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp b/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp new file mode 100644 index 00000000..c05e87e2 --- /dev/null +++ b/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DApplyExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DApplyExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DApplyExpr.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DApplyExpr.hpp" + +namespace xo { namespace scm { class IPrintable_DApplyExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DApplyExpr + **/ + class IPrintable_DApplyExpr { + public: + /** @defgroup scm-printable-dapplyexpr-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dapplyexpr-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DApplyExpr & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 9dea6457..b8be9468 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -22,6 +22,9 @@ set(SELF_SRCS IExpression_DDefineExpr.cpp IPrintable_DDefineExpr.cpp + IExpression_DApplyExpr.cpp + IPrintable_DApplyExpr.cpp + DLocalSymtab.cpp DGlobalSymtab.cpp diff --git a/src/expression2/DApplyExpr.cpp b/src/expression2/DApplyExpr.cpp index 0c0546f3..ce5e1951 100644 --- a/src/expression2/DApplyExpr.cpp +++ b/src/expression2/DApplyExpr.cpp @@ -11,30 +11,62 @@ namespace xo { using xo::print::APrintable; using xo::facet::FacetRegistry; + using xo::reflect::typeseq; using xo::mm::AGCObject; namespace scm { + /* incomplete! */ + DApplyExpr::DApplyExpr(TypeRef typeref, + obj fn_expr, + size_type n_args) : typeref_{typeref}, + fn_{fn_expr}, + n_args_{n_args} + {} + + DApplyExpr * + DApplyExpr::scaffold(obj mm, + TypeRef typeref, + obj fn_expr, + size_type n_args) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DApplyExpr) + (n_args * sizeof(obj))); + + DApplyExpr * result = new (mem) DApplyExpr(typeref, + fn_expr, + n_args); + + return result; + } + + void + DApplyExpr::assign_arg(size_type i_arg, + obj expr) + { + if (i_arg < n_args_) { + this->args_[i_arg] = expr; + } else { + assert(false); + + throw std::runtime_error(tostr("assign out-of-range argument i_arg where [0..n_args) expected", + xtag("i_arg", i_arg), + xtag("expr", expr), + xtag("n_args", n_args_))); + + } + } + obj DApplyExpr::arg(size_type i) const { - if (i >= args_->size()) [[unlikely]] { + if (i >= n_args_) [[unlikely]] { throw std::runtime_error(tostr("attempt to fetch argument i where [0..n) expected", xtag("i", i), - xtag("n", args_->size()), + xtag("n", n_args_), xtag("src", "DApplyExpr::arg"))); } - obj arg_i = args_->at(i); - - auto expr_i = FacetRegistry::instance().variant(arg_i); - - if (!expr_i) [[unlikely]] { - throw std::runtime_error(tostr("expected expression interface on argument i", - xtag("i", i), - xtag("arg[i]", arg_i))); - } - - return expr_i; + return args_[i]; } void @@ -60,9 +92,9 @@ namespace xo { return false; } - for (size_t i_arg = 0, n_arg = this->n_arg(); i_arg < n_arg; ++i_arg) { + for (size_t i_arg = 0; i_arg < n_args_; ++i_arg) { obj arg_i - = FacetRegistry::instance().variant(this->arg(i_arg)); + = FacetRegistry::instance().variant(args_[i_arg]); if (!pps->print_upto(refrtag(concat("arg", 1+i_arg), arg_i))) return false; @@ -78,13 +110,14 @@ namespace xo { pps->newline_indent(ppii.ci1()); pps->pretty(refrtag("fn", fn)); - for (size_t i_arg = 0, n_arg = this->n_arg(); i_arg < n_arg; ++i_arg) { + for (size_t i_arg = 0; i_arg < n_args_; ++i_arg) { obj arg_i - = FacetRegistry::instance().variant(fn_); + = FacetRegistry::instance().variant(args_[i_arg]); pps->newline_indent(ppii.ci1()); pps->pretty(refrtag(concat("arg", 1+i_arg), arg_i)); } + return false; } } diff --git a/src/expression2/IExpression_DApplyExpr.cpp b/src/expression2/IExpression_DApplyExpr.cpp new file mode 100644 index 00000000..2098e050 --- /dev/null +++ b/src/expression2/IExpression_DApplyExpr.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DApplyExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DApplyExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DApplyExpr.json5] +**/ + +#include "detail/IExpression_DApplyExpr.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DApplyExpr::extype(const DApplyExpr & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DApplyExpr::typeref(const DApplyExpr & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DApplyExpr::valuetype(const DApplyExpr & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DApplyExpr::assign_valuetype(DApplyExpr & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DApplyExpr.cpp */ \ No newline at end of file diff --git a/src/expression2/IPrintable_DApplyExpr.cpp b/src/expression2/IPrintable_DApplyExpr.cpp new file mode 100644 index 00000000..4f4a50d3 --- /dev/null +++ b/src/expression2/IPrintable_DApplyExpr.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DApplyExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DApplyExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DApplyExpr.json5] +**/ + +#include "detail/IPrintable_DApplyExpr.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DApplyExpr::pretty(const DApplyExpr & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DApplyExpr.cpp */ \ No newline at end of file diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 1854f3eb..fc6ef3c1 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -17,6 +17,9 @@ #include #include +#include +#include + #include #include #include @@ -40,7 +43,8 @@ namespace xo { // Expression // +- Constant // +- Variable - // \- DefineExpr + // +- DefineExpr + // \- ApplyExpr FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -51,10 +55,14 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + log && log(xtag("DUniqueString.tseq", typeseq::id())); log && log(xtag("DDefineExpr.tseq", typeseq::id())); log && log(xtag("DVariable.tseq", typeseq::id())); log && log(xtag("DConstant.tseq", typeseq::id())); + log && log(xtag("DApplyExpr.tseq", typeseq::id())); log && log(xtag("AExpression.tqseq", typeseq::id())); From 6dcf43e3acc044f5da48c7f7e5e41a8a66f758f6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 26 Jan 2026 15:33:58 -0500 Subject: [PATCH 036/128] xo-expression2: + DConstant utest --- include/xo/expression2/DConstant.hpp | 12 +- src/expression2/DConstant.cpp | 11 +- utest/CMakeLists.txt | 1 + utest/DConstant.test.cpp | 232 +++++++++++++++++++++++++++ 4 files changed, 253 insertions(+), 3 deletions(-) create mode 100644 utest/DConstant.test.cpp diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp index 81561e68..50f0e38f 100644 --- a/include/xo/expression2/DConstant.hpp +++ b/include/xo/expression2/DConstant.hpp @@ -5,6 +5,7 @@ #pragma once +#include "Expression.hpp" #include "TypeRef.hpp" #include "exprtype.hpp" #include @@ -27,12 +28,19 @@ namespace xo { public: explicit DConstant(obj value) noexcept; + /** create isntance + * @p mm memory allocator + * @p value literal constant + **/ + static obj make(obj mm, + obj value); + /** create instance * @p mm memory allocator * @p value literal constant **/ - static DConstant * make(obj mm, - obj value); + static DConstant * _make(obj mm, + obj value); bool is_resolved() const noexcept { return typeref_.is_resolved(); } diff --git a/src/expression2/DConstant.cpp b/src/expression2/DConstant.cpp index f65ba013..f03fe625 100644 --- a/src/expression2/DConstant.cpp +++ b/src/expression2/DConstant.cpp @@ -4,10 +4,12 @@ **/ #include "DConstant.hpp" +#include "detail/IExpression_DConstant.hpp" #include "TypeDescr.hpp" #include #include #include +#include #include #include #include @@ -38,9 +40,16 @@ namespace xo { } } - DConstant * + obj DConstant::make(obj mm, obj value) + { + return obj(_make(mm, value)); + } + + DConstant * + DConstant::_make(obj mm, + obj value) { void * mem = mm.alloc(typeseq::id(), sizeof(DConstant)); diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index 2b8bceec..aefc8c8c 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -5,6 +5,7 @@ set(UTEST_SRCS expression2_utest_main.cpp StringTable.test.cpp X1Collector.test.cpp + DConstant.test.cpp ) xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) diff --git a/utest/DConstant.test.cpp b/utest/DConstant.test.cpp new file mode 100644 index 00000000..ddff5b20 --- /dev/null +++ b/utest/DConstant.test.cpp @@ -0,0 +1,232 @@ +/** @file DConstant.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_expression2.hpp" +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include + +namespace ut { + using xo::S_expression2_tag; + using xo::scm::DConstant; + using xo::scm::DFloat; + using xo::scm::DInteger; + using xo::scm::AExpression; + using xo::mm::CollectorTypeRegistry; + using xo::mm::AAllocator; + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::mm::DX1Collector; + using xo::mm::CollectorConfig; + using xo::mm::ArenaConfig; + using xo::print::APrintable; + using xo::print::ppstate_standalone; + using xo::print::ppconfig; + using xo::facet::FacetRegistry; + using xo::facet::with_facet; + using xo::facet::obj; + using xo::facet::typeseq; + using xo::reflect::Reflect; + using xo::InitEvidence; + using xo::InitSubsys; + using xo::scope; + + // Ensure subsystem initialized before tests + static InitEvidence s_init = InitSubsys::require(); + + TEST_CASE("DConstant-init", "[expression2][DConstant]") + { + // Verify subsystem initialization succeeded + REQUIRE(s_init.evidence()); + } + + TEST_CASE("DConstant-from-float", "[expression2][DConstant]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dconstant_float_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + // Box a float value + obj fval = DFloat::box(alloc, 3.14); + REQUIRE(fval.data() != nullptr); + + // Create DConstant from the boxed float + auto expr = DConstant::make(alloc, fval); + REQUIRE(expr.data() != nullptr); + + // Verify expression type + REQUIRE(expr.data()->extype() == xo::scm::exprtype::constant); + + // Verify valuetype is double (DFloat::value_type) + REQUIRE(expr.data()->valuetype() == Reflect::require()); + + // Verify value is accessible + REQUIRE(expr.data()->value().data() != nullptr); + } + + TEST_CASE("DConstant-from-integer", "[expression2][DConstant]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dconstant_int_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + // Box an integer value + obj ival = DInteger::box(alloc, 42); + REQUIRE(ival.data() != nullptr); + + // Create DConstant from the boxed integer + auto expr = DConstant::make(alloc, ival); + REQUIRE(expr.data() != nullptr); + + // Verify expression type + REQUIRE(expr.data()->extype() == xo::scm::exprtype::constant); + + // Verify valuetype is long (DInteger::value_type) + REQUIRE(expr.data()->valuetype() == Reflect::require()); + + // Verify value is accessible + REQUIRE(expr.data()->value().data() != nullptr); + } + + TEST_CASE("DConstant-pretty-float", "[expression2][DConstant][pp]") + { + scope log(XO_DEBUG(true)); + + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dconstant_pp_float_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + // Box a float value + obj fval = DFloat::box(alloc, 2.718); + auto expr = DConstant::make(alloc, fval); + REQUIRE(expr.data() != nullptr); + + // Pretty print + std::stringstream ss; + ppconfig ppc; + ppstate_standalone pps(&ss, 0, &ppc); + + obj expr_pr(expr.data()); + pps.pretty(expr_pr); + + std::string output = ss.str(); + + log && log(output); + + // Output should contain "DConstant" struct name + CHECK(output.find("DConstant") != std::string::npos); + } + + TEST_CASE("DConstant-pretty-integer", "[expression2][DConstant][pp]") + { + scope log(XO_DEBUG(false)); + + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dconstant_pp_int_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + // Box an integer value + obj ival = DInteger::box(alloc, 123); + auto expr = DConstant::make(alloc, ival); + REQUIRE(expr.data() != nullptr); + + // Pretty print + std::stringstream ss; + ppconfig ppc; + ppstate_standalone pps(&ss, 0, &ppc); + + obj expr_pr(expr.data()); + pps.pretty(expr_pr); + + std::string output = ss.str(); + + log && log(output); + + // Output should contain "DConstant" struct name + CHECK(output.find("DConstant") != std::string::npos); + } +} + +/* end DConstant.test.cpp */ From 78e3d2819623001716e58ed9ea006a281702add1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 26 Jan 2026 15:45:40 -0500 Subject: [PATCH 037/128] xo-expression2: + DApplyExpr::make --- src/expression2/DApplyExpr.cpp | 32 ++++++++++++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/src/expression2/DApplyExpr.cpp b/src/expression2/DApplyExpr.cpp index ce5e1951..ffc6372a 100644 --- a/src/expression2/DApplyExpr.cpp +++ b/src/expression2/DApplyExpr.cpp @@ -3,8 +3,9 @@ * @author Roland Conybeare, Jan 2026 **/ -#include "DApplyExpr.hpp" #include "Expression.hpp" +#include "DApplyExpr.hpp" +#include "detail/IExpression_DApplyExpr.hpp" #include #include @@ -15,7 +16,34 @@ namespace xo { using xo::mm::AGCObject; namespace scm { - /* incomplete! */ + obj + DApplyExpr::make2(obj mm, + TypeRef typeref, + obj fn_expr, + obj arg1, + obj arg2) + { + return obj + (DApplyExpr::_make2(mm, typeref, fn_expr, arg1, arg2)); + } + + DApplyExpr * + DApplyExpr::_make2(obj mm, + TypeRef typeref, + obj fn_expr, + obj arg1, + obj arg2) + { + DApplyExpr * result + = DApplyExpr::scaffold(mm, typeref, fn_expr, 2 /*n_args*/); + + result->assign_arg(0, arg1); + result->assign_arg(1, arg2); + + return result; + } + + /* incomplete, in the sense that does not populate args_[] */ DApplyExpr::DApplyExpr(TypeRef typeref, obj fn_expr, size_type n_args) : typeref_{typeref}, From 8366dc62a1e2c0ea9141c5aedc5d1bb49f5a74fc Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 26 Jan 2026 16:05:37 -0500 Subject: [PATCH 038/128] init dep handling for xo-expression2 -> xo-procedure2 --- cmake/xo_expression2Config.cmake.in | 2 +- src/expression2/CMakeLists.txt | 2 +- src/expression2/init_expression2.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/xo_expression2Config.cmake.in b/cmake/xo_expression2Config.cmake.in index c8cfbcad..15ff18ff 100644 --- a/cmake/xo_expression2Config.cmake.in +++ b/cmake/xo_expression2Config.cmake.in @@ -8,7 +8,7 @@ include(CMakeFindDependencyMacro) # find_dependency(xo_gc) find_dependency(reflect) -find_dependency(xo_object2) +find_dependency(xo_procedure2) find_dependency(xo_printable2) find_dependency(xo_flatstring) find_dependency(cmake) diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index b8be9468..7a7013de 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -44,7 +44,7 @@ xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 $ # note: deps here must also appear in cmake/xo_expression2Config.cmake.in xo_dependency(${SELF_LIB} xo_gc) xo_dependency(${SELF_LIB} reflect) -xo_dependency(${SELF_LIB} xo_object2) +xo_dependency(${SELF_LIB} xo_procedure2) xo_dependency(${SELF_LIB} xo_printable2) xo_dependency(${SELF_LIB} xo_flatstring) xo_dependency(${SELF_LIB} subsys) diff --git a/src/expression2/init_expression2.cpp b/src/expression2/init_expression2.cpp index e975ef99..1ee5ec9e 100644 --- a/src/expression2/init_expression2.cpp +++ b/src/expression2/init_expression2.cpp @@ -7,7 +7,7 @@ #include "expression2_register_facets.hpp" #include "expression2_register_types.hpp" -#include +#include #include namespace xo { @@ -29,7 +29,7 @@ namespace xo { InitEvidence retval; /* direct subsystem deps for xo-object2/ */ - retval ^= InitSubsys::require(); + retval ^= InitSubsys::require(); /* xo-expression2/'s own initialization code */ retval ^= Subsystem::provide("expression2", &init); From 09850306adc42906380a123436a31d4eff7884fb Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 26 Jan 2026 17:26:42 -0500 Subject: [PATCH 039/128] xo-expression2: + DVariable utest --- utest/CMakeLists.txt | 1 + utest/DVariable.test.cpp | 227 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 228 insertions(+) create mode 100644 utest/DVariable.test.cpp diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index aefc8c8c..687c75ab 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -6,6 +6,7 @@ set(UTEST_SRCS StringTable.test.cpp X1Collector.test.cpp DConstant.test.cpp + DVariable.test.cpp ) xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) diff --git a/utest/DVariable.test.cpp b/utest/DVariable.test.cpp new file mode 100644 index 00000000..8afee360 --- /dev/null +++ b/utest/DVariable.test.cpp @@ -0,0 +1,227 @@ +/** @file DVariable.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_expression2.hpp" +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include +#include + +namespace ut { + using xo::S_expression2_tag; + using xo::scm::DVariable; + using xo::scm::DUniqueString; + using xo::scm::StringTable; + using xo::scm::TypeRef; + using xo::scm::Binding; + using xo::scm::AExpression; + using xo::mm::CollectorTypeRegistry; + using xo::mm::AAllocator; + using xo::mm::ACollector; + using xo::mm::DX1Collector; + using xo::mm::CollectorConfig; + using xo::mm::ArenaConfig; + using xo::print::APrintable; + using xo::print::ppstate_standalone; + using xo::print::ppconfig; + using xo::facet::FacetRegistry; + using xo::facet::with_facet; + using xo::facet::obj; + using xo::reflect::Reflect; + using xo::InitEvidence; + using xo::InitSubsys; + using xo::scope; + + static InitEvidence s_init = InitSubsys::require(); + + TEST_CASE("DVariable-init", "[expression2][DVariable]") + { + REQUIRE(s_init.evidence()); + } + + TEST_CASE("DVariable-make", "[expression2][DVariable]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dvariable_make_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("x"); + REQUIRE(name != nullptr); + + TypeRef typeref = TypeRef::resolved(Reflect::require()); + + DVariable * var = DVariable::make(alloc, name, typeref); + REQUIRE(var != nullptr); + } + + TEST_CASE("DVariable-extype", "[expression2][DVariable]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dvariable_extype_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("y"); + TypeRef typeref = TypeRef::resolved(Reflect::require()); + + DVariable * var = DVariable::make(alloc, name, typeref); + REQUIRE(var != nullptr); + REQUIRE(var->extype() == xo::scm::exprtype::variable); + } + + TEST_CASE("DVariable-valuetype", "[expression2][DVariable]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dvariable_valuetype_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("z"); + TypeRef typeref = TypeRef::resolved(Reflect::require()); + + DVariable * var = DVariable::make(alloc, name, typeref); + REQUIRE(var != nullptr); + REQUIRE(var->valuetype() == Reflect::require()); + } + + TEST_CASE("DVariable-name", "[expression2][DVariable]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dvariable_name_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("myvar"); + TypeRef typeref = TypeRef::resolved(Reflect::require()); + + DVariable * var = DVariable::make(alloc, name, typeref); + REQUIRE(var != nullptr); + REQUIRE(var->name() == name); + REQUIRE(std::strcmp(var->name()->chars(), "myvar") == 0); + } + + TEST_CASE("DVariable-pretty", "[expression2][DVariable][pp]") + { + scope log(XO_DEBUG(false)); + + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dvariable_pretty_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("foo"); + TypeRef typeref = TypeRef::resolved(Reflect::require()); + + DVariable * var = DVariable::make(alloc, name, typeref); + REQUIRE(var != nullptr); + + std::stringstream ss; + ppconfig ppc; + ppstate_standalone pps(&ss, 0, &ppc); + + obj var_pr(var); + pps.pretty(var_pr); + + std::string output = ss.str(); + + log && log(output); + + CHECK(output.find("DVariable") != std::string::npos); + } +} + +/* end DVariable.test.cpp */ From 772bbc1b6514a29934cfbd49f8d0d5a132dfc17c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 26 Jan 2026 18:15:44 -0500 Subject: [PATCH 040/128] xo-expression2: utest for DApplyExpr --- utest/CMakeLists.txt | 1 + utest/DApplyExpr.test.cpp | 309 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 310 insertions(+) create mode 100644 utest/DApplyExpr.test.cpp diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index 687c75ab..b1662736 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -7,6 +7,7 @@ set(UTEST_SRCS X1Collector.test.cpp DConstant.test.cpp DVariable.test.cpp + DApplyExpr.test.cpp ) xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) diff --git a/utest/DApplyExpr.test.cpp b/utest/DApplyExpr.test.cpp new file mode 100644 index 00000000..d151b776 --- /dev/null +++ b/utest/DApplyExpr.test.cpp @@ -0,0 +1,309 @@ +/** @file DApplyExpr.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_expression2.hpp" +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include + +namespace ut { + using xo::S_expression2_tag; + using xo::scm::DApplyExpr; + using xo::scm::DConstant; + using xo::scm::DFloat; + using xo::scm::AExpression; + using xo::scm::TypeRef; + using xo::scm::Primitives; + using xo::scm::DPrimitive_gco_2_gco_gco; + using xo::mm::CollectorTypeRegistry; + using xo::mm::AAllocator; + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::mm::DX1Collector; + using xo::mm::CollectorConfig; + using xo::mm::ArenaConfig; + using xo::print::APrintable; + using xo::print::ppstate_standalone; + using xo::print::ppconfig; + using xo::facet::FacetRegistry; + using xo::facet::with_facet; + using xo::facet::obj; + using xo::reflect::Reflect; + using xo::InitEvidence; + using xo::InitSubsys; + using xo::scope; + + static InitEvidence s_init = InitSubsys::require(); + + TEST_CASE("DApplyExpr-init", "[expression2][DApplyExpr]") + { + REQUIRE(s_init.evidence()); + } + + TEST_CASE("DApplyExpr-make2", "[expression2][DApplyExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dapplyexpr_make2_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + // wrap primitive as GCObject, then as expression + obj prim_gco = with_facet::mkobj(&Primitives::s_mul_gco_gco_pm); + obj fn_expr = DConstant::make(alloc, prim_gco); + REQUIRE(fn_expr.data() != nullptr); + + // create argument expressions + obj val1 = DFloat::box(alloc, 3.0); + obj val2 = DFloat::box(alloc, 7.0); + obj arg1 = DConstant::make(alloc, val1); + obj arg2 = DConstant::make(alloc, val2); + REQUIRE(arg1.data() != nullptr); + REQUIRE(arg2.data() != nullptr); + + // create apply expression: mul(3.0, 7.0) + TypeRef result_type = TypeRef::resolved(Reflect::require()); + auto apply_expr = DApplyExpr::make2(alloc, result_type, fn_expr, arg1, arg2); + REQUIRE(apply_expr.data() != nullptr); + } + + TEST_CASE("DApplyExpr-extype", "[expression2][DApplyExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dapplyexpr_extype_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj prim_gco = with_facet::mkobj(&Primitives::s_mul_gco_gco_pm); + obj fn_expr = DConstant::make(alloc, prim_gco); + + obj val1 = DFloat::box(alloc, 3.0); + obj val2 = DFloat::box(alloc, 7.0); + obj arg1 = DConstant::make(alloc, val1); + obj arg2 = DConstant::make(alloc, val2); + + TypeRef result_type = TypeRef::resolved(Reflect::require()); + auto apply_expr = DApplyExpr::make2(alloc, result_type, fn_expr, arg1, arg2); + + REQUIRE(apply_expr.data()->extype() == xo::scm::exprtype::apply); + } + + TEST_CASE("DApplyExpr-n_args", "[expression2][DApplyExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dapplyexpr_n_args_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj prim_gco = with_facet::mkobj(&Primitives::s_mul_gco_gco_pm); + obj fn_expr = DConstant::make(alloc, prim_gco); + + obj val1 = DFloat::box(alloc, 3.0); + obj val2 = DFloat::box(alloc, 7.0); + obj arg1 = DConstant::make(alloc, val1); + obj arg2 = DConstant::make(alloc, val2); + + TypeRef result_type = TypeRef::resolved(Reflect::require()); + auto apply_expr = DApplyExpr::make2(alloc, result_type, fn_expr, arg1, arg2); + + REQUIRE(apply_expr.data()->n_args() == 2); + } + + TEST_CASE("DApplyExpr-fn", "[expression2][DApplyExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dapplyexpr_fn_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj prim_gco = with_facet::mkobj(&Primitives::s_mul_gco_gco_pm); + obj fn_expr = DConstant::make(alloc, prim_gco); + + obj val1 = DFloat::box(alloc, 3.0); + obj val2 = DFloat::box(alloc, 7.0); + obj arg1 = DConstant::make(alloc, val1); + obj arg2 = DConstant::make(alloc, val2); + + TypeRef result_type = TypeRef::resolved(Reflect::require()); + auto apply_expr = DApplyExpr::make2(alloc, result_type, fn_expr, arg1, arg2); + + // verify fn() returns an expression + obj fn = apply_expr.data()->fn(); + REQUIRE(fn.data() != nullptr); + REQUIRE(fn.extype() == xo::scm::exprtype::constant); + } + + TEST_CASE("DApplyExpr-arg", "[expression2][DApplyExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dapplyexpr_arg_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj prim_gco = with_facet::mkobj(&Primitives::s_mul_gco_gco_pm); + obj fn_expr = DConstant::make(alloc, prim_gco); + + obj val1 = DFloat::box(alloc, 3.0); + obj val2 = DFloat::box(alloc, 7.0); + obj arg1 = DConstant::make(alloc, val1); + obj arg2 = DConstant::make(alloc, val2); + + TypeRef result_type = TypeRef::resolved(Reflect::require()); + auto apply_expr = DApplyExpr::make2(alloc, result_type, fn_expr, arg1, arg2); + + // verify arg(0) and arg(1) return expressions + obj a0 = apply_expr.data()->arg(0); + obj a1 = apply_expr.data()->arg(1); + + REQUIRE(a0.data() != nullptr); + REQUIRE(a1.data() != nullptr); + REQUIRE(a0.extype() == xo::scm::exprtype::constant); + REQUIRE(a1.extype() == xo::scm::exprtype::constant); + } + + TEST_CASE("DApplyExpr-pretty", "[expression2][DApplyExpr][pp]") + { + scope log(XO_DEBUG(false)); + + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "dapplyexpr_pretty_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj prim_gco = with_facet::mkobj(&Primitives::s_mul_gco_gco_pm); + obj fn_expr = DConstant::make(alloc, prim_gco); + + obj val1 = DFloat::box(alloc, 3.0); + obj val2 = DFloat::box(alloc, 7.0); + obj arg1 = DConstant::make(alloc, val1); + obj arg2 = DConstant::make(alloc, val2); + + TypeRef result_type = TypeRef::resolved(Reflect::require()); + auto apply_expr = DApplyExpr::make2(alloc, result_type, fn_expr, arg1, arg2); + + std::stringstream ss; + ppconfig ppc; + ppstate_standalone pps(&ss, 0, &ppc); + + obj expr_pr(apply_expr.data()); + pps.pretty(expr_pr); + + std::string output = ss.str(); + + log && log(output); + + CHECK(output.find("ApplyExpr") != std::string::npos); + } +} + +/* end DApplyExpr.test.cpp */ From 37283140ab79c5636e2b03bdffb1a03f2b06b6a5 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 26 Jan 2026 20:25:24 -0500 Subject: [PATCH 041/128] xo-expression2: + utest for DDefineExpr --- utest/CMakeLists.txt | 1 + utest/DDefineExpr.test.cpp | 317 +++++++++++++++++++++++++++++++++++++ 2 files changed, 318 insertions(+) create mode 100644 utest/DDefineExpr.test.cpp diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index b1662736..f464708e 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -8,6 +8,7 @@ set(UTEST_SRCS DConstant.test.cpp DVariable.test.cpp DApplyExpr.test.cpp + DDefineExpr.test.cpp ) xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) diff --git a/utest/DDefineExpr.test.cpp b/utest/DDefineExpr.test.cpp new file mode 100644 index 00000000..5bb91582 --- /dev/null +++ b/utest/DDefineExpr.test.cpp @@ -0,0 +1,317 @@ +/** @file DDefineExpr.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_expression2.hpp" +#include +#include +#include +#include +#include +#include + +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include +#include + +namespace ut { + using xo::S_expression2_tag; + using xo::scm::DDefineExpr; + using xo::scm::DConstant; + using xo::scm::DFloat; + using xo::scm::DVariable; + using xo::scm::DUniqueString; + using xo::scm::StringTable; + using xo::scm::AExpression; + using xo::mm::CollectorTypeRegistry; + using xo::mm::AAllocator; + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::mm::DX1Collector; + using xo::mm::CollectorConfig; + using xo::mm::ArenaConfig; + using xo::print::APrintable; + using xo::print::ppstate_standalone; + using xo::print::ppconfig; + using xo::facet::FacetRegistry; + using xo::facet::with_facet; + using xo::facet::obj; + using xo::reflect::Reflect; + using xo::InitEvidence; + using xo::InitSubsys; + using xo::scope; + + static InitEvidence s_init = InitSubsys::require(); + + TEST_CASE("DDefineExpr-init", "[expression2][DDefineExpr]") + { + REQUIRE(s_init.evidence()); + } + + TEST_CASE("DDefineExpr-make", "[expression2][DDefineExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "ddefineexpr_make_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("x"); + REQUIRE(name != nullptr); + + // Create rhs expression: constant 42.0 + obj fval = DFloat::box(alloc, 42.0); + auto rhs_expr = DConstant::make(alloc, fval); + REQUIRE(rhs_expr.data() != nullptr); + + // Create define expression: def x = 42.0 + DDefineExpr * def = DDefineExpr::make(alloc, name, rhs_expr); + REQUIRE(def != nullptr); + } + + TEST_CASE("DDefineExpr-lhs", "[expression2][DDefineExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "ddefineexpr_lhs_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("myvar"); + + obj fval = DFloat::box(alloc, 3.14); + auto rhs_expr = DConstant::make(alloc, fval); + + DDefineExpr * def = DDefineExpr::make(alloc, name, rhs_expr); + REQUIRE(def != nullptr); + + DVariable * lhs = def->lhs(); + REQUIRE(lhs != nullptr); + REQUIRE(lhs->name() == name); + } + + TEST_CASE("DDefineExpr-rhs", "[expression2][DDefineExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "ddefineexpr_rhs_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("y"); + + obj fval = DFloat::box(alloc, 2.718); + auto rhs_expr = DConstant::make(alloc, fval); + + DDefineExpr * def = DDefineExpr::make(alloc, name, rhs_expr); + REQUIRE(def != nullptr); + + obj rhs = def->rhs(); + REQUIRE(rhs.data() != nullptr); + // Verify rhs expression type is constant + REQUIRE(rhs.extype() == xo::scm::exprtype::constant); + } + + TEST_CASE("DDefineExpr-name", "[expression2][DDefineExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "ddefineexpr_name_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("foo"); + + obj fval = DFloat::box(alloc, 1.0); + auto rhs_expr = DConstant::make(alloc, fval); + + DDefineExpr * def = DDefineExpr::make(alloc, name, rhs_expr); + REQUIRE(def != nullptr); + REQUIRE(def->name() == name); + REQUIRE(std::strcmp(def->name()->chars(), "foo") == 0); + } + + TEST_CASE("DDefineExpr-extype", "[expression2][DDefineExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "ddefineexpr_extype_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("z"); + + obj fval = DFloat::box(alloc, 0.0); + auto rhs_expr = DConstant::make(alloc, fval); + + DDefineExpr * def = DDefineExpr::make(alloc, name, rhs_expr); + REQUIRE(def != nullptr); + REQUIRE(def->extype() == xo::scm::exprtype::define); + } + + TEST_CASE("DDefineExpr-valuetype", "[expression2][DDefineExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "ddefineexpr_valuetype_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("w"); + + obj fval = DFloat::box(alloc, 99.9); + auto rhs_expr = DConstant::make(alloc, fval); + + DDefineExpr * def = DDefineExpr::make(alloc, name, rhs_expr); + REQUIRE(def != nullptr); + REQUIRE(def->valuetype() == Reflect::require()); + } + + TEST_CASE("DDefineExpr-pretty", "[expression2][DDefineExpr][pp]") + { + scope log(XO_DEBUG(true)); + + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "ddefineexpr_pretty_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + StringTable table(1024); + const DUniqueString * name = table.intern("bar"); + + obj fval = DFloat::box(alloc, 123.456); + auto rhs_expr = DConstant::make(alloc, fval); + + DDefineExpr * def = DDefineExpr::make(alloc, name, rhs_expr); + REQUIRE(def != nullptr); + + std::stringstream ss; + ppconfig ppc; + ppstate_standalone pps(&ss, 0, &ppc); + + obj def_pr(def); + pps.pretty(def_pr); + + std::string output = ss.str(); + + log && log(output); + + CHECK(output.find("DDefineExpr") != std::string::npos); + } +} + +/* end DDefineExpr.test.cpp */ From 5033b65ef2cc2ee650716000dc5ba6a7406dde11 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 26 Jan 2026 21:36:10 -0500 Subject: [PATCH 042/128] xo-reader2: formatting + asserts --- src/expression2/DDefineExpr.cpp | 23 ++++++++++++++++++----- src/expression2/DVariable.cpp | 7 ++++--- src/expression2/TypeRef.cpp | 8 +++++--- 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index 47465c0e..ba2304ad 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -75,23 +75,36 @@ namespace xo { bool DDefineExpr::pretty(const ppindentinfo & ppii) const { + assert(lhs_var_); + auto lhs = obj(lhs_var_); auto rhs = FacetRegistry::instance().try_variant(rhs_); + if (lhs_var_) + assert(lhs.data()); + + (void)lhs; + (void)rhs; + + if (rhs_) + assert(rhs.data()); + // note: xo::print::cond() doesn't resolve the way we want here if (rhs) { return ppii.pps()->pretty_struct (ppii, - "DDefineExpr", - refrtag("lhs", lhs), - refrtag("rhs", rhs)); + "DDefineExpr" + , refrtag("lhs", lhs) + , refrtag("rhs", rhs) + ); } else { return ppii.pps()->pretty_struct (ppii, - "DDefineExpr", - refrtag("lhs", lhs)); + "DDefineExpr" + , refrtag("lhs", lhs) + ); } } diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index 4550a102..af47de00 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -47,9 +47,10 @@ namespace xo { return ppii.pps()->pretty_struct (ppii, - "DVariable", - refrtag("name", quot(name)), - refrtag("typeref", typeref_)); + "DVariable" + , refrtag("name", quot(name)) + , refrtag("typeref", typeref_) + ); } } /*namespace scm*/ diff --git a/src/expression2/TypeRef.cpp b/src/expression2/TypeRef.cpp index 01cb043c..5ff1d258 100644 --- a/src/expression2/TypeRef.cpp +++ b/src/expression2/TypeRef.cpp @@ -4,6 +4,7 @@ **/ #include "TypeRef.hpp" +#include #include #include @@ -71,9 +72,10 @@ namespace xo { return ppii.pps()->pretty_struct (ppii, - "TypeRef", - refrtag("id", quot(id_)), - refrtag("td", td_)); + "TypeRef" + , refrtag("id", quot(id_)) + , refrtag("td", cond(td_, td_, "null")) + ); } } /*namespace scm*/ From bbbcfd2c4b5ef20e9128805d727473e7e2ed79e3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 26 Jan 2026 21:36:38 -0500 Subject: [PATCH 043/128] xo-expression2: bugfix: init for TypeRef.td_ --- include/xo/expression2/TypeRef.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/xo/expression2/TypeRef.hpp b/include/xo/expression2/TypeRef.hpp index 7ec6e388..eecb438d 100644 --- a/include/xo/expression2/TypeRef.hpp +++ b/include/xo/expression2/TypeRef.hpp @@ -66,7 +66,7 @@ namespace xo { * May be null when this TypeRef created, * but expected to be immutable once established. **/ - TypeDescr td_; + TypeDescr td_ = nullptr; }; } /*namespace scm*/ From 0fcb548587af16eda8d9439cfea372e324b3f7f1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 27 Jan 2026 10:09:26 -0500 Subject: [PATCH 044/128] xo-expression2: + DIfElseExpr + utest --- CMakeLists.txt | 26 ++ idl/IExpression_DIfElseExpr.json5 | 12 + idl/IPrintable_DIfElseExpr.json5 | 13 + include/xo/expression2/DIfElseExpr.hpp | 230 ++++++++++++ .../detail/IExpression_DIfElseExpr.hpp | 66 ++++ .../detail/IPrintable_DIfElseExpr.hpp | 62 ++++ include/xo/expression2/exprtype.hpp | 2 +- src/expression2/CMakeLists.txt | 4 + src/expression2/DDefineExpr.cpp | 2 +- src/expression2/DIfElseExpr.cpp | 184 ++++++++++ src/expression2/IExpression_DIfElseExpr.cpp | 45 +++ src/expression2/IPrintable_DIfElseExpr.cpp | 28 ++ .../expression2_register_facets.cpp | 10 +- utest/CMakeLists.txt | 1 + utest/DIfElseExpr.test.cpp | 345 ++++++++++++++++++ 15 files changed, 1027 insertions(+), 3 deletions(-) create mode 100644 idl/IExpression_DIfElseExpr.json5 create mode 100644 idl/IPrintable_DIfElseExpr.json5 create mode 100644 include/xo/expression2/DIfElseExpr.hpp create mode 100644 include/xo/expression2/detail/IExpression_DIfElseExpr.hpp create mode 100644 include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp create mode 100644 src/expression2/DIfElseExpr.cpp create mode 100644 src/expression2/IExpression_DIfElseExpr.cpp create mode 100644 src/expression2/IPrintable_DIfElseExpr.cpp create mode 100644 utest/DIfElseExpr.test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 869f891d..5fc6d451 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,32 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-ifelseexpr + FACET_PKG xo_expression2 + FACET Expression + REPR IfElseExpr + INPUT idl/IExpression_DIfElseExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-ifelseexpr + FACET_PKG xo_printable2 + FACET Printable + REPR IfElseExpr + INPUT idl/IPrintable_DIfElseExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-uniquestring diff --git a/idl/IExpression_DIfElseExpr.json5 b/idl/IExpression_DIfElseExpr.json5 new file mode 100644 index 00000000..ed2fb1e8 --- /dev/null +++ b/idl/IExpression_DIfElseExpr.json5 @@ -0,0 +1,12 @@ +{ + mode: "implementation", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DIfElseExpr state", + using_doxygen: true, + repr: "DIfElseExpr", + doc: ["doc for IExpression+DIfElseExpr" ], +} diff --git a/idl/IPrintable_DIfElseExpr.json5 b/idl/IPrintable_DIfElseExpr.json5 new file mode 100644 index 00000000..a8011385 --- /dev/null +++ b/idl/IPrintable_DIfElseExpr.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DIfElseExpr", + using_doxygen: true, + repr: "DIfElseExpr", + doc: [ "implement APrintable for DIfElseExpr" ], +} diff --git a/include/xo/expression2/DIfElseExpr.hpp b/include/xo/expression2/DIfElseExpr.hpp new file mode 100644 index 00000000..4a1107ca --- /dev/null +++ b/include/xo/expression2/DIfElseExpr.hpp @@ -0,0 +1,230 @@ +/** @file DIfElseExpr.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "Expression.hpp" +#include "TypeRef.hpp" +#include "exprtype.hpp" +#include +//#include +#include +//#include + +namespace xo { + namespace scm { + + /** @class DIfExpr + * @brief abstract syntax tree for a function definition + **/ + class DIfElseExpr { + public: + using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; + using ppindentinfo = xo::print::ppindentinfo; + + public: + /** @defgroup scm-ifelseexpr-constructors **/ + ///@{ + + /** + * @p ifexpr_type type for value produced by if-expression. + * same as both when_true->valuetype() and + * when_false->valuetype(). + * @p test test-expression; always execute + * @p when_true then-branch; executes only when test succeeds + * @p when_false else-branch; executes only when test fails + **/ + DIfElseExpr(TypeRef ifexpr_type, + obj test_expr, + obj when_true, + obj when_false); + + /** create if-else expression using memory from @p mm. + * @p when_false can be null + **/ + static obj make(obj mm, + obj test, + obj when_true, + obj when_false); + + /** create expression for conditional execution of + * @p when_true or @p when_false, depending on result + * of evaluating expression @p test + **/ + static DIfElseExpr * _make(obj mm, + obj test, + obj when_true, + obj when_false); + + ///@} + /** @defgroup scm-ifelseexpr-access-methods **/ + ///@{ + + obj test() const noexcept { return test_; } + obj when_true() const noexcept { return when_true_; } + obj when_false() const noexcept { return when_false_; } + + ///@} + /** @defgroup scm-ifelseexpr-expression-facet **/ + ///@{ + + exprtype extype() const noexcept { return exprtype::ifexpr; } + TypeRef typeref() const noexcept { return typeref_; } + TypeDescr valuetype() const noexcept { return typeref_.td(); } + void assign_valuetype(TypeDescr td) noexcept; + + ///@} + /** @defgroup scm-ifelseexpr-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + +#ifdef NOT_YET + virtual std::set get_free_variables() const override { + std::set retval = test_->get_free_variables(); + + std::set free_vars; + free_vars = when_true_->get_free_variables(); + for (const auto & s : free_vars) + retval.insert(s); + + free_vars = when_false_->get_free_variables(); + for (const auto & s : free_vars) + retval.insert(s); + + return retval; + } + + virtual std::size_t visit_preorder(VisitFn visitor_fn) override { + std::size_t n = 1; + + visitor_fn(this); + + n += this->test_->visit_preorder(visitor_fn); + n += this->when_true_->visit_preorder(visitor_fn); + n += this->when_false_->visit_preorder(visitor_fn); + + return n; + } + + virtual std::size_t visit_layer(VisitFn visitor_fn) override { + std::size_t n = 1; + + visitor_fn(this); + + n += this->test_->visit_layer(visitor_fn); + n += this->when_true_->visit_layer(visitor_fn); + n += this->when_false_->visit_layer(visitor_fn); + + return n; + } + + virtual rp xform_layer(TransformFn xform_fn) override { + this->test_ = this->test_->xform_layer(xform_fn); + this->when_true_ = this->when_true_->xform_layer(xform_fn); + this->when_false_= this->when_false_->xform_layer(xform_fn); + + return xform_fn(this); + } + + virtual void attach_envs(bp p) override { + test_->attach_envs(p); + when_true_->attach_envs(p); + when_false_->attach_envs(p); + } +#endif + +#ifdef NOT_USING + virtual std::int32_t find_free_vars(std::set> * p_set) override { + return (test_->find_free_vars(p_set) + + when_true_->find_free_vars(p_set) + + when_false_->find_free_vars(p_set)); + } +#endif + +#ifdef NOPE + virtual void display(std::ostream & os) const override; + virtual std::uint32_t pretty_print(const ppindentinfo & ppi) const override; +#endif + + protected: +#ifdef NOT_YET + /** + * @p ifexpr_type type for value produced by if-expression. + * same as both when_true->valuetype() and + * when_false->valuetype(). + * @p test test-expression; always execute + * @p when_true then-branch; executes only when test succeeds + * @p when_false else-branch; executes only when test fails + **/ + IfExpr(TypeDescr ifexpr_type, + rp test, + rp when_true, + rp when_false) + : Expression(exprtype::ifexpr, ifexpr_type), + test_{std::move(test)}, + when_true_{std::move(when_true)}, + when_false_{std::move(when_false)} {} + + static TypeDescr check_consistent_valuetype(const rp & when_true, + const rp & when_false); + + /** determine if-expr valuetype **/ + void establish_valuetype(); +#endif + + private: + /** expression value always has type consistent + * with this description + **/ + TypeRef typeref_; + /** if: + * (if x y z) + * + * executes x; if true execute y; otherwise execute z + **/ + obj test_; + obj when_true_; + obj when_false_; + }; /*IfExpr*/ + +#ifdef NOPE + inline rp + make_ifexpr(const rp & test, + const rp & when_true, + const rp & when_false) + { + return IfExpr::make(test, when_true, when_false); + } + + class IfExprAccess : public IfExpr { + public: + static rp make(rp test, + rp when_true, + rp when_false); + static rp make_empty(); + + void assign_test(rp x) { test_ = std::move(x); } + void assign_when_true(rp x); + void assign_when_false(rp x); + + private: + IfExprAccess(TypeDescr ifexpr_type, + rp test, + rp when_true, + rp when_false) + : IfExpr(ifexpr_type, + std::move(test), + std::move(when_true), + std::move(when_false)) {} + }; +#endif + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DIfElseExpr.hpp */ diff --git a/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp b/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp new file mode 100644 index 00000000..03500a39 --- /dev/null +++ b/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DIfElseExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DIfElseExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DIfElseExpr.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DIfElseExpr.hpp" + +namespace xo { namespace scm { class IExpression_DIfElseExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DIfElseExpr + **/ + class IExpression_DIfElseExpr { + public: + /** @defgroup scm-expression-difelseexpr-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-difelseexpr-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DIfElseExpr & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DIfElseExpr & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DIfElseExpr & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DIfElseExpr & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp b/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp new file mode 100644 index 00000000..e9cf67ff --- /dev/null +++ b/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DIfElseExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DIfElseExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DIfElseExpr.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DIfElseExpr.hpp" + +namespace xo { namespace scm { class IPrintable_DIfElseExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DIfElseExpr + **/ + class IPrintable_DIfElseExpr { + public: + /** @defgroup scm-printable-difelseexpr-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-difelseexpr-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DIfElseExpr & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/exprtype.hpp b/include/xo/expression2/exprtype.hpp index df4e3be6..952051be 100644 --- a/include/xo/expression2/exprtype.hpp +++ b/include/xo/expression2/exprtype.hpp @@ -38,9 +38,9 @@ namespace xo { #endif /** variable reference **/ variable, -#ifdef NOT_YET /** if-then-else **/ ifexpr, +#ifdef NOT_YET /** sequence **/ sequence, /** type conversion **/ diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 7a7013de..840e7070 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -8,6 +8,7 @@ set(SELF_SRCS DVariable.cpp DDefineExpr.cpp DApplyExpr.cpp + DIfElseExpr.cpp TypeRef.cpp @@ -25,6 +26,9 @@ set(SELF_SRCS IExpression_DApplyExpr.cpp IPrintable_DApplyExpr.cpp + IExpression_DIfElseExpr.cpp + IPrintable_DIfElseExpr.cpp + DLocalSymtab.cpp DGlobalSymtab.cpp diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index ba2304ad..961fbecc 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -1,5 +1,5 @@ /** @file DDefineExpr.cpp -* + * * @author Roland Conybeare, Jan 2026 **/ diff --git a/src/expression2/DIfElseExpr.cpp b/src/expression2/DIfElseExpr.cpp new file mode 100644 index 00000000..0e18114e --- /dev/null +++ b/src/expression2/DIfElseExpr.cpp @@ -0,0 +1,184 @@ +/** @file DIfElseExpr.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DIfElseExpr.hpp" +#include "detail/IExpression_DIfElseExpr.hpp" +#include +#include +#include + +namespace xo { + using xo::print::APrintable; + using xo::reflect::typeseq; + using xo::facet::FacetRegistry; + + namespace scm { + DIfElseExpr::DIfElseExpr(TypeRef ifexpr_tref, + obj test_expr, + obj when_true, + obj when_false) + : typeref_{ifexpr_tref}, + test_{test_expr}, + when_true_{when_true}, + when_false_{when_false} + {} + + obj + DIfElseExpr::make(obj mm, + obj test, + obj when_true, + obj when_false) + { + return obj + (_make(mm, + test, when_true, when_false)); + } + + DIfElseExpr * + DIfElseExpr::_make(obj mm, + obj test, + obj when_true, + obj when_false) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DIfElseExpr)); + + // just crete typevar here, then rely on type checking + // later + + auto prefix = TypeRef::prefix_type::from_chars("if"); + TypeRef tref = TypeRef::dwim(prefix, nullptr); + + return new (mem) DIfElseExpr(tref, + test, + when_true, + when_false); + } + + void + DIfElseExpr::assign_valuetype(TypeDescr td) noexcept + { + typeref_.resolve(td); + } + + bool + DIfElseExpr::pretty(const ppindentinfo & ppii) const + { + auto test + = FacetRegistry::instance().try_variant(test_); + auto when_true + = FacetRegistry::instance().try_variant(when_true_); + auto when_false + = FacetRegistry::instance().try_variant(when_false_); + + + return ppii.pps()->pretty_struct + (ppii, + "DIfElseExpr", + refrtag("typeref", typeref_), + refrtag("test", test), + refrtag("when_true", when_true), + refrtag("when_false", when_false)); + } + + // ---------------------------------------------------------------- + +#ifdef NOPE + auto IfExpr::check_consistent_valuetype(const rp & when_true, + const rp & when_false) -> TypeDescr + { + if (when_true->valuetype() != when_false->valuetype()) + return nullptr; + + return when_true->valuetype(); + } + + void IfExpr::establish_valuetype() + { + if (this->when_true_.get() && this->when_false_.get()) + this->assign_valuetype(check_consistent_valuetype(this->when_true_, this->when_false_)); + } + + rp + IfExpr::make(const rp & test, + const rp & when_true, + const rp & when_false) + { + /** TODO: verify test returns _boolean_ type **/ + + if (when_true->valuetype() != when_false->valuetype()) { + throw std::runtime_error + (tostr("IfExpr::make:" + " types {T1,T2} found for branches of if-expr" + " where equal types expected", + xtag("T1", when_true->valuetype()->canonical_name()), + xtag("T2", when_false->valuetype()->canonical_name()))); + } + + /* arbitrary choice here */ + auto ifexpr_type = when_true->valuetype(); + + return new IfExpr(ifexpr_type, + test, + when_true, + when_false); + } /*make*/ + + void + IfExpr::display(std::ostream & os) const { + os << ""; + } /*display*/ + + std::uint32_t + IfExpr::pretty_print(const ppindentinfo & ppii) const { + return ppii.pps()->pretty_struct(ppii, "IfExpr", + refrtag("test", test_), + refrtag("when_true", when_true_), + refrtag("when_false", when_false_)); + } + + rp + IfExprAccess::make(rp test, + rp when_true, + rp when_false) + { + auto ifexpr_type = check_consistent_valuetype(when_true, when_false); + + return new IfExprAccess(ifexpr_type, std::move(test), std::move(when_true), std::move(when_false)); + } + + rp + IfExprAccess::make_empty() + { + return new IfExprAccess(nullptr /*ifexpr_valuetype*/, + nullptr /*test*/, + nullptr /*when_true*/, + nullptr /*when_false*/); + } + + void + IfExprAccess::assign_when_true(rp x) + { + this->when_true_ = std::move(x); + } + + void + IfExprAccess::assign_when_false(rp x) + { + this->when_false_ = std::move(x); + } +#endif + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DIfElseExpr.cpp */ diff --git a/src/expression2/IExpression_DIfElseExpr.cpp b/src/expression2/IExpression_DIfElseExpr.cpp new file mode 100644 index 00000000..78680310 --- /dev/null +++ b/src/expression2/IExpression_DIfElseExpr.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DIfElseExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DIfElseExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DIfElseExpr.json5] +**/ + +#include "detail/IExpression_DIfElseExpr.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DIfElseExpr::extype(const DIfElseExpr & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DIfElseExpr::typeref(const DIfElseExpr & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DIfElseExpr::valuetype(const DIfElseExpr & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DIfElseExpr::assign_valuetype(DIfElseExpr & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DIfElseExpr.cpp */ \ No newline at end of file diff --git a/src/expression2/IPrintable_DIfElseExpr.cpp b/src/expression2/IPrintable_DIfElseExpr.cpp new file mode 100644 index 00000000..ec68b9fc --- /dev/null +++ b/src/expression2/IPrintable_DIfElseExpr.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DIfElseExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DIfElseExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DIfElseExpr.json5] +**/ + +#include "detail/IPrintable_DIfElseExpr.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DIfElseExpr::pretty(const DIfElseExpr & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DIfElseExpr.cpp */ \ No newline at end of file diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index fc6ef3c1..8ab2ff51 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -20,6 +20,9 @@ #include #include +#include +#include + #include #include #include @@ -44,7 +47,8 @@ namespace xo { // +- Constant // +- Variable // +- DefineExpr - // \- ApplyExpr + // +- ApplyExpr + // \- IfElseExpr FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -58,11 +62,15 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + log && log(xtag("DUniqueString.tseq", typeseq::id())); log && log(xtag("DDefineExpr.tseq", typeseq::id())); log && log(xtag("DVariable.tseq", typeseq::id())); log && log(xtag("DConstant.tseq", typeseq::id())); log && log(xtag("DApplyExpr.tseq", typeseq::id())); + log && log(xtag("DIfElseExpr.tseq", typeseq::id())); log && log(xtag("AExpression.tqseq", typeseq::id())); diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index f464708e..deb1d25a 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -9,6 +9,7 @@ set(UTEST_SRCS DVariable.test.cpp DApplyExpr.test.cpp DDefineExpr.test.cpp + DIfElseExpr.test.cpp ) xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) diff --git a/utest/DIfElseExpr.test.cpp b/utest/DIfElseExpr.test.cpp new file mode 100644 index 00000000..a82521a0 --- /dev/null +++ b/utest/DIfElseExpr.test.cpp @@ -0,0 +1,345 @@ +/** @file DIfElseExpr.test.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "init_expression2.hpp" +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include +#include + +#include +#include +#include + +#include + +#include + +#include + +namespace ut { + using xo::S_expression2_tag; + using xo::scm::DIfElseExpr; + using xo::scm::DConstant; + using xo::scm::DFloat; + using xo::scm::DBoolean; + using xo::scm::AExpression; + using xo::mm::CollectorTypeRegistry; + using xo::mm::AAllocator; + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::mm::DX1Collector; + using xo::mm::CollectorConfig; + using xo::mm::ArenaConfig; + using xo::print::APrintable; + using xo::print::ppstate_standalone; + using xo::print::ppconfig; + using xo::facet::FacetRegistry; + using xo::facet::with_facet; + using xo::facet::obj; + using xo::reflect::Reflect; + using xo::InitEvidence; + using xo::InitSubsys; + using xo::scope; + + static InitEvidence s_init = InitSubsys::require(); + + TEST_CASE("DIfElseExpr-init", "[expression2][DIfElseExpr]") + { + REQUIRE(s_init.evidence()); + } + + TEST_CASE("DIfElseExpr-make", "[expression2][DIfElseExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "difelseexpr_make_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + // Create test expression: constant true + obj bval = DBoolean::box(alloc, true); + auto test_expr = DConstant::make(alloc, bval); + REQUIRE(test_expr.data() != nullptr); + + // Create when_true expression: constant 1.0 + obj fval1 = DFloat::box(alloc, 1.0); + auto when_true_expr = DConstant::make(alloc, fval1); + REQUIRE(when_true_expr.data() != nullptr); + + // Create when_false expression: constant 2.0 + obj fval2 = DFloat::box(alloc, 2.0); + auto when_false_expr = DConstant::make(alloc, fval2); + REQUIRE(when_false_expr.data() != nullptr); + + // Create if-else expression: if true then 1.0 else 2.0 + auto ifexpr = DIfElseExpr::make(alloc, test_expr, when_true_expr, when_false_expr); + REQUIRE(ifexpr.data() != nullptr); + } + + TEST_CASE("DIfElseExpr-test", "[expression2][DIfElseExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "difelseexpr_test_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj bval = DBoolean::box(alloc, true); + auto test_expr = DConstant::make(alloc, bval); + + obj fval1 = DFloat::box(alloc, 1.0); + auto when_true_expr = DConstant::make(alloc, fval1); + + obj fval2 = DFloat::box(alloc, 2.0); + auto when_false_expr = DConstant::make(alloc, fval2); + + auto ifexpr = DIfElseExpr::make(alloc, test_expr, when_true_expr, when_false_expr); + REQUIRE(ifexpr.data() != nullptr); + + obj test = ifexpr.data()->test(); + REQUIRE(test.data() != nullptr); + REQUIRE(test.extype() == xo::scm::exprtype::constant); + } + + TEST_CASE("DIfElseExpr-when-true", "[expression2][DIfElseExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "difelseexpr_when_true_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj bval = DBoolean::box(alloc, true); + auto test_expr = DConstant::make(alloc, bval); + + obj fval1 = DFloat::box(alloc, 1.0); + auto when_true_expr = DConstant::make(alloc, fval1); + + obj fval2 = DFloat::box(alloc, 2.0); + auto when_false_expr = DConstant::make(alloc, fval2); + + auto ifexpr = DIfElseExpr::make(alloc, test_expr, when_true_expr, when_false_expr); + REQUIRE(ifexpr.data() != nullptr); + + obj wt = ifexpr.data()->when_true(); + REQUIRE(wt.data() != nullptr); + REQUIRE(wt.extype() == xo::scm::exprtype::constant); + } + + TEST_CASE("DIfElseExpr-when-false", "[expression2][DIfElseExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "difelseexpr_when_false_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj bval = DBoolean::box(alloc, false); + auto test_expr = DConstant::make(alloc, bval); + + obj fval1 = DFloat::box(alloc, 1.0); + auto when_true_expr = DConstant::make(alloc, fval1); + + obj fval2 = DFloat::box(alloc, 2.0); + auto when_false_expr = DConstant::make(alloc, fval2); + + auto ifexpr = DIfElseExpr::make(alloc, test_expr, when_true_expr, when_false_expr); + REQUIRE(ifexpr.data() != nullptr); + + obj wf = ifexpr.data()->when_false(); + REQUIRE(wf.data() != nullptr); + REQUIRE(wf.extype() == xo::scm::exprtype::constant); + } + + TEST_CASE("DIfElseExpr-extype", "[expression2][DIfElseExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "difelseexpr_extype_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj bval = DBoolean::box(alloc, true); + auto test_expr = DConstant::make(alloc, bval); + + obj fval1 = DFloat::box(alloc, 1.0); + auto when_true_expr = DConstant::make(alloc, fval1); + + obj fval2 = DFloat::box(alloc, 2.0); + auto when_false_expr = DConstant::make(alloc, fval2); + + auto ifexpr = DIfElseExpr::make(alloc, test_expr, when_true_expr, when_false_expr); + REQUIRE(ifexpr.data() != nullptr); + REQUIRE(ifexpr.data()->extype() == xo::scm::exprtype::ifexpr); + } + + TEST_CASE("DIfElseExpr-valuetype", "[expression2][DIfElseExpr]") + { + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "difelseexpr_valuetype_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj bval = DBoolean::box(alloc, true); + auto test_expr = DConstant::make(alloc, bval); + + obj fval1 = DFloat::box(alloc, 1.0); + auto when_true_expr = DConstant::make(alloc, fval1); + + obj fval2 = DFloat::box(alloc, 2.0); + auto when_false_expr = DConstant::make(alloc, fval2); + + auto ifexpr = DIfElseExpr::make(alloc, test_expr, when_true_expr, when_false_expr); + REQUIRE(ifexpr.data() != nullptr); + + // valuetype may be null before type resolution + // just verify we can call it + ifexpr.data()->valuetype(); + } + + TEST_CASE("DIfElseExpr-pretty", "[expression2][DIfElseExpr][pp]") + { + scope log(XO_DEBUG(true)); + + REQUIRE(s_init.evidence()); + + CollectorConfig cfg{ + .name_ = "difelseexpr_pretty_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{4096, 4096}}, + .debug_flag_ = false, + }; + + DX1Collector gc(cfg); + auto alloc = with_facet::mkobj(&gc); + auto coll = with_facet::mkobj(&gc); + + bool ok = CollectorTypeRegistry::instance().install_types(coll); + REQUIRE(ok); + + obj bval = DBoolean::box(alloc, true); + auto test_expr = DConstant::make(alloc, bval); + + obj fval1 = DFloat::box(alloc, 1.0); + auto when_true_expr = DConstant::make(alloc, fval1); + + obj fval2 = DFloat::box(alloc, 2.0); + auto when_false_expr = DConstant::make(alloc, fval2); + + auto ifexpr = DIfElseExpr::make(alloc, + test_expr, + when_true_expr, when_false_expr); + REQUIRE(ifexpr.data() != nullptr); + + std::stringstream ss; + ppconfig ppc; + ppstate_standalone pps(&ss, 0, &ppc); + + obj ifexpr_pr(ifexpr.data()); + pps.pretty(ifexpr_pr); + + std::string output = ss.str(); + + log && log(output); + + CHECK(output.find("DIfElseExpr") != std::string::npos); + } +} + +/* end DIfElseExpr.test.cpp */ From a69023096d486afb38ea5beb35a61a13f1961529 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 27 Jan 2026 15:50:10 -0500 Subject: [PATCH 045/128] xo-reader2: support if-then-else expressions. + detailed utest --- include/xo/expression2/DIfElseExpr.hpp | 10 +++++ src/expression2/DIfElseExpr.cpp | 53 ++++++++++++++++++++++---- 2 files changed, 55 insertions(+), 8 deletions(-) diff --git a/include/xo/expression2/DIfElseExpr.hpp b/include/xo/expression2/DIfElseExpr.hpp index 4a1107ca..8222834a 100644 --- a/include/xo/expression2/DIfElseExpr.hpp +++ b/include/xo/expression2/DIfElseExpr.hpp @@ -59,6 +59,12 @@ namespace xo { obj when_true, obj when_false); + /** create empty if-else expression using memory from @p mm **/ + static obj make_empty(obj mm); + + /** create empty if-else expression using memory from @p mm **/ + static DIfElseExpr * _make_empty(obj mm); + ///@} /** @defgroup scm-ifelseexpr-access-methods **/ ///@{ @@ -67,6 +73,10 @@ namespace xo { obj when_true() const noexcept { return when_true_; } obj when_false() const noexcept { return when_false_; } + void assign_test(obj x) { this->test_ = x; } + void assign_when_true(obj x) { this->when_true_ = x; } + void assign_when_false(obj x) { this->when_false_ = x; } + ///@} /** @defgroup scm-ifelseexpr-expression-facet **/ ///@{ diff --git a/src/expression2/DIfElseExpr.cpp b/src/expression2/DIfElseExpr.cpp index 0e18114e..d858dfab 100644 --- a/src/expression2/DIfElseExpr.cpp +++ b/src/expression2/DIfElseExpr.cpp @@ -57,6 +57,21 @@ namespace xo { when_false); } + obj + DIfElseExpr::make_empty(obj mm) + { + return obj(_make_empty(mm)); + } + + DIfElseExpr * + DIfElseExpr::_make_empty(obj mm) + { + return _make(mm, + obj() /*test*/, + obj() /*when_true*/, + obj() /*when_false*/); + } + void DIfElseExpr::assign_valuetype(TypeDescr td) noexcept { @@ -76,14 +91,33 @@ namespace xo { = FacetRegistry::instance().try_variant(when_false_); - - return ppii.pps()->pretty_struct - (ppii, - "DIfElseExpr", - refrtag("typeref", typeref_), - refrtag("test", test), - refrtag("when_true", when_true), - refrtag("when_false", when_false)); + if (when_false) { + return ppii.pps()->pretty_struct + (ppii, + "DIfElseExpr", + refrtag("typeref", typeref_), + refrtag("test", test), + refrtag("when_true", when_true), + refrtag("when_false", when_false)); + } else if (when_true) { + return ppii.pps()->pretty_struct + (ppii, + "DIfElseExpr", + refrtag("typeref", typeref_), + refrtag("test", test), + refrtag("when_true", when_true)); + } else if (test) { + return ppii.pps()->pretty_struct + (ppii, + "DIfElseExpr", + refrtag("typeref", typeref_), + refrtag("test", test)); + } else { + return ppii.pps()->pretty_struct + (ppii, + "DIfElseExpr", + refrtag("typeref", typeref_)); + } } // ---------------------------------------------------------------- @@ -141,10 +175,13 @@ namespace xo { std::uint32_t IfExpr::pretty_print(const ppindentinfo & ppii) const { + return ppii.pps()->pretty_struct(ppii, "IfExpr"); +#ifdef NOT_YET return ppii.pps()->pretty_struct(ppii, "IfExpr", refrtag("test", test_), refrtag("when_true", when_true_), refrtag("when_false", when_false_)); +#endif } rp From 666482a9451e0aef4865e6689353023749dd3bd3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 27 Jan 2026 22:35:22 -0500 Subject: [PATCH 046/128] xo-expression2: + LambdaExpr ++ LocalSymtab --- CMakeLists.txt | 26 ++++ idl/IExpression_DLambdaExpr.json5 | 12 ++ idl/IPrintable_DLambdaExpr.json5 | 13 ++ include/xo/expression2/Binding.hpp | 1 + include/xo/expression2/DLambdaExpr.hpp | 111 +++++++++++++++ include/xo/expression2/DLocalSymtab.hpp | 68 ++++++++- .../detail/IExpression_DLambdaExpr.hpp | 66 +++++++++ .../detail/IPrintable_DLambdaExpr.hpp | 62 +++++++++ include/xo/expression2/exprtype.hpp | 4 +- src/expression2/CMakeLists.txt | 4 + src/expression2/DLambdaExpr.cpp | 129 ++++++++++++++++++ src/expression2/DLocalSymtab.cpp | 53 ++++++- src/expression2/IExpression_DLambdaExpr.cpp | 45 ++++++ src/expression2/IPrintable_DLambdaExpr.cpp | 28 ++++ .../expression2_register_facets.cpp | 8 ++ 15 files changed, 621 insertions(+), 9 deletions(-) create mode 100644 idl/IExpression_DLambdaExpr.json5 create mode 100644 idl/IPrintable_DLambdaExpr.json5 create mode 100644 include/xo/expression2/DLambdaExpr.hpp create mode 100644 include/xo/expression2/detail/IExpression_DLambdaExpr.hpp create mode 100644 include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp create mode 100644 src/expression2/DLambdaExpr.cpp create mode 100644 src/expression2/IExpression_DLambdaExpr.cpp create mode 100644 src/expression2/IPrintable_DLambdaExpr.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fc6d451..3eaff32c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,6 +150,32 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-lambdaexpr + FACET_PKG xo_expression2 + FACET Expression + REPR LambdaExpr + INPUT idl/IExpression_DLambdaExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-lambdaexpr + FACET_PKG xo_printable2 + FACET Printable + REPR LambdaExpr + INPUT idl/IPrintable_DLambdaExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-ifelseexpr diff --git a/idl/IExpression_DLambdaExpr.json5 b/idl/IExpression_DLambdaExpr.json5 new file mode 100644 index 00000000..ef1b6704 --- /dev/null +++ b/idl/IExpression_DLambdaExpr.json5 @@ -0,0 +1,12 @@ +{ + mode: "implementation", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DLambdaExpr state", + using_doxygen: true, + repr: "DLambdaExpr", + doc: ["doc for IExpression+DLambdaExpr" ], +} diff --git a/idl/IPrintable_DLambdaExpr.json5 b/idl/IPrintable_DLambdaExpr.json5 new file mode 100644 index 00000000..02a09424 --- /dev/null +++ b/idl/IPrintable_DLambdaExpr.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DLambdaExpr", + using_doxygen: true, + repr: "DLambdaExpr", + doc: [ "implement APrintable for DLambdaExpr" ], +} diff --git a/include/xo/expression2/Binding.hpp b/include/xo/expression2/Binding.hpp index 5f0f7e27..e97cc715 100644 --- a/include/xo/expression2/Binding.hpp +++ b/include/xo/expression2/Binding.hpp @@ -19,6 +19,7 @@ namespace xo { Binding(int32_t i_link, int32_t j_slot) : i_link_{i_link}, j_slot_{j_slot} {} + static Binding null() { return Binding(); } /** global bindings are located by symbol name **/ static Binding global() { return Binding(s_link_global, 0); } static Binding local(int32_t j_slot) { return Binding(0, j_slot); } diff --git a/include/xo/expression2/DLambdaExpr.hpp b/include/xo/expression2/DLambdaExpr.hpp new file mode 100644 index 00000000..72492ffb --- /dev/null +++ b/include/xo/expression2/DLambdaExpr.hpp @@ -0,0 +1,111 @@ +/** @file DLambdaExpr.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "Expression.hpp" +#include "TypeRef.hpp" +#include "exprtype.hpp" +#include "DLocalSymtab.hpp" +#include "DString.hpp" +#include + +namespace xo { + namespace scm { + /** @class DLambdaExpr + * @brief syntax tree for a function/procedure definition + * + **/ + class DLambdaExpr { + public: + using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; + using ppindentinfo = xo::print::ppindentinfo; + + public: + + /** @defgroup scm-lambdaexpr-ctors **/ + ///@{ + + DLambdaExpr(TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body); + +#ifdef NOT_YET + /** create instance using memory from @p mm **/ + static obj make(obj mm, + TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body); +#endif + + /** create instance, using memory from @p mm **/ + static DLambdaExpr * _make(obj mm, + TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body); + ///@} + /** @defgroup scm-lambdaexpr-methods **/ + ///@{ + + // get_free_variables() + // visit_preorder() + // visit_layer() + // xform_layer() + // attach_envs(SymbolTable*) + + ///@} + /** @defgroup scm-lambdaexpr-expression-facet **/ + ///@{ + + exprtype extype() const noexcept; + TypeRef typeref() const noexcept; + TypeDescr valuetype() const noexcept; + void assign_valuetype(TypeDescr td) noexcept; + + ///@} + /** @defgroup scm-lambdaexpr-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + private: + /** expression value always has type consistent + * with description here + **/ + TypeRef typeref_; + + /** name for this lambda (generated if necessary) **/ + const DUniqueString * name_ = nullptr; + +#ifdef NOT_YET + /** e.g. + * i64(f64,string) + * for function of two arguments with types (f64, string) respectively, + * that returns an i64. + **/ + const DUniqueString * type_name_str_ = nullptr; +#endif + + /** symbol table for lambda arguments **/ + DLocalSymtab * local_symtab_ = nullptr;; + + /** expression for function body **/ + obj body_expr_; + + // free_var_set + // captured_var_set + // layer_var_map + // nested_lambda_map + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DLambdaExpr.hpp */ diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index b60b6570..9eada176 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -6,6 +6,7 @@ #pragma once #include "Binding.hpp" +#include "DVariable.hpp" #include "DUniqueString.hpp" //#include "exprtype.hpp" //#include @@ -23,15 +24,61 @@ namespace xo { // using AGCObject = xo::mm::AGCObject; // using typeseq = xo::reflect::typeseq; + using ppindentinfo = xo::print::ppindentinfo; + using AAllocator = xo::mm::AAllocator; + /* note: uint16_t would be fine too */ + using size_type = std::uint32_t; + struct Slot { - // obj var_; - Binding binding_; + Slot() = default; + explicit Slot(const DVariable * var) : var_{var} {} + + /** variable representing a formal argument. + * binding will be correct only within the same layer + * as top-level lambda body + * (i.e. up to the doorstep of each and every nested lambda) + **/ + const DVariable * var_ = nullptr; }; public: -// explicit DLocalSymtab(obj value) noexcept; + /** @defgroup scm-lambdaexpr-constructors **/ + ///@{ - /** @defgroup xo-expression2-symboltable-facet symboltable facet**/ + /** empty instance with capacity for n slots. + * Caller must ensure that slots_[0..n) are actually addressable + **/ + DLocalSymtab(size_type n); + + /** scaffold empty symtab instance, + * with capacity for @p n slots, using memory from allocator @p mm + **/ + static DLocalSymtab * _make_empty(obj mm, size_type n); + + ///@} + /** @defgroup scm-lambdaexpr-methods **/ + ///@{ + + size_type capacity() const noexcept { return capacity_; } + size_type size() const noexcept { return size_; } + + const DVariable * lookup_var(Binding ix) const noexcept { + assert(ix.i_link() == 0); + assert(ix.j_slot() < static_cast(size_)); + + return slots_[ix.j_slot()].var_; + } + + /** increase slot size (provided beleow capacity) to append + * binding for one local variable. Local variable will be allocated + * from @p mm, named @p name, with type described by @p typeref. + **/ + Binding append_var(obj mm, + const DUniqueString * name, + TypeRef typeref); + + ///@} + /** @defgroup xo-localsymtab-symboltable-facet symboltable facet**/ ///@{ /** true for global symbol table **/ @@ -41,9 +88,20 @@ namespace xo { Binding lookup_binding(const DUniqueString * sym) const noexcept; ///@} + /** @defgroup xo-localsymtab-printable-facet printable facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} private: - + /** actual range of slots_[] array. Can use inices in [0,..,n) **/ + size_type capacity_ = 0; + /** number of slots in use **/ + size_type size_ = 0; + /** memory for names and bindings **/ + Slot slots_[]; }; } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp b/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp new file mode 100644 index 00000000..d488b6b3 --- /dev/null +++ b/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DLambdaExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DLambdaExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DLambdaExpr.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DLambdaExpr.hpp" + +namespace xo { namespace scm { class IExpression_DLambdaExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DLambdaExpr + **/ + class IExpression_DLambdaExpr { + public: + /** @defgroup scm-expression-dlambdaexpr-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-dlambdaexpr-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DLambdaExpr & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DLambdaExpr & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DLambdaExpr & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DLambdaExpr & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp b/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp new file mode 100644 index 00000000..64ab6af1 --- /dev/null +++ b/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DLambdaExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DLambdaExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DLambdaExpr.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DLambdaExpr.hpp" + +namespace xo { namespace scm { class IPrintable_DLambdaExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DLambdaExpr + **/ + class IPrintable_DLambdaExpr { + public: + /** @defgroup scm-printable-dlambdaexpr-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dlambdaexpr-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DLambdaExpr & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/exprtype.hpp b/include/xo/expression2/exprtype.hpp index 952051be..861d62bd 100644 --- a/include/xo/expression2/exprtype.hpp +++ b/include/xo/expression2/exprtype.hpp @@ -32,10 +32,10 @@ namespace xo { #endif /** function call **/ apply, -#ifdef NOT_YET + /** function definition **/ lambda, -#endif + /** variable reference **/ variable, /** if-then-else **/ diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 840e7070..0aa357b9 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -7,6 +7,7 @@ set(SELF_SRCS DConstant.cpp DVariable.cpp DDefineExpr.cpp + DLambdaExpr.cpp DApplyExpr.cpp DIfElseExpr.cpp @@ -26,6 +27,9 @@ set(SELF_SRCS IExpression_DApplyExpr.cpp IPrintable_DApplyExpr.cpp + IExpression_DLambdaExpr.cpp + IPrintable_DLambdaExpr.cpp + IExpression_DIfElseExpr.cpp IPrintable_DIfElseExpr.cpp diff --git a/src/expression2/DLambdaExpr.cpp b/src/expression2/DLambdaExpr.cpp new file mode 100644 index 00000000..18f737ab --- /dev/null +++ b/src/expression2/DLambdaExpr.cpp @@ -0,0 +1,129 @@ +/** @file DLambda.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DLambdaExpr.hpp" +// #include "detail/IExpression_DLambdaExpr.hpp" +#include +#include +#include +#include + +namespace xo { + using xo::print::APrintable; + using xo::facet::FacetRegistry; + using xo::reflect::TypeDescr; + using xo::reflect::typeseq; + + namespace scm { + +#ifdef NOT_YET + TypeDescr + assemble_lambda_td() + { + std::vector arg_td_v; + { + arg_td_v.reserve(local_symtab->size()); + + for (DLocalSymtab::size_type i = 0, n = local_symtab->size(); i < n; ++i) { + const DVariable * var = local_symtab->lookup_var(i); + + if (!var) + break; + + TypeDescr arg_td = var->valuetype(); + + if (!arg_td) + break; + + arg_td_v.push_back(arg_td); + } + } + } +#endif + + DLambdaExpr::DLambdaExpr(TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body) : typeref_{typeref}, + name_{name}, + local_symtab_{local_symtab}, + body_expr_{body} + { + } + +#ifdef NOT_YET + obj + DLambdaExpr::make(obj mm, + TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body) + { + return obj(_make(mm, typeref, + name, local_symtab, body); + } +#endif + + DLambdaExpr * + DLambdaExpr::_make(obj mm, + TypeRef typeref, + const DUniqueString * name, + DLocalSymtab * local_symtab, + obj body) + { + // in general we're not going to know argument types yet. + // perhaps want to delay this until after type resolution. + + void * mem = mm.alloc(typeseq::id(), sizeof(DLambdaExpr)); + + return new (mem) DLambdaExpr(typeref, + name, + local_symtab, + body); + } + + exprtype + DLambdaExpr::extype() const noexcept { + return exprtype::lambda; + } + + TypeRef + DLambdaExpr::typeref() const noexcept { + return typeref_; + } + + TypeDescr + DLambdaExpr::valuetype() const noexcept { + return typeref_.td(); + } + + void + DLambdaExpr::assign_valuetype(TypeDescr td) noexcept { + typeref_.resolve(td); + } + + bool + DLambdaExpr::pretty(const ppindentinfo & ppii) const + { + auto body + = FacetRegistry::instance().try_variant(body_expr_); + + if (name_ && body) { + return ppii.pps()->pretty_struct(ppii, + "LambdaExpr", + refrtag("name", name_), + //refrtag("argv", local_env_->argv()), + refrtag("body", body)); + } else { + return ppii.pps()->pretty_struct(ppii, + "LambdaExpr"); + } + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DLambda.cpp */ diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index febd1463..c38096ff 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -8,13 +8,62 @@ #include namespace xo { + using xo::facet::typeseq; + namespace scm { + DLocalSymtab::DLocalSymtab(size_type n) : capacity_{n}, size_{0} + { + for (size_type i = 0; i < n; ++i) { + void * mem = &slots_[i]; + new (mem) Slot(); + } + } + + DLocalSymtab * + DLocalSymtab::_make_empty(obj mm, size_type n) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DLocalSymtab) + (n * sizeof(Slot))); + + return new (mem) DLocalSymtab(n); + } + + Binding + DLocalSymtab::append_var(obj mm, + const DUniqueString * name, + TypeRef typeref) + { + assert(name); + + if (size_ >= capacity_ || !name) { + assert(false); + + return Binding::null(); + } else { + size_type i_slot = (this->size_)++; + Binding binding = Binding::local(i_slot); + DVariable * var = DVariable::make(mm, name, typeref, binding); + + this->slots_[i_slot] = Slot(var); + + return binding; + } + } + Binding DLocalSymtab::lookup_binding(const DUniqueString * sym) const noexcept { - scope log(XO_DEBUG(true), "stub impl"); - log && log(xtag("sym", std::string_view(*sym))); + assert(sym); + + if (sym) { + for (size_type i = 0; i < size_; ++i) { + const Slot & slot = slots_[i]; + + if (*sym == *(slot.var_->name())) + return slot.var_->path(); + } + } return Binding(); } diff --git a/src/expression2/IExpression_DLambdaExpr.cpp b/src/expression2/IExpression_DLambdaExpr.cpp new file mode 100644 index 00000000..273f5544 --- /dev/null +++ b/src/expression2/IExpression_DLambdaExpr.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DLambdaExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DLambdaExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DLambdaExpr.json5] +**/ + +#include "detail/IExpression_DLambdaExpr.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DLambdaExpr::extype(const DLambdaExpr & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DLambdaExpr::typeref(const DLambdaExpr & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DLambdaExpr::valuetype(const DLambdaExpr & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DLambdaExpr::assign_valuetype(DLambdaExpr & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DLambdaExpr.cpp */ \ No newline at end of file diff --git a/src/expression2/IPrintable_DLambdaExpr.cpp b/src/expression2/IPrintable_DLambdaExpr.cpp new file mode 100644 index 00000000..12e6c22c --- /dev/null +++ b/src/expression2/IPrintable_DLambdaExpr.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DLambdaExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DLambdaExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DLambdaExpr.json5] +**/ + +#include "detail/IPrintable_DLambdaExpr.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DLambdaExpr::pretty(const DLambdaExpr & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DLambdaExpr.cpp */ \ No newline at end of file diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 8ab2ff51..8e10e9a4 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -20,6 +20,9 @@ #include #include +#include +#include + #include #include @@ -48,6 +51,7 @@ namespace xo { // +- Variable // +- DefineExpr // +- ApplyExpr + // +- LambdaExpr // \- IfElseExpr FacetRegistry::register_impl(); @@ -62,6 +66,9 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -70,6 +77,7 @@ namespace xo { log && log(xtag("DVariable.tseq", typeseq::id())); log && log(xtag("DConstant.tseq", typeseq::id())); log && log(xtag("DApplyExpr.tseq", typeseq::id())); + log && log(xtag("DLambdaExpr.tseq", typeseq::id())); log && log(xtag("DIfElseExpr.tseq", typeseq::id())); log && log(xtag("AExpression.tqseq", typeseq::id())); From 0eb1d9b526d3add1e3645b0ed550631fa12a3526 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 28 Jan 2026 10:57:55 -0500 Subject: [PATCH 047/128] xo-reader2 xo-expression2: + DLambdaSsm [WIP] --- include/xo/expression2/DConstant.hpp | 14 +++++++++++--- include/xo/expression2/DLambdaExpr.hpp | 4 ++-- src/expression2/DLambdaExpr.cpp | 6 ++---- 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp index 50f0e38f..1046176a 100644 --- a/include/xo/expression2/DConstant.hpp +++ b/include/xo/expression2/DConstant.hpp @@ -44,18 +44,26 @@ namespace xo { bool is_resolved() const noexcept { return typeref_.is_resolved(); } - exprtype extype() const noexcept { return exprtype::constant; } + obj value() const noexcept { return value_; } TypeDescr value_td() const noexcept { return typeref_.td(); } TaggedPtr value_tp() const noexcept { return TaggedPtr(typeref_.td(), value_.data()); } + /** @defgroup scm-constant-expression-facet **/ + ///@{ + + exprtype extype() const noexcept { return exprtype::constant; } TypeRef typeref() const noexcept { return typeref_; } TypeDescr valuetype() const noexcept { return typeref_.td(); } - obj value() const noexcept { return value_; } - void assign_valuetype(TypeDescr td) noexcept { typeref_.resolve(td); } + ///@} + /** @defgroup scm-constant-printable-facet **/ + ///@{ + bool pretty(const ppindentinfo & ppii) const; + ///@} + private: static TypeDescr _lookup_td(typeseq tseq); diff --git a/include/xo/expression2/DLambdaExpr.hpp b/include/xo/expression2/DLambdaExpr.hpp index 72492ffb..bd9ff2c5 100644 --- a/include/xo/expression2/DLambdaExpr.hpp +++ b/include/xo/expression2/DLambdaExpr.hpp @@ -34,14 +34,12 @@ namespace xo { DLocalSymtab * local_symtab, obj body); -#ifdef NOT_YET /** create instance using memory from @p mm **/ static obj make(obj mm, TypeRef typeref, const DUniqueString * name, DLocalSymtab * local_symtab, obj body); -#endif /** create instance, using memory from @p mm **/ static DLambdaExpr * _make(obj mm, @@ -53,6 +51,8 @@ namespace xo { /** @defgroup scm-lambdaexpr-methods **/ ///@{ + DLocalSymtab * local_symtab() const noexcept { return local_symtab_; } + // get_free_variables() // visit_preorder() // visit_layer() diff --git a/src/expression2/DLambdaExpr.cpp b/src/expression2/DLambdaExpr.cpp index 18f737ab..fec939ac 100644 --- a/src/expression2/DLambdaExpr.cpp +++ b/src/expression2/DLambdaExpr.cpp @@ -4,7 +4,7 @@ **/ #include "DLambdaExpr.hpp" -// #include "detail/IExpression_DLambdaExpr.hpp" +#include "detail/IExpression_DLambdaExpr.hpp" #include #include #include @@ -53,7 +53,6 @@ namespace xo { { } -#ifdef NOT_YET obj DLambdaExpr::make(obj mm, TypeRef typeref, @@ -62,9 +61,8 @@ namespace xo { obj body) { return obj(_make(mm, typeref, - name, local_symtab, body); + name, local_symtab, body)); } -#endif DLambdaExpr * DLambdaExpr::_make(obj mm, From 2a7d6d24a819a91b1246a32c074a028d7c9d47e6 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 28 Jan 2026 17:40:57 -0500 Subject: [PATCH 048/128] xo-reader2: + DExpectFormalArgSsm [WIP] --- src/expression2/DApplyExpr.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/expression2/DApplyExpr.cpp b/src/expression2/DApplyExpr.cpp index ffc6372a..751c1d85 100644 --- a/src/expression2/DApplyExpr.cpp +++ b/src/expression2/DApplyExpr.cpp @@ -128,6 +128,8 @@ namespace xo { return false; } + pps->write(">"); + return true; } else { pps->write("pretty(refrtag(concat("arg", 1+i_arg), arg_i)); } + pps->write(">"); + return false; } } From a26b7811019f97a887bd04fd21e4f2080c3c55fd Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 29 Jan 2026 10:16:13 -0500 Subject: [PATCH 049/128] xo-expression2: AGCObject support for DVariable --- CMakeLists.txt | 12 ++++ idl/IGCObject_DVariable.json5 | 15 +++++ include/xo/expression2/DVariable.hpp | 9 +++ .../detail/IGCObject_DVariable.hpp | 67 +++++++++++++++++++ src/expression2/CMakeLists.txt | 1 + src/expression2/DVariable.cpp | 31 +++++++++ src/expression2/IGCObject_DVariable.cpp | 39 +++++++++++ .../expression2_register_facets.cpp | 2 + 8 files changed, 176 insertions(+) create mode 100644 idl/IGCObject_DVariable.json5 create mode 100644 include/xo/expression2/detail/IGCObject_DVariable.hpp create mode 100644 src/expression2/IGCObject_DVariable.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 3eaff32c..63ff9fad 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -84,6 +84,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-variable + FACET_PKG xo_gc + FACET GCObject + REPR Variable + INPUT idl/IGCObject_DVariable.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-variable diff --git a/idl/IGCObject_DVariable.json5 b/idl/IGCObject_DVariable.json5 new file mode 100644 index 00000000..7327507f --- /dev/null +++ b/idl/IGCObject_DVariable.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DVariable", + using_doxygen: true, + repr: "DVariable", + doc: [ "implement AGCObject for DVariable" ], +} diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp index af2eddd5..3c89cc58 100644 --- a/include/xo/expression2/DVariable.hpp +++ b/include/xo/expression2/DVariable.hpp @@ -21,6 +21,7 @@ namespace xo { class DVariable { public: using ppindentinfo = xo::print::ppindentinfo; + using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -56,6 +57,14 @@ namespace xo { TypeDescr valuetype() const noexcept { return typeref_.td(); }; void assign_valuetype(TypeDescr td) noexcept; + ///@} + /** @defgroup scm-variable-gcobject-facet **/ + ///@{ + + size_t shallow_size() const noexcept; + DVariable * shallow_copy(obj mm) const noexcept; + size_t forward_children(obj gc) noexcept; + ///@} /** @defgroup scm-variable-printable-facet **/ ///@{ diff --git a/include/xo/expression2/detail/IGCObject_DVariable.hpp b/include/xo/expression2/detail/IGCObject_DVariable.hpp new file mode 100644 index 00000000..aee612ea --- /dev/null +++ b/include/xo/expression2/detail/IGCObject_DVariable.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DVariable.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVariable.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DVariable.hpp" + +namespace xo { namespace scm { class IGCObject_DVariable; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DVariable + **/ + class IGCObject_DVariable { + public: + /** @defgroup scm-gcobject-dvariable-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dvariable-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DVariable & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DVariable & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DVariable & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 0aa357b9..03bd8230 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -19,6 +19,7 @@ set(SELF_SRCS IPrintable_DConstant.cpp IExpression_DVariable.cpp + IGCObject_DVariable.cpp IPrintable_DVariable.cpp IExpression_DDefineExpr.cpp diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index af47de00..ac051387 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -5,9 +5,11 @@ #include "DVariable.hpp" #include "exprtype.hpp" +#include #include namespace xo { + using xo::mm::ACollector; using xo::facet::typeseq; namespace scm { @@ -36,6 +38,35 @@ namespace xo { typeref_.resolve(td); } + size_t + DVariable::shallow_size() const noexcept + { + return sizeof(DVariable); + } + + DVariable * + DVariable::shallow_copy(obj mm) const noexcept + { + DVariable * copy = (DVariable *)mm.alloc_copy((std::byte *)this); + + if (copy) { + *copy = *this; + } + + return copy; + } + + size_t + DVariable::forward_children(obj) noexcept + { + // nothing to collect. + // - DUniqueString never in GC space + // - TypeDescr not in GC space + // - path only integers + + return shallow_size(); + } + bool DVariable::pretty(const ppindentinfo & ppii) const { diff --git a/src/expression2/IGCObject_DVariable.cpp b/src/expression2/IGCObject_DVariable.cpp new file mode 100644 index 00000000..8735b286 --- /dev/null +++ b/src/expression2/IGCObject_DVariable.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DVariable.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVariable.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVariable.json5] +**/ + +#include "detail/IGCObject_DVariable.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DVariable::shallow_size(const DVariable & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DVariable::shallow_copy(const DVariable & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DVariable::forward_children(DVariable & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVariable.cpp */ \ No newline at end of file diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 8e10e9a4..a6bd50e5 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -12,6 +12,7 @@ #include #include +#include #include #include @@ -58,6 +59,7 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); From d953246acdb25800f28e71598c476178c2ec4bd2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 30 Jan 2026 10:26:35 -0500 Subject: [PATCH 050/128] xo-expression2 xo-reader2: local symtab stack in PSM --- CMakeLists.txt | 24 +++++++ idl/IPrintable_DLocalSymtab.json5 | 13 ++++ idl/ISymbolTable_DLocalSymtab.json5 | 12 ++++ include/xo/expression2/Binding.hpp | 1 + include/xo/expression2/DLocalSymtab.hpp | 11 +++- .../detail/IExpression_DIfElseExpr.hpp | 2 +- .../detail/IGCObject_DVariable.hpp | 2 +- .../detail/IPrintable_DIfElseExpr.hpp | 2 +- .../symtab/IPrintable_DLocalSymtab.hpp | 62 +++++++++++++++++++ .../symtab/ISymbolTable_DLocalSymtab.hpp | 60 ++++++++++++++++++ src/expression2/CMakeLists.txt | 3 + src/expression2/DLocalSymtab.cpp | 62 ++++++++++++++++++- src/expression2/IExpression_DIfElseExpr.cpp | 2 +- src/expression2/IGCObject_DVariable.cpp | 2 +- src/expression2/IPrintable_DIfElseExpr.cpp | 2 +- src/expression2/IPrintable_DLocalSymtab.cpp | 28 +++++++++ src/expression2/ISymbolTable_DLocalSymtab.cpp | 34 ++++++++++ .../expression2_register_facets.cpp | 9 +++ 18 files changed, 319 insertions(+), 12 deletions(-) create mode 100644 idl/IPrintable_DLocalSymtab.json5 create mode 100644 idl/ISymbolTable_DLocalSymtab.json5 create mode 100644 include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp create mode 100644 include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp create mode 100644 src/expression2/IPrintable_DLocalSymtab.cpp create mode 100644 src/expression2/ISymbolTable_DLocalSymtab.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 63ff9fad..ae1bb8c2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,30 @@ xo_add_genfacet( # ---------------------------------------------------------------- +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-symboltable-localsymtab + FACET_PKG xo_expression2 + FACET SymbolTable + REPR LocalSymtab + INPUT idl/ISymbolTable_DLocalSymtab.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR symtab + OUTPUT_CPP_DIR src/expression2 +) + +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-localsymtab + FACET_PKG xo_printable2 + FACET Printable + REPR LocalSymtab + INPUT idl/IPrintable_DLocalSymtab.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR symtab + OUTPUT_CPP_DIR src/expression2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacet( TARGET xo-expression2-facet-expression diff --git a/idl/IPrintable_DLocalSymtab.json5 b/idl/IPrintable_DLocalSymtab.json5 new file mode 100644 index 00000000..3f17e64e --- /dev/null +++ b/idl/IPrintable_DLocalSymtab.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DLocalSymtab", + using_doxygen: true, + repr: "DLocalSymtab", + doc: [ "implement APrintable for DLocalSymtab" ], +} diff --git a/idl/ISymbolTable_DLocalSymtab.json5 b/idl/ISymbolTable_DLocalSymtab.json5 new file mode 100644 index 00000000..026c0ed1 --- /dev/null +++ b/idl/ISymbolTable_DLocalSymtab.json5 @@ -0,0 +1,12 @@ +{ + mode: "implementation", + includes: [ ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/SymbolTable.json5", + brief: "provide ASymbolTable interface for DLocalSymtab", + using_doxygen: true, + repr: "DLocalSymtab", + doc: [ "implement ASymbolTable for DLocalSymtab" ], +} diff --git a/include/xo/expression2/Binding.hpp b/include/xo/expression2/Binding.hpp index e97cc715..6dffb16b 100644 --- a/include/xo/expression2/Binding.hpp +++ b/include/xo/expression2/Binding.hpp @@ -25,6 +25,7 @@ namespace xo { static Binding local(int32_t j_slot) { return Binding(0, j_slot); } bool is_global() const { return i_link_ == s_link_global; } + bool is_local() const { return (i_link_ == 0) && (j_slot_ >= 0); } int32_t i_link() const noexcept { return i_link_; } int32_t j_slot() const noexcept { return j_slot_; } diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index 9eada176..01d9aa85 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -45,20 +45,23 @@ namespace xo { /** @defgroup scm-lambdaexpr-constructors **/ ///@{ - /** empty instance with capacity for n slots. + /** empty instance with parent @p p and capacity for @p n slots. * Caller must ensure that slots_[0..n) are actually addressable **/ - DLocalSymtab(size_type n); + DLocalSymtab(DLocalSymtab * p, size_type n); /** scaffold empty symtab instance, * with capacity for @p n slots, using memory from allocator @p mm **/ - static DLocalSymtab * _make_empty(obj mm, size_type n); + static DLocalSymtab * _make_empty(obj mm, + DLocalSymtab * p, + size_type n); ///@} /** @defgroup scm-lambdaexpr-methods **/ ///@{ + DLocalSymtab * parent() const noexcept { return parent_; } size_type capacity() const noexcept { return capacity_; } size_type size() const noexcept { return size_; } @@ -96,6 +99,8 @@ namespace xo { ///@} private: + /** parent symbol table from scoping surrounding this one **/ + DLocalSymtab * parent_ = nullptr; /** actual range of slots_[] array. Can use inices in [0,..,n) **/ size_type capacity_ = 0; /** number of slots in use **/ diff --git a/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp b/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp index 03500a39..7d726dde 100644 --- a/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IGCObject_DVariable.hpp b/include/xo/expression2/detail/IGCObject_DVariable.hpp index aee612ea..24dc591f 100644 --- a/include/xo/expression2/detail/IGCObject_DVariable.hpp +++ b/include/xo/expression2/detail/IGCObject_DVariable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp b/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp index e9cf67ff..fcf80fd5 100644 --- a/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp b/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp new file mode 100644 index 00000000..c013e937 --- /dev/null +++ b/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DLocalSymtab.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DLocalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DLocalSymtab.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DLocalSymtab.hpp" + +namespace xo { namespace scm { class IPrintable_DLocalSymtab; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DLocalSymtab + **/ + class IPrintable_DLocalSymtab { + public: + /** @defgroup scm-printable-dlocalsymtab-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dlocalsymtab-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DLocalSymtab & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp b/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp new file mode 100644 index 00000000..72f409dd --- /dev/null +++ b/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp @@ -0,0 +1,60 @@ +/** @file ISymbolTable_DLocalSymtab.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/ISymbolTable_DLocalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/ISymbolTable_DLocalSymtab.json5] + **/ + +#pragma once + +#include "SymbolTable.hpp" +#include "DLocalSymtab.hpp" + +namespace xo { namespace scm { class ISymbolTable_DLocalSymtab; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::ISymbolTable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class ISymbolTable_DLocalSymtab + **/ + class ISymbolTable_DLocalSymtab { + public: + /** @defgroup scm-symboltable-dlocalsymtab-type-traits **/ + ///@{ + using Copaque = xo::scm::ASymbolTable::Copaque; + using Opaque = xo::scm::ASymbolTable::Opaque; + ///@} + /** @defgroup scm-symboltable-dlocalsymtab-methods **/ + ///@{ + // const methods + /** true iff this is toplevel (global) symbol table. **/ + static bool is_global_symtab(const DLocalSymtab & self) noexcept; + /** report ingredients needed to address variable at runtime. **/ + static Binding lookup_binding(const DLocalSymtab & self, const DUniqueString * sym) noexcept; + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 03bd8230..8e6565c4 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -39,6 +39,9 @@ set(SELF_SRCS ISymbolTable_Any.cpp + ISymbolTable_DLocalSymtab.cpp + IPrintable_DLocalSymtab.cpp + StringTable.cpp DUniqueString.cpp diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index c38096ff..85631d34 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -5,14 +5,21 @@ #include "DLocalSymtab.hpp" #include "DUniqueString.hpp" +#include +#include #include namespace xo { + using xo::print::APrintable; using xo::facet::typeseq; + using xo::print::ppstate; namespace scm { - DLocalSymtab::DLocalSymtab(size_type n) : capacity_{n}, size_{0} + DLocalSymtab::DLocalSymtab(DLocalSymtab * p, + size_type n) : parent_{p}, + capacity_{n}, + size_{0} { for (size_type i = 0; i < n; ++i) { void * mem = &slots_[i]; @@ -21,12 +28,14 @@ namespace xo { } DLocalSymtab * - DLocalSymtab::_make_empty(obj mm, size_type n) + DLocalSymtab::_make_empty(obj mm, + DLocalSymtab * p, + size_type n) { void * mem = mm.alloc(typeseq::id(), sizeof(DLocalSymtab) + (n * sizeof(Slot))); - return new (mem) DLocalSymtab(n); + return new (mem) DLocalSymtab(p, n); } Binding @@ -68,6 +77,53 @@ namespace xo { return Binding(); } + bool + DLocalSymtab::pretty(const ppindentinfo & ppii) const + { + ppstate * pps = ppii.pps(); + + if (ppii.upto()) { + /* perhaps print on one line */ + if (!pps->print_upto("print_upto(xrefrtag("size", size_))) + return false; + + for (size_type i = 0; i < size_; ++i) { + char buf[32]; + snprintf(buf, sizeof(buf), "[%u]", i); + + assert(slots_[i].var_); + + obj arg_pr(const_cast(slots_[i].var_)); + + if (!pps->print_upto(xrefrtag(buf, arg_pr))) + return false; + } + + pps->write(">"); + return true; + } else { + /* with line breaks */ + + pps->write("newline_pretty_tag(ppii.ci1(), "size", size_); + + for (size_type i = 0; i < size_; ++i) { + char buf[32]; + snprintf(buf, sizeof(buf), "[%u]", i); + + assert(slots_[i].var_); + + obj arg_pr(const_cast(slots_[i].var_)); + + pps->newline_pretty_tag(ppii.ci1(), buf, arg_pr); + } + + pps->write(">"); + return false; + } + } } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/expression2/IExpression_DIfElseExpr.cpp b/src/expression2/IExpression_DIfElseExpr.cpp index 78680310..d913eaf0 100644 --- a/src/expression2/IExpression_DIfElseExpr.cpp +++ b/src/expression2/IExpression_DIfElseExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IGCObject_DVariable.cpp b/src/expression2/IGCObject_DVariable.cpp index 8735b286..4af0f906 100644 --- a/src/expression2/IGCObject_DVariable.cpp +++ b/src/expression2/IGCObject_DVariable.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DIfElseExpr.cpp b/src/expression2/IPrintable_DIfElseExpr.cpp index ec68b9fc..a75cd6a4 100644 --- a/src/expression2/IPrintable_DIfElseExpr.cpp +++ b/src/expression2/IPrintable_DIfElseExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DLocalSymtab.cpp b/src/expression2/IPrintable_DLocalSymtab.cpp new file mode 100644 index 00000000..dbd4887b --- /dev/null +++ b/src/expression2/IPrintable_DLocalSymtab.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DLocalSymtab.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DLocalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DLocalSymtab.json5] +**/ + +#include "symtab/IPrintable_DLocalSymtab.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DLocalSymtab::pretty(const DLocalSymtab & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DLocalSymtab.cpp */ \ No newline at end of file diff --git a/src/expression2/ISymbolTable_DLocalSymtab.cpp b/src/expression2/ISymbolTable_DLocalSymtab.cpp new file mode 100644 index 00000000..778cfdf4 --- /dev/null +++ b/src/expression2/ISymbolTable_DLocalSymtab.cpp @@ -0,0 +1,34 @@ +/** @file ISymbolTable_DLocalSymtab.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/ISymbolTable_DLocalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/ISymbolTable_DLocalSymtab.json5] +**/ + +#include "symtab/ISymbolTable_DLocalSymtab.hpp" + +namespace xo { + namespace scm { + auto + ISymbolTable_DLocalSymtab::is_global_symtab(const DLocalSymtab & self) noexcept -> bool + { + return self.is_global_symtab(); + } + + auto + ISymbolTable_DLocalSymtab::lookup_binding(const DLocalSymtab & self, const DUniqueString * sym) noexcept -> Binding + { + return self.lookup_binding(sym); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end ISymbolTable_DLocalSymtab.cpp */ \ No newline at end of file diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index a6bd50e5..06ccc7d5 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -27,6 +27,9 @@ #include #include +#include +#include + #include #include #include @@ -74,6 +77,9 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + log && log(xtag("DUniqueString.tseq", typeseq::id())); log && log(xtag("DDefineExpr.tseq", typeseq::id())); log && log(xtag("DVariable.tseq", typeseq::id())); @@ -82,7 +88,10 @@ namespace xo { log && log(xtag("DLambdaExpr.tseq", typeseq::id())); log && log(xtag("DIfElseExpr.tseq", typeseq::id())); + log && log(xtag("DLocalSymtab.tseq", typeseq::id())); + log && log(xtag("AExpression.tqseq", typeseq::id())); + log && log(xtag("ASymbolTable.tseq", typeseq::id())); return true; } From dd64b61e51fe3b9d3f818a1a5c2e6c5100e3ba43 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 30 Jan 2026 12:41:09 -0500 Subject: [PATCH 051/128] xo-reader2: + assemble lambda function type in DLambdaSsm --- include/xo/expression2/DLambdaExpr.hpp | 8 +++++++ src/expression2/DLambdaExpr.cpp | 29 ++++++++++++++++++++++++++ 2 files changed, 37 insertions(+) diff --git a/include/xo/expression2/DLambdaExpr.hpp b/include/xo/expression2/DLambdaExpr.hpp index bd9ff2c5..14be115f 100644 --- a/include/xo/expression2/DLambdaExpr.hpp +++ b/include/xo/expression2/DLambdaExpr.hpp @@ -47,6 +47,14 @@ namespace xo { const DUniqueString * name, DLocalSymtab * local_symtab, obj body); + + /** create type description for lambda with arguments described by @p symtab + * and return type @p return_td. + * Load-bearing for DLambdaSsm in xo-reader2/ + **/ + static TypeDescr assemble_lambda_td(DLocalSymtab * symtab, + TypeDescr return_td); + ///@} /** @defgroup scm-lambdaexpr-methods **/ ///@{ diff --git a/src/expression2/DLambdaExpr.cpp b/src/expression2/DLambdaExpr.cpp index fec939ac..a27e788b 100644 --- a/src/expression2/DLambdaExpr.cpp +++ b/src/expression2/DLambdaExpr.cpp @@ -14,6 +14,8 @@ namespace xo { using xo::print::APrintable; using xo::facet::FacetRegistry; using xo::reflect::TypeDescr; + using xo::reflect::TypeDescrBase; + using xo::reflect::FunctionTdxInfo; using xo::reflect::typeseq; namespace scm { @@ -82,6 +84,33 @@ namespace xo { body); } + TypeDescr + DLambdaExpr::assemble_lambda_td(DLocalSymtab * symtab, + TypeDescr return_td) + { + assert(return_td); + + std::vector arg_td_v; + { + DLocalSymtab::size_type z = symtab->size(); + + arg_td_v.reserve(z); + + for (DLocalSymtab::size_type i = 0; i < z; ++i) { + auto param = symtab->lookup_var(Binding::local(i)); + + assert(param); + arg_td_v.push_back(param->valuetype()); + } + } + + auto function_tdx = FunctionTdxInfo(return_td, arg_td_v, false /*!is_noexcept*/); + + TypeDescr lambda_td = TypeDescrBase::require_by_fn_info(function_tdx); + + return lambda_td; + } + exprtype DLambdaExpr::extype() const noexcept { return exprtype::lambda; From 2d3f55876693b9dc4bea6c4c47a3e9095204b81f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 30 Jan 2026 20:08:41 -0500 Subject: [PATCH 052/128] xo-expression2 xo-reader2 DSequenceExpr, DSequenceSsm [WIP] --- DSequenceExpr.hpp | 77 +++++++++++++++++++++++++ include/xo/expression2/exprtype.hpp | 4 +- src/expression2/DSequenceExpr.cpp | 88 +++++++++++++++++++++++++++++ 3 files changed, 167 insertions(+), 2 deletions(-) create mode 100644 DSequenceExpr.hpp create mode 100644 src/expression2/DSequenceExpr.cpp diff --git a/DSequenceExpr.hpp b/DSequenceExpr.hpp new file mode 100644 index 00000000..12caf649 --- /dev/null +++ b/DSequenceExpr.hpp @@ -0,0 +1,77 @@ +/** @file DSequenceExpr.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include "TypeRef.hpp" +#include + +namespace xo { + namespace scm { + + /** syntax for a sequence of expressions + * { + * expr(1); + * expr(2); + * ... + * expr(n); + * } + **/ + class DSequenceExpr { + public: + using size_type = DArray::size_type; + using ppindentinfo = xo::print::ppindentinfo; + + public: + DSequenceExpr() = default; + DSequenceExpr(DArray * xv) : expr_v_{xv} {} + + /** create empty sequence using memory from @p mm **/ + static obj make_empty(obj mm); + + /** create empty sequence expression using mmeory from @p mm **/ + static DSequenceExpr * _make_empty(obj mm); + + size_type size() const noexcept; + obj operator[](std::size_t i) const; + + /** append @p expr to the end of this sequence **/ + void push_back(obj expr); + + // get_free_variables(); + // visit_preorder(); + // visit_layer(); + // xform_layer() + // attach_envs() + + /** @defgroup scm-ifelseexpr-expression-facets **/ + ///@{ + + exprtype extype() const noexcept { return exprtype::sequence; } + TypeRef typeref() const noexcept { return typeref_; } + TypeDescr valuetype() const noexcept { return typeref_.td(); } + void assign_valuetype(TypeDescr td) noexcept; + + ///@} + /** @defgroup scm-sequenceexpr-printable-facet printable facet methods **/ + ///@{ + + /** pretty-printing driver; combine layout+printing **/ + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + private: + /** expression value always has type consistent with this description + **/ + TypeRef typeref_; + /** array of expressions **/ + DArray * expr_v_ = nullptr; + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DSequenceExpr.hpp */ diff --git a/include/xo/expression2/exprtype.hpp b/include/xo/expression2/exprtype.hpp index 861d62bd..3bcda3c4 100644 --- a/include/xo/expression2/exprtype.hpp +++ b/include/xo/expression2/exprtype.hpp @@ -40,10 +40,10 @@ namespace xo { variable, /** if-then-else **/ ifexpr, -#ifdef NOT_YET /** sequence **/ sequence, - /** type conversion **/ +#ifdef NOT_YET + ) /** type conversion **/ convert, #endif diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp new file mode 100644 index 00000000..c5abf27b --- /dev/null +++ b/src/expression2/DSequenceExpr.cpp @@ -0,0 +1,88 @@ +/** @file DSequenceExpr.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "DSequenceExpr.hpp" + +namespace xo { + namespace scm { + + obj + DSequenceExpr::make_empty(obj mm) + { + return obj(_make_empty(mm)); + } + + DSequenceExpr * + DSequenceExpr::_make_empty(obj mm) + { + void * mem = mm.alloc(typeseq::id(), + sizeof(DSequenceExpr)); + + DSequenceExpr * expr = new (mem) DSequenceExpr(); + + constexpr size_type c_hint_capacity = 8; + + /** allocate 2nd, so it comes after DSequenceExpr in + * memory. This may later allow realloc + **/ + DArray * expr_v = DArray::empty(mm, + c_hint_capacity); + + expr->expr_v_ = expr_v; + + return expr; + } + + size_type + DSequenceExpr::size() const noexcept + { + return expr_v_->size(); + } + + obj + DSequenceExpr::operator[](std::size_t i) const + { + return (*expr_v_)[i]; + } + + void + DSequenceExpr::push_back(obj mm, + obj expr) + { + if (expr_v_->size() == expr_v_->capacity()) { + /* reallocate+expand */ + + DArray * expr_2x_v + = DArray::empty(mm, 2 * expr_v_->capacity()); + + for (size_type i = 0, z = expr_v_->size(); i < z; ++i) { + expr_2x_v->push_back((*expr_2x_v)[i]); + } + + this->expr_v_ = expr_2x_v; + } + + this->expr_v_->push_back(expr); + } + + void + DSequenceExpr::assign_valuetype(TypeDescr td) noexcept + { + typeref_.resolve(td); + } + + void + DSequenceExpr::pretty(const ppindentinfo & ppii) const + { + using xo::print::ppstate; + + ppstate * pps = ppii.pps(); + + xxx; + } + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DSequenceExpr.cpp */ From 5d089dc34d0d397d0d00d5bbe044c5c011f59068 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 31 Jan 2026 01:44:53 -0500 Subject: [PATCH 053/128] xo-expression2 xo-gc: DSequenceExpr builds [WIP] --- CMakeLists.txt | 14 ++++ idl/IExpression_DSequenceExpr.json5 | 12 ++++ .../xo/expression2/DSequenceExpr.hpp | 10 ++- include/xo/expression2/Expression.hpp | 2 +- include/xo/expression2/SymbolTable.hpp | 2 +- include/xo/expression2/detail/AExpression.hpp | 2 +- .../xo/expression2/detail/IExpression_Any.hpp | 2 +- .../detail/IExpression_DApplyExpr.hpp | 2 +- .../detail/IExpression_DConstant.hpp | 2 +- .../detail/IExpression_DDefineExpr.hpp | 2 +- .../detail/IExpression_DIfElseExpr.hpp | 2 +- .../detail/IExpression_DLambdaExpr.hpp | 2 +- .../detail/IExpression_DSequenceExpr.hpp | 66 +++++++++++++++++++ .../detail/IExpression_DVariable.hpp | 2 +- .../expression2/detail/IExpression_Xfer.hpp | 2 +- .../detail/IGCObject_DUniqueString.hpp | 2 +- .../detail/IGCObject_DVariable.hpp | 2 +- .../detail/IPrintable_DApplyExpr.hpp | 2 +- .../detail/IPrintable_DConstant.hpp | 2 +- .../detail/IPrintable_DDefineExpr.hpp | 2 +- .../detail/IPrintable_DIfElseExpr.hpp | 2 +- .../detail/IPrintable_DLambdaExpr.hpp | 2 +- .../detail/IPrintable_DUniqueString.hpp | 2 +- .../detail/IPrintable_DVariable.hpp | 2 +- include/xo/expression2/detail/RExpression.hpp | 2 +- .../xo/expression2/symtab/ASymbolTable.hpp | 2 +- .../symtab/IPrintable_DLocalSymtab.hpp | 2 +- .../expression2/symtab/ISymbolTable_Any.hpp | 2 +- .../symtab/ISymbolTable_DLocalSymtab.hpp | 2 +- .../expression2/symtab/ISymbolTable_Xfer.hpp | 2 +- .../xo/expression2/symtab/RSymbolTable.hpp | 2 +- src/expression2/CMakeLists.txt | 3 + src/expression2/DSequenceExpr.cpp | 33 +++++++--- src/expression2/IExpression_DApplyExpr.cpp | 2 +- src/expression2/IExpression_DConstant.cpp | 2 +- src/expression2/IExpression_DDefineExpr.cpp | 2 +- src/expression2/IExpression_DIfElseExpr.cpp | 2 +- src/expression2/IExpression_DLambdaExpr.cpp | 2 +- src/expression2/IExpression_DSequenceExpr.cpp | 45 +++++++++++++ src/expression2/IExpression_DVariable.cpp | 2 +- src/expression2/IGCObject_DUniqueString.cpp | 2 +- src/expression2/IGCObject_DVariable.cpp | 2 +- src/expression2/IPrintable_DApplyExpr.cpp | 2 +- src/expression2/IPrintable_DConstant.cpp | 2 +- src/expression2/IPrintable_DDefineExpr.cpp | 2 +- src/expression2/IPrintable_DIfElseExpr.cpp | 2 +- src/expression2/IPrintable_DLambdaExpr.cpp | 2 +- src/expression2/IPrintable_DLocalSymtab.cpp | 2 +- src/expression2/IPrintable_DUniqueString.cpp | 2 +- src/expression2/IPrintable_DVariable.cpp | 2 +- src/expression2/ISymbolTable_DLocalSymtab.cpp | 2 +- 51 files changed, 217 insertions(+), 54 deletions(-) create mode 100644 idl/IExpression_DSequenceExpr.json5 rename DSequenceExpr.hpp => include/xo/expression2/DSequenceExpr.hpp (85%) create mode 100644 include/xo/expression2/detail/IExpression_DSequenceExpr.hpp create mode 100644 src/expression2/IExpression_DSequenceExpr.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index ae1bb8c2..4f7705ce 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -238,6 +238,20 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-sequenceexpr + FACET_PKG xo_expression2 + FACET Expression + REPR SequenceExpr + INPUT idl/IExpression_DSequenceExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-uniquestring diff --git a/idl/IExpression_DSequenceExpr.json5 b/idl/IExpression_DSequenceExpr.json5 new file mode 100644 index 00000000..451d39f1 --- /dev/null +++ b/idl/IExpression_DSequenceExpr.json5 @@ -0,0 +1,12 @@ +{ + mode: "implementation", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DSequenceExpr state", + using_doxygen: true, + repr: "DSequenceExpr", + doc: ["doc for something or other IExpression+DSequenceExpr" ], +} diff --git a/DSequenceExpr.hpp b/include/xo/expression2/DSequenceExpr.hpp similarity index 85% rename from DSequenceExpr.hpp rename to include/xo/expression2/DSequenceExpr.hpp index 12caf649..7285ada8 100644 --- a/DSequenceExpr.hpp +++ b/include/xo/expression2/DSequenceExpr.hpp @@ -5,6 +5,7 @@ #pragma once +#include "Expression.hpp" #include "TypeRef.hpp" #include @@ -21,6 +22,8 @@ namespace xo { **/ class DSequenceExpr { public: + using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; using size_type = DArray::size_type; using ppindentinfo = xo::print::ppindentinfo; @@ -37,8 +40,11 @@ namespace xo { size_type size() const noexcept; obj operator[](std::size_t i) const; - /** append @p expr to the end of this sequence **/ - void push_back(obj expr); + /** append @p expr to the end of this sequence; + * use memory from @p mm if need to expand storage + **/ + void push_back(obj mm, + obj expr); // get_free_variables(); // visit_preorder(); diff --git a/include/xo/expression2/Expression.hpp b/include/xo/expression2/Expression.hpp index df4161a1..60e8a402 100644 --- a/include/xo/expression2/Expression.hpp +++ b/include/xo/expression2/Expression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for facet .hpp file: diff --git a/include/xo/expression2/SymbolTable.hpp b/include/xo/expression2/SymbolTable.hpp index 26576ed6..09fc04a8 100644 --- a/include/xo/expression2/SymbolTable.hpp +++ b/include/xo/expression2/SymbolTable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for facet .hpp file: diff --git a/include/xo/expression2/detail/AExpression.hpp b/include/xo/expression2/detail/AExpression.hpp index e080ece8..10375114 100644 --- a/include/xo/expression2/detail/AExpression.hpp +++ b/include/xo/expression2/detail/AExpression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_Any.hpp b/include/xo/expression2/detail/IExpression_Any.hpp index 17545afb..c92c2c4a 100644 --- a/include/xo/expression2/detail/IExpression_Any.hpp +++ b/include/xo/expression2/detail/IExpression_Any.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DApplyExpr.hpp b/include/xo/expression2/detail/IExpression_DApplyExpr.hpp index c8952199..d577854f 100644 --- a/include/xo/expression2/detail/IExpression_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DApplyExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DApplyExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DConstant.hpp b/include/xo/expression2/detail/IExpression_DConstant.hpp index 61b92e12..89c5044c 100644 --- a/include/xo/expression2/detail/IExpression_DConstant.hpp +++ b/include/xo/expression2/detail/IExpression_DConstant.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DConstant.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DDefineExpr.hpp b/include/xo/expression2/detail/IExpression_DDefineExpr.hpp index 3ac7fd49..f5585b60 100644 --- a/include/xo/expression2/detail/IExpression_DDefineExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DDefineExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DDefineExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp b/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp index 7d726dde..03500a39 100644 --- a/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp b/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp index d488b6b3..916b82ac 100644 --- a/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DLambdaExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DSequenceExpr.hpp b/include/xo/expression2/detail/IExpression_DSequenceExpr.hpp new file mode 100644 index 00000000..b010ac65 --- /dev/null +++ b/include/xo/expression2/detail/IExpression_DSequenceExpr.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DSequenceExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DSequenceExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DSequenceExpr.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DSequenceExpr.hpp" + +namespace xo { namespace scm { class IExpression_DSequenceExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DSequenceExpr + **/ + class IExpression_DSequenceExpr { + public: + /** @defgroup scm-expression-dsequenceexpr-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-dsequenceexpr-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DSequenceExpr & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DSequenceExpr & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DSequenceExpr & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DSequenceExpr & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IExpression_DVariable.hpp b/include/xo/expression2/detail/IExpression_DVariable.hpp index 6b9b702f..95b1becb 100644 --- a/include/xo/expression2/detail/IExpression_DVariable.hpp +++ b/include/xo/expression2/detail/IExpression_DVariable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_Xfer.hpp b/include/xo/expression2/detail/IExpression_Xfer.hpp index fac8c541..9f7356bc 100644 --- a/include/xo/expression2/detail/IExpression_Xfer.hpp +++ b/include/xo/expression2/detail/IExpression_Xfer.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IGCObject_DUniqueString.hpp b/include/xo/expression2/detail/IGCObject_DUniqueString.hpp index b971daea..c95db10f 100644 --- a/include/xo/expression2/detail/IGCObject_DUniqueString.hpp +++ b/include/xo/expression2/detail/IGCObject_DUniqueString.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DUniqueString.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IGCObject_DVariable.hpp b/include/xo/expression2/detail/IGCObject_DVariable.hpp index 24dc591f..aee612ea 100644 --- a/include/xo/expression2/detail/IGCObject_DVariable.hpp +++ b/include/xo/expression2/detail/IGCObject_DVariable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp b/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp index c05e87e2..b7782166 100644 --- a/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DApplyExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DConstant.hpp b/include/xo/expression2/detail/IPrintable_DConstant.hpp index a1e31382..35535d80 100644 --- a/include/xo/expression2/detail/IPrintable_DConstant.hpp +++ b/include/xo/expression2/detail/IPrintable_DConstant.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DConstant.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp b/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp index 6d727d86..758022a6 100644 --- a/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp +++ b/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DDefineExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp b/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp index fcf80fd5..e9cf67ff 100644 --- a/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp b/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp index 64ab6af1..45970bd8 100644 --- a/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DLambdaExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DUniqueString.hpp b/include/xo/expression2/detail/IPrintable_DUniqueString.hpp index 34c9da79..51afa9da 100644 --- a/include/xo/expression2/detail/IPrintable_DUniqueString.hpp +++ b/include/xo/expression2/detail/IPrintable_DUniqueString.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DUniqueString.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DVariable.hpp b/include/xo/expression2/detail/IPrintable_DVariable.hpp index 6e97451b..a31ee97e 100644 --- a/include/xo/expression2/detail/IPrintable_DVariable.hpp +++ b/include/xo/expression2/detail/IPrintable_DVariable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/RExpression.hpp b/include/xo/expression2/detail/RExpression.hpp index 4d717640..caf69fe0 100644 --- a/include/xo/expression2/detail/RExpression.hpp +++ b/include/xo/expression2/detail/RExpression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/ASymbolTable.hpp b/include/xo/expression2/symtab/ASymbolTable.hpp index f0c6e10f..36d4c812 100644 --- a/include/xo/expression2/symtab/ASymbolTable.hpp +++ b/include/xo/expression2/symtab/ASymbolTable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp b/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp index c013e937..d4481dca 100644 --- a/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DLocalSymtab.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/ISymbolTable_Any.hpp b/include/xo/expression2/symtab/ISymbolTable_Any.hpp index b642adb7..6a119832 100644 --- a/include/xo/expression2/symtab/ISymbolTable_Any.hpp +++ b/include/xo/expression2/symtab/ISymbolTable_Any.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp b/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp index 72f409dd..2c1816e4 100644 --- a/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/ISymbolTable_DLocalSymtab.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp b/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp index 3d5f7221..2333bb05 100644 --- a/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp +++ b/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/RSymbolTable.hpp b/include/xo/expression2/symtab/RSymbolTable.hpp index 600ea4f8..c72503cc 100644 --- a/include/xo/expression2/symtab/RSymbolTable.hpp +++ b/include/xo/expression2/symtab/RSymbolTable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 8e6565c4..ab10048e 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -10,6 +10,7 @@ set(SELF_SRCS DLambdaExpr.cpp DApplyExpr.cpp DIfElseExpr.cpp + DSequenceExpr.cpp TypeRef.cpp @@ -34,6 +35,8 @@ set(SELF_SRCS IExpression_DIfElseExpr.cpp IPrintable_DIfElseExpr.cpp + IExpression_DSequenceExpr.cpp + DLocalSymtab.cpp DGlobalSymtab.cpp diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index c5abf27b..5e449531 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -4,8 +4,19 @@ **/ #include "DSequenceExpr.hpp" +#include "detail/IExpression_DSequenceExpr.hpp" +#include +#include +#include +#include +#include +#include namespace xo { + using xo::mm::AGCObject; + using xo::facet::FacetRegistry; + using xo::reflect::typeseq; + namespace scm { obj @@ -35,8 +46,8 @@ namespace xo { return expr; } - size_type - DSequenceExpr::size() const noexcept + auto + DSequenceExpr::size() const noexcept -> size_type { return expr_v_->size(); } @@ -44,7 +55,9 @@ namespace xo { obj DSequenceExpr::operator[](std::size_t i) const { - return (*expr_v_)[i]; + obj gco = (*expr_v_)[i]; + + return FacetRegistry::instance().variant(gco); } void @@ -64,7 +77,10 @@ namespace xo { this->expr_v_ = expr_2x_v; } - this->expr_v_->push_back(expr); + obj expr_gco + = FacetRegistry::instance().variant(expr); + + this->expr_v_->push_back(expr_gco); } void @@ -73,15 +89,16 @@ namespace xo { typeref_.resolve(td); } - void + bool DSequenceExpr::pretty(const ppindentinfo & ppii) const { using xo::print::ppstate; - ppstate * pps = ppii.pps(); - - xxx; + return ppii.pps()->pretty_struct + (ppii, + "DSequenceExpr"); } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/expression2/IExpression_DApplyExpr.cpp b/src/expression2/IExpression_DApplyExpr.cpp index 2098e050..c00e91dc 100644 --- a/src/expression2/IExpression_DApplyExpr.cpp +++ b/src/expression2/IExpression_DApplyExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DApplyExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IExpression_DConstant.cpp b/src/expression2/IExpression_DConstant.cpp index 2d39c36d..0e91d27d 100644 --- a/src/expression2/IExpression_DConstant.cpp +++ b/src/expression2/IExpression_DConstant.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DConstant.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IExpression_DDefineExpr.cpp b/src/expression2/IExpression_DDefineExpr.cpp index 3222eabd..ab0676a4 100644 --- a/src/expression2/IExpression_DDefineExpr.cpp +++ b/src/expression2/IExpression_DDefineExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DDefineExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IExpression_DIfElseExpr.cpp b/src/expression2/IExpression_DIfElseExpr.cpp index d913eaf0..78680310 100644 --- a/src/expression2/IExpression_DIfElseExpr.cpp +++ b/src/expression2/IExpression_DIfElseExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IExpression_DLambdaExpr.cpp b/src/expression2/IExpression_DLambdaExpr.cpp index 273f5544..d9174ad2 100644 --- a/src/expression2/IExpression_DLambdaExpr.cpp +++ b/src/expression2/IExpression_DLambdaExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DLambdaExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IExpression_DSequenceExpr.cpp b/src/expression2/IExpression_DSequenceExpr.cpp new file mode 100644 index 00000000..e269a114 --- /dev/null +++ b/src/expression2/IExpression_DSequenceExpr.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DSequenceExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DSequenceExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DSequenceExpr.json5] +**/ + +#include "detail/IExpression_DSequenceExpr.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DSequenceExpr::extype(const DSequenceExpr & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DSequenceExpr::typeref(const DSequenceExpr & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DSequenceExpr::valuetype(const DSequenceExpr & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DSequenceExpr::assign_valuetype(DSequenceExpr & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DSequenceExpr.cpp */ \ No newline at end of file diff --git a/src/expression2/IExpression_DVariable.cpp b/src/expression2/IExpression_DVariable.cpp index 2b4a007b..ca657c36 100644 --- a/src/expression2/IExpression_DVariable.cpp +++ b/src/expression2/IExpression_DVariable.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IGCObject_DUniqueString.cpp b/src/expression2/IGCObject_DUniqueString.cpp index b13b3f79..5d2553f0 100644 --- a/src/expression2/IGCObject_DUniqueString.cpp +++ b/src/expression2/IGCObject_DUniqueString.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DUniqueString.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IGCObject_DVariable.cpp b/src/expression2/IGCObject_DVariable.cpp index 4af0f906..8735b286 100644 --- a/src/expression2/IGCObject_DVariable.cpp +++ b/src/expression2/IGCObject_DVariable.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DApplyExpr.cpp b/src/expression2/IPrintable_DApplyExpr.cpp index 4f4a50d3..6c7c16a8 100644 --- a/src/expression2/IPrintable_DApplyExpr.cpp +++ b/src/expression2/IPrintable_DApplyExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DApplyExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DConstant.cpp b/src/expression2/IPrintable_DConstant.cpp index 1bacfb9d..02e8bde0 100644 --- a/src/expression2/IPrintable_DConstant.cpp +++ b/src/expression2/IPrintable_DConstant.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DConstant.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DDefineExpr.cpp b/src/expression2/IPrintable_DDefineExpr.cpp index e8c6a799..31f8c554 100644 --- a/src/expression2/IPrintable_DDefineExpr.cpp +++ b/src/expression2/IPrintable_DDefineExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DDefineExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DIfElseExpr.cpp b/src/expression2/IPrintable_DIfElseExpr.cpp index a75cd6a4..ec68b9fc 100644 --- a/src/expression2/IPrintable_DIfElseExpr.cpp +++ b/src/expression2/IPrintable_DIfElseExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DLambdaExpr.cpp b/src/expression2/IPrintable_DLambdaExpr.cpp index 12e6c22c..966c9d2f 100644 --- a/src/expression2/IPrintable_DLambdaExpr.cpp +++ b/src/expression2/IPrintable_DLambdaExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DLambdaExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DLocalSymtab.cpp b/src/expression2/IPrintable_DLocalSymtab.cpp index dbd4887b..90f69407 100644 --- a/src/expression2/IPrintable_DLocalSymtab.cpp +++ b/src/expression2/IPrintable_DLocalSymtab.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DLocalSymtab.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DUniqueString.cpp b/src/expression2/IPrintable_DUniqueString.cpp index a7b92af8..ef7cf037 100644 --- a/src/expression2/IPrintable_DUniqueString.cpp +++ b/src/expression2/IPrintable_DUniqueString.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DUniqueString.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DVariable.cpp b/src/expression2/IPrintable_DVariable.cpp index 75e673ae..edf79638 100644 --- a/src/expression2/IPrintable_DVariable.cpp +++ b/src/expression2/IPrintable_DVariable.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/ISymbolTable_DLocalSymtab.cpp b/src/expression2/ISymbolTable_DLocalSymtab.cpp index 778cfdf4..3e5e465c 100644 --- a/src/expression2/ISymbolTable_DLocalSymtab.cpp +++ b/src/expression2/ISymbolTable_DLocalSymtab.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] * arguments: * --input [idl/ISymbolTable_DLocalSymtab.json5] * 2. jinja2 template for abstract facet .hpp file: From 440d43e1099ca0d077d274891681eec306f3d01b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 31 Jan 2026 12:40:50 -0500 Subject: [PATCH 054/128] xo-expression2: + GCObject,Printable facets for DSequenceExpr --- CMakeLists.txt | 24 +++++++ idl/IGCObject_DSequenceExpr.json5 | 15 +++++ idl/IPrintable_DSequenceExpr.json5 | 13 ++++ include/xo/expression2/DSequenceExpr.hpp | 9 +++ include/xo/expression2/Expression.hpp | 2 +- include/xo/expression2/SymbolTable.hpp | 2 +- include/xo/expression2/detail/AExpression.hpp | 2 +- .../xo/expression2/detail/IExpression_Any.hpp | 2 +- .../detail/IExpression_DApplyExpr.hpp | 2 +- .../detail/IExpression_DConstant.hpp | 2 +- .../detail/IExpression_DDefineExpr.hpp | 2 +- .../detail/IExpression_DIfElseExpr.hpp | 2 +- .../detail/IExpression_DLambdaExpr.hpp | 2 +- .../detail/IExpression_DSequenceExpr.hpp | 2 +- .../detail/IExpression_DVariable.hpp | 2 +- .../expression2/detail/IExpression_Xfer.hpp | 2 +- .../detail/IGCObject_DSequenceExpr.hpp | 67 +++++++++++++++++++ .../detail/IGCObject_DUniqueString.hpp | 2 +- .../detail/IGCObject_DVariable.hpp | 2 +- .../detail/IPrintable_DApplyExpr.hpp | 2 +- .../detail/IPrintable_DConstant.hpp | 2 +- .../detail/IPrintable_DDefineExpr.hpp | 2 +- .../detail/IPrintable_DIfElseExpr.hpp | 2 +- .../detail/IPrintable_DLambdaExpr.hpp | 2 +- .../detail/IPrintable_DSequenceExpr.hpp | 62 +++++++++++++++++ .../detail/IPrintable_DUniqueString.hpp | 2 +- .../detail/IPrintable_DVariable.hpp | 2 +- include/xo/expression2/detail/RExpression.hpp | 2 +- .../xo/expression2/symtab/ASymbolTable.hpp | 2 +- .../symtab/IPrintable_DLocalSymtab.hpp | 2 +- .../expression2/symtab/ISymbolTable_Any.hpp | 2 +- .../symtab/ISymbolTable_DLocalSymtab.hpp | 2 +- .../expression2/symtab/ISymbolTable_Xfer.hpp | 2 +- .../xo/expression2/symtab/RSymbolTable.hpp | 2 +- src/expression2/CMakeLists.txt | 2 + src/expression2/DSequenceExpr.cpp | 34 ++++++++++ src/expression2/IExpression_DApplyExpr.cpp | 2 +- src/expression2/IExpression_DConstant.cpp | 2 +- src/expression2/IExpression_DDefineExpr.cpp | 2 +- src/expression2/IExpression_DIfElseExpr.cpp | 2 +- src/expression2/IExpression_DLambdaExpr.cpp | 2 +- src/expression2/IExpression_DSequenceExpr.cpp | 2 +- src/expression2/IExpression_DVariable.cpp | 2 +- src/expression2/IGCObject_DSequenceExpr.cpp | 39 +++++++++++ src/expression2/IGCObject_DUniqueString.cpp | 2 +- src/expression2/IGCObject_DVariable.cpp | 2 +- src/expression2/IPrintable_DApplyExpr.cpp | 2 +- src/expression2/IPrintable_DConstant.cpp | 2 +- src/expression2/IPrintable_DDefineExpr.cpp | 2 +- src/expression2/IPrintable_DIfElseExpr.cpp | 2 +- src/expression2/IPrintable_DLambdaExpr.cpp | 2 +- src/expression2/IPrintable_DLocalSymtab.cpp | 2 +- src/expression2/IPrintable_DSequenceExpr.cpp | 28 ++++++++ src/expression2/IPrintable_DUniqueString.cpp | 2 +- src/expression2/IPrintable_DVariable.cpp | 2 +- src/expression2/ISymbolTable_DLocalSymtab.cpp | 2 +- .../expression2_register_facets.cpp | 9 +++ 57 files changed, 348 insertions(+), 46 deletions(-) create mode 100644 idl/IGCObject_DSequenceExpr.json5 create mode 100644 idl/IPrintable_DSequenceExpr.json5 create mode 100644 include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp create mode 100644 include/xo/expression2/detail/IPrintable_DSequenceExpr.hpp create mode 100644 src/expression2/IGCObject_DSequenceExpr.cpp create mode 100644 src/expression2/IPrintable_DSequenceExpr.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f7705ce..7cc83f11 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -250,6 +250,30 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-sequenceexpr + FACET_PKG xo_gc + FACET GCObject + REPR SequenceExpr + INPUT idl/IGCObject_DSequenceExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-sequenceexpr + FACET_PKG xo_printable2 + FACET Printable + REPR SequenceExpr + INPUT idl/IPrintable_DSequenceExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + # ---------------------------------------------------------------- # note: manual target; generated code committed to git diff --git a/idl/IGCObject_DSequenceExpr.json5 b/idl/IGCObject_DSequenceExpr.json5 new file mode 100644 index 00000000..d3bf4aef --- /dev/null +++ b/idl/IGCObject_DSequenceExpr.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DSequenceExpr", + using_doxygen: true, + repr: "DSequenceExpr", + doc: [ "implement AGCObject for DSequenceExpr" ], +} diff --git a/idl/IPrintable_DSequenceExpr.json5 b/idl/IPrintable_DSequenceExpr.json5 new file mode 100644 index 00000000..34154a1e --- /dev/null +++ b/idl/IPrintable_DSequenceExpr.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DSequenceExpr", + using_doxygen: true, + repr: "DSequenceExpr", + doc: [ "implement APrintable for DSequenceExpr" ], +} diff --git a/include/xo/expression2/DSequenceExpr.hpp b/include/xo/expression2/DSequenceExpr.hpp index 7285ada8..c5bb6f16 100644 --- a/include/xo/expression2/DSequenceExpr.hpp +++ b/include/xo/expression2/DSequenceExpr.hpp @@ -22,6 +22,7 @@ namespace xo { **/ class DSequenceExpr { public: + using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; using size_type = DArray::size_type; @@ -68,6 +69,14 @@ namespace xo { bool pretty(const ppindentinfo & ppii) const; ///@} + /** @defgroup scm-sequenceexpr-gcobject-facet gcobject facet methods **/ + ///@{ + + std::size_t shallow_size() const noexcept; + DSequenceExpr * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + + ///@} private: /** expression value always has type consistent with this description diff --git a/include/xo/expression2/Expression.hpp b/include/xo/expression2/Expression.hpp index 60e8a402..df4161a1 100644 --- a/include/xo/expression2/Expression.hpp +++ b/include/xo/expression2/Expression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for facet .hpp file: diff --git a/include/xo/expression2/SymbolTable.hpp b/include/xo/expression2/SymbolTable.hpp index 09fc04a8..26576ed6 100644 --- a/include/xo/expression2/SymbolTable.hpp +++ b/include/xo/expression2/SymbolTable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for facet .hpp file: diff --git a/include/xo/expression2/detail/AExpression.hpp b/include/xo/expression2/detail/AExpression.hpp index 10375114..e080ece8 100644 --- a/include/xo/expression2/detail/AExpression.hpp +++ b/include/xo/expression2/detail/AExpression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_Any.hpp b/include/xo/expression2/detail/IExpression_Any.hpp index c92c2c4a..17545afb 100644 --- a/include/xo/expression2/detail/IExpression_Any.hpp +++ b/include/xo/expression2/detail/IExpression_Any.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DApplyExpr.hpp b/include/xo/expression2/detail/IExpression_DApplyExpr.hpp index d577854f..c8952199 100644 --- a/include/xo/expression2/detail/IExpression_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DApplyExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DApplyExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DConstant.hpp b/include/xo/expression2/detail/IExpression_DConstant.hpp index 89c5044c..61b92e12 100644 --- a/include/xo/expression2/detail/IExpression_DConstant.hpp +++ b/include/xo/expression2/detail/IExpression_DConstant.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DConstant.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DDefineExpr.hpp b/include/xo/expression2/detail/IExpression_DDefineExpr.hpp index f5585b60..3ac7fd49 100644 --- a/include/xo/expression2/detail/IExpression_DDefineExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DDefineExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DDefineExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp b/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp index 03500a39..7d726dde 100644 --- a/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp b/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp index 916b82ac..d488b6b3 100644 --- a/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DLambdaExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DSequenceExpr.hpp b/include/xo/expression2/detail/IExpression_DSequenceExpr.hpp index b010ac65..e66d657c 100644 --- a/include/xo/expression2/detail/IExpression_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DSequenceExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DSequenceExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DVariable.hpp b/include/xo/expression2/detail/IExpression_DVariable.hpp index 95b1becb..6b9b702f 100644 --- a/include/xo/expression2/detail/IExpression_DVariable.hpp +++ b/include/xo/expression2/detail/IExpression_DVariable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_Xfer.hpp b/include/xo/expression2/detail/IExpression_Xfer.hpp index 9f7356bc..fac8c541 100644 --- a/include/xo/expression2/detail/IExpression_Xfer.hpp +++ b/include/xo/expression2/detail/IExpression_Xfer.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp new file mode 100644 index 00000000..5ffb5007 --- /dev/null +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DSequenceExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DSequenceExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DSequenceExpr.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DSequenceExpr.hpp" + +namespace xo { namespace scm { class IGCObject_DSequenceExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DSequenceExpr + **/ + class IGCObject_DSequenceExpr { + public: + /** @defgroup scm-gcobject-dsequenceexpr-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dsequenceexpr-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DSequenceExpr & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DSequenceExpr & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DSequenceExpr & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IGCObject_DUniqueString.hpp b/include/xo/expression2/detail/IGCObject_DUniqueString.hpp index c95db10f..b971daea 100644 --- a/include/xo/expression2/detail/IGCObject_DUniqueString.hpp +++ b/include/xo/expression2/detail/IGCObject_DUniqueString.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DUniqueString.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IGCObject_DVariable.hpp b/include/xo/expression2/detail/IGCObject_DVariable.hpp index aee612ea..24dc591f 100644 --- a/include/xo/expression2/detail/IGCObject_DVariable.hpp +++ b/include/xo/expression2/detail/IGCObject_DVariable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp b/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp index b7782166..c05e87e2 100644 --- a/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DApplyExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DConstant.hpp b/include/xo/expression2/detail/IPrintable_DConstant.hpp index 35535d80..a1e31382 100644 --- a/include/xo/expression2/detail/IPrintable_DConstant.hpp +++ b/include/xo/expression2/detail/IPrintable_DConstant.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DConstant.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp b/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp index 758022a6..6d727d86 100644 --- a/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp +++ b/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DDefineExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp b/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp index e9cf67ff..fcf80fd5 100644 --- a/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp b/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp index 45970bd8..64ab6af1 100644 --- a/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DLambdaExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DSequenceExpr.hpp b/include/xo/expression2/detail/IPrintable_DSequenceExpr.hpp new file mode 100644 index 00000000..eec1649c --- /dev/null +++ b/include/xo/expression2/detail/IPrintable_DSequenceExpr.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DSequenceExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DSequenceExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DSequenceExpr.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DSequenceExpr.hpp" + +namespace xo { namespace scm { class IPrintable_DSequenceExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DSequenceExpr + **/ + class IPrintable_DSequenceExpr { + public: + /** @defgroup scm-printable-dsequenceexpr-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dsequenceexpr-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DSequenceExpr & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IPrintable_DUniqueString.hpp b/include/xo/expression2/detail/IPrintable_DUniqueString.hpp index 51afa9da..34c9da79 100644 --- a/include/xo/expression2/detail/IPrintable_DUniqueString.hpp +++ b/include/xo/expression2/detail/IPrintable_DUniqueString.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DUniqueString.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DVariable.hpp b/include/xo/expression2/detail/IPrintable_DVariable.hpp index a31ee97e..6e97451b 100644 --- a/include/xo/expression2/detail/IPrintable_DVariable.hpp +++ b/include/xo/expression2/detail/IPrintable_DVariable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/RExpression.hpp b/include/xo/expression2/detail/RExpression.hpp index caf69fe0..4d717640 100644 --- a/include/xo/expression2/detail/RExpression.hpp +++ b/include/xo/expression2/detail/RExpression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/ASymbolTable.hpp b/include/xo/expression2/symtab/ASymbolTable.hpp index 36d4c812..f0c6e10f 100644 --- a/include/xo/expression2/symtab/ASymbolTable.hpp +++ b/include/xo/expression2/symtab/ASymbolTable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp b/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp index d4481dca..c013e937 100644 --- a/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DLocalSymtab.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/ISymbolTable_Any.hpp b/include/xo/expression2/symtab/ISymbolTable_Any.hpp index 6a119832..b642adb7 100644 --- a/include/xo/expression2/symtab/ISymbolTable_Any.hpp +++ b/include/xo/expression2/symtab/ISymbolTable_Any.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp b/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp index 2c1816e4..72f409dd 100644 --- a/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/ISymbolTable_DLocalSymtab.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp b/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp index 2333bb05..3d5f7221 100644 --- a/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp +++ b/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/RSymbolTable.hpp b/include/xo/expression2/symtab/RSymbolTable.hpp index c72503cc..600ea4f8 100644 --- a/include/xo/expression2/symtab/RSymbolTable.hpp +++ b/include/xo/expression2/symtab/RSymbolTable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index ab10048e..4f929fa4 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -36,6 +36,8 @@ set(SELF_SRCS IPrintable_DIfElseExpr.cpp IExpression_DSequenceExpr.cpp + IGCObject_DSequenceExpr.cpp + IPrintable_DSequenceExpr.cpp DLocalSymtab.cpp DGlobalSymtab.cpp diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index 5e449531..73b9c2b5 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -5,6 +5,7 @@ #include "DSequenceExpr.hpp" #include "detail/IExpression_DSequenceExpr.hpp" +#include #include #include #include @@ -99,6 +100,39 @@ namespace xo { "DSequenceExpr"); } + // gc hooks for IGCObject_DSequenceExpr + + std::size_t + DSequenceExpr::shallow_size() const noexcept + { + return sizeof(DSequenceExpr); + } + + DSequenceExpr * + DSequenceExpr::shallow_copy(obj mm) const noexcept + { + DSequenceExpr * copy = (DSequenceExpr *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + std::size_t + DSequenceExpr::forward_children(obj gc) noexcept + { + // WARNING. + // if this proves problematic, + // may resort to obj for expr_v_ member + + auto iface = facet::impl_for(); + + gc.forward_inplace(&iface, (void**)&expr_v_); + + return shallow_size(); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/expression2/IExpression_DApplyExpr.cpp b/src/expression2/IExpression_DApplyExpr.cpp index c00e91dc..2098e050 100644 --- a/src/expression2/IExpression_DApplyExpr.cpp +++ b/src/expression2/IExpression_DApplyExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DApplyExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IExpression_DConstant.cpp b/src/expression2/IExpression_DConstant.cpp index 0e91d27d..2d39c36d 100644 --- a/src/expression2/IExpression_DConstant.cpp +++ b/src/expression2/IExpression_DConstant.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DConstant.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IExpression_DDefineExpr.cpp b/src/expression2/IExpression_DDefineExpr.cpp index ab0676a4..3222eabd 100644 --- a/src/expression2/IExpression_DDefineExpr.cpp +++ b/src/expression2/IExpression_DDefineExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DDefineExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IExpression_DIfElseExpr.cpp b/src/expression2/IExpression_DIfElseExpr.cpp index 78680310..d913eaf0 100644 --- a/src/expression2/IExpression_DIfElseExpr.cpp +++ b/src/expression2/IExpression_DIfElseExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IExpression_DLambdaExpr.cpp b/src/expression2/IExpression_DLambdaExpr.cpp index d9174ad2..273f5544 100644 --- a/src/expression2/IExpression_DLambdaExpr.cpp +++ b/src/expression2/IExpression_DLambdaExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DLambdaExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IExpression_DSequenceExpr.cpp b/src/expression2/IExpression_DSequenceExpr.cpp index e269a114..cf00bc60 100644 --- a/src/expression2/IExpression_DSequenceExpr.cpp +++ b/src/expression2/IExpression_DSequenceExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DSequenceExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IExpression_DVariable.cpp b/src/expression2/IExpression_DVariable.cpp index ca657c36..2b4a007b 100644 --- a/src/expression2/IExpression_DVariable.cpp +++ b/src/expression2/IExpression_DVariable.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IGCObject_DSequenceExpr.cpp b/src/expression2/IGCObject_DSequenceExpr.cpp new file mode 100644 index 00000000..474851ed --- /dev/null +++ b/src/expression2/IGCObject_DSequenceExpr.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DSequenceExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DSequenceExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DSequenceExpr.json5] +**/ + +#include "detail/IGCObject_DSequenceExpr.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DSequenceExpr::shallow_size(const DSequenceExpr & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DSequenceExpr::shallow_copy(const DSequenceExpr & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DSequenceExpr::forward_children(DSequenceExpr & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DSequenceExpr.cpp */ \ No newline at end of file diff --git a/src/expression2/IGCObject_DUniqueString.cpp b/src/expression2/IGCObject_DUniqueString.cpp index 5d2553f0..b13b3f79 100644 --- a/src/expression2/IGCObject_DUniqueString.cpp +++ b/src/expression2/IGCObject_DUniqueString.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DUniqueString.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IGCObject_DVariable.cpp b/src/expression2/IGCObject_DVariable.cpp index 8735b286..4af0f906 100644 --- a/src/expression2/IGCObject_DVariable.cpp +++ b/src/expression2/IGCObject_DVariable.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DApplyExpr.cpp b/src/expression2/IPrintable_DApplyExpr.cpp index 6c7c16a8..4f4a50d3 100644 --- a/src/expression2/IPrintable_DApplyExpr.cpp +++ b/src/expression2/IPrintable_DApplyExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DApplyExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DConstant.cpp b/src/expression2/IPrintable_DConstant.cpp index 02e8bde0..1bacfb9d 100644 --- a/src/expression2/IPrintable_DConstant.cpp +++ b/src/expression2/IPrintable_DConstant.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DConstant.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DDefineExpr.cpp b/src/expression2/IPrintable_DDefineExpr.cpp index 31f8c554..e8c6a799 100644 --- a/src/expression2/IPrintable_DDefineExpr.cpp +++ b/src/expression2/IPrintable_DDefineExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DDefineExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DIfElseExpr.cpp b/src/expression2/IPrintable_DIfElseExpr.cpp index ec68b9fc..a75cd6a4 100644 --- a/src/expression2/IPrintable_DIfElseExpr.cpp +++ b/src/expression2/IPrintable_DIfElseExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DLambdaExpr.cpp b/src/expression2/IPrintable_DLambdaExpr.cpp index 966c9d2f..12e6c22c 100644 --- a/src/expression2/IPrintable_DLambdaExpr.cpp +++ b/src/expression2/IPrintable_DLambdaExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DLambdaExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DLocalSymtab.cpp b/src/expression2/IPrintable_DLocalSymtab.cpp index 90f69407..dbd4887b 100644 --- a/src/expression2/IPrintable_DLocalSymtab.cpp +++ b/src/expression2/IPrintable_DLocalSymtab.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DLocalSymtab.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DSequenceExpr.cpp b/src/expression2/IPrintable_DSequenceExpr.cpp new file mode 100644 index 00000000..d07c5f08 --- /dev/null +++ b/src/expression2/IPrintable_DSequenceExpr.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DSequenceExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DSequenceExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DSequenceExpr.json5] +**/ + +#include "detail/IPrintable_DSequenceExpr.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DSequenceExpr::pretty(const DSequenceExpr & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DSequenceExpr.cpp */ \ No newline at end of file diff --git a/src/expression2/IPrintable_DUniqueString.cpp b/src/expression2/IPrintable_DUniqueString.cpp index ef7cf037..a7b92af8 100644 --- a/src/expression2/IPrintable_DUniqueString.cpp +++ b/src/expression2/IPrintable_DUniqueString.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DUniqueString.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/IPrintable_DVariable.cpp b/src/expression2/IPrintable_DVariable.cpp index edf79638..75e673ae 100644 --- a/src/expression2/IPrintable_DVariable.cpp +++ b/src/expression2/IPrintable_DVariable.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/ISymbolTable_DLocalSymtab.cpp b/src/expression2/ISymbolTable_DLocalSymtab.cpp index 3e5e465c..778cfdf4 100644 --- a/src/expression2/ISymbolTable_DLocalSymtab.cpp +++ b/src/expression2/ISymbolTable_DLocalSymtab.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/Users/roland/proj/xo-umbrella2/xo-facet/codegen/genfacet] + * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] * arguments: * --input [idl/ISymbolTable_DLocalSymtab.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 06ccc7d5..8109293a 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -27,6 +27,10 @@ #include #include +#include +#include +#include + #include #include @@ -77,6 +81,10 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -87,6 +95,7 @@ namespace xo { log && log(xtag("DApplyExpr.tseq", typeseq::id())); log && log(xtag("DLambdaExpr.tseq", typeseq::id())); log && log(xtag("DIfElseExpr.tseq", typeseq::id())); + log && log(xtag("DSequenceExpr.tseq", typeseq::id())); log && log(xtag("DLocalSymtab.tseq", typeseq::id())); From ce5728f3c074c326edd394cb73e15eca944d6382 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 31 Jan 2026 13:00:12 -0500 Subject: [PATCH 055/128] xo-expression2: stable generated facet files. --- include/xo/expression2/Expression.hpp | 4 ++-- include/xo/expression2/SymbolTable.hpp | 4 ++-- include/xo/expression2/detail/AExpression.hpp | 4 ++-- include/xo/expression2/detail/IExpression_Any.hpp | 4 ++-- include/xo/expression2/detail/IExpression_DApplyExpr.hpp | 2 +- include/xo/expression2/detail/IExpression_DConstant.hpp | 2 +- include/xo/expression2/detail/IExpression_DDefineExpr.hpp | 2 +- include/xo/expression2/detail/IExpression_DIfElseExpr.hpp | 2 +- include/xo/expression2/detail/IExpression_DLambdaExpr.hpp | 2 +- include/xo/expression2/detail/IExpression_DSequenceExpr.hpp | 2 +- include/xo/expression2/detail/IExpression_DVariable.hpp | 2 +- include/xo/expression2/detail/IExpression_Xfer.hpp | 4 ++-- include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DUniqueString.hpp | 2 +- include/xo/expression2/detail/IGCObject_DVariable.hpp | 2 +- include/xo/expression2/detail/IPrintable_DApplyExpr.hpp | 2 +- include/xo/expression2/detail/IPrintable_DConstant.hpp | 2 +- include/xo/expression2/detail/IPrintable_DDefineExpr.hpp | 2 +- include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp | 2 +- include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp | 2 +- include/xo/expression2/detail/IPrintable_DSequenceExpr.hpp | 2 +- include/xo/expression2/detail/IPrintable_DUniqueString.hpp | 2 +- include/xo/expression2/detail/IPrintable_DVariable.hpp | 2 +- include/xo/expression2/detail/RExpression.hpp | 4 ++-- include/xo/expression2/symtab/ASymbolTable.hpp | 4 ++-- include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp | 2 +- include/xo/expression2/symtab/ISymbolTable_Any.hpp | 4 ++-- include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp | 2 +- include/xo/expression2/symtab/ISymbolTable_Xfer.hpp | 4 ++-- include/xo/expression2/symtab/RSymbolTable.hpp | 4 ++-- src/expression2/IExpression_Any.cpp | 2 +- src/expression2/IExpression_DApplyExpr.cpp | 4 ++-- src/expression2/IExpression_DConstant.cpp | 4 ++-- src/expression2/IExpression_DDefineExpr.cpp | 4 ++-- src/expression2/IExpression_DIfElseExpr.cpp | 4 ++-- src/expression2/IExpression_DLambdaExpr.cpp | 4 ++-- src/expression2/IExpression_DSequenceExpr.cpp | 4 ++-- src/expression2/IExpression_DVariable.cpp | 4 ++-- src/expression2/IGCObject_DSequenceExpr.cpp | 4 ++-- src/expression2/IGCObject_DUniqueString.cpp | 4 ++-- src/expression2/IGCObject_DVariable.cpp | 4 ++-- src/expression2/IPrintable_DApplyExpr.cpp | 4 ++-- src/expression2/IPrintable_DConstant.cpp | 4 ++-- src/expression2/IPrintable_DDefineExpr.cpp | 4 ++-- src/expression2/IPrintable_DIfElseExpr.cpp | 4 ++-- src/expression2/IPrintable_DLambdaExpr.cpp | 4 ++-- src/expression2/IPrintable_DLocalSymtab.cpp | 4 ++-- src/expression2/IPrintable_DSequenceExpr.cpp | 4 ++-- src/expression2/IPrintable_DUniqueString.cpp | 4 ++-- src/expression2/IPrintable_DVariable.cpp | 4 ++-- src/expression2/ISymbolTable_Any.cpp | 2 +- src/expression2/ISymbolTable_DLocalSymtab.cpp | 4 ++-- 52 files changed, 82 insertions(+), 82 deletions(-) diff --git a/include/xo/expression2/Expression.hpp b/include/xo/expression2/Expression.hpp index df4161a1..6ed0e1f2 100644 --- a/include/xo/expression2/Expression.hpp +++ b/include/xo/expression2/Expression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for facet .hpp file: @@ -19,4 +19,4 @@ #include "detail/RExpression.hpp" -/* end Expression.hpp */ \ No newline at end of file +/* end Expression.hpp */ diff --git a/include/xo/expression2/SymbolTable.hpp b/include/xo/expression2/SymbolTable.hpp index 26576ed6..618cf2bf 100644 --- a/include/xo/expression2/SymbolTable.hpp +++ b/include/xo/expression2/SymbolTable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for facet .hpp file: @@ -19,4 +19,4 @@ #include "symtab/RSymbolTable.hpp" -/* end SymbolTable.hpp */ \ No newline at end of file +/* end SymbolTable.hpp */ diff --git a/include/xo/expression2/detail/AExpression.hpp b/include/xo/expression2/detail/AExpression.hpp index e080ece8..59c83339 100644 --- a/include/xo/expression2/detail/AExpression.hpp +++ b/include/xo/expression2/detail/AExpression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -79,4 +79,4 @@ using IExpression_ImplType = xo::facet::FacetImplType; } /*namespace scm*/ } /*namespace xo*/ -/* AExpression.hpp */ \ No newline at end of file +/* AExpression.hpp */ diff --git a/include/xo/expression2/detail/IExpression_Any.hpp b/include/xo/expression2/detail/IExpression_Any.hpp index 17545afb..8ecb604d 100644 --- a/include/xo/expression2/detail/IExpression_Any.hpp +++ b/include/xo/expression2/detail/IExpression_Any.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -86,4 +86,4 @@ namespace scm { } /*namespace scm */ } /*namespace xo */ -/* IExpression_Any.hpp */ \ No newline at end of file +/* IExpression_Any.hpp */ diff --git a/include/xo/expression2/detail/IExpression_DApplyExpr.hpp b/include/xo/expression2/detail/IExpression_DApplyExpr.hpp index c8952199..49cce701 100644 --- a/include/xo/expression2/detail/IExpression_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DApplyExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DApplyExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DConstant.hpp b/include/xo/expression2/detail/IExpression_DConstant.hpp index 61b92e12..c6bbd819 100644 --- a/include/xo/expression2/detail/IExpression_DConstant.hpp +++ b/include/xo/expression2/detail/IExpression_DConstant.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DConstant.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DDefineExpr.hpp b/include/xo/expression2/detail/IExpression_DDefineExpr.hpp index 3ac7fd49..135c7bb4 100644 --- a/include/xo/expression2/detail/IExpression_DDefineExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DDefineExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DDefineExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp b/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp index 7d726dde..ca6e5705 100644 --- a/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DIfElseExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp b/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp index d488b6b3..bdb074d9 100644 --- a/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DLambdaExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DLambdaExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DSequenceExpr.hpp b/include/xo/expression2/detail/IExpression_DSequenceExpr.hpp index e66d657c..6e0107dd 100644 --- a/include/xo/expression2/detail/IExpression_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IExpression_DSequenceExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DSequenceExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_DVariable.hpp b/include/xo/expression2/detail/IExpression_DVariable.hpp index 6b9b702f..cacd4be2 100644 --- a/include/xo/expression2/detail/IExpression_DVariable.hpp +++ b/include/xo/expression2/detail/IExpression_DVariable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IExpression_Xfer.hpp b/include/xo/expression2/detail/IExpression_Xfer.hpp index fac8c541..b95b8526 100644 --- a/include/xo/expression2/detail/IExpression_Xfer.hpp +++ b/include/xo/expression2/detail/IExpression_Xfer.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -89,4 +89,4 @@ namespace scm { } /*namespace scm */ } /*namespace xo*/ -/* end IExpression_Xfer.hpp */ \ No newline at end of file +/* end IExpression_Xfer.hpp */ diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index 5ffb5007..1f6b8deb 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DSequenceExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IGCObject_DUniqueString.hpp b/include/xo/expression2/detail/IGCObject_DUniqueString.hpp index b971daea..398e3eed 100644 --- a/include/xo/expression2/detail/IGCObject_DUniqueString.hpp +++ b/include/xo/expression2/detail/IGCObject_DUniqueString.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DUniqueString.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IGCObject_DVariable.hpp b/include/xo/expression2/detail/IGCObject_DVariable.hpp index 24dc591f..242f335f 100644 --- a/include/xo/expression2/detail/IGCObject_DVariable.hpp +++ b/include/xo/expression2/detail/IGCObject_DVariable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp b/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp index c05e87e2..930846ce 100644 --- a/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IPrintable_DApplyExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DApplyExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DConstant.hpp b/include/xo/expression2/detail/IPrintable_DConstant.hpp index a1e31382..dc907b89 100644 --- a/include/xo/expression2/detail/IPrintable_DConstant.hpp +++ b/include/xo/expression2/detail/IPrintable_DConstant.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DConstant.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp b/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp index 6d727d86..f399c743 100644 --- a/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp +++ b/include/xo/expression2/detail/IPrintable_DDefineExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DDefineExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp b/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp index fcf80fd5..f4045504 100644 --- a/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IPrintable_DIfElseExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp b/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp index 64ab6af1..c14cfefe 100644 --- a/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IPrintable_DLambdaExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DLambdaExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DSequenceExpr.hpp b/include/xo/expression2/detail/IPrintable_DSequenceExpr.hpp index eec1649c..a27ba9a4 100644 --- a/include/xo/expression2/detail/IPrintable_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IPrintable_DSequenceExpr.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DSequenceExpr.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DUniqueString.hpp b/include/xo/expression2/detail/IPrintable_DUniqueString.hpp index 34c9da79..a57039a8 100644 --- a/include/xo/expression2/detail/IPrintable_DUniqueString.hpp +++ b/include/xo/expression2/detail/IPrintable_DUniqueString.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DUniqueString.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/IPrintable_DVariable.hpp b/include/xo/expression2/detail/IPrintable_DVariable.hpp index 6e97451b..10bbecca 100644 --- a/include/xo/expression2/detail/IPrintable_DVariable.hpp +++ b/include/xo/expression2/detail/IPrintable_DVariable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/detail/RExpression.hpp b/include/xo/expression2/detail/RExpression.hpp index 4d717640..a14a2ee5 100644 --- a/include/xo/expression2/detail/RExpression.hpp +++ b/include/xo/expression2/detail/RExpression.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/Expression.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -86,4 +86,4 @@ namespace xo { namespace facet { }; } } -/* end RExpression.hpp */ \ No newline at end of file +/* end RExpression.hpp */ diff --git a/include/xo/expression2/symtab/ASymbolTable.hpp b/include/xo/expression2/symtab/ASymbolTable.hpp index f0c6e10f..50d6b4b7 100644 --- a/include/xo/expression2/symtab/ASymbolTable.hpp +++ b/include/xo/expression2/symtab/ASymbolTable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -72,4 +72,4 @@ using ISymbolTable_ImplType = xo::facet::FacetImplType; } /*namespace scm*/ } /*namespace xo*/ -/* ASymbolTable.hpp */ \ No newline at end of file +/* ASymbolTable.hpp */ diff --git a/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp b/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp index c013e937..729534c0 100644 --- a/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IPrintable_DLocalSymtab.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DLocalSymtab.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/ISymbolTable_Any.hpp b/include/xo/expression2/symtab/ISymbolTable_Any.hpp index b642adb7..1f4c9b2e 100644 --- a/include/xo/expression2/symtab/ISymbolTable_Any.hpp +++ b/include/xo/expression2/symtab/ISymbolTable_Any.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -83,4 +83,4 @@ namespace scm { } /*namespace scm */ } /*namespace xo */ -/* ISymbolTable_Any.hpp */ \ No newline at end of file +/* ISymbolTable_Any.hpp */ diff --git a/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp b/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp index 72f409dd..9c9a2f0d 100644 --- a/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/ISymbolTable_DLocalSymtab.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISymbolTable_DLocalSymtab.json5] * 2. jinja2 template for abstract facet .hpp file: diff --git a/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp b/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp index 3d5f7221..f19f6e2e 100644 --- a/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp +++ b/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -81,4 +81,4 @@ namespace scm { } /*namespace scm */ } /*namespace xo*/ -/* end ISymbolTable_Xfer.hpp */ \ No newline at end of file +/* end ISymbolTable_Xfer.hpp */ diff --git a/include/xo/expression2/symtab/RSymbolTable.hpp b/include/xo/expression2/symtab/RSymbolTable.hpp index 600ea4f8..f6375b37 100644 --- a/include/xo/expression2/symtab/RSymbolTable.hpp +++ b/include/xo/expression2/symtab/RSymbolTable.hpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/SymbolTable.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -79,4 +79,4 @@ namespace xo { namespace facet { }; } } -/* end RSymbolTable.hpp */ \ No newline at end of file +/* end RSymbolTable.hpp */ diff --git a/src/expression2/IExpression_Any.cpp b/src/expression2/IExpression_Any.cpp index 7f60e5af..9557e7e7 100644 --- a/src/expression2/IExpression_Any.cpp +++ b/src/expression2/IExpression_Any.cpp @@ -44,4 +44,4 @@ IExpression_Any::assign_valuetype(Opaque, TypeDescr) noexcept -> void } /*namespace scm*/ } /*namespace xo*/ -/* end IExpression_Any.cpp */ \ No newline at end of file +/* end IExpression_Any.cpp */ diff --git a/src/expression2/IExpression_DApplyExpr.cpp b/src/expression2/IExpression_DApplyExpr.cpp index 2098e050..4ee365e0 100644 --- a/src/expression2/IExpression_DApplyExpr.cpp +++ b/src/expression2/IExpression_DApplyExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DApplyExpr.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -42,4 +42,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IExpression_DApplyExpr.cpp */ \ No newline at end of file +/* end IExpression_DApplyExpr.cpp */ diff --git a/src/expression2/IExpression_DConstant.cpp b/src/expression2/IExpression_DConstant.cpp index 2d39c36d..836a6aee 100644 --- a/src/expression2/IExpression_DConstant.cpp +++ b/src/expression2/IExpression_DConstant.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DConstant.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -42,4 +42,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IExpression_DConstant.cpp */ \ No newline at end of file +/* end IExpression_DConstant.cpp */ diff --git a/src/expression2/IExpression_DDefineExpr.cpp b/src/expression2/IExpression_DDefineExpr.cpp index 3222eabd..f8f2429c 100644 --- a/src/expression2/IExpression_DDefineExpr.cpp +++ b/src/expression2/IExpression_DDefineExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DDefineExpr.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -42,4 +42,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IExpression_DDefineExpr.cpp */ \ No newline at end of file +/* end IExpression_DDefineExpr.cpp */ diff --git a/src/expression2/IExpression_DIfElseExpr.cpp b/src/expression2/IExpression_DIfElseExpr.cpp index d913eaf0..947ca8de 100644 --- a/src/expression2/IExpression_DIfElseExpr.cpp +++ b/src/expression2/IExpression_DIfElseExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -42,4 +42,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IExpression_DIfElseExpr.cpp */ \ No newline at end of file +/* end IExpression_DIfElseExpr.cpp */ diff --git a/src/expression2/IExpression_DLambdaExpr.cpp b/src/expression2/IExpression_DLambdaExpr.cpp index 273f5544..1b177c91 100644 --- a/src/expression2/IExpression_DLambdaExpr.cpp +++ b/src/expression2/IExpression_DLambdaExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DLambdaExpr.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -42,4 +42,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IExpression_DLambdaExpr.cpp */ \ No newline at end of file +/* end IExpression_DLambdaExpr.cpp */ diff --git a/src/expression2/IExpression_DSequenceExpr.cpp b/src/expression2/IExpression_DSequenceExpr.cpp index cf00bc60..5ae4f3f7 100644 --- a/src/expression2/IExpression_DSequenceExpr.cpp +++ b/src/expression2/IExpression_DSequenceExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DSequenceExpr.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -42,4 +42,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IExpression_DSequenceExpr.cpp */ \ No newline at end of file +/* end IExpression_DSequenceExpr.cpp */ diff --git a/src/expression2/IExpression_DVariable.cpp b/src/expression2/IExpression_DVariable.cpp index 2b4a007b..bea2a24e 100644 --- a/src/expression2/IExpression_DVariable.cpp +++ b/src/expression2/IExpression_DVariable.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IExpression_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -42,4 +42,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IExpression_DVariable.cpp */ \ No newline at end of file +/* end IExpression_DVariable.cpp */ diff --git a/src/expression2/IGCObject_DSequenceExpr.cpp b/src/expression2/IGCObject_DSequenceExpr.cpp index 474851ed..54ad1bd5 100644 --- a/src/expression2/IGCObject_DSequenceExpr.cpp +++ b/src/expression2/IGCObject_DSequenceExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DSequenceExpr.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -36,4 +36,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DSequenceExpr.cpp */ \ No newline at end of file +/* end IGCObject_DSequenceExpr.cpp */ diff --git a/src/expression2/IGCObject_DUniqueString.cpp b/src/expression2/IGCObject_DUniqueString.cpp index b13b3f79..8238990f 100644 --- a/src/expression2/IGCObject_DUniqueString.cpp +++ b/src/expression2/IGCObject_DUniqueString.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DUniqueString.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -36,4 +36,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DUniqueString.cpp */ \ No newline at end of file +/* end IGCObject_DUniqueString.cpp */ diff --git a/src/expression2/IGCObject_DVariable.cpp b/src/expression2/IGCObject_DVariable.cpp index 4af0f906..ecc403ef 100644 --- a/src/expression2/IGCObject_DVariable.cpp +++ b/src/expression2/IGCObject_DVariable.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IGCObject_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -36,4 +36,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IGCObject_DVariable.cpp */ \ No newline at end of file +/* end IGCObject_DVariable.cpp */ diff --git a/src/expression2/IPrintable_DApplyExpr.cpp b/src/expression2/IPrintable_DApplyExpr.cpp index 4f4a50d3..06b7b752 100644 --- a/src/expression2/IPrintable_DApplyExpr.cpp +++ b/src/expression2/IPrintable_DApplyExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DApplyExpr.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DApplyExpr.cpp */ \ No newline at end of file +/* end IPrintable_DApplyExpr.cpp */ diff --git a/src/expression2/IPrintable_DConstant.cpp b/src/expression2/IPrintable_DConstant.cpp index 1bacfb9d..57bd271f 100644 --- a/src/expression2/IPrintable_DConstant.cpp +++ b/src/expression2/IPrintable_DConstant.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DConstant.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DConstant.cpp */ \ No newline at end of file +/* end IPrintable_DConstant.cpp */ diff --git a/src/expression2/IPrintable_DDefineExpr.cpp b/src/expression2/IPrintable_DDefineExpr.cpp index e8c6a799..2774e610 100644 --- a/src/expression2/IPrintable_DDefineExpr.cpp +++ b/src/expression2/IPrintable_DDefineExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DDefineExpr.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DDefineExpr.cpp */ \ No newline at end of file +/* end IPrintable_DDefineExpr.cpp */ diff --git a/src/expression2/IPrintable_DIfElseExpr.cpp b/src/expression2/IPrintable_DIfElseExpr.cpp index a75cd6a4..52694cb5 100644 --- a/src/expression2/IPrintable_DIfElseExpr.cpp +++ b/src/expression2/IPrintable_DIfElseExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DIfElseExpr.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DIfElseExpr.cpp */ \ No newline at end of file +/* end IPrintable_DIfElseExpr.cpp */ diff --git a/src/expression2/IPrintable_DLambdaExpr.cpp b/src/expression2/IPrintable_DLambdaExpr.cpp index 12e6c22c..049a81c8 100644 --- a/src/expression2/IPrintable_DLambdaExpr.cpp +++ b/src/expression2/IPrintable_DLambdaExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DLambdaExpr.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DLambdaExpr.cpp */ \ No newline at end of file +/* end IPrintable_DLambdaExpr.cpp */ diff --git a/src/expression2/IPrintable_DLocalSymtab.cpp b/src/expression2/IPrintable_DLocalSymtab.cpp index dbd4887b..0e178e09 100644 --- a/src/expression2/IPrintable_DLocalSymtab.cpp +++ b/src/expression2/IPrintable_DLocalSymtab.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DLocalSymtab.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DLocalSymtab.cpp */ \ No newline at end of file +/* end IPrintable_DLocalSymtab.cpp */ diff --git a/src/expression2/IPrintable_DSequenceExpr.cpp b/src/expression2/IPrintable_DSequenceExpr.cpp index d07c5f08..a3471232 100644 --- a/src/expression2/IPrintable_DSequenceExpr.cpp +++ b/src/expression2/IPrintable_DSequenceExpr.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DSequenceExpr.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DSequenceExpr.cpp */ \ No newline at end of file +/* end IPrintable_DSequenceExpr.cpp */ diff --git a/src/expression2/IPrintable_DUniqueString.cpp b/src/expression2/IPrintable_DUniqueString.cpp index a7b92af8..5f490bd9 100644 --- a/src/expression2/IPrintable_DUniqueString.cpp +++ b/src/expression2/IPrintable_DUniqueString.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DUniqueString.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DUniqueString.cpp */ \ No newline at end of file +/* end IPrintable_DUniqueString.cpp */ diff --git a/src/expression2/IPrintable_DVariable.cpp b/src/expression2/IPrintable_DVariable.cpp index 75e673ae..53364de5 100644 --- a/src/expression2/IPrintable_DVariable.cpp +++ b/src/expression2/IPrintable_DVariable.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/IPrintable_DVariable.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -25,4 +25,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end IPrintable_DVariable.cpp */ \ No newline at end of file +/* end IPrintable_DVariable.cpp */ diff --git a/src/expression2/ISymbolTable_Any.cpp b/src/expression2/ISymbolTable_Any.cpp index 7c811253..95718429 100644 --- a/src/expression2/ISymbolTable_Any.cpp +++ b/src/expression2/ISymbolTable_Any.cpp @@ -38,4 +38,4 @@ ISymbolTable_Any::_valid } /*namespace scm*/ } /*namespace xo*/ -/* end ISymbolTable_Any.cpp */ \ No newline at end of file +/* end ISymbolTable_Any.cpp */ diff --git a/src/expression2/ISymbolTable_DLocalSymtab.cpp b/src/expression2/ISymbolTable_DLocalSymtab.cpp index 778cfdf4..b67ada5c 100644 --- a/src/expression2/ISymbolTable_DLocalSymtab.cpp +++ b/src/expression2/ISymbolTable_DLocalSymtab.cpp @@ -2,7 +2,7 @@ * * Generated automagically from ingredients: * 1. code generator: - * [/home/roland/proj/xo-umbrella2-claude1/xo-facet/codegen/genfacet] + * [xo-facet/codegen/genfacet] * arguments: * --input [idl/ISymbolTable_DLocalSymtab.json5] * 2. jinja2 template for abstract facet .hpp file: @@ -31,4 +31,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end ISymbolTable_DLocalSymtab.cpp */ \ No newline at end of file +/* end ISymbolTable_DLocalSymtab.cpp */ From 0f7dccc1931176e15ff9d327972972c60f5858ee Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 31 Jan 2026 18:28:25 -0500 Subject: [PATCH 056/128] xo-reader2 xo-expression2: + DSequenceSsm ++ utest --- CMakeLists.txt | 24 +++++++ idl/IGCObject_DConstant.json5 | 15 +++++ idl/IGCObject_DIfElseExpr.json5 | 15 +++++ include/xo/expression2/DConstant.hpp | 12 +++- include/xo/expression2/DIfElseExpr.hpp | 10 +++ .../detail/IGCObject_DConstant.hpp | 67 +++++++++++++++++++ .../detail/IGCObject_DIfElseExpr.hpp | 67 +++++++++++++++++++ src/expression2/CMakeLists.txt | 2 + src/expression2/DConstant.cpp | 25 +++++++ src/expression2/DIfElseExpr.cpp | 41 ++++++++++++ src/expression2/IGCObject_DConstant.cpp | 39 +++++++++++ src/expression2/IGCObject_DIfElseExpr.cpp | 39 +++++++++++ .../expression2_register_facets.cpp | 11 ++- .../expression2_register_types.cpp | 21 +++++- 14 files changed, 384 insertions(+), 4 deletions(-) create mode 100644 idl/IGCObject_DConstant.json5 create mode 100644 idl/IGCObject_DIfElseExpr.json5 create mode 100644 include/xo/expression2/detail/IGCObject_DConstant.hpp create mode 100644 include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp create mode 100644 src/expression2/IGCObject_DConstant.cpp create mode 100644 src/expression2/IGCObject_DIfElseExpr.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 7cc83f11..a9060ce1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -82,6 +82,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-constant + FACET_PKG xo_gc + FACET GCObject + REPR Constant + INPUT idl/IGCObject_DConstant.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-constant @@ -224,6 +236,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-ifelseexpr + FACET_PKG xo_gc + FACET GCObject + REPR IfElseExpr + INPUT idl/IGCObject_DIfElseExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-ifelseexpr diff --git a/idl/IGCObject_DConstant.json5 b/idl/IGCObject_DConstant.json5 new file mode 100644 index 00000000..f67c5b52 --- /dev/null +++ b/idl/IGCObject_DConstant.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DConstant", + using_doxygen: true, + repr: "DConstant", + doc: [ "implement AGCObject for DConstant" ], +} diff --git a/idl/IGCObject_DIfElseExpr.json5 b/idl/IGCObject_DIfElseExpr.json5 new file mode 100644 index 00000000..1c5d0661 --- /dev/null +++ b/idl/IGCObject_DIfElseExpr.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DIfElseExpr", + using_doxygen: true, + repr: "DIfElseExpr", + doc: [ "implement AGCObject for DIfElseExpr" ], +} diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp index 1046176a..0c57f924 100644 --- a/include/xo/expression2/DConstant.hpp +++ b/include/xo/expression2/DConstant.hpp @@ -8,8 +8,9 @@ #include "Expression.hpp" #include "TypeRef.hpp" #include "exprtype.hpp" -#include +#include #include +#include namespace xo { namespace scm { @@ -20,6 +21,7 @@ namespace xo { public: using TaggedPtr = xo::reflect::TaggedPtr; using TypeDescr = xo::reflect::TypeDescr; + using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; using typeseq = xo::reflect::typeseq; @@ -56,6 +58,14 @@ namespace xo { TypeDescr valuetype() const noexcept { return typeref_.td(); } void assign_valuetype(TypeDescr td) noexcept { typeref_.resolve(td); } + ///@} + /** @defgroup scm-constant-gcobject-facet **/ + ///@{ + + size_t shallow_size() const noexcept; + DConstant * shallow_copy(obj mm) const noexcept; + size_t forward_children(obj gc) noexcept; + ///@} /** @defgroup scm-constant-printable-facet **/ ///@{ diff --git a/include/xo/expression2/DIfElseExpr.hpp b/include/xo/expression2/DIfElseExpr.hpp index 8222834a..3b7b07e2 100644 --- a/include/xo/expression2/DIfElseExpr.hpp +++ b/include/xo/expression2/DIfElseExpr.hpp @@ -8,6 +8,7 @@ #include "Expression.hpp" #include "TypeRef.hpp" #include "exprtype.hpp" +#include #include //#include #include @@ -21,6 +22,7 @@ namespace xo { **/ class DIfElseExpr { public: + using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; using ppindentinfo = xo::print::ppindentinfo; @@ -93,6 +95,14 @@ namespace xo { bool pretty(const ppindentinfo & ppii) const; ///@} + /** @defgroup scm-ifelseexpr-gcobject-facet **/ + ///@{ + + std::size_t shallow_size() const noexcept; + DIfElseExpr * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + + ///@} #ifdef NOT_YET virtual std::set get_free_variables() const override { diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp new file mode 100644 index 00000000..871f9c91 --- /dev/null +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DConstant.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DConstant.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DConstant.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DConstant.hpp" + +namespace xo { namespace scm { class IGCObject_DConstant; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DConstant + **/ + class IGCObject_DConstant { + public: + /** @defgroup scm-gcobject-dconstant-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dconstant-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DConstant & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DConstant & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DConstant & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp new file mode 100644 index 00000000..6a47d9b8 --- /dev/null +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DIfElseExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DIfElseExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DIfElseExpr.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DIfElseExpr.hpp" + +namespace xo { namespace scm { class IGCObject_DIfElseExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DIfElseExpr + **/ + class IGCObject_DIfElseExpr { + public: + /** @defgroup scm-gcobject-difelseexpr-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-difelseexpr-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DIfElseExpr & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DIfElseExpr & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DIfElseExpr & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 4f929fa4..4f3d63c1 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -17,6 +17,7 @@ set(SELF_SRCS IExpression_Any.cpp IExpression_DConstant.cpp + IGCObject_DConstant.cpp IPrintable_DConstant.cpp IExpression_DVariable.cpp @@ -33,6 +34,7 @@ set(SELF_SRCS IPrintable_DLambdaExpr.cpp IExpression_DIfElseExpr.cpp + IGCObject_DIfElseExpr.cpp IPrintable_DIfElseExpr.cpp IExpression_DSequenceExpr.cpp diff --git a/src/expression2/DConstant.cpp b/src/expression2/DConstant.cpp index f03fe625..f1f560be 100644 --- a/src/expression2/DConstant.cpp +++ b/src/expression2/DConstant.cpp @@ -71,6 +71,31 @@ namespace xo { return nullptr; } + std::size_t + DConstant::shallow_size() const noexcept + { + return sizeof(DConstant); + } + + DConstant * + DConstant::shallow_copy(obj mm) const noexcept + { + DConstant * copy = (DConstant *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + std::size_t + DConstant::forward_children(obj gc) noexcept + { + gc.forward_inplace(value_.iface(), (void **)&(value_.data_)); + + return shallow_size(); + } + bool DConstant::pretty(const ppindentinfo & ppii) const { diff --git a/src/expression2/DIfElseExpr.cpp b/src/expression2/DIfElseExpr.cpp index d858dfab..e1d5e70e 100644 --- a/src/expression2/DIfElseExpr.cpp +++ b/src/expression2/DIfElseExpr.cpp @@ -5,11 +5,13 @@ #include "DIfElseExpr.hpp" #include "detail/IExpression_DIfElseExpr.hpp" +#include #include #include #include namespace xo { + using xo::mm::AGCObject; using xo::print::APrintable; using xo::reflect::typeseq; using xo::facet::FacetRegistry; @@ -120,6 +122,45 @@ namespace xo { } } + // GCObject facet + + std::size_t + DIfElseExpr::shallow_size() const noexcept + { + return sizeof(DIfElseExpr); + } + + DIfElseExpr * + DIfElseExpr::shallow_copy(obj mm) const noexcept + { + DIfElseExpr * copy = (DIfElseExpr *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + std::size_t + DIfElseExpr::forward_children(obj gc) noexcept + { + // GC needs to locate AGCObject iface for each member. + { + auto gco = FacetRegistry::instance().variant(test_); + gc.forward_inplace(gco.iface(), (void **)&(test_.data_)); + } + { + auto gco = FacetRegistry::instance().variant(when_true_); + gc.forward_inplace(gco.iface(), (void **)&(when_true_.data_)); + } + { + auto gco = FacetRegistry::instance().variant(when_false_); + gc.forward_inplace(gco.iface(), (void **)&(when_false_.data_)); + } + + return shallow_size(); + } + // ---------------------------------------------------------------- #ifdef NOPE diff --git a/src/expression2/IGCObject_DConstant.cpp b/src/expression2/IGCObject_DConstant.cpp new file mode 100644 index 00000000..ea3be262 --- /dev/null +++ b/src/expression2/IGCObject_DConstant.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DConstant.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DConstant.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DConstant.json5] +**/ + +#include "detail/IGCObject_DConstant.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DConstant::shallow_size(const DConstant & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DConstant::shallow_copy(const DConstant & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DConstant::forward_children(DConstant & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DConstant.cpp */ diff --git a/src/expression2/IGCObject_DIfElseExpr.cpp b/src/expression2/IGCObject_DIfElseExpr.cpp new file mode 100644 index 00000000..8a0f03d5 --- /dev/null +++ b/src/expression2/IGCObject_DIfElseExpr.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DIfElseExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DIfElseExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DIfElseExpr.json5] +**/ + +#include "detail/IGCObject_DIfElseExpr.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DIfElseExpr::shallow_size(const DIfElseExpr & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DIfElseExpr::shallow_copy(const DIfElseExpr & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DIfElseExpr::forward_children(DIfElseExpr & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DIfElseExpr.cpp */ diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 8109293a..26869d50 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -9,6 +9,7 @@ #include #include +//#include #include #include @@ -16,15 +17,19 @@ #include #include +#include #include #include +//#include #include #include +//#include #include #include +#include #include #include @@ -32,6 +37,7 @@ #include #include +//#include #include #include @@ -60,9 +66,11 @@ namespace xo { // +- DefineExpr // +- ApplyExpr // +- LambdaExpr - // \- IfElseExpr + // +- IfElseExpr + // \- SequenceExpr FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -79,6 +87,7 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); diff --git a/src/expression2/expression2_register_types.cpp b/src/expression2/expression2_register_types.cpp index 2b8aadcf..b3dd21f8 100644 --- a/src/expression2/expression2_register_types.cpp +++ b/src/expression2/expression2_register_types.cpp @@ -5,11 +5,18 @@ #include "expression2_register_types.hpp" +#include "detail/IGCObject_DConstant.hpp" +#include "detail/IGCObject_DVariable.hpp" +//#include "detail/IGCObject_DDefineExpr.hpp" // when avail +//#include "detail/IGCObject_DApplyExpr.hpp" // when avail +//#include "detail/IGCObject_DLambdaExpr.hpp" // when avail +#include "detail/IGCObject_DIfElseExpr.hpp" +#include "detail/IGCObject_DSequenceExpr.hpp" +//#include "detail/IGCObject_DLocalSymtab.hpp" // when avail #include "detail/IGCObject_DUniqueString.hpp" -//#include "detail/IPrintable_DUniqueString.hpp" +//#include "detail/IPrintable_DUniqueString.hpp" // when avail -//#include #include namespace xo { @@ -27,6 +34,16 @@ namespace xo { bool ok = true; + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + //ok &= gc.install_type(impl_for()); // when avail + //ok &= gc.install_type(impl_for()); // when avail + //ok &= gc.install_type(impl_for()); // when avail + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); + + //ok &= gc.install_type(impl_for()); // when avail + ok &= gc.install_type(impl_for()); return ok; From c6c05ab6335165140b91ae5ae6bd957d426e67da Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 1 Feb 2026 00:16:37 -0500 Subject: [PATCH 057/128] xo-reader2: construct LambdaExpr to complete LambdaSsm + utest --- include/xo/expression2/StringTable.hpp | 5 +++++ src/expression2/DLambdaExpr.cpp | 12 +++++++++-- src/expression2/DSequenceExpr.cpp | 7 +++++- src/expression2/StringTable.cpp | 30 ++++++++++++++++++++++++++ 4 files changed, 51 insertions(+), 3 deletions(-) diff --git a/include/xo/expression2/StringTable.hpp b/include/xo/expression2/StringTable.hpp index 54b0a826..471fbc0d 100644 --- a/include/xo/expression2/StringTable.hpp +++ b/include/xo/expression2/StringTable.hpp @@ -35,6 +35,11 @@ namespace xo { /** return unique string with contents @p key. Idempotent! **/ const DUniqueString * intern(std::string_view key); + /** generate unique symbol -- guaranteed not to collide + * with existing symbol in this table. + **/ + const DUniqueString * gensym(std::string_view prefix); + /** verify StringTable invariants. * Act on failure according to policy @p p **/ diff --git a/src/expression2/DLambdaExpr.cpp b/src/expression2/DLambdaExpr.cpp index a27e788b..080e49b5 100644 --- a/src/expression2/DLambdaExpr.cpp +++ b/src/expression2/DLambdaExpr.cpp @@ -1,10 +1,12 @@ -/** @file DLambda.cpp +/** @file DLambdaExpr.cpp * * @author Roland Conybeare, Jan 2026 **/ #include "DLambdaExpr.hpp" #include "detail/IExpression_DLambdaExpr.hpp" +#include "DLocalSymtab.hpp" +#include "symtab/IPrintable_DLocalSymtab.hpp" #include #include #include @@ -17,6 +19,7 @@ namespace xo { using xo::reflect::TypeDescrBase; using xo::reflect::FunctionTdxInfo; using xo::reflect::typeseq; + using xo::print::quot; namespace scm { @@ -139,9 +142,14 @@ namespace xo { AExpression>(body_expr_); if (name_ && body) { + auto local_symtab_pr + = obj(local_symtab_); + return ppii.pps()->pretty_struct(ppii, "LambdaExpr", - refrtag("name", name_), + refrtag("tref", typeref_), + refrtag("name", quot(std::string_view(*name_))), + refrtag("local_symtab", local_symtab_pr), //refrtag("argv", local_env_->argv()), refrtag("body", body)); } else { diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index 73b9c2b5..a9783802 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -6,6 +6,7 @@ #include "DSequenceExpr.hpp" #include "detail/IExpression_DSequenceExpr.hpp" #include +#include #include #include #include @@ -15,6 +16,7 @@ namespace xo { using xo::mm::AGCObject; + using xo::print::APrintable; using xo::facet::FacetRegistry; using xo::reflect::typeseq; @@ -95,9 +97,12 @@ namespace xo { { using xo::print::ppstate; + auto expr_v_pr = obj(expr_v_); + return ppii.pps()->pretty_struct (ppii, - "DSequenceExpr"); + "DSequenceExpr", + refrtag("expr_v", expr_v_pr)); } // gc hooks for IGCObject_DSequenceExpr diff --git a/src/expression2/StringTable.cpp b/src/expression2/StringTable.cpp index ae48eea9..f59bb24d 100644 --- a/src/expression2/StringTable.cpp +++ b/src/expression2/StringTable.cpp @@ -72,6 +72,36 @@ namespace xo { return nullptr; } + const DUniqueString * + StringTable::gensym(std::string_view prefix) + { + static std::size_t s_counter = 0; + + while (true) { + ++s_counter; + + char buf[80]; + assert(prefix.size() + 20 < sizeof(buf)); + + int n = snprintf(buf, sizeof(buf), + "%s:%lu", + prefix.data(), s_counter); + + if ((0 < n) && (std::size_t(n) < sizeof(buf))) + buf[n] = '\0'; + else + buf[sizeof(buf)-1] = '\0'; + + std::string_view sv(buf); + const DUniqueString * retval = this->lookup(sv); + if (!retval) { + /* not already in string view -> we have viable candidate */ + retval = this->intern(sv); + return retval; + } + } + } + bool StringTable::verify_ok(verify_policy policy) const { From 88c4b752d4efac7111f47c6707a83707e2656fcc Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 1 Feb 2026 22:12:28 -0500 Subject: [PATCH 058/128] xo-interpreter2: work towards utest w/ vsm+reader [WIP] --- utest/X1Collector.test.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index a664f9a2..b872d877 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -39,7 +39,7 @@ namespace ut { using xo::mm::ACollector; using xo::mm::AGCObject; using xo::mm::DX1Collector; - using xo::mm::CollectorConfig; + using xo::mm::X1CollectorConfig; using xo::mm::ArenaConfig; using xo::facet::with_facet; using xo::facet::typeseq; @@ -54,14 +54,13 @@ namespace ut { REQUIRE(s_init.evidence()); // Create collector - CollectorConfig cfg{ - .name_ = "x1_duniquestring_test", - .arena_config_ = ArenaConfig{ - .size_ = 8192, - .store_header_flag_ = true}, - .object_types_z_ = 16384, - .gc_trigger_v_{{1024, 1024}}, - .debug_flag_ = false, + X1CollectorConfig cfg{ .name_ = "x1_duniquestring_test", + .arena_config_ = ArenaConfig{ + .size_ = 8192, + .store_header_flag_ = true}, + .object_types_z_ = 16384, + .gc_trigger_v_{{1024, 1024}}, + .debug_flag_ = false, }; DX1Collector gc(cfg); From ac2b307eb91c9454d201dfc362d56610bbdf97c7 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 2 Feb 2026 10:53:28 -0500 Subject: [PATCH 059/128] xo-interpreter2: refactor to setup vsm utest + repl --- utest/DApplyExpr.test.cpp | 14 +++++++------- utest/DConstant.test.cpp | 10 +++++----- utest/DDefineExpr.test.cpp | 16 ++++++++-------- utest/DIfElseExpr.test.cpp | 20 ++++++++++---------- utest/DVariable.test.cpp | 12 ++++++------ 5 files changed, 36 insertions(+), 36 deletions(-) diff --git a/utest/DApplyExpr.test.cpp b/utest/DApplyExpr.test.cpp index d151b776..f217d47e 100644 --- a/utest/DApplyExpr.test.cpp +++ b/utest/DApplyExpr.test.cpp @@ -47,7 +47,7 @@ namespace ut { using xo::mm::ACollector; using xo::mm::AGCObject; using xo::mm::DX1Collector; - using xo::mm::CollectorConfig; + using xo::mm::X1CollectorConfig; using xo::mm::ArenaConfig; using xo::print::APrintable; using xo::print::ppstate_standalone; @@ -71,7 +71,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dapplyexpr_make2_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -111,7 +111,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dapplyexpr_extype_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -146,7 +146,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dapplyexpr_n_args_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -181,7 +181,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dapplyexpr_fn_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -219,7 +219,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dapplyexpr_arg_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -263,7 +263,7 @@ namespace ut { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dapplyexpr_pretty_test", .arena_config_ = ArenaConfig{ .size_ = 8192, diff --git a/utest/DConstant.test.cpp b/utest/DConstant.test.cpp index ddff5b20..fd8e9b1b 100644 --- a/utest/DConstant.test.cpp +++ b/utest/DConstant.test.cpp @@ -39,7 +39,7 @@ namespace ut { using xo::mm::ACollector; using xo::mm::AGCObject; using xo::mm::DX1Collector; - using xo::mm::CollectorConfig; + using xo::mm::X1CollectorConfig; using xo::mm::ArenaConfig; using xo::print::APrintable; using xo::print::ppstate_standalone; @@ -66,7 +66,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dconstant_float_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -105,7 +105,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dconstant_int_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -146,7 +146,7 @@ namespace ut { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dconstant_pp_float_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -190,7 +190,7 @@ namespace ut { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dconstant_pp_int_test", .arena_config_ = ArenaConfig{ .size_ = 8192, diff --git a/utest/DDefineExpr.test.cpp b/utest/DDefineExpr.test.cpp index 5bb91582..5f78891d 100644 --- a/utest/DDefineExpr.test.cpp +++ b/utest/DDefineExpr.test.cpp @@ -44,7 +44,7 @@ namespace ut { using xo::mm::ACollector; using xo::mm::AGCObject; using xo::mm::DX1Collector; - using xo::mm::CollectorConfig; + using xo::mm::X1CollectorConfig; using xo::mm::ArenaConfig; using xo::print::APrintable; using xo::print::ppstate_standalone; @@ -68,7 +68,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "ddefineexpr_make_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -103,7 +103,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "ddefineexpr_lhs_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -138,7 +138,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "ddefineexpr_rhs_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -174,7 +174,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "ddefineexpr_name_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -207,7 +207,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "ddefineexpr_extype_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -239,7 +239,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "ddefineexpr_valuetype_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -273,7 +273,7 @@ namespace ut { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "ddefineexpr_pretty_test", .arena_config_ = ArenaConfig{ .size_ = 8192, diff --git a/utest/DIfElseExpr.test.cpp b/utest/DIfElseExpr.test.cpp index a82521a0..2dee2f26 100644 --- a/utest/DIfElseExpr.test.cpp +++ b/utest/DIfElseExpr.test.cpp @@ -42,15 +42,15 @@ namespace ut { using xo::mm::ACollector; using xo::mm::AGCObject; using xo::mm::DX1Collector; - using xo::mm::CollectorConfig; + using xo::mm::X1CollectorConfig; using xo::mm::ArenaConfig; using xo::print::APrintable; using xo::print::ppstate_standalone; using xo::print::ppconfig; - using xo::facet::FacetRegistry; + //using xo::facet::FacetRegistry; using xo::facet::with_facet; using xo::facet::obj; - using xo::reflect::Reflect; + //using xo::reflect::Reflect; using xo::InitEvidence; using xo::InitSubsys; using xo::scope; @@ -66,7 +66,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "difelseexpr_make_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -107,7 +107,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "difelseexpr_test_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -145,7 +145,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "difelseexpr_when_true_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -183,7 +183,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "difelseexpr_when_false_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -221,7 +221,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "difelseexpr_extype_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -256,7 +256,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "difelseexpr_valuetype_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -296,7 +296,7 @@ namespace ut { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "difelseexpr_pretty_test", .arena_config_ = ArenaConfig{ .size_ = 8192, diff --git a/utest/DVariable.test.cpp b/utest/DVariable.test.cpp index 8afee360..9c26a7c4 100644 --- a/utest/DVariable.test.cpp +++ b/utest/DVariable.test.cpp @@ -37,7 +37,7 @@ namespace ut { using xo::mm::AAllocator; using xo::mm::ACollector; using xo::mm::DX1Collector; - using xo::mm::CollectorConfig; + using xo::mm::X1CollectorConfig; using xo::mm::ArenaConfig; using xo::print::APrintable; using xo::print::ppstate_standalone; @@ -61,7 +61,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dvariable_make_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -92,7 +92,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dvariable_extype_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -122,7 +122,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dvariable_valuetype_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -152,7 +152,7 @@ namespace ut { { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dvariable_name_test", .arena_config_ = ArenaConfig{ .size_ = 8192, @@ -185,7 +185,7 @@ namespace ut { REQUIRE(s_init.evidence()); - CollectorConfig cfg{ + X1CollectorConfig cfg{ .name_ = "dvariable_pretty_test", .arena_config_ = ArenaConfig{ .size_ = 8192, From 438e92d51b91ad219b8f100b3f9d4a6065a0830d Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 2 Feb 2026 21:55:34 -0500 Subject: [PATCH 060/128] xo-interpreter2: scaffold repl + alloc measurement frameowkr --- include/xo/expression2/StringTable.hpp | 4 ++++ src/expression2/StringTable.cpp | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+) diff --git a/include/xo/expression2/StringTable.hpp b/include/xo/expression2/StringTable.hpp index 471fbc0d..b55c48ee 100644 --- a/include/xo/expression2/StringTable.hpp +++ b/include/xo/expression2/StringTable.hpp @@ -21,6 +21,7 @@ namespace xo { class StringTable { public: using DArena = xo::mm::DArena; + using MemorySizeInfo = xo::mm::MemorySizeInfo; using StringMap = xo::map::DArenaHashMap; using size_type = StringMap::size_type; @@ -45,6 +46,9 @@ namespace xo { **/ bool verify_ok(verify_policy p = verify_policy::throw_only()) const; + std::size_t _n_store() const noexcept; + MemorySizeInfo _store_info(std::size_t i) const noexcept; + private: /** allocate string storage in this arena; use DString to represent each string. * Can't use DArenaVector b/c DString has variable size diff --git a/src/expression2/StringTable.cpp b/src/expression2/StringTable.cpp index f59bb24d..79a17067 100644 --- a/src/expression2/StringTable.cpp +++ b/src/expression2/StringTable.cpp @@ -10,6 +10,7 @@ namespace xo { using xo::mm::ArenaConfig; using xo::mm::AAllocator; + using xo::mm::MemorySizeInfo; using xo::facet::with_facet; using xo::facet::obj; @@ -159,6 +160,24 @@ namespace xo { return true; } + std::size_t + StringTable::_n_store() const noexcept + { + return 1 + map_._n_store(); + } + + MemorySizeInfo + StringTable::_store_info(std::size_t i) const noexcept + { + if (i == 0) + return strings_._store_info(); + + if (i+1 < map_._n_store()) + return map_._store_info(i-1); + + return MemorySizeInfo::sentinel(); + } + } /*namespace scm*/ } /*namespace xo*/ From 6ec8bd53a295846feb0f92a2c52c7123d1fa6806 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Feb 2026 01:05:36 -0500 Subject: [PATCH 061/128] xo-interpreter2 .. xo-arena. memory pool introspection --- include/xo/expression2/StringTable.hpp | 6 +++--- src/expression2/StringTable.cpp | 19 ++++--------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/include/xo/expression2/StringTable.hpp b/include/xo/expression2/StringTable.hpp index b55c48ee..8d0354c8 100644 --- a/include/xo/expression2/StringTable.hpp +++ b/include/xo/expression2/StringTable.hpp @@ -21,7 +21,7 @@ namespace xo { class StringTable { public: using DArena = xo::mm::DArena; - using MemorySizeInfo = xo::mm::MemorySizeInfo; + using MemorySizeVisitor = xo::mm::MemorySizeVisitor; using StringMap = xo::map::DArenaHashMap; using size_type = StringMap::size_type; @@ -46,8 +46,8 @@ namespace xo { **/ bool verify_ok(verify_policy p = verify_policy::throw_only()) const; - std::size_t _n_store() const noexcept; - MemorySizeInfo _store_info(std::size_t i) const noexcept; + /** visit string-table memory pools, call visitor(info) for each **/ + void visit_pools(const MemorySizeVisitor & visitor) const; private: /** allocate string storage in this arena; use DString to represent each string. diff --git a/src/expression2/StringTable.cpp b/src/expression2/StringTable.cpp index 79a17067..174c9e9f 100644 --- a/src/expression2/StringTable.cpp +++ b/src/expression2/StringTable.cpp @@ -160,22 +160,11 @@ namespace xo { return true; } - std::size_t - StringTable::_n_store() const noexcept + void + StringTable::visit_pools(const MemorySizeVisitor & visitor) const { - return 1 + map_._n_store(); - } - - MemorySizeInfo - StringTable::_store_info(std::size_t i) const noexcept - { - if (i == 0) - return strings_._store_info(); - - if (i+1 < map_._n_store()) - return map_._store_info(i-1); - - return MemorySizeInfo::sentinel(); + strings_.visit_pools(visitor); + map_.visit_pools(visitor); } } /*namespace scm*/ From cbe845ec29d59cc7d735c28cef3a20f45b0cdefd Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Feb 2026 10:32:43 -0500 Subject: [PATCH 062/128] xo-reader2 stack: curate memory pool naming --- src/expression2/StringTable.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/expression2/StringTable.cpp b/src/expression2/StringTable.cpp index 174c9e9f..2d23d03e 100644 --- a/src/expression2/StringTable.cpp +++ b/src/expression2/StringTable.cpp @@ -19,7 +19,7 @@ namespace xo { bool debug_flag) : strings_{DArena::map(ArenaConfig{.name_ = "strings", .size_ = hint_max_capacity})}, - map_{hint_max_capacity} + map_{"stringkeys", hint_max_capacity} { (void)debug_flag; } From f77a94af6fd5be8526426fd92035865fe8558f22 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Feb 2026 13:23:38 -0500 Subject: [PATCH 063/128] xo-reader2 stack: misc qol improvements + improve reader2 utest --- include/xo/expression2/Constant.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 include/xo/expression2/Constant.hpp diff --git a/include/xo/expression2/Constant.hpp b/include/xo/expression2/Constant.hpp new file mode 100644 index 00000000..29e6694f --- /dev/null +++ b/include/xo/expression2/Constant.hpp @@ -0,0 +1,13 @@ +/** @file Constant.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DConstant.hpp" +#include "detail/IExpression_DConstant.hpp" +#include "detail/IGCObject_DConstant.hpp" +#include "detail/IPrintable_DConstant.hpp" + +/* end Constant.hpp */ From 523538b21ce69f2eeb8a8b9e16f991f01d9a6c32 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Feb 2026 13:43:00 -0500 Subject: [PATCH 064/128] xo-reader2 stack: convenience #includes + parsing examples --- include/xo/expression2/DefineExpr.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 include/xo/expression2/DefineExpr.hpp diff --git a/include/xo/expression2/DefineExpr.hpp b/include/xo/expression2/DefineExpr.hpp new file mode 100644 index 00000000..37a77c03 --- /dev/null +++ b/include/xo/expression2/DefineExpr.hpp @@ -0,0 +1,13 @@ +/** @file DefineExpr.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DDefineExpr.hpp" +#include "detail/IExpression_DDefineExpr.hpp" +//#include "detail/IGCObject_DDefineExpr.hpp" +#include "detail/IPrintable_DDefineExpr.hpp" + +/* end DefineExpr.hpp */ From 0fff79d6b702522adb0e8e609df5f75f8838ccaf Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 3 Feb 2026 14:27:42 -0500 Subject: [PATCH 065/128] xo-reader2 stack: streamlining + arith parser test --- include/xo/expression2/ApplyExpr.hpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 include/xo/expression2/ApplyExpr.hpp diff --git a/include/xo/expression2/ApplyExpr.hpp b/include/xo/expression2/ApplyExpr.hpp new file mode 100644 index 00000000..fd9c0764 --- /dev/null +++ b/include/xo/expression2/ApplyExpr.hpp @@ -0,0 +1,13 @@ +/** @file ApplyExpr.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DApplyExpr.hpp" +#include "detail/IExpression_DApplyExpr.hpp" +//#include "detail/IGCObject_DApplyExpr.hpp" +#include "detail/IPrintable_DApplyExpr.hpp" + +/* end ApplyExpr.hpp */ From 8ed2b489f54dbee0cc78e70d23c2dd903a5e0439 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Feb 2026 01:44:28 -0500 Subject: [PATCH 066/128] xo-interpreter2: vsm stack: facet + gcobject + printable + init --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a9060ce1..d826a155 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -317,7 +317,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-uniquestring FACET_PKG xo_printable2 FACET Printable - REPR DUniqueString + REPR UniqueString INPUT idl/IPrintable_DUniqueString.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail From a0b2e02785e74c4163b7113646eda9ecde235083 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Feb 2026 10:32:16 -0500 Subject: [PATCH 067/128] xo-reader2 xo-expression2: streamline pretty w/ presence flag --- src/expression2/DIfElseExpr.cpp | 38 ++++++++++----------------------- 1 file changed, 11 insertions(+), 27 deletions(-) diff --git a/src/expression2/DIfElseExpr.cpp b/src/expression2/DIfElseExpr.cpp index e1d5e70e..631be466 100644 --- a/src/expression2/DIfElseExpr.cpp +++ b/src/expression2/DIfElseExpr.cpp @@ -93,33 +93,17 @@ namespace xo { = FacetRegistry::instance().try_variant(when_false_); - if (when_false) { - return ppii.pps()->pretty_struct - (ppii, - "DIfElseExpr", - refrtag("typeref", typeref_), - refrtag("test", test), - refrtag("when_true", when_true), - refrtag("when_false", when_false)); - } else if (when_true) { - return ppii.pps()->pretty_struct - (ppii, - "DIfElseExpr", - refrtag("typeref", typeref_), - refrtag("test", test), - refrtag("when_true", when_true)); - } else if (test) { - return ppii.pps()->pretty_struct - (ppii, - "DIfElseExpr", - refrtag("typeref", typeref_), - refrtag("test", test)); - } else { - return ppii.pps()->pretty_struct - (ppii, - "DIfElseExpr", - refrtag("typeref", typeref_)); - } + bool test_present = test; + bool when_true_present = when_true; + bool when_false_present = when_false; + + return ppii.pps()->pretty_struct + (ppii, + "DIfElseExpr", + refrtag("typeref", typeref_), + refrtag("test", test, test_present), + refrtag("when_true", when_true, when_true_present), + refrtag("when_false", when_false, when_false_present)); } // GCObject facet From 4278ea726aed222a067255449760c8ca1df6d5e1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Feb 2026 19:17:07 -0500 Subject: [PATCH 068/128] xo-interpreter2 stack: scaffold DClosure, DLocalEnv [WIP] --- include/xo/expression2/DLambdaExpr.hpp | 2 ++ include/xo/expression2/DLocalSymtab.hpp | 2 +- include/xo/expression2/LambdaExpr.hpp | 13 +++++++++++++ include/xo/expression2/LocalSymtab.hpp | 12 ++++++++++++ 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 include/xo/expression2/LambdaExpr.hpp create mode 100644 include/xo/expression2/LocalSymtab.hpp diff --git a/include/xo/expression2/DLambdaExpr.hpp b/include/xo/expression2/DLambdaExpr.hpp index 14be115f..2a0cc2c3 100644 --- a/include/xo/expression2/DLambdaExpr.hpp +++ b/include/xo/expression2/DLambdaExpr.hpp @@ -23,6 +23,7 @@ namespace xo { using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; using ppindentinfo = xo::print::ppindentinfo; + using size_type = DLocalSymtab::size_type; public: @@ -60,6 +61,7 @@ namespace xo { ///@{ DLocalSymtab * local_symtab() const noexcept { return local_symtab_; } + size_type n_args() const noexcept { return local_symtab_->size(); } // get_free_variables() // visit_preorder() diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index 01d9aa85..163d031e 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -101,7 +101,7 @@ namespace xo { private: /** parent symbol table from scoping surrounding this one **/ DLocalSymtab * parent_ = nullptr; - /** actual range of slots_[] array. Can use inices in [0,..,n) **/ + /** actual range of slots_[] array. Can use indices in [0,..,n) **/ size_type capacity_ = 0; /** number of slots in use **/ size_type size_ = 0; diff --git a/include/xo/expression2/LambdaExpr.hpp b/include/xo/expression2/LambdaExpr.hpp new file mode 100644 index 00000000..45f86b25 --- /dev/null +++ b/include/xo/expression2/LambdaExpr.hpp @@ -0,0 +1,13 @@ +/** @file LambdaExpr.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DLambdaExpr.hpp" +#include "detail/IExpression_DLambdaExpr.hpp" +//#include "detail/IGCObject_DLambdaExpr.hpp" +#include "detail/IPrintable_DLambdaExpr.hpp" + +/* end LambdaExpr.hpp */ diff --git a/include/xo/expression2/LocalSymtab.hpp b/include/xo/expression2/LocalSymtab.hpp new file mode 100644 index 00000000..4c852652 --- /dev/null +++ b/include/xo/expression2/LocalSymtab.hpp @@ -0,0 +1,12 @@ +/** @file LocalSymtab.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DLocalSymtab.hpp" +#include "symtab/ISymbolTable_DLocalSymtab.hpp" +#include "symtab/IPrintable_DLocalSymtab.hpp" + +/* end LocalSymtab.hpp */ From da1f099b4f8ff384e8d9b1fe8914749f666b6d5c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 5 Feb 2026 10:44:11 -0500 Subject: [PATCH 069/128] xo-interpreter2 stack: work on variable references [WIP] --- include/xo/expression2/Binding.hpp | 3 +++ include/xo/expression2/Variable.hpp | 13 +++++++++++++ 2 files changed, 16 insertions(+) create mode 100644 include/xo/expression2/Variable.hpp diff --git a/include/xo/expression2/Binding.hpp b/include/xo/expression2/Binding.hpp index 6dffb16b..a27de6b3 100644 --- a/include/xo/expression2/Binding.hpp +++ b/include/xo/expression2/Binding.hpp @@ -24,6 +24,9 @@ namespace xo { static Binding global() { return Binding(s_link_global, 0); } static Binding local(int32_t j_slot) { return Binding(0, j_slot); } + bool is_null() const { + return (i_link_ == s_link_sentinel) && (j_slot_ == -1); + } bool is_global() const { return i_link_ == s_link_global; } bool is_local() const { return (i_link_ == 0) && (j_slot_ >= 0); } diff --git a/include/xo/expression2/Variable.hpp b/include/xo/expression2/Variable.hpp new file mode 100644 index 00000000..26ef649b --- /dev/null +++ b/include/xo/expression2/Variable.hpp @@ -0,0 +1,13 @@ +/** @file Variable.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DVariable.hpp" +#include "detail/IExpression_DVariable.hpp" +#include "detail/IGCObject_DVariable.hpp" +#include "detail/IPrintable_DVariable.hpp" + +/* end Variable.hpp */ From 60b8fda134c3c15c5cf026bdf130e4a7aa8dd431 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 5 Feb 2026 15:45:40 -0500 Subject: [PATCH 070/128] xo-reader2 stack: top-level lambda w/ apply parses --- CMakeLists.txt | 50 +++++++++ idl/Expression.json5 | 1 + idl/IExpression_DVarRef.json5 | 12 ++ idl/IGCObject_DApplyExpr.json5 | 15 +++ idl/IGCObject_DVarRef.json5 | 15 +++ idl/IPrintable_DVarRef.json5 | 13 +++ include/xo/expression2/ApplyExpr.hpp | 2 +- include/xo/expression2/Binding.hpp | 22 +++- include/xo/expression2/DApplyExpr.hpp | 5 +- include/xo/expression2/DLocalSymtab.hpp | 6 +- include/xo/expression2/DVarRef.hpp | 84 ++++++++++++++ include/xo/expression2/VarRef.hpp | 13 +++ .../detail/IExpression_DVarRef.hpp | 66 +++++++++++ .../detail/IGCObject_DApplyExpr.hpp | 67 +++++++++++ .../expression2/detail/IGCObject_DVarRef.hpp | 67 +++++++++++ .../expression2/detail/IPrintable_DVarRef.hpp | 62 +++++++++++ include/xo/expression2/exprtype.hpp | 10 +- src/expression2/Binding.cpp | 41 +++++++ src/expression2/CMakeLists.txt | 11 +- src/expression2/DApplyExpr.cpp | 42 +++++++ src/expression2/DVarRef.cpp | 105 ++++++++++++++++++ src/expression2/IExpression_DVarRef.cpp | 45 ++++++++ src/expression2/IGCObject_DApplyExpr.cpp | 39 +++++++ src/expression2/IGCObject_DVarRef.cpp | 39 +++++++ src/expression2/IPrintable_DVarRef.cpp | 28 +++++ .../expression2_register_facets.cpp | 18 ++- 26 files changed, 858 insertions(+), 20 deletions(-) create mode 100644 idl/IExpression_DVarRef.json5 create mode 100644 idl/IGCObject_DApplyExpr.json5 create mode 100644 idl/IGCObject_DVarRef.json5 create mode 100644 idl/IPrintable_DVarRef.json5 create mode 100644 include/xo/expression2/DVarRef.hpp create mode 100644 include/xo/expression2/VarRef.hpp create mode 100644 include/xo/expression2/detail/IExpression_DVarRef.hpp create mode 100644 include/xo/expression2/detail/IGCObject_DApplyExpr.hpp create mode 100644 include/xo/expression2/detail/IGCObject_DVarRef.hpp create mode 100644 include/xo/expression2/detail/IPrintable_DVarRef.hpp create mode 100644 src/expression2/Binding.cpp create mode 100644 src/expression2/DVarRef.cpp create mode 100644 src/expression2/IExpression_DVarRef.cpp create mode 100644 src/expression2/IGCObject_DApplyExpr.cpp create mode 100644 src/expression2/IGCObject_DVarRef.cpp create mode 100644 src/expression2/IPrintable_DVarRef.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d826a155..d070190e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -146,6 +146,44 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-expression-varref + FACET_PKG xo_expression2 + FACET Expression + REPR VarRef + INPUT idl/IExpression_DVarRef.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-varref + FACET_PKG xo_gc + FACET GCObject + REPR VarRef + INPUT idl/IGCObject_DVarRef.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-varref + FACET_PKG xo_printable2 + FACET Printable + REPR VarRef + INPUT idl/IPrintable_DVarRef.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-defineexpr @@ -184,6 +222,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-applyexpr + FACET_PKG xo_gc + FACET GCObject + REPR ApplyExpr + INPUT idl/IGCObject_DApplyExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-applyexpr diff --git a/idl/Expression.json5 b/idl/Expression.json5 index f2f7d44a..83ae1402 100644 --- a/idl/Expression.json5 +++ b/idl/Expression.json5 @@ -67,4 +67,5 @@ attributes: [], } ], + router_facet_explicit_content: [ ], } diff --git a/idl/IExpression_DVarRef.json5 b/idl/IExpression_DVarRef.json5 new file mode 100644 index 00000000..8dea30e5 --- /dev/null +++ b/idl/IExpression_DVarRef.json5 @@ -0,0 +1,12 @@ +{ + mode: "implementation", + includes: [ "\"Expression.hpp\"" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Expression.json5", + brief: "provide AExpression interface for DVarRef state", + using_doxygen: true, + repr: "DVarRef", + doc: ["doc for IExpression+DVarRef" ], +} diff --git a/idl/IGCObject_DApplyExpr.json5 b/idl/IGCObject_DApplyExpr.json5 new file mode 100644 index 00000000..4bf4304b --- /dev/null +++ b/idl/IGCObject_DApplyExpr.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DApplyExpr", + using_doxygen: true, + repr: "DApplyExpr", + doc: [ "implement AGCObject for DApplyExpr" ], +} diff --git a/idl/IGCObject_DVarRef.json5 b/idl/IGCObject_DVarRef.json5 new file mode 100644 index 00000000..3101a035 --- /dev/null +++ b/idl/IGCObject_DVarRef.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DVarRef", + using_doxygen: true, + repr: "DVarRef", + doc: [ "implement AGCObject for DVarRef" ], +} diff --git a/idl/IPrintable_DVarRef.json5 b/idl/IPrintable_DVarRef.json5 new file mode 100644 index 00000000..d525886c --- /dev/null +++ b/idl/IPrintable_DVarRef.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DVarRef", + using_doxygen: true, + repr: "DVarRef", + doc: [ "implement APrintable for DVarRef" ], +} diff --git a/include/xo/expression2/ApplyExpr.hpp b/include/xo/expression2/ApplyExpr.hpp index fd9c0764..38625855 100644 --- a/include/xo/expression2/ApplyExpr.hpp +++ b/include/xo/expression2/ApplyExpr.hpp @@ -7,7 +7,7 @@ #include "DApplyExpr.hpp" #include "detail/IExpression_DApplyExpr.hpp" -//#include "detail/IGCObject_DApplyExpr.hpp" +#include "detail/IGCObject_DApplyExpr.hpp" #include "detail/IPrintable_DApplyExpr.hpp" /* end ApplyExpr.hpp */ diff --git a/include/xo/expression2/Binding.hpp b/include/xo/expression2/Binding.hpp index a27de6b3..97f74c27 100644 --- a/include/xo/expression2/Binding.hpp +++ b/include/xo/expression2/Binding.hpp @@ -5,14 +5,15 @@ #pragma once +#include #include namespace xo { namespace scm { class Binding { public: - static constexpr int32_t s_link_sentinel = -2; - static constexpr int32_t s_link_global = -1; + static constexpr int32_t c_link_sentinel = -2; + static constexpr int32_t c_link_global = -1; public: Binding() : i_link_{-2}, j_slot_{-1} {} @@ -21,18 +22,22 @@ namespace xo { static Binding null() { return Binding(); } /** global bindings are located by symbol name **/ - static Binding global() { return Binding(s_link_global, 0); } + static Binding global() { return Binding(c_link_global, 0); } static Binding local(int32_t j_slot) { return Binding(0, j_slot); } + static Binding relative(int32_t i_link, Binding def); bool is_null() const { - return (i_link_ == s_link_sentinel) && (j_slot_ == -1); + return (i_link_ == c_link_sentinel) && (j_slot_ == -1); } - bool is_global() const { return i_link_ == s_link_global; } + bool is_global() const { return i_link_ == c_link_global; } bool is_local() const { return (i_link_ == 0) && (j_slot_ >= 0); } int32_t i_link() const noexcept { return i_link_; } int32_t j_slot() const noexcept { return j_slot_; } + /** print human-readable repr to stream @p os **/ + void print(std::ostream & os) const; + private: /** * >= 0: number of parent links to traverse @@ -40,13 +45,18 @@ namespace xo { * -1: resolve globally * -2: sentinel (binding info not computed) **/ - int32_t i_link_ = s_link_sentinel; + int32_t i_link_ = c_link_sentinel; /** if @ref i_link_ >= 0, frame offset * (in 'variables' not bytes). * ignored if @ref i_link_ is global **/ int32_t j_slot_ = -1; }; + + inline std::ostream & operator<< (std::ostream & os, Binding x) { + x.print(os); + return os; + } } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/expression2/DApplyExpr.hpp b/include/xo/expression2/DApplyExpr.hpp index 8502c62a..94bcea73 100644 --- a/include/xo/expression2/DApplyExpr.hpp +++ b/include/xo/expression2/DApplyExpr.hpp @@ -20,6 +20,7 @@ namespace xo { **/ class DApplyExpr { public: + using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; using ppindentinfo = xo::print::ppindentinfo; @@ -81,7 +82,9 @@ namespace xo { /** @defgroup scm-applyexpr-gcobject-facet **/ ///@{ - // shallow_copy() etc. + std::size_t shallow_size() const noexcept; + DApplyExpr * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; ///@} /** @defgroup scm-applyexpr-printable-facet **/ diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index 163d031e..6d1a6480 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -31,14 +31,14 @@ namespace xo { struct Slot { Slot() = default; - explicit Slot(const DVariable * var) : var_{var} {} + explicit Slot(DVariable * var) : var_{var} {} /** variable representing a formal argument. * binding will be correct only within the same layer * as top-level lambda body * (i.e. up to the doorstep of each and every nested lambda) **/ - const DVariable * var_ = nullptr; + DVariable * var_ = nullptr; }; public: @@ -65,7 +65,7 @@ namespace xo { size_type capacity() const noexcept { return capacity_; } size_type size() const noexcept { return size_; } - const DVariable * lookup_var(Binding ix) const noexcept { + DVariable * lookup_var(Binding ix) noexcept { assert(ix.i_link() == 0); assert(ix.j_slot() < static_cast(size_)); diff --git a/include/xo/expression2/DVarRef.hpp b/include/xo/expression2/DVarRef.hpp new file mode 100644 index 00000000..d4a230b3 --- /dev/null +++ b/include/xo/expression2/DVarRef.hpp @@ -0,0 +1,84 @@ +/** @file DVarRef.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "Variable.hpp" + +namespace xo { + namespace scm { + + /** @class DVarRef + * @brief syntax for a variable reference + * + * Reference to a known variable possibly + * defined in another scope. + * For non-local non-global variables, + **/ + class DVarRef { + public: + using ppindentinfo = xo::print::ppindentinfo; + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + using TypeDescr = xo::reflect::TypeDescr; + + public: + DVarRef(DVariable * vardef, + Binding path); + + /** create instance + * @p mm memory allocator + * @p vardef variable definition (name, typeref, binding) + * @p link number of lexical scope boundaries we must cross + * to reach scope containing @p vardef. + * Only relevant for non-global vardef + **/ + static DVarRef * make(obj mm, + DVariable * vardef, + int32_t link); + + const DUniqueString * name() const; + Binding path() const { return path_; } + + /** @defgroup scm-variable-expression-facet **/ + ///@{ + + exprtype extype() const noexcept { return exprtype::varref; } + TypeRef typeref() const noexcept; + TypeDescr valuetype() const noexcept; + void assign_valuetype(TypeDescr td) noexcept; + + ///@} + /** @defgroup scm-variable-gcobject-facet **/ + ///@{ + + size_t shallow_size() const noexcept; + DVarRef * shallow_copy(obj mm) const noexcept; + size_t forward_children(obj gc) noexcept; + + ///@} + /** @defgroup scm-variable-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + private: + /** variable definition. Created in the sccope where variable introduced. + * Has an associated @ref Binding, but that binding is only correct + * around any nested scopes. + **/ + DVariable * vardef_ = nullptr; + + /** at runtime: navigate environemnt via this path to get + * runtime memory location for this variable + **/ + Binding path_; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DVarRef.hpp */ diff --git a/include/xo/expression2/VarRef.hpp b/include/xo/expression2/VarRef.hpp new file mode 100644 index 00000000..19f2d1d0 --- /dev/null +++ b/include/xo/expression2/VarRef.hpp @@ -0,0 +1,13 @@ +/** @file VarRef.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DVarRef.hpp" +#include "detail/IExpression_DVarRef.hpp" +#include "detail/IGCObject_DVarRef.hpp" +#include "detail/IPrintable_DVarRef.hpp" + +/* end VarRef.hpp */ diff --git a/include/xo/expression2/detail/IExpression_DVarRef.hpp b/include/xo/expression2/detail/IExpression_DVarRef.hpp new file mode 100644 index 00000000..332113c1 --- /dev/null +++ b/include/xo/expression2/detail/IExpression_DVarRef.hpp @@ -0,0 +1,66 @@ +/** @file IExpression_DVarRef.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DVarRef.json5] + **/ + +#pragma once + +#include "Expression.hpp" +#include "Expression.hpp" +#include "DVarRef.hpp" + +namespace xo { namespace scm { class IExpression_DVarRef; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::IExpression_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IExpression_DVarRef + **/ + class IExpression_DVarRef { + public: + /** @defgroup scm-expression-dvarref-type-traits **/ + ///@{ + using TypeDescr = xo::scm::AExpression::TypeDescr; + using Copaque = xo::scm::AExpression::Copaque; + using Opaque = xo::scm::AExpression::Opaque; + ///@} + /** @defgroup scm-expression-dvarref-methods **/ + ///@{ + // const methods + /** expression type (constant | apply | ..) **/ + static exprtype extype(const DVarRef & self) noexcept; + /** placeholder for type giving possible values for this expression **/ + static TypeRef typeref(const DVarRef & self) noexcept; + /** type giving possible values for this expression. Maybe null before typecheck **/ + static TypeDescr valuetype(const DVarRef & self) noexcept; + + // non-const methods + /** assing to valuetype member. Useful when scaffolding expressions **/ + static void assign_valuetype(DVarRef & self, TypeDescr td) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp new file mode 100644 index 00000000..10b08c10 --- /dev/null +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DApplyExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DApplyExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DApplyExpr.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DApplyExpr.hpp" + +namespace xo { namespace scm { class IGCObject_DApplyExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DApplyExpr + **/ + class IGCObject_DApplyExpr { + public: + /** @defgroup scm-gcobject-dapplyexpr-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dapplyexpr-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DApplyExpr & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DApplyExpr & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DApplyExpr & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp new file mode 100644 index 00000000..e991ebb8 --- /dev/null +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DVarRef.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVarRef.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DVarRef.hpp" + +namespace xo { namespace scm { class IGCObject_DVarRef; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DVarRef + **/ + class IGCObject_DVarRef { + public: + /** @defgroup scm-gcobject-dvarref-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dvarref-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DVarRef & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DVarRef & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DVarRef & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IPrintable_DVarRef.hpp b/include/xo/expression2/detail/IPrintable_DVarRef.hpp new file mode 100644 index 00000000..50034312 --- /dev/null +++ b/include/xo/expression2/detail/IPrintable_DVarRef.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DVarRef.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVarRef.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DVarRef.hpp" + +namespace xo { namespace scm { class IPrintable_DVarRef; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DVarRef + **/ + class IPrintable_DVarRef { + public: + /** @defgroup scm-printable-dvarref-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dvarref-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DVarRef & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/exprtype.hpp b/include/xo/expression2/exprtype.hpp index 3bcda3c4..8b1778fb 100644 --- a/include/xo/expression2/exprtype.hpp +++ b/include/xo/expression2/exprtype.hpp @@ -36,8 +36,10 @@ namespace xo { /** function definition **/ lambda, - /** variable reference **/ + /** variable definition **/ variable, + /** variabele reference (possibly non-local) **/ + varref, /** if-then-else **/ ifexpr, /** sequence **/ @@ -65,14 +67,16 @@ namespace xo { case exprtype::assign: return "assign"; #endif case exprtype::apply: return "apply"; -#ifdef NOT_YET case exprtype::lambda: return "lambda"; case exprtype::variable: return "variable"; + case exprtype::varref: return "varref"; case exprtype::ifexpr: return "if_expr"; case exprtype::sequence: return "sequence"; +#ifdef NOT_YET case exprtype::convert: return "convert"; #endif - default: break; + case exprtype::N: break; + //default: break; } return "???exprtype???"; diff --git a/src/expression2/Binding.cpp b/src/expression2/Binding.cpp new file mode 100644 index 00000000..6802ba69 --- /dev/null +++ b/src/expression2/Binding.cpp @@ -0,0 +1,41 @@ +/** @file Binding.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "Binding.hpp" +#include + +namespace xo { + namespace scm { + + Binding + Binding::relative(int32_t i_link, Binding def) + { + if (def.i_link_ == Binding::c_link_global) { + // for globally defined vars, i_link always -1 + return def; + } else if (def.i_link_ >= 0) { + return Binding(i_link + def.i_link_, def.j_slot_); + } else { + assert(false); + return Binding(); + } + } + + void + Binding::print(std::ostream & os) const + { + if (i_link_ == c_link_global) { + os << "{path:global}"; + } else if (i_link_ == c_link_sentinel) { + os << "{path}"; + } else { + os << "{path:" << i_link_ << ":" << j_slot_ << "}"; + } + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end Binding.cpp */ diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 4f3d63c1..45b5a06e 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -3,9 +3,12 @@ set(SELF_LIB xo_expression2) set(SELF_SRCS init_expression2.cpp + expression2_register_facets.cpp + expression2_register_types.cpp DConstant.cpp DVariable.cpp + DVarRef.cpp DDefineExpr.cpp DLambdaExpr.cpp DApplyExpr.cpp @@ -13,6 +16,7 @@ set(SELF_SRCS DSequenceExpr.cpp TypeRef.cpp + Binding.cpp IExpression_Any.cpp @@ -24,10 +28,15 @@ set(SELF_SRCS IGCObject_DVariable.cpp IPrintable_DVariable.cpp + IExpression_DVarRef.cpp + IGCObject_DVarRef.cpp + IPrintable_DVarRef.cpp + IExpression_DDefineExpr.cpp IPrintable_DDefineExpr.cpp IExpression_DApplyExpr.cpp + IGCObject_DApplyExpr.cpp IPrintable_DApplyExpr.cpp IExpression_DLambdaExpr.cpp @@ -55,8 +64,6 @@ set(SELF_SRCS IGCObject_DUniqueString.cpp IPrintable_DUniqueString.cpp - expression2_register_facets.cpp - expression2_register_types.cpp ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) diff --git a/src/expression2/DApplyExpr.cpp b/src/expression2/DApplyExpr.cpp index 751c1d85..d4e1fa55 100644 --- a/src/expression2/DApplyExpr.cpp +++ b/src/expression2/DApplyExpr.cpp @@ -102,6 +102,48 @@ namespace xo { typeref_.resolve(td); } + // ----- gcobject facet ----- + + std::size_t + DApplyExpr::shallow_size() const noexcept { + return sizeof(DApplyExpr) + (n_args_ * sizeof(obj)); + } + + DApplyExpr * + DApplyExpr::shallow_copy(obj mm) const noexcept { + DApplyExpr * copy = (DApplyExpr *)mm.alloc_copy((std::byte *)this); + + if (copy) { + copy->typeref_ = typeref_; + copy->fn_ = fn_; + copy->n_args_ = n_args_; + + constexpr auto c_obj_z = sizeof(obj); + + ::memcpy((void*)&(copy->args_[0]), (void*)&(args_[0]), n_args_ * c_obj_z); + } + + return copy; + } + + std::size_t + DApplyExpr::forward_children(obj gc) noexcept + { + for (size_type i = 0; i < n_args_; ++i) { + obj & arg = args_[i]; + + // runtime poly here + obj arg_gco = arg.to_facet(); + + // need the data address within *this + gc.forward_inplace(arg_gco.iface(), (void **)(&arg.data_)); + } + + return shallow_size(); + } + + // ----- printable facet ----- + bool DApplyExpr::pretty(const ppindentinfo & ppii) const { using xo::print::ppstate; diff --git a/src/expression2/DVarRef.cpp b/src/expression2/DVarRef.cpp new file mode 100644 index 00000000..afd9190e --- /dev/null +++ b/src/expression2/DVarRef.cpp @@ -0,0 +1,105 @@ +/** @file DVarRef.cpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#include "DVarRef.hpp" + +namespace xo { + using xo::mm::AGCObject; + using xo::reflect::TypeDescr; + + namespace scm { + + DVarRef::DVarRef(DVariable * vardef, + Binding path) + : vardef_{vardef}, + path_{path} + {} + + DVarRef * + DVarRef::make(obj mm, + DVariable * vardef, + int32_t link) + { + assert(vardef); + + void * mem = mm.alloc_for(); + + return new (mem) DVarRef(vardef, + Binding::relative(link, + vardef->path())); + } + + const DUniqueString * + DVarRef::name() const { + return vardef_->name(); + } + + TypeRef + DVarRef::typeref() const noexcept { + assert(vardef_); + + return vardef_->typeref(); + } + + TypeDescr + DVarRef::valuetype() const noexcept + { + return this->typeref().td(); + } + + void + DVarRef::assign_valuetype(TypeDescr td) noexcept + { + assert(vardef_); + vardef_->assign_valuetype(td); + } + + // gcobject facet + + std::size_t + DVarRef::shallow_size() const noexcept + { + return sizeof(DVarRef); + } + + DVarRef * + DVarRef::shallow_copy(obj mm) const noexcept + { + DVarRef * copy = (DVarRef *)mm.alloc_copy((std::byte *)this); + + if (copy) + *copy = *this; + + return copy; + } + + std::size_t + DVarRef::forward_children(obj gc) noexcept + { + // TODO: this can be helper in RCollector interface + auto iface = xo::facet::impl_for(); + gc.forward_inplace(&iface, (void **)vardef_); + + // TODO: concept to indicate that no gc pointers in Binding + + return shallow_size(); + } + + // printable facet + + bool + DVarRef::pretty(const ppindentinfo & ppii) const + { + return ppii.pps()->pretty_struct + (ppii, + "DVarRef", + refrtag("name", std::string_view(*(this->name()))), + refrtag("path", this->path_)); + } + + } +} /*namespace xo*/ + +/* end DVarRef.cpp */ diff --git a/src/expression2/IExpression_DVarRef.cpp b/src/expression2/IExpression_DVarRef.cpp new file mode 100644 index 00000000..843a0653 --- /dev/null +++ b/src/expression2/IExpression_DVarRef.cpp @@ -0,0 +1,45 @@ +/** @file IExpression_DVarRef.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IExpression_DVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IExpression_DVarRef.json5] +**/ + +#include "detail/IExpression_DVarRef.hpp" + +namespace xo { + namespace scm { + auto + IExpression_DVarRef::extype(const DVarRef & self) noexcept -> exprtype + { + return self.extype(); + } + + auto + IExpression_DVarRef::typeref(const DVarRef & self) noexcept -> TypeRef + { + return self.typeref(); + } + + auto + IExpression_DVarRef::valuetype(const DVarRef & self) noexcept -> TypeDescr + { + return self.valuetype(); + } + + auto + IExpression_DVarRef::assign_valuetype(DVarRef & self, TypeDescr td) noexcept -> void + { + self.assign_valuetype(td); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IExpression_DVarRef.cpp */ diff --git a/src/expression2/IGCObject_DApplyExpr.cpp b/src/expression2/IGCObject_DApplyExpr.cpp new file mode 100644 index 00000000..ad6571e0 --- /dev/null +++ b/src/expression2/IGCObject_DApplyExpr.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DApplyExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DApplyExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DApplyExpr.json5] +**/ + +#include "detail/IGCObject_DApplyExpr.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DApplyExpr::shallow_size(const DApplyExpr & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DApplyExpr::shallow_copy(const DApplyExpr & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DApplyExpr::forward_children(DApplyExpr & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DApplyExpr.cpp */ diff --git a/src/expression2/IGCObject_DVarRef.cpp b/src/expression2/IGCObject_DVarRef.cpp new file mode 100644 index 00000000..61596baa --- /dev/null +++ b/src/expression2/IGCObject_DVarRef.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DVarRef.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DVarRef.json5] +**/ + +#include "detail/IGCObject_DVarRef.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DVarRef::shallow_size(const DVarRef & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DVarRef::shallow_copy(const DVarRef & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DVarRef::forward_children(DVarRef & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DVarRef.cpp */ diff --git a/src/expression2/IPrintable_DVarRef.cpp b/src/expression2/IPrintable_DVarRef.cpp new file mode 100644 index 00000000..a2027a2a --- /dev/null +++ b/src/expression2/IPrintable_DVarRef.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DVarRef.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DVarRef.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DVarRef.json5] +**/ + +#include "detail/IPrintable_DVarRef.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DVarRef::pretty(const DVarRef & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DVarRef.cpp */ diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 26869d50..67944a08 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -16,13 +16,13 @@ #include #include +#include + #include #include #include -#include -//#include -#include +#include #include //#include @@ -63,6 +63,7 @@ namespace xo { // Expression // +- Constant // +- Variable + // +- VarRef // +- DefineExpr // +- ApplyExpr // +- LambdaExpr @@ -77,13 +78,20 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + //FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); + //FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -95,11 +103,13 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + //FacetRegistry::register_impl(); FacetRegistry::register_impl(); log && log(xtag("DUniqueString.tseq", typeseq::id())); log && log(xtag("DDefineExpr.tseq", typeseq::id())); log && log(xtag("DVariable.tseq", typeseq::id())); + log && log(xtag("DVarRef.tseq", typeseq::id())); log && log(xtag("DConstant.tseq", typeseq::id())); log && log(xtag("DApplyExpr.tseq", typeseq::id())); log && log(xtag("DLambdaExpr.tseq", typeseq::id())); @@ -108,7 +118,7 @@ namespace xo { log && log(xtag("DLocalSymtab.tseq", typeseq::id())); - log && log(xtag("AExpression.tqseq", typeseq::id())); + log && log(xtag("AExpression.tseq", typeseq::id())); log && log(xtag("ASymbolTable.tseq", typeseq::id())); return true; From e9413abbd6a2356bd8916bbf70ae71d349287ec2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 8 Feb 2026 01:01:03 -0500 Subject: [PATCH 071/128] xo-interpreter2 stack: work on VSM for apply -> closure action [WIP] --- CMakeLists.txt | 26 +++++++ idl/IGCObject_DLambdaExpr.json5 | 15 +++++ idl/IGCObject_DLocalSymtab.json5 | 15 +++++ idl/SymbolTable.json5 | 1 + include/xo/expression2/DLocalSymtab.hpp | 9 +++ include/xo/expression2/LambdaExpr.hpp | 2 +- include/xo/expression2/LocalSymtab.hpp | 1 + include/xo/expression2/detail/AExpression.hpp | 2 + .../xo/expression2/detail/IExpression_Any.hpp | 5 +- .../expression2/detail/IExpression_Xfer.hpp | 5 +- .../detail/IGCObject_DLambdaExpr.hpp | 67 +++++++++++++++++++ include/xo/expression2/detail/RExpression.hpp | 7 +- .../xo/expression2/symtab/ASymbolTable.hpp | 2 + .../symtab/IGCObject_DLocalSymtab.hpp | 67 +++++++++++++++++++ .../expression2/symtab/ISymbolTable_Any.hpp | 5 +- .../expression2/symtab/ISymbolTable_Xfer.hpp | 5 +- .../xo/expression2/symtab/RSymbolTable.hpp | 7 +- src/expression2/IGCObject_DLambdaExpr.cpp | 39 +++++++++++ src/expression2/IGCObject_DLocalSymtab.cpp | 39 +++++++++++ 19 files changed, 312 insertions(+), 7 deletions(-) create mode 100644 idl/IGCObject_DLambdaExpr.json5 create mode 100644 idl/IGCObject_DLocalSymtab.json5 create mode 100644 include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp create mode 100644 include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp create mode 100644 src/expression2/IGCObject_DLambdaExpr.cpp create mode 100644 src/expression2/IGCObject_DLocalSymtab.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index d070190e..382769ba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,6 +34,7 @@ xo_add_genfacet( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-symboltable-localsymtab FACET_PKG xo_expression2 @@ -45,6 +46,19 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-localsymtab + FACET_PKG xo_gc + FACET GCObject + REPR LocalSymtab + INPUT idl/IGCObject_DLocalSymtab.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR symtab + OUTPUT_CPP_DIR src/expression2 +) + +# note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-localsymtab FACET_PKG xo_printable2 @@ -260,6 +274,18 @@ xo_add_genfacetimpl( OUTPUT_CPP_DIR src/expression2 ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-lambdaexpr + FACET_PKG xo_gc + FACET GCObject + REPR LambdaExpr + INPUT idl/IGCObject_DLambdaExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR detail + OUTPUT_CPP_DIR src/expression2 +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-lambdaexpr diff --git a/idl/IGCObject_DLambdaExpr.json5 b/idl/IGCObject_DLambdaExpr.json5 new file mode 100644 index 00000000..b35ad45e --- /dev/null +++ b/idl/IGCObject_DLambdaExpr.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DLambdaExpr", + using_doxygen: true, + repr: "DLambdaExpr", + doc: [ "implement AGCObject for DLambdaExpr" ], +} diff --git a/idl/IGCObject_DLocalSymtab.json5 b/idl/IGCObject_DLocalSymtab.json5 new file mode 100644 index 00000000..03705f5e --- /dev/null +++ b/idl/IGCObject_DLocalSymtab.json5 @@ -0,0 +1,15 @@ +{ + mode: "implementation", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DLocalSymtab", + using_doxygen: true, + repr: "DLocalSymtab", + doc: [ "implement AGCObject for DLocalSymtab" ], +} diff --git a/idl/SymbolTable.json5 b/idl/SymbolTable.json5 index 3d91a3d7..4d7dc2a4 100644 --- a/idl/SymbolTable.json5 +++ b/idl/SymbolTable.json5 @@ -56,4 +56,5 @@ // // Variable gives both {name, type} // void upsert_local(DVariable * target) = 0; ], + router_facet_explicit_content: [ ], } diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index 6d1a6480..6a75422d 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -25,6 +25,7 @@ namespace xo { // using typeseq = xo::reflect::typeseq; using ppindentinfo = xo::print::ppindentinfo; + using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; /* note: uint16_t would be fine too */ using size_type = std::uint32_t; @@ -90,6 +91,14 @@ namespace xo { /** lookup binding for variable @p sym **/ Binding lookup_binding(const DUniqueString * sym) const noexcept; + ///@} + /** @defgroup xo-localsymtab-gcobject-facet gcobject facet **/ + ///@{ + + std::size_t shallow_size() const noexcept; + DLocalSymtab * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + ///@} /** @defgroup xo-localsymtab-printable-facet printable facet **/ ///@{ diff --git a/include/xo/expression2/LambdaExpr.hpp b/include/xo/expression2/LambdaExpr.hpp index 45f86b25..043ca319 100644 --- a/include/xo/expression2/LambdaExpr.hpp +++ b/include/xo/expression2/LambdaExpr.hpp @@ -7,7 +7,7 @@ #include "DLambdaExpr.hpp" #include "detail/IExpression_DLambdaExpr.hpp" -//#include "detail/IGCObject_DLambdaExpr.hpp" +#include "detail/IGCObject_DLambdaExpr.hpp" #include "detail/IPrintable_DLambdaExpr.hpp" /* end LambdaExpr.hpp */ diff --git a/include/xo/expression2/LocalSymtab.hpp b/include/xo/expression2/LocalSymtab.hpp index 4c852652..e594a08d 100644 --- a/include/xo/expression2/LocalSymtab.hpp +++ b/include/xo/expression2/LocalSymtab.hpp @@ -7,6 +7,7 @@ #include "DLocalSymtab.hpp" #include "symtab/ISymbolTable_DLocalSymtab.hpp" +#include "symtab/IGCObject_DLocalSymtab.hpp" #include "symtab/IPrintable_DLocalSymtab.hpp" /* end LocalSymtab.hpp */ diff --git a/include/xo/expression2/detail/AExpression.hpp b/include/xo/expression2/detail/AExpression.hpp index 59c83339..96d68a65 100644 --- a/include/xo/expression2/detail/AExpression.hpp +++ b/include/xo/expression2/detail/AExpression.hpp @@ -50,6 +50,8 @@ public: // const methods /** 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 **/ + virtual void _drop(Opaque d) const noexcept = 0; /** expression type (constant | apply | ..) **/ virtual exprtype extype(Copaque data) const noexcept = 0; /** placeholder for type giving possible values for this expression **/ diff --git a/include/xo/expression2/detail/IExpression_Any.hpp b/include/xo/expression2/detail/IExpression_Any.hpp index 8ecb604d..827f9d9b 100644 --- a/include/xo/expression2/detail/IExpression_Any.hpp +++ b/include/xo/expression2/detail/IExpression_Any.hpp @@ -54,8 +54,11 @@ namespace scm { // from AExpression - // const methods + // builtin methods typeseq _typeseq() const noexcept override { return s_typeseq; } + [[noreturn]] void _drop(Opaque) const noexcept override { _fatal(); } + + // const methods [[noreturn]] exprtype extype(Copaque) const noexcept override { _fatal(); } [[noreturn]] TypeRef typeref(Copaque) const noexcept override { _fatal(); } [[noreturn]] TypeDescr valuetype(Copaque) const noexcept override { _fatal(); } diff --git a/include/xo/expression2/detail/IExpression_Xfer.hpp b/include/xo/expression2/detail/IExpression_Xfer.hpp index b95b8526..095e21ed 100644 --- a/include/xo/expression2/detail/IExpression_Xfer.hpp +++ b/include/xo/expression2/detail/IExpression_Xfer.hpp @@ -41,8 +41,11 @@ namespace scm { // from AExpression - // const methods + // builtin methods typeseq _typeseq() const noexcept override { return s_typeseq; } + void _drop(Opaque d) const noexcept override { _dcast(d).~DRepr(); } + + // const methods exprtype extype(Copaque data) const noexcept override { return I::extype(_dcast(data)); } diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp new file mode 100644 index 00000000..7d1ba5b0 --- /dev/null +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DLambdaExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DLambdaExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DLambdaExpr.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DLambdaExpr.hpp" + +namespace xo { namespace scm { class IGCObject_DLambdaExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DLambdaExpr + **/ + class IGCObject_DLambdaExpr { + public: + /** @defgroup scm-gcobject-dlambdaexpr-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dlambdaexpr-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DLambdaExpr & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DLambdaExpr & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DLambdaExpr & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/RExpression.hpp b/include/xo/expression2/detail/RExpression.hpp index a14a2ee5..89a8990f 100644 --- a/include/xo/expression2/detail/RExpression.hpp +++ b/include/xo/expression2/detail/RExpression.hpp @@ -46,8 +46,13 @@ public: /** @defgroup scm-expression-router-methods **/ ///@{ - // const methods + // explicit injected content + + // builtin methods typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); } + void _drop() const noexcept { O::iface()->_drop(O::data()); } + + // const methods exprtype extype() const noexcept { return O::iface()->extype(O::data()); } diff --git a/include/xo/expression2/symtab/ASymbolTable.hpp b/include/xo/expression2/symtab/ASymbolTable.hpp index 50d6b4b7..59cf246f 100644 --- a/include/xo/expression2/symtab/ASymbolTable.hpp +++ b/include/xo/expression2/symtab/ASymbolTable.hpp @@ -47,6 +47,8 @@ public: // const methods /** 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 **/ + virtual void _drop(Opaque d) const noexcept = 0; /** true iff this is toplevel (global) symbol table. **/ virtual bool is_global_symtab(Copaque data) const noexcept = 0; /** report ingredients needed to address variable at runtime. **/ diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp new file mode 100644 index 00000000..94b9e279 --- /dev/null +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DLocalSymtab.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DLocalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DLocalSymtab.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DLocalSymtab.hpp" + +namespace xo { namespace scm { class IGCObject_DLocalSymtab; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DLocalSymtab + **/ + class IGCObject_DLocalSymtab { + public: + /** @defgroup scm-gcobject-dlocalsymtab-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dlocalsymtab-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DLocalSymtab & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DLocalSymtab & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DLocalSymtab & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/symtab/ISymbolTable_Any.hpp b/include/xo/expression2/symtab/ISymbolTable_Any.hpp index 1f4c9b2e..2d873ea1 100644 --- a/include/xo/expression2/symtab/ISymbolTable_Any.hpp +++ b/include/xo/expression2/symtab/ISymbolTable_Any.hpp @@ -53,8 +53,11 @@ namespace scm { // from ASymbolTable - // const methods + // builtin methods typeseq _typeseq() const noexcept override { return s_typeseq; } + [[noreturn]] void _drop(Opaque) const noexcept override { _fatal(); } + + // const methods [[noreturn]] bool is_global_symtab(Copaque) const noexcept override { _fatal(); } [[noreturn]] Binding lookup_binding(Copaque, const DUniqueString *) const noexcept override { _fatal(); } diff --git a/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp b/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp index f19f6e2e..db81237f 100644 --- a/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp +++ b/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp @@ -39,8 +39,11 @@ namespace scm { // from ASymbolTable - // const methods + // builtin methods typeseq _typeseq() const noexcept override { return s_typeseq; } + void _drop(Opaque d) const noexcept override { _dcast(d).~DRepr(); } + + // const methods bool is_global_symtab(Copaque data) const noexcept override { return I::is_global_symtab(_dcast(data)); } diff --git a/include/xo/expression2/symtab/RSymbolTable.hpp b/include/xo/expression2/symtab/RSymbolTable.hpp index f6375b37..31405e89 100644 --- a/include/xo/expression2/symtab/RSymbolTable.hpp +++ b/include/xo/expression2/symtab/RSymbolTable.hpp @@ -45,8 +45,13 @@ public: /** @defgroup scm-symboltable-router-methods **/ ///@{ - // const methods + // explicit injected content + + // builtin methods typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); } + void _drop() const noexcept { O::iface()->_drop(O::data()); } + + // const methods bool is_global_symtab() const noexcept { return O::iface()->is_global_symtab(O::data()); } diff --git a/src/expression2/IGCObject_DLambdaExpr.cpp b/src/expression2/IGCObject_DLambdaExpr.cpp new file mode 100644 index 00000000..c7724cd5 --- /dev/null +++ b/src/expression2/IGCObject_DLambdaExpr.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DLambdaExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DLambdaExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DLambdaExpr.json5] +**/ + +#include "detail/IGCObject_DLambdaExpr.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DLambdaExpr::shallow_size(const DLambdaExpr & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DLambdaExpr::shallow_copy(const DLambdaExpr & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DLambdaExpr::forward_children(DLambdaExpr & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DLambdaExpr.cpp */ diff --git a/src/expression2/IGCObject_DLocalSymtab.cpp b/src/expression2/IGCObject_DLocalSymtab.cpp new file mode 100644 index 00000000..ca96d3b6 --- /dev/null +++ b/src/expression2/IGCObject_DLocalSymtab.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DLocalSymtab.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DLocalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DLocalSymtab.json5] +**/ + +#include "symtab/IGCObject_DLocalSymtab.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DLocalSymtab::shallow_size(const DLocalSymtab & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DLocalSymtab::shallow_copy(const DLocalSymtab & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DLocalSymtab::forward_children(DLocalSymtab & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DLocalSymtab.cpp */ From 0df7e05e82449d4da9b662049b03c2f73af1ab32 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 8 Feb 2026 23:32:20 -0500 Subject: [PATCH 072/128] xo-interpreter2 stack: lambda expr -> closure runs in VSM utest --- include/xo/expression2/DLambdaExpr.hpp | 11 +++- include/xo/expression2/IfElseExpr.hpp | 13 +++++ include/xo/expression2/UniqueString.hpp | 12 +++++ src/expression2/CMakeLists.txt | 15 +++--- src/expression2/DIfElseExpr.cpp | 54 ++++++++++--------- src/expression2/DLambdaExpr.cpp | 51 ++++++++++++++++-- src/expression2/DLocalSymtab.cpp | 49 ++++++++++++++++- .../expression2_register_facets.cpp | 28 ++++------ 8 files changed, 175 insertions(+), 58 deletions(-) create mode 100644 include/xo/expression2/IfElseExpr.hpp create mode 100644 include/xo/expression2/UniqueString.hpp diff --git a/include/xo/expression2/DLambdaExpr.hpp b/include/xo/expression2/DLambdaExpr.hpp index 2a0cc2c3..b21a37ce 100644 --- a/include/xo/expression2/DLambdaExpr.hpp +++ b/include/xo/expression2/DLambdaExpr.hpp @@ -20,6 +20,7 @@ namespace xo { **/ class DLambdaExpr { public: + using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; using ppindentinfo = xo::print::ppindentinfo; @@ -78,6 +79,14 @@ namespace xo { TypeDescr valuetype() const noexcept; void assign_valuetype(TypeDescr td) noexcept; + ///@} + /** @defgroup scm-lambdaexpr-gcobject-facet **/ + ///@{ + + std::size_t shallow_size() const noexcept; + DLambdaExpr * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + ///@} /** @defgroup scm-lambdaexpr-printable-facet **/ ///@{ @@ -95,7 +104,7 @@ namespace xo { /** name for this lambda (generated if necessary) **/ const DUniqueString * name_ = nullptr; -#ifdef NOT_YET +#ifdef NOT_YET // when enabled, need to visit forward_children() /** e.g. * i64(f64,string) * for function of two arguments with types (f64, string) respectively, diff --git a/include/xo/expression2/IfElseExpr.hpp b/include/xo/expression2/IfElseExpr.hpp new file mode 100644 index 00000000..901062b2 --- /dev/null +++ b/include/xo/expression2/IfElseExpr.hpp @@ -0,0 +1,13 @@ +/** @file IfElseExpr.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DIfElseExpr.hpp" +#include "detail/IExpression_DIfElseExpr.hpp" +#include "detail/IGCObject_DIfElseExpr.hpp" +#include "detail/IPrintable_DIfElseExpr.hpp" + +/* end IfElseExpr.hpp */ diff --git a/include/xo/expression2/UniqueString.hpp b/include/xo/expression2/UniqueString.hpp new file mode 100644 index 00000000..90cd1cd2 --- /dev/null +++ b/include/xo/expression2/UniqueString.hpp @@ -0,0 +1,12 @@ +/** @file UniqueString.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DUniqueString.hpp" +#include "detail/IGCObject_DUniqueString.hpp" +#include "detail/IPrintable_DUniqueString.hpp" + +/* end UniqueString.hpp */ diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 45b5a06e..749910e4 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -10,15 +10,13 @@ set(SELF_SRCS DVariable.cpp DVarRef.cpp DDefineExpr.cpp - DLambdaExpr.cpp DApplyExpr.cpp - DIfElseExpr.cpp - DSequenceExpr.cpp TypeRef.cpp Binding.cpp IExpression_Any.cpp + ISymbolTable_Any.cpp IExpression_DConstant.cpp IGCObject_DConstant.cpp @@ -39,25 +37,28 @@ set(SELF_SRCS IGCObject_DApplyExpr.cpp IPrintable_DApplyExpr.cpp + DLambdaExpr.cpp IExpression_DLambdaExpr.cpp + IGCObject_DLambdaExpr.cpp IPrintable_DLambdaExpr.cpp + DIfElseExpr.cpp IExpression_DIfElseExpr.cpp IGCObject_DIfElseExpr.cpp IPrintable_DIfElseExpr.cpp + DSequenceExpr.cpp IExpression_DSequenceExpr.cpp IGCObject_DSequenceExpr.cpp IPrintable_DSequenceExpr.cpp DLocalSymtab.cpp - DGlobalSymtab.cpp - - ISymbolTable_Any.cpp - ISymbolTable_DLocalSymtab.cpp + IGCObject_DLocalSymtab.cpp IPrintable_DLocalSymtab.cpp + DGlobalSymtab.cpp + StringTable.cpp DUniqueString.cpp diff --git a/src/expression2/DIfElseExpr.cpp b/src/expression2/DIfElseExpr.cpp index 631be466..6a0b053c 100644 --- a/src/expression2/DIfElseExpr.cpp +++ b/src/expression2/DIfElseExpr.cpp @@ -80,32 +80,6 @@ namespace xo { typeref_.resolve(td); } - bool - DIfElseExpr::pretty(const ppindentinfo & ppii) const - { - auto test - = FacetRegistry::instance().try_variant(test_); - auto when_true - = FacetRegistry::instance().try_variant(when_true_); - auto when_false - = FacetRegistry::instance().try_variant(when_false_); - - bool test_present = test; - bool when_true_present = when_true; - bool when_false_present = when_false; - - return ppii.pps()->pretty_struct - (ppii, - "DIfElseExpr", - refrtag("typeref", typeref_), - refrtag("test", test, test_present), - refrtag("when_true", when_true, when_true_present), - refrtag("when_false", when_false, when_false_present)); - } - // GCObject facet std::size_t @@ -145,6 +119,34 @@ namespace xo { return shallow_size(); } + // ----- printable facet ----- + + bool + DIfElseExpr::pretty(const ppindentinfo & ppii) const + { + auto test + = FacetRegistry::instance().try_variant(test_); + auto when_true + = FacetRegistry::instance().try_variant(when_true_); + auto when_false + = FacetRegistry::instance().try_variant(when_false_); + + bool test_present = test; + bool when_true_present = when_true; + bool when_false_present = when_false; + + return ppii.pps()->pretty_struct + (ppii, + "DIfElseExpr", + refrtag("typeref", typeref_), + refrtag("test", test, test_present), + refrtag("when_true", when_true, when_true_present), + refrtag("when_false", when_false, when_false_present)); + } + // ---------------------------------------------------------------- #ifdef NOPE diff --git a/src/expression2/DLambdaExpr.cpp b/src/expression2/DLambdaExpr.cpp index 080e49b5..56d55c03 100644 --- a/src/expression2/DLambdaExpr.cpp +++ b/src/expression2/DLambdaExpr.cpp @@ -3,16 +3,16 @@ * @author Roland Conybeare, Jan 2026 **/ -#include "DLambdaExpr.hpp" -#include "detail/IExpression_DLambdaExpr.hpp" -#include "DLocalSymtab.hpp" -#include "symtab/IPrintable_DLocalSymtab.hpp" +#include "LambdaExpr.hpp" +#include "LocalSymtab.hpp" +#include "UniqueString.hpp" #include #include #include #include namespace xo { + using xo::mm::AGCObject; using xo::print::APrintable; using xo::facet::FacetRegistry; using xo::reflect::TypeDescr; @@ -134,6 +134,49 @@ namespace xo { typeref_.resolve(td); } + std::size_t + DLambdaExpr::shallow_size() const noexcept { + return sizeof(DLambdaExpr); + } + + DLambdaExpr * + DLambdaExpr::shallow_copy(obj mm) const noexcept { + DLambdaExpr * copy = (DLambdaExpr *)mm.alloc_copy((std::byte *)this); + + if (copy) { + *copy = *this; + } + + return copy; + } + + std::size_t + DLambdaExpr::forward_children(obj gc) noexcept { + { + auto iface = xo::facet::impl_for(); + gc.forward_inplace(&iface, (void **)(&name_)); + } + + // type_name_str_ + + { + auto iface = xo::facet::impl_for(); + gc.forward_inplace(&iface, (void **)(&local_symtab_)); + } + + { + auto iface = body_expr_.to_facet().iface(); + gc.forward_inplace(iface, (void **)(&body_expr_)); + } + + // xxx free_var_set + // xxx captured_var_set + // xxx layer_var_map + // xxx nested_lambda_map + + return shallow_size(); + } + bool DLambdaExpr::pretty(const ppindentinfo & ppii) const { diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index 85631d34..cf9c8459 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -3,13 +3,14 @@ * @author Roland Conybeare, Jan 2026 **/ -#include "DLocalSymtab.hpp" +#include "LocalSymtab.hpp" +#include "Variable.hpp" #include "DUniqueString.hpp" -#include #include #include namespace xo { + using xo::mm::AGCObject; using xo::print::APrintable; using xo::facet::typeseq; using xo::print::ppstate; @@ -77,6 +78,50 @@ namespace xo { return Binding(); } + // ----- gcobject facet ----- + + std::size_t + DLocalSymtab::shallow_size() const noexcept + { + return (sizeof(DLocalSymtab) + (capacity_ * sizeof(Slot))); + } + + DLocalSymtab * + DLocalSymtab::shallow_copy(obj mm) const noexcept + { + DLocalSymtab * copy = (DLocalSymtab *)mm.alloc_copy((std::byte *)this); + + if (copy) { + *copy = *this; + + ::memcpy((void*)&(copy->slots_[0]), + (void*)&(slots_[0]), + capacity_ * sizeof(Slot)); + } + + return copy; + } + + std::size_t + DLocalSymtab::forward_children(obj gc) noexcept + { + { + auto iface + = xo::facet::impl_for(); + gc.forward_inplace(&iface, (void **)(&parent_)); + } + + auto iface + = xo::facet::impl_for(); + for (size_type i = 0; i < size_; ++i) { + gc.forward_inplace(&iface, (void **)(&(slots_[i].var_))); + } + + return shallow_size(); + } + + // ----- printable facet ----- + bool DLocalSymtab::pretty(const ppindentinfo & ppii) const { diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 67944a08..16bfac2a 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -17,28 +17,16 @@ #include #include - -#include -#include -#include - +#include #include - -#include -//#include -#include - -#include -#include -#include +#include +#include #include #include #include -#include -//#include -#include +#include #include #include @@ -70,6 +58,10 @@ namespace xo { // +- IfElseExpr // \- SequenceExpr + // SymbolTable + // +- LocalSymtab + // \- GlobalSymtab + FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -91,7 +83,7 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); - //FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -103,7 +95,7 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); - //FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); log && log(xtag("DUniqueString.tseq", typeseq::id())); From e76660e226dbda489fef6226641f1c1ea42e54b5 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 13 Feb 2026 02:05:47 -0500 Subject: [PATCH 073/128] xo-interpreter2 stack: invoke closures w/ tail-call opt [WIP] --- include/xo/expression2/DLambdaExpr.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/xo/expression2/DLambdaExpr.hpp b/include/xo/expression2/DLambdaExpr.hpp index b21a37ce..30ed2b74 100644 --- a/include/xo/expression2/DLambdaExpr.hpp +++ b/include/xo/expression2/DLambdaExpr.hpp @@ -63,6 +63,7 @@ namespace xo { DLocalSymtab * local_symtab() const noexcept { return local_symtab_; } size_type n_args() const noexcept { return local_symtab_->size(); } + obj body_expr() const noexcept { return body_expr_; } // get_free_variables() // visit_preorder() From 1ebd714e3d7d0c6745c9b351a7db68c0401f80b8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 13 Feb 2026 15:16:05 -0500 Subject: [PATCH 074/128] xo-interpreter2 stack: handle SequenceExpr + gc for frames --- include/xo/expression2/SequenceExpr.hpp | 14 ++++++++++++++ src/expression2/DSequenceExpr.cpp | 2 +- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 include/xo/expression2/SequenceExpr.hpp diff --git a/include/xo/expression2/SequenceExpr.hpp b/include/xo/expression2/SequenceExpr.hpp new file mode 100644 index 00000000..0cfe188c --- /dev/null +++ b/include/xo/expression2/SequenceExpr.hpp @@ -0,0 +1,14 @@ +/** @file SequenceExpr.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DSequenceExpr.hpp" +#include "detail/IExpression_DSequenceExpr.hpp" +#include "detail/IGCObject_DSequenceExpr.hpp" +#include "detail/IPrintable_DSequenceExpr.hpp" + +/* end SequenceExpr.hpp */ + diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index a9783802..22b097fb 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -135,7 +135,7 @@ namespace xo { gc.forward_inplace(&iface, (void**)&expr_v_); - return shallow_size(); + return this->shallow_size(); } } /*namespace scm*/ From 8c0bf6a3112834274de827759a27ea69e1ff362e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 13 Feb 2026 20:46:53 -0500 Subject: [PATCH 075/128] xo-interpreter2: work on global symtab [WIP] --- include/xo/expression2/DGlobalSymtab.hpp | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index bb668ff3..91117888 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -6,6 +6,7 @@ #pragma once #include "Binding.hpp" +#include namespace xo { namespace scm { @@ -13,10 +14,21 @@ namespace xo { /** @class DGlobalSymtab * @brief symbol table for toplevel environment + * + * We're using DArenaHashMap to store pairs. + * Both of these are outside GC-space, so we don't need collector + * to traverse these. **/ - struct DGlobalSymtab { + class DGlobalSymtab { public: + using key_type = const DUniqueString *; + using value_type = Binding; + using repr_type = xo::map::DArenaHashMap; + using MemorySizeVisitor = xo::mm::MemorySizeVisitor; + public: + /** visit symtab-owned memory pools; call visitor(info) for each **/ + void visit_pools(const MemorySizeVisitor & visitor) const; public: /** @defgroup xo-expression2-symboltable-facet symboltable facet**/ @@ -31,6 +43,12 @@ namespace xo { ///@} private: + /** next binding will use this global index. See DGlobalEnv **/ + uint32_t next_binding_ix_ = 0; + + /** map symbols -> bindings **/ + repr_type map_; + }; } /*namespace scm*/ From 017a7a092cf643c4d8459a8c9f97b5994e915dfa Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 14 Feb 2026 13:06:54 -0500 Subject: [PATCH 076/128] xo-expression2 stack: + mvp DGlobalSymtab impl --- include/xo/expression2/Binding.hpp | 4 +- include/xo/expression2/DGlobalSymtab.hpp | 23 +++++- include/xo/expression2/DLocalSymtab.hpp | 2 +- src/expression2/DGlobalSymtab.cpp | 92 +++++++++++++++++++++++- 4 files changed, 116 insertions(+), 5 deletions(-) diff --git a/include/xo/expression2/Binding.hpp b/include/xo/expression2/Binding.hpp index 97f74c27..805ebeb9 100644 --- a/include/xo/expression2/Binding.hpp +++ b/include/xo/expression2/Binding.hpp @@ -12,6 +12,8 @@ namespace xo { namespace scm { class Binding { public: + using slot_type = int32_t; + static constexpr int32_t c_link_sentinel = -2; static constexpr int32_t c_link_global = -1; @@ -22,7 +24,7 @@ namespace xo { static Binding null() { return Binding(); } /** global bindings are located by symbol name **/ - static Binding global() { return Binding(c_link_global, 0); } + static Binding global(int32_t j_slot) { return Binding(c_link_global, j_slot); } static Binding local(int32_t j_slot) { return Binding(0, j_slot); } static Binding relative(int32_t i_link, Binding def); diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index 91117888..0aca15c6 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -6,6 +6,8 @@ #pragma once #include "Binding.hpp" +#include "DVariable.hpp" +#include #include namespace xo { @@ -23,7 +25,8 @@ namespace xo { public: using key_type = const DUniqueString *; using value_type = Binding; - using repr_type = xo::map::DArenaHashMap; + using repr_type = xo::map::DArenaHashMap; + using AAllocator = xo::mm::AAllocator; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; public: @@ -31,6 +34,17 @@ namespace xo { void visit_pools(const MemorySizeVisitor & visitor) const; public: + /** lookup global symbol with name @p sym **/ + DVariable * lookup_variable(const DUniqueString * sym) const noexcept; + + /** establish binding for @p sym, with type described by @p typeref, + * replacing existing global (if present) with the same name. + * Use memory from @p mm to create variable-expr + **/ + DVariable * establish_variable(obj mm, + const DUniqueString * sym, + TypeRef typeref); + /** @defgroup xo-expression2-symboltable-facet symboltable facet**/ ///@{ @@ -49,6 +63,13 @@ namespace xo { /** map symbols -> bindings **/ repr_type map_; + /** array of variables. + * When S is a unique-string for a global symbol, then: + * 1. map_[S] is unique global index i(S) for S. + * 2. vars_[i(S)] is variable-expr var(S) for S + * 3. var(S)->name == S + **/ + DArray * vars_ = nullptr; }; } /*namespace scm*/ diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index 6a75422d..f4073226 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -73,7 +73,7 @@ namespace xo { return slots_[ix.j_slot()].var_; } - /** increase slot size (provided beleow capacity) to append + /** increase slot size (provided below capacity) to append * binding for one local variable. Local variable will be allocated * from @p mm, named @p name, with type described by @p typeref. **/ diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index c11761d9..10e1665f 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -5,20 +5,108 @@ #include "DGlobalSymtab.hpp" #include "DUniqueString.hpp" +#include +#include +#include +#include #include namespace xo { + using xo::mm::AGCObject; + namespace scm { +#ifdef NOT_YET + DVariable * + DGlobalSymtab::lookup_binding(Binding ix) noexcept + { + assert(ix.i_link() == -1); + assert(ix.j_slot() >= 0); + assert(vars_); + assert(std::uint64_t(ix.j_slot()) < vars_->size()); + + auto var_gco = obj::from((*vars_)[ix.j_slot()]);; + auto var = var_gco.to_facet(); + + assert(var.data()); + + return var.data(); + } +#endif + + DVariable * + DGlobalSymtab::lookup_variable(const DUniqueString * sym) const noexcept + { + Binding existing = this->lookup_binding(sym); + + if (existing.is_null()) + return nullptr; + + auto var_gco = obj::from((*vars_)[existing.j_slot()]); + auto var = var_gco.to_facet(); + + assert(var.data()); + + return var.data(); + } + + DVariable * + DGlobalSymtab::establish_variable(obj mm, + const DUniqueString * sym, + TypeRef typeref) + { + DVariable * var = this->lookup_variable(sym); + + if (!var) { + assert(vars_); + + DArray::size_type n = vars_->size(); + + /** make sure vars_ has room **/ + if (n == vars_->capacity()) { + // reallocate with more capacity + DArray * vars_2x = DArray::copy(mm, vars_, vars_->capacity() * 2); + + assert(vars_2x); + + this->vars_ = vars_2x; + } + + /** create new variable **/ + Binding binding = Binding::global(n); + var = DVariable::make(mm, sym, typeref, binding); + + if (!var) { + // something terribly wrong + assert(false); + return var; + } + + map_[sym] = binding.j_slot(); + + bool ok = vars_->push_back(obj(var)); + + if (!ok) + assert(false); + } + + return var; + } + Binding DGlobalSymtab::lookup_binding(const DUniqueString * sym) const noexcept { - (void)sym; + assert(sym); scope log(XO_DEBUG(true), "stub"); log && log(xtag("sym", std::string_view(*sym))); - return Binding(); + auto ix = map_.find(sym); + + if (ix == map_.end()) + return Binding::null(); + + return Binding::global(ix->second); } } /*namespace scm*/ From b187f1a719e6ba41bdfa1b84f2d0df7fda45d615 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 15 Feb 2026 13:17:21 -0500 Subject: [PATCH 077/128] xo-expression2: DGlobalSymtab mvp implementation --- include/xo/expression2/DGlobalSymtab.hpp | 47 +++++++++++-- src/expression2/DGlobalSymtab.cpp | 90 +++++++++++++++++++----- 2 files changed, 112 insertions(+), 25 deletions(-) diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index 0aca15c6..32fb9570 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -25,18 +25,41 @@ namespace xo { public: using key_type = const DUniqueString *; using value_type = Binding; + using ArenaHashMapConfig = xo::map::ArenaHashMapConfig; using repr_type = xo::map::DArenaHashMap; + using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; public: + /** @defgroup scm-globalsymtab-ctors constructors **/ + ///@{ + + DGlobalSymtab(repr_type * map, DArray * vars); + + /** create instance. + * Use memory from @p fixed_mm for @ref map_. + * Use memory from @p mm for DGlobalSymtab instance. + * Hashmap configured per @p cfg. + **/ + DGlobalSymtab * make(obj fixed_mm, + obj mm, + const ArenaHashMapConfig & cfg); + + ///@} + /** @defgroup scm-globalsymtab-access-methods access methods **/ + ///@{ + /** visit symtab-owned memory pools; call visitor(info) for each **/ void visit_pools(const MemorySizeVisitor & visitor) const; - public: /** lookup global symbol with name @p sym **/ DVariable * lookup_variable(const DUniqueString * sym) const noexcept; + ///@} + /** @defgroup scm-globalsymtab-general-methods general methods **/ + ///@{ + /** establish binding for @p sym, with type described by @p typeref, * replacing existing global (if present) with the same name. * Use memory from @p mm to create variable-expr @@ -45,7 +68,8 @@ namespace xo { const DUniqueString * sym, TypeRef typeref); - /** @defgroup xo-expression2-symboltable-facet symboltable facet**/ + ///@} + /** @defgroup scm-globalsymtab-symboltable-facet symboltable facet **/ ///@{ /** true for global symbol table **/ @@ -55,13 +79,22 @@ namespace xo { Binding lookup_binding(const DUniqueString * sym) const noexcept; ///@} + /** @defgroup scm-globalsymtab-gcobject-facet gcobject facet **/ + ///@{ + + std::size_t shallow_size() const noexcept; + DGlobalSymtab * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + ///@} + private: - /** next binding will use this global index. See DGlobalEnv **/ - uint32_t next_binding_ix_ = 0; - - /** map symbols -> bindings **/ - repr_type map_; + /** map symbols -> bindings. + * Minor point: storing offsets instead of Variables allows us to omit + * iterating over map elements during GC. Possible savings if map_ slots + * sparsely populated. + **/ + repr_type * map_ = nullptr; /** array of variables. * When S is a unique-string for a global symbol, then: diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index 10e1665f..85fd6e93 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -7,32 +7,57 @@ #include "DUniqueString.hpp" #include #include +#include #include #include #include namespace xo { + using xo::map::DArenaHashMap; using xo::mm::AGCObject; namespace scm { -#ifdef NOT_YET - DVariable * - DGlobalSymtab::lookup_binding(Binding ix) noexcept + DGlobalSymtab::DGlobalSymtab(repr_type * map, + DArray * vars) + : map_{map}, vars_{vars} { - assert(ix.i_link() == -1); - assert(ix.j_slot() >= 0); - assert(vars_); - assert(std::uint64_t(ix.j_slot()) < vars_->size()); - - auto var_gco = obj::from((*vars_)[ix.j_slot()]);; - auto var = var_gco.to_facet(); - - assert(var.data()); - - return var.data(); } -#endif + + DGlobalSymtab * + DGlobalSymtab::make(obj global_mm, + obj mm, + const ArenaHashMapConfig & cfg) + { + repr_type * map = nullptr; + { + /** memory DGlobalSymtab::map_ + * (but not counting the mmap()'s that map will make for itself) + **/ + void * global_mem = global_mm.alloc_for(); + + map = new (global_mem) repr_type(cfg); + } + assert(map); + + void * symtab_mem = mm.alloc_for(); + + /* choosing same capacity for hash, vars */ + DArray * vars = DArray::empty(mm, map->capacity()); + assert(vars); + + DGlobalSymtab * symtab = new (symtab_mem) DGlobalSymtab(map, vars); + assert(symtab); + + return symtab; + } + + void + DGlobalSymtab::visit_pools(const MemorySizeVisitor & visitor) const + { + if (map_) + map_->visit_pools(visitor); + } DVariable * DGlobalSymtab::lookup_variable(const DUniqueString * sym) const noexcept @@ -62,6 +87,9 @@ namespace xo { DArray::size_type n = vars_->size(); + // NOTE: expansion here is moot at present (Feb 2026). + // Not implemented in ArenaHashMap + /** make sure vars_ has room **/ if (n == vars_->capacity()) { // reallocate with more capacity @@ -82,7 +110,9 @@ namespace xo { return var; } - map_[sym] = binding.j_slot(); + assert(map_->size() < map_->capacity()); + + (*map_)[sym] = binding.j_slot(); bool ok = vars_->push_back(obj(var)); @@ -101,14 +131,38 @@ namespace xo { scope log(XO_DEBUG(true), "stub"); log && log(xtag("sym", std::string_view(*sym))); - auto ix = map_.find(sym); + auto ix = map_->find(sym); - if (ix == map_.end()) + if (ix == map_->end()) return Binding::null(); return Binding::global(ix->second); } + // ----- gcobject facet ----- + + std::size_t + DGlobalSymtab::shallow_size() const noexcept + { + return sizeof(DGlobalSymtab); + } + + DGlobalSymtab * + DGlobalSymtab::shallow_copy(obj mm) const noexcept + { + return mm.std_copy_for(this); + } + + std::size_t + DGlobalSymtab::forward_children(obj gc) noexcept + { + // map_ doesn't contain any gc-owned data, can skip + + gc.forward_inplace(&vars_); + + return this->shallow_size(); + } + } /*namespace scm*/ } /*namespace xo*/ From 3666bf3dd174998568f7d1d42b0e874aec453657 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 15 Feb 2026 14:12:31 -0500 Subject: [PATCH 078/128] xo-expression2 stack: + dp<> template + robustify DGlobalSymtab --- include/xo/expression2/DGlobalSymtab.hpp | 17 +++++----- src/expression2/DGlobalSymtab.cpp | 41 +++++++++++++----------- 2 files changed, 32 insertions(+), 26 deletions(-) diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index 32fb9570..566d8981 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -8,6 +8,7 @@ #include "Binding.hpp" #include "DVariable.hpp" #include +#include #include namespace xo { @@ -35,16 +36,16 @@ namespace xo { /** @defgroup scm-globalsymtab-ctors constructors **/ ///@{ - DGlobalSymtab(repr_type * map, DArray * vars); + DGlobalSymtab(dp map, DArray * vars); /** create instance. * Use memory from @p fixed_mm for @ref map_. * Use memory from @p mm for DGlobalSymtab instance. * Hashmap configured per @p cfg. **/ - DGlobalSymtab * make(obj fixed_mm, - obj mm, - const ArenaHashMapConfig & cfg); + dp make(obj fixed_mm, + obj mm, + const ArenaHashMapConfig & cfg); ///@} /** @defgroup scm-globalsymtab-access-methods access methods **/ @@ -81,21 +82,21 @@ namespace xo { ///@} /** @defgroup scm-globalsymtab-gcobject-facet gcobject facet **/ ///@{ - + std::size_t shallow_size() const noexcept; DGlobalSymtab * shallow_copy(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; ///@} - + private: /** map symbols -> bindings. * Minor point: storing offsets instead of Variables allows us to omit * iterating over map elements during GC. Possible savings if map_ slots * sparsely populated. **/ - repr_type * map_ = nullptr; - + dp map_; + /** array of variables. * When S is a unique-string for a global symbol, then: * 1. map_[S] is unique global index i(S) for S. diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index 85fd6e93..b7eb4d73 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -18,35 +18,25 @@ namespace xo { namespace scm { - DGlobalSymtab::DGlobalSymtab(repr_type * map, + DGlobalSymtab::DGlobalSymtab(dp map, DArray * vars) - : map_{map}, vars_{vars} + : map_{std::move(map)}, vars_{vars} { } - DGlobalSymtab * - DGlobalSymtab::make(obj global_mm, + dp + DGlobalSymtab::make(obj aux_mm, obj mm, const ArenaHashMapConfig & cfg) { - repr_type * map = nullptr; - { - /** memory DGlobalSymtab::map_ - * (but not counting the mmap()'s that map will make for itself) - **/ - void * global_mem = global_mm.alloc_for(); - - map = new (global_mem) repr_type(cfg); - } + auto map = dp::make(aux_mm, cfg); assert(map); - void * symtab_mem = mm.alloc_for(); - /* choosing same capacity for hash, vars */ DArray * vars = DArray::empty(mm, map->capacity()); assert(vars); - DGlobalSymtab * symtab = new (symtab_mem) DGlobalSymtab(map, vars); + auto symtab = dp::make(mm, std::move(map), vars); assert(symtab); return symtab; @@ -133,7 +123,7 @@ namespace xo { auto ix = map_->find(sym); - if (ix == map_->end()) + if (ix == map_->end()) return Binding::null(); return Binding::global(ix->second); @@ -150,7 +140,22 @@ namespace xo { DGlobalSymtab * DGlobalSymtab::shallow_copy(obj mm) const noexcept { - return mm.std_copy_for(this); + /** can't use std_copy_for because of non-copyable dp + * + * TODO: rename to shallow_move() throughout, and have std_copy_for() + * -> std_move_for() + * + **/ + + void * copy_mem = mm.alloc_copy_for(this); + + if (copy_mem) { + DGlobalSymtab * self = const_cast(this); + + return new (copy_mem) DGlobalSymtab(std::move(self->map_), vars_); + } + + return nullptr; } std::size_t From 8e3b8691fc5edf1763caa5ec860874daea623458 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 15 Feb 2026 14:26:33 -0500 Subject: [PATCH 079/128] xo-interpreter2 stack: mark non-trivial dtors b/c DGlobalSymtab --- include/xo/expression2/DGlobalSymtab.hpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index 566d8981..8eec6d2e 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -47,6 +47,9 @@ namespace xo { obj mm, const ArenaHashMapConfig & cfg); + /** non-trivial destructor for @ref map_ **/ + ~DGlobalSymtab() = default; + ///@} /** @defgroup scm-globalsymtab-access-methods access methods **/ ///@{ From 1918dd06e5ebe3998bed331007f49694152667ad Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 15 Feb 2026 16:16:02 -0500 Subject: [PATCH 080/128] xo-reader2 stack: streamline + mem sizing + bugfixes --- include/xo/expression2/DGlobalSymtab.hpp | 6 +++--- src/expression2/DGlobalSymtab.cpp | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index 8eec6d2e..879c7073 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -43,9 +43,9 @@ namespace xo { * Use memory from @p mm for DGlobalSymtab instance. * Hashmap configured per @p cfg. **/ - dp make(obj fixed_mm, - obj mm, - const ArenaHashMapConfig & cfg); + static dp make(obj mm, + obj fixed_mm, + const ArenaHashMapConfig & cfg); /** non-trivial destructor for @ref map_ **/ ~DGlobalSymtab() = default; diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index b7eb4d73..c9897670 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -25,8 +25,8 @@ namespace xo { } dp - DGlobalSymtab::make(obj aux_mm, - obj mm, + DGlobalSymtab::make(obj mm, + obj aux_mm, const ArenaHashMapConfig & cfg) { auto map = dp::make(aux_mm, cfg); From 95b02926670d1caaa818f917b7f1c522bb56c2b2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 00:48:00 -0500 Subject: [PATCH 081/128] xo-expression2 stack: expand MemorySizeInfo w/ per-type detail --- include/xo/expression2/GlobalSymtab.hpp | 13 +++++++++++++ src/expression2/expression2_register_facets.cpp | 16 ++++++++++++---- 2 files changed, 25 insertions(+), 4 deletions(-) create mode 100644 include/xo/expression2/GlobalSymtab.hpp diff --git a/include/xo/expression2/GlobalSymtab.hpp b/include/xo/expression2/GlobalSymtab.hpp new file mode 100644 index 00000000..0c0dabf4 --- /dev/null +++ b/include/xo/expression2/GlobalSymtab.hpp @@ -0,0 +1,13 @@ +/** @file GlobalSymtab.hpp + * + * @author Roland Conybeare, Feb 2026 + **/ + +#pragma once + +#include "DGlobalSymtab.hpp" +//#include "symtab/ISymbolTable_DGlobalSymtab.hpp" +//#include "symtab/IGCObject_DGlobalSymtab.hpp" +//#include "symtab/IPrintable_DGlobalSymtab.hpp" + +/* end GlobalSymtab.hpp */ diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 16bfac2a..f14ceae6 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -26,6 +26,7 @@ #include #include +#include #include #include @@ -37,6 +38,7 @@ namespace xo { using xo::mm::AGCObject; using xo::print::APrintable; using xo::facet::FacetRegistry; + using xo::facet::TypeRegistry; using xo::facet::typeseq; namespace scm { @@ -45,6 +47,8 @@ namespace xo { { scope log(XO_DEBUG(true)); + + FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -58,10 +62,6 @@ namespace xo { // +- IfElseExpr // \- SequenceExpr - // SymbolTable - // +- LocalSymtab - // \- GlobalSymtab - FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -94,10 +94,17 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + // SymbolTable + // +- LocalSymtab + // \- GlobalSymtab + FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); + // until we register facets + TypeRegistry::register_type(); + log && log(xtag("DUniqueString.tseq", typeseq::id())); log && log(xtag("DDefineExpr.tseq", typeseq::id())); log && log(xtag("DVariable.tseq", typeseq::id())); @@ -108,6 +115,7 @@ namespace xo { log && log(xtag("DIfElseExpr.tseq", typeseq::id())); log && log(xtag("DSequenceExpr.tseq", typeseq::id())); + log && log(xtag("DGlobalSymtab.tseq", typeseq::id())); log && log(xtag("DLocalSymtab.tseq", typeseq::id())); log && log(xtag("AExpression.tseq", typeseq::id())); From 556eaf992878ab7dab14de935dee221b2dfc6b00 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 09:32:53 -0500 Subject: [PATCH 082/128] xo-expression2: register DGlobalSymtab type + rename --- src/expression2/expression2_register_facets.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index f14ceae6..a3a4b520 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -5,6 +5,7 @@ #include "expression2_register_facets.hpp" +#include #include #include @@ -47,8 +48,6 @@ namespace xo { { scope log(XO_DEBUG(true)); - - FacetRegistry::register_impl(); FacetRegistry::register_impl(); @@ -105,6 +104,8 @@ namespace xo { // until we register facets TypeRegistry::register_type(); + TypeRegistry::register_type(); + log && log(xtag("DUniqueString.tseq", typeseq::id())); log && log(xtag("DDefineExpr.tseq", typeseq::id())); log && log(xtag("DVariable.tseq", typeseq::id())); From fc4bfafa0aeedda97b981124a6141ab7a4d71c52 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 17:46:51 -0500 Subject: [PATCH 083/128] xo-interpreter2 stack: OUTPUT_CPP_DIR cmake->idl/ --- CMakeLists.txt | 30 ----------------------------- idl/Expression.json5 | 1 + idl/IExpression_DApplyExpr.json5 | 1 + idl/IExpression_DConstant.json5 | 1 + idl/IExpression_DDefineExpr.json5 | 1 + idl/IExpression_DIfElseExpr.json5 | 1 + idl/IExpression_DLambdaExpr.json5 | 1 + idl/IExpression_DSequenceExpr.json5 | 1 + idl/IExpression_DVarRef.json5 | 1 + idl/IExpression_DVariable.json5 | 1 + idl/IGCObject_DApplyExpr.json5 | 1 + idl/IGCObject_DConstant.json5 | 1 + idl/IGCObject_DIfElseExpr.json5 | 1 + idl/IGCObject_DLambdaExpr.json5 | 1 + idl/IGCObject_DLocalSymtab.json5 | 1 + idl/IGCObject_DSequenceExpr.json5 | 1 + idl/IGCObject_DUniqueString.json5 | 1 + idl/IGCObject_DVarRef.json5 | 1 + idl/IGCObject_DVariable.json5 | 1 + idl/IPrintable_DApplyExpr.json5 | 1 + idl/IPrintable_DConstant.json5 | 1 + idl/IPrintable_DDefineExpr.json5 | 1 + idl/IPrintable_DIfElseExpr.json5 | 1 + idl/IPrintable_DLambdaExpr.json5 | 1 + idl/IPrintable_DLocalSymtab.json5 | 1 + idl/IPrintable_DSequenceExpr.json5 | 1 + idl/IPrintable_DUniqueString.json5 | 1 + idl/IPrintable_DVarRef.json5 | 1 + idl/IPrintable_DVariable.json5 | 1 + idl/ISymbolTable_DLocalSymtab.json5 | 1 + idl/SymbolTable.json5 | 1 + 31 files changed, 30 insertions(+), 30 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 382769ba..dd7ee89a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,7 +29,6 @@ xo_add_genfacet( INPUT idl/SymbolTable.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # ---------------------------------------------------------------- @@ -43,7 +42,6 @@ xo_add_genfacetimpl( INPUT idl/ISymbolTable_DLocalSymtab.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -55,7 +53,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DLocalSymtab.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -67,7 +64,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DLocalSymtab.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab - OUTPUT_CPP_DIR src/expression2 ) # ---------------------------------------------------------------- @@ -79,7 +75,6 @@ xo_add_genfacet( INPUT idl/Expression.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # ---------------------------------------------------------------- @@ -93,7 +88,6 @@ xo_add_genfacetimpl( INPUT idl/IExpression_DConstant.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -105,7 +99,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DConstant.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -117,7 +110,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DConstant.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # ---------------------------------------------------------------- @@ -131,7 +123,6 @@ xo_add_genfacetimpl( INPUT idl/IExpression_DVariable.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -143,7 +134,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DVariable.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -155,7 +145,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DVariable.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # ---------------------------------------------------------------- @@ -169,7 +158,6 @@ xo_add_genfacetimpl( INPUT idl/IExpression_DVarRef.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -181,7 +169,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DVarRef.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -193,7 +180,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DVarRef.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # ---------------------------------------------------------------- @@ -207,7 +193,6 @@ xo_add_genfacetimpl( INPUT idl/IExpression_DDefineExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -219,7 +204,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DDefineExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # ---------------------------------------------------------------- @@ -233,7 +217,6 @@ xo_add_genfacetimpl( INPUT idl/IExpression_DApplyExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -245,7 +228,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DApplyExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -257,7 +239,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DApplyExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # ---------------------------------------------------------------- @@ -271,7 +252,6 @@ xo_add_genfacetimpl( INPUT idl/IExpression_DLambdaExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -283,7 +263,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DLambdaExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -295,7 +274,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DLambdaExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # ---------------------------------------------------------------- @@ -309,7 +287,6 @@ xo_add_genfacetimpl( INPUT idl/IExpression_DIfElseExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -321,7 +298,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DIfElseExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -333,7 +309,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DIfElseExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # ---------------------------------------------------------------- @@ -347,7 +322,6 @@ xo_add_genfacetimpl( INPUT idl/IExpression_DSequenceExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -359,7 +333,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DSequenceExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -371,7 +344,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DSequenceExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # ---------------------------------------------------------------- @@ -385,7 +357,6 @@ xo_add_genfacetimpl( INPUT idl/IGCObject_DUniqueString.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # note: manual target; generated code committed to git @@ -397,7 +368,6 @@ xo_add_genfacetimpl( INPUT idl/IPrintable_DUniqueString.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail - OUTPUT_CPP_DIR src/expression2 ) # ---------------------------------------------------------------- diff --git a/idl/Expression.json5 b/idl/Expression.json5 index 83ae1402..5391e89a 100644 --- a/idl/Expression.json5 +++ b/idl/Expression.json5 @@ -1,5 +1,6 @@ { mode: "facet", + output_cpp_dir: "src/expression2", includes: [ "\"TypeRef.hpp\"", "\"exprtype.hpp\"", ""], diff --git a/idl/IExpression_DApplyExpr.json5 b/idl/IExpression_DApplyExpr.json5 index 6814547c..353a7147 100644 --- a/idl/IExpression_DApplyExpr.json5 +++ b/idl/IExpression_DApplyExpr.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IExpression_DConstant.json5 b/idl/IExpression_DConstant.json5 index d7628f81..3e491f2b 100644 --- a/idl/IExpression_DConstant.json5 +++ b/idl/IExpression_DConstant.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IExpression_DDefineExpr.json5 b/idl/IExpression_DDefineExpr.json5 index ff35d6d6..28940c7b 100644 --- a/idl/IExpression_DDefineExpr.json5 +++ b/idl/IExpression_DDefineExpr.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IExpression_DIfElseExpr.json5 b/idl/IExpression_DIfElseExpr.json5 index ed2fb1e8..39c6cd70 100644 --- a/idl/IExpression_DIfElseExpr.json5 +++ b/idl/IExpression_DIfElseExpr.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IExpression_DLambdaExpr.json5 b/idl/IExpression_DLambdaExpr.json5 index ef1b6704..675d6d9f 100644 --- a/idl/IExpression_DLambdaExpr.json5 +++ b/idl/IExpression_DLambdaExpr.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IExpression_DSequenceExpr.json5 b/idl/IExpression_DSequenceExpr.json5 index 451d39f1..5c5f1b9a 100644 --- a/idl/IExpression_DSequenceExpr.json5 +++ b/idl/IExpression_DSequenceExpr.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IExpression_DVarRef.json5 b/idl/IExpression_DVarRef.json5 index 8dea30e5..89ee50d8 100644 --- a/idl/IExpression_DVarRef.json5 +++ b/idl/IExpression_DVarRef.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IExpression_DVariable.json5 b/idl/IExpression_DVariable.json5 index 6e7993d3..f22f7d4b 100644 --- a/idl/IExpression_DVariable.json5 +++ b/idl/IExpression_DVariable.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IGCObject_DApplyExpr.json5 b/idl/IGCObject_DApplyExpr.json5 index 4bf4304b..9946116a 100644 --- a/idl/IGCObject_DApplyExpr.json5 +++ b/idl/IGCObject_DApplyExpr.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" diff --git a/idl/IGCObject_DConstant.json5 b/idl/IGCObject_DConstant.json5 index f67c5b52..1c97456e 100644 --- a/idl/IGCObject_DConstant.json5 +++ b/idl/IGCObject_DConstant.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" diff --git a/idl/IGCObject_DIfElseExpr.json5 b/idl/IGCObject_DIfElseExpr.json5 index 1c5d0661..751c0b9f 100644 --- a/idl/IGCObject_DIfElseExpr.json5 +++ b/idl/IGCObject_DIfElseExpr.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" diff --git a/idl/IGCObject_DLambdaExpr.json5 b/idl/IGCObject_DLambdaExpr.json5 index b35ad45e..506feb48 100644 --- a/idl/IGCObject_DLambdaExpr.json5 +++ b/idl/IGCObject_DLambdaExpr.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" diff --git a/idl/IGCObject_DLocalSymtab.json5 b/idl/IGCObject_DLocalSymtab.json5 index 03705f5e..ca815ee0 100644 --- a/idl/IGCObject_DLocalSymtab.json5 +++ b/idl/IGCObject_DLocalSymtab.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" diff --git a/idl/IGCObject_DSequenceExpr.json5 b/idl/IGCObject_DSequenceExpr.json5 index d3bf4aef..c3bd7458 100644 --- a/idl/IGCObject_DSequenceExpr.json5 +++ b/idl/IGCObject_DSequenceExpr.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" diff --git a/idl/IGCObject_DUniqueString.json5 b/idl/IGCObject_DUniqueString.json5 index 8cf516b2..cb16d6a2 100644 --- a/idl/IGCObject_DUniqueString.json5 +++ b/idl/IGCObject_DUniqueString.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" diff --git a/idl/IGCObject_DVarRef.json5 b/idl/IGCObject_DVarRef.json5 index 3101a035..1a46f47e 100644 --- a/idl/IGCObject_DVarRef.json5 +++ b/idl/IGCObject_DVarRef.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" diff --git a/idl/IGCObject_DVariable.json5 b/idl/IGCObject_DVariable.json5 index 7327507f..84a47d01 100644 --- a/idl/IGCObject_DVariable.json5 +++ b/idl/IGCObject_DVariable.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" diff --git a/idl/IPrintable_DApplyExpr.json5 b/idl/IPrintable_DApplyExpr.json5 index fe743b0b..88a3fef7 100644 --- a/idl/IPrintable_DApplyExpr.json5 +++ b/idl/IPrintable_DApplyExpr.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DConstant.json5 b/idl/IPrintable_DConstant.json5 index 1d955d79..9e4e1ad0 100644 --- a/idl/IPrintable_DConstant.json5 +++ b/idl/IPrintable_DConstant.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DDefineExpr.json5 b/idl/IPrintable_DDefineExpr.json5 index 351f8caf..89c2fdff 100644 --- a/idl/IPrintable_DDefineExpr.json5 +++ b/idl/IPrintable_DDefineExpr.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DIfElseExpr.json5 b/idl/IPrintable_DIfElseExpr.json5 index a8011385..90f02307 100644 --- a/idl/IPrintable_DIfElseExpr.json5 +++ b/idl/IPrintable_DIfElseExpr.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DLambdaExpr.json5 b/idl/IPrintable_DLambdaExpr.json5 index 02a09424..60e0397e 100644 --- a/idl/IPrintable_DLambdaExpr.json5 +++ b/idl/IPrintable_DLambdaExpr.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DLocalSymtab.json5 b/idl/IPrintable_DLocalSymtab.json5 index 3f17e64e..5d48e5f4 100644 --- a/idl/IPrintable_DLocalSymtab.json5 +++ b/idl/IPrintable_DLocalSymtab.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DSequenceExpr.json5 b/idl/IPrintable_DSequenceExpr.json5 index 34154a1e..1b45094f 100644 --- a/idl/IPrintable_DSequenceExpr.json5 +++ b/idl/IPrintable_DSequenceExpr.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DUniqueString.json5 b/idl/IPrintable_DUniqueString.json5 index 540f7b71..d640ce9c 100644 --- a/idl/IPrintable_DUniqueString.json5 +++ b/idl/IPrintable_DUniqueString.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVarRef.json5 b/idl/IPrintable_DVarRef.json5 index d525886c..0d73c1d9 100644 --- a/idl/IPrintable_DVarRef.json5 +++ b/idl/IPrintable_DVarRef.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVariable.json5 b/idl/IPrintable_DVariable.json5 index 52c301b2..8e88cde0 100644 --- a/idl/IPrintable_DVariable.json5 +++ b/idl/IPrintable_DVariable.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ "", "" ], local_types: [ ], diff --git a/idl/ISymbolTable_DLocalSymtab.json5 b/idl/ISymbolTable_DLocalSymtab.json5 index 026c0ed1..ff46c622 100644 --- a/idl/ISymbolTable_DLocalSymtab.json5 +++ b/idl/ISymbolTable_DLocalSymtab.json5 @@ -1,5 +1,6 @@ { mode: "implementation", + output_cpp_dir: "src/expression2", includes: [ ], local_types: [ ], namespace1: "xo", diff --git a/idl/SymbolTable.json5 b/idl/SymbolTable.json5 index 4d7dc2a4..9cd6e45b 100644 --- a/idl/SymbolTable.json5 +++ b/idl/SymbolTable.json5 @@ -1,5 +1,6 @@ { mode: "facet", + output_cpp_dir: "src/expression2", includes: [ "\"Binding.hpp\"", "\"DUniqueString.hpp\"" From 06521e5e79bf09b2e566f764e89fd7621d4573f1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 18:21:03 -0500 Subject: [PATCH 084/128] xo-expression2: + DGlobalSymtab facet support gen + files --- CMakeLists.txt | 35 ++++++++++ idl/IGCObject_DGlobalSymtab.json5 | 16 +++++ idl/IPrintable_DGlobalSymtab.json5 | 14 ++++ idl/ISymbolTable_DGlobalSymtab.json5 | 13 ++++ include/xo/expression2/DGlobalSymtab.hpp | 8 +++ include/xo/expression2/GlobalSymtab.hpp | 6 +- .../symtab/IGCObject_DGlobalSymtab.hpp | 67 +++++++++++++++++++ .../symtab/IPrintable_DGlobalSymtab.hpp | 62 +++++++++++++++++ .../symtab/ISymbolTable_DGlobalSymtab.hpp | 60 +++++++++++++++++ src/expression2/CMakeLists.txt | 3 + src/expression2/DGlobalSymtab.cpp | 12 ++++ src/expression2/IGCObject_DGlobalSymtab.cpp | 39 +++++++++++ src/expression2/IPrintable_DGlobalSymtab.cpp | 28 ++++++++ .../ISymbolTable_DGlobalSymtab.cpp | 34 ++++++++++ .../expression2_register_facets.cpp | 8 ++- 15 files changed, 400 insertions(+), 5 deletions(-) create mode 100644 idl/IGCObject_DGlobalSymtab.json5 create mode 100644 idl/IPrintable_DGlobalSymtab.json5 create mode 100644 idl/ISymbolTable_DGlobalSymtab.json5 create mode 100644 include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp create mode 100644 include/xo/expression2/symtab/IPrintable_DGlobalSymtab.hpp create mode 100644 include/xo/expression2/symtab/ISymbolTable_DGlobalSymtab.hpp create mode 100644 src/expression2/IGCObject_DGlobalSymtab.cpp create mode 100644 src/expression2/IPrintable_DGlobalSymtab.cpp create mode 100644 src/expression2/ISymbolTable_DGlobalSymtab.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index dd7ee89a..1b84df8d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,6 +68,41 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-symboltable-globalsymtab + FACET_PKG xo_expression2 + FACET SymbolTable + REPR GlobalSymtab + INPUT idl/ISymbolTable_DGlobalSymtab.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR symtab +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-globalsymtab + FACET_PKG xo_gc + FACET GCObject + REPR GlobalSymtab + INPUT idl/IGCObject_DGlobalSymtab.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR symtab +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-globalsymtab + FACET_PKG xo_printable2 + FACET Printable + REPR GlobalSymtab + INPUT idl/IPrintable_DGlobalSymtab.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR symtab +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacet( TARGET xo-expression2-facet-expression diff --git a/idl/IGCObject_DGlobalSymtab.json5 b/idl/IGCObject_DGlobalSymtab.json5 new file mode 100644 index 00000000..dac8ebac --- /dev/null +++ b/idl/IGCObject_DGlobalSymtab.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DGlobalSymtab", + using_doxygen: true, + repr: "DGlobalSymtab", + doc: [ "implement AGCObject for DGlobalSymtab" ], +} diff --git a/idl/IPrintable_DGlobalSymtab.json5 b/idl/IPrintable_DGlobalSymtab.json5 new file mode 100644 index 00000000..151f8a90 --- /dev/null +++ b/idl/IPrintable_DGlobalSymtab.json5 @@ -0,0 +1,14 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DGlobalSymtab", + using_doxygen: true, + repr: "DGlobalSymtab", + doc: [ "implement APrintable for DGlobalSymtab" ], +} diff --git a/idl/ISymbolTable_DGlobalSymtab.json5 b/idl/ISymbolTable_DGlobalSymtab.json5 new file mode 100644 index 00000000..8cc1035b --- /dev/null +++ b/idl/ISymbolTable_DGlobalSymtab.json5 @@ -0,0 +1,13 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + includes: [ ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/SymbolTable.json5", + brief: "provide ASymbolTable interface for DGlobalSymtab", + using_doxygen: true, + repr: "DGlobalSymtab", + doc: [ "implement ASymbolTable for DGlobalSymtab" ], +} diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index 879c7073..6ae8895b 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -31,6 +31,7 @@ namespace xo { using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; + using ppindentinfo = xo::print::ppindentinfo; public: /** @defgroup scm-globalsymtab-ctors constructors **/ @@ -91,6 +92,13 @@ namespace xo { std::size_t forward_children(obj gc) noexcept; ///@} + /** @defgroup scm-globalsymtab-printable-facet printable facet **/ + ///@{ + + /** pretty-printing support **/ + bool pretty(const ppindentinfo & ppii) const; + + ///@} private: /** map symbols -> bindings. diff --git a/include/xo/expression2/GlobalSymtab.hpp b/include/xo/expression2/GlobalSymtab.hpp index 0c0dabf4..05ad9f4b 100644 --- a/include/xo/expression2/GlobalSymtab.hpp +++ b/include/xo/expression2/GlobalSymtab.hpp @@ -6,8 +6,8 @@ #pragma once #include "DGlobalSymtab.hpp" -//#include "symtab/ISymbolTable_DGlobalSymtab.hpp" -//#include "symtab/IGCObject_DGlobalSymtab.hpp" -//#include "symtab/IPrintable_DGlobalSymtab.hpp" +#include "symtab/ISymbolTable_DGlobalSymtab.hpp" +#include "symtab/IGCObject_DGlobalSymtab.hpp" +#include "symtab/IPrintable_DGlobalSymtab.hpp" /* end GlobalSymtab.hpp */ diff --git a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp new file mode 100644 index 00000000..92149015 --- /dev/null +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DGlobalSymtab.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DGlobalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DGlobalSymtab.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DGlobalSymtab.hpp" + +namespace xo { namespace scm { class IGCObject_DGlobalSymtab; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DGlobalSymtab + **/ + class IGCObject_DGlobalSymtab { + public: + /** @defgroup scm-gcobject-dglobalsymtab-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dglobalsymtab-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DGlobalSymtab & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DGlobalSymtab & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DGlobalSymtab & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/symtab/IPrintable_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IPrintable_DGlobalSymtab.hpp new file mode 100644 index 00000000..3e6d065c --- /dev/null +++ b/include/xo/expression2/symtab/IPrintable_DGlobalSymtab.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DGlobalSymtab.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DGlobalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DGlobalSymtab.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DGlobalSymtab.hpp" + +namespace xo { namespace scm { class IPrintable_DGlobalSymtab; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DGlobalSymtab + **/ + class IPrintable_DGlobalSymtab { + public: + /** @defgroup scm-printable-dglobalsymtab-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dglobalsymtab-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DGlobalSymtab & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/symtab/ISymbolTable_DGlobalSymtab.hpp b/include/xo/expression2/symtab/ISymbolTable_DGlobalSymtab.hpp new file mode 100644 index 00000000..64f90528 --- /dev/null +++ b/include/xo/expression2/symtab/ISymbolTable_DGlobalSymtab.hpp @@ -0,0 +1,60 @@ +/** @file ISymbolTable_DGlobalSymtab.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/ISymbolTable_DGlobalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/ISymbolTable_DGlobalSymtab.json5] + **/ + +#pragma once + +#include "SymbolTable.hpp" +#include "DGlobalSymtab.hpp" + +namespace xo { namespace scm { class ISymbolTable_DGlobalSymtab; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::scm::ISymbolTable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class ISymbolTable_DGlobalSymtab + **/ + class ISymbolTable_DGlobalSymtab { + public: + /** @defgroup scm-symboltable-dglobalsymtab-type-traits **/ + ///@{ + using Copaque = xo::scm::ASymbolTable::Copaque; + using Opaque = xo::scm::ASymbolTable::Opaque; + ///@} + /** @defgroup scm-symboltable-dglobalsymtab-methods **/ + ///@{ + // const methods + /** true iff this is toplevel (global) symbol table. **/ + static bool is_global_symtab(const DGlobalSymtab & self) noexcept; + /** report ingredients needed to address variable at runtime. **/ + static Binding lookup_binding(const DGlobalSymtab & self, const DUniqueString * sym) noexcept; + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 749910e4..8aafa01a 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -58,6 +58,9 @@ set(SELF_SRCS IPrintable_DLocalSymtab.cpp DGlobalSymtab.cpp + ISymbolTable_DGlobalSymtab.cpp + IGCObject_DGlobalSymtab.cpp + IPrintable_DGlobalSymtab.cpp StringTable.cpp diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index c9897670..70b953dd 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -168,6 +168,18 @@ namespace xo { return this->shallow_size(); } + // ----- printable facet ----- + + bool + DGlobalSymtab::pretty(const ppindentinfo & ppii) const + { + return ppii.pps()->pretty_struct + (ppii, + "DGlobalSymtab", + refrtag("nsym", vars_->size()), + refrtag("capacity", vars_->capacity())); + } + } /*namespace scm*/ } /*namespace xo*/ diff --git a/src/expression2/IGCObject_DGlobalSymtab.cpp b/src/expression2/IGCObject_DGlobalSymtab.cpp new file mode 100644 index 00000000..d59e6bbf --- /dev/null +++ b/src/expression2/IGCObject_DGlobalSymtab.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DGlobalSymtab.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DGlobalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DGlobalSymtab.json5] +**/ + +#include "symtab/IGCObject_DGlobalSymtab.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DGlobalSymtab::shallow_size(const DGlobalSymtab & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DGlobalSymtab::shallow_copy(const DGlobalSymtab & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DGlobalSymtab::forward_children(DGlobalSymtab & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DGlobalSymtab.cpp */ diff --git a/src/expression2/IPrintable_DGlobalSymtab.cpp b/src/expression2/IPrintable_DGlobalSymtab.cpp new file mode 100644 index 00000000..35ecf6e7 --- /dev/null +++ b/src/expression2/IPrintable_DGlobalSymtab.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DGlobalSymtab.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DGlobalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DGlobalSymtab.json5] +**/ + +#include "symtab/IPrintable_DGlobalSymtab.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DGlobalSymtab::pretty(const DGlobalSymtab & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DGlobalSymtab.cpp */ diff --git a/src/expression2/ISymbolTable_DGlobalSymtab.cpp b/src/expression2/ISymbolTable_DGlobalSymtab.cpp new file mode 100644 index 00000000..b735a6fb --- /dev/null +++ b/src/expression2/ISymbolTable_DGlobalSymtab.cpp @@ -0,0 +1,34 @@ +/** @file ISymbolTable_DGlobalSymtab.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/ISymbolTable_DGlobalSymtab.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/ISymbolTable_DGlobalSymtab.json5] +**/ + +#include "symtab/ISymbolTable_DGlobalSymtab.hpp" + +namespace xo { + namespace scm { + auto + ISymbolTable_DGlobalSymtab::is_global_symtab(const DGlobalSymtab & self) noexcept -> bool + { + return self.is_global_symtab(); + } + + auto + ISymbolTable_DGlobalSymtab::lookup_binding(const DGlobalSymtab & self, const DUniqueString * sym) noexcept -> Binding + { + return self.lookup_binding(sym); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end ISymbolTable_DGlobalSymtab.cpp */ diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index a3a4b520..c563c9da 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -6,8 +6,8 @@ #include "expression2_register_facets.hpp" #include -#include -#include +//#include +//#include #include //#include @@ -101,6 +101,10 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + // until we register facets TypeRegistry::register_type(); From 03847102befed6e0319ca53bb7a334ce394b0679 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 19:48:14 -0500 Subject: [PATCH 085/128] xo-expression2: upsert global vars works in DDefineSsm --- include/xo/expression2/DGlobalSymtab.hpp | 11 ++- include/xo/expression2/DVariable.hpp | 1 + src/expression2/DGlobalSymtab.cpp | 94 +++++++++++++++--------- 3 files changed, 67 insertions(+), 39 deletions(-) diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index 6ae8895b..63a2a91f 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -65,13 +65,12 @@ namespace xo { /** @defgroup scm-globalsymtab-general-methods general methods **/ ///@{ - /** establish binding for @p sym, with type described by @p typeref, - * replacing existing global (if present) with the same name. - * Use memory from @p mm to create variable-expr + /** update this symtab to associate @p var with @c var->name(). + * If there was a previous variable with the same name, + * replace it with @p var. **/ - DVariable * establish_variable(obj mm, - const DUniqueString * sym, - TypeRef typeref); + void upsert_variable(obj mm, + DVariable * var); ///@} /** @defgroup scm-globalsymtab-symboltable-facet symboltable facet **/ diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp index 3c89cc58..29253097 100644 --- a/include/xo/expression2/DVariable.hpp +++ b/include/xo/expression2/DVariable.hpp @@ -48,6 +48,7 @@ namespace xo { Binding path() const { return path_; } void assign_name(const DUniqueString * name) { this->name_ = name; } + void assign_path(Binding b) { this->path_ = b; } /** @defgroup scm-variable-expression-facet **/ ///@{ diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index 70b953dd..89d10f32 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -65,6 +65,65 @@ namespace xo { return var.data(); } + void + DGlobalSymtab::upsert_variable(obj mm, + DVariable * var) + { + // It's possible there's already a global variable + // with the same name. + // + // For example redefining a variable in an interactive session. + // In this case use the established binding. + // + DVariable * existing = this->lookup_variable(var->name()); + + if (existing) { + if (existing == var) { + // impossible, but.. noop, right? + return; + } + + // adopt the existing binding + var->assign_path(existing->path()); + + // stash new definition (possibly has different type), + // replacing previous one + // + (*vars_)[existing->path().j_slot()] = obj(var); + } else { + DArray::size_type n = vars_->size(); + + // NOTE: expansion of var_ array here is moot at present (Feb 2026), + // since the feature isn't yet implemented in ArenaHashMap + + /** make sure vars_ has room **/ + if (n == vars_->capacity()) { + // DArray is out of room. Reallocate with more capacity + DArray * vars_2x = DArray::copy(mm, vars_, vars_->capacity() * 2); + + if (!vars_2x) { + assert(false); + + // in any case, we can't make progress + return; + } + + this->vars_ = vars_2x; + } + + /** now we know binding for var **/ + Binding binding = Binding::global(n); + + var->assign_path(binding); + + // need slot# in .map_ for this unique symbol + (*map_)[var->name()] = binding.j_slot(); + + vars_->push_back(obj(var)); + } + } + +#ifdef NOT_USING // don't know if we need this path DVariable * DGlobalSymtab::establish_variable(obj mm, const DUniqueString * sym, @@ -75,43 +134,12 @@ namespace xo { if (!var) { assert(vars_); - DArray::size_type n = vars_->size(); - - // NOTE: expansion here is moot at present (Feb 2026). - // Not implemented in ArenaHashMap - - /** make sure vars_ has room **/ - if (n == vars_->capacity()) { - // reallocate with more capacity - DArray * vars_2x = DArray::copy(mm, vars_, vars_->capacity() * 2); - - assert(vars_2x); - - this->vars_ = vars_2x; - } - - /** create new variable **/ - Binding binding = Binding::global(n); - var = DVariable::make(mm, sym, typeref, binding); - - if (!var) { - // something terribly wrong - assert(false); - return var; - } - - assert(map_->size() < map_->capacity()); - - (*map_)[sym] = binding.j_slot(); - - bool ok = vars_->push_back(obj(var)); - - if (!ok) - assert(false); + xxx; } return var; } +#endif Binding DGlobalSymtab::lookup_binding(const DUniqueString * sym) const noexcept From 058d518e8b016024810ce1774a37d661509cea33 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 22:33:32 -0500 Subject: [PATCH 086/128] xo-facet: move output-hpp-dir + subdir to idl/*.json5 --- idl/Expression.json5 | 2 ++ idl/IExpression_DApplyExpr.json5 | 2 ++ idl/IExpression_DConstant.json5 | 2 ++ idl/IExpression_DDefineExpr.json5 | 2 ++ idl/IExpression_DIfElseExpr.json5 | 2 ++ idl/IExpression_DLambdaExpr.json5 | 2 ++ idl/IExpression_DSequenceExpr.json5 | 2 ++ idl/IExpression_DVarRef.json5 | 2 ++ idl/IExpression_DVariable.json5 | 2 ++ idl/IGCObject_DApplyExpr.json5 | 2 ++ idl/IGCObject_DConstant.json5 | 2 ++ idl/IGCObject_DGlobalSymtab.json5 | 2 ++ idl/IGCObject_DIfElseExpr.json5 | 2 ++ idl/IGCObject_DLambdaExpr.json5 | 2 ++ idl/IGCObject_DLocalSymtab.json5 | 2 ++ idl/IGCObject_DSequenceExpr.json5 | 2 ++ idl/IGCObject_DUniqueString.json5 | 2 ++ idl/IGCObject_DVarRef.json5 | 2 ++ idl/IGCObject_DVariable.json5 | 2 ++ idl/IPrintable_DApplyExpr.json5 | 2 ++ idl/IPrintable_DConstant.json5 | 2 ++ idl/IPrintable_DDefineExpr.json5 | 2 ++ idl/IPrintable_DGlobalSymtab.json5 | 2 ++ idl/IPrintable_DIfElseExpr.json5 | 2 ++ idl/IPrintable_DLambdaExpr.json5 | 2 ++ idl/IPrintable_DLocalSymtab.json5 | 2 ++ idl/IPrintable_DSequenceExpr.json5 | 2 ++ idl/IPrintable_DUniqueString.json5 | 2 ++ idl/IPrintable_DVarRef.json5 | 2 ++ idl/IPrintable_DVariable.json5 | 2 ++ idl/ISymbolTable_DGlobalSymtab.json5 | 2 ++ idl/ISymbolTable_DLocalSymtab.json5 | 2 ++ idl/SymbolTable.json5 | 2 ++ 33 files changed, 66 insertions(+) diff --git a/idl/Expression.json5 b/idl/Expression.json5 index 5391e89a..66c60def 100644 --- a/idl/Expression.json5 +++ b/idl/Expression.json5 @@ -1,6 +1,8 @@ { mode: "facet", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "\"TypeRef.hpp\"", "\"exprtype.hpp\"", ""], diff --git a/idl/IExpression_DApplyExpr.json5 b/idl/IExpression_DApplyExpr.json5 index 353a7147..29762364 100644 --- a/idl/IExpression_DApplyExpr.json5 +++ b/idl/IExpression_DApplyExpr.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IExpression_DConstant.json5 b/idl/IExpression_DConstant.json5 index 3e491f2b..bbbcc402 100644 --- a/idl/IExpression_DConstant.json5 +++ b/idl/IExpression_DConstant.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IExpression_DDefineExpr.json5 b/idl/IExpression_DDefineExpr.json5 index 28940c7b..8fd6149f 100644 --- a/idl/IExpression_DDefineExpr.json5 +++ b/idl/IExpression_DDefineExpr.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IExpression_DIfElseExpr.json5 b/idl/IExpression_DIfElseExpr.json5 index 39c6cd70..431fd60a 100644 --- a/idl/IExpression_DIfElseExpr.json5 +++ b/idl/IExpression_DIfElseExpr.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IExpression_DLambdaExpr.json5 b/idl/IExpression_DLambdaExpr.json5 index 675d6d9f..36aa9bb4 100644 --- a/idl/IExpression_DLambdaExpr.json5 +++ b/idl/IExpression_DLambdaExpr.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IExpression_DSequenceExpr.json5 b/idl/IExpression_DSequenceExpr.json5 index 5c5f1b9a..71b13aba 100644 --- a/idl/IExpression_DSequenceExpr.json5 +++ b/idl/IExpression_DSequenceExpr.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IExpression_DVarRef.json5 b/idl/IExpression_DVarRef.json5 index 89ee50d8..7b50c7fb 100644 --- a/idl/IExpression_DVarRef.json5 +++ b/idl/IExpression_DVarRef.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IExpression_DVariable.json5 b/idl/IExpression_DVariable.json5 index f22f7d4b..c68a9609 100644 --- a/idl/IExpression_DVariable.json5 +++ b/idl/IExpression_DVariable.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IGCObject_DApplyExpr.json5 b/idl/IGCObject_DApplyExpr.json5 index 9946116a..60f997c8 100644 --- a/idl/IGCObject_DApplyExpr.json5 +++ b/idl/IGCObject_DApplyExpr.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" diff --git a/idl/IGCObject_DConstant.json5 b/idl/IGCObject_DConstant.json5 index 1c97456e..961f39bb 100644 --- a/idl/IGCObject_DConstant.json5 +++ b/idl/IGCObject_DConstant.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" diff --git a/idl/IGCObject_DGlobalSymtab.json5 b/idl/IGCObject_DGlobalSymtab.json5 index dac8ebac..ac779ec2 100644 --- a/idl/IGCObject_DGlobalSymtab.json5 +++ b/idl/IGCObject_DGlobalSymtab.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "symtab", includes: [ "", "" diff --git a/idl/IGCObject_DIfElseExpr.json5 b/idl/IGCObject_DIfElseExpr.json5 index 751c0b9f..6fb8c07a 100644 --- a/idl/IGCObject_DIfElseExpr.json5 +++ b/idl/IGCObject_DIfElseExpr.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" diff --git a/idl/IGCObject_DLambdaExpr.json5 b/idl/IGCObject_DLambdaExpr.json5 index 506feb48..a0f494ff 100644 --- a/idl/IGCObject_DLambdaExpr.json5 +++ b/idl/IGCObject_DLambdaExpr.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" diff --git a/idl/IGCObject_DLocalSymtab.json5 b/idl/IGCObject_DLocalSymtab.json5 index ca815ee0..ec8260a0 100644 --- a/idl/IGCObject_DLocalSymtab.json5 +++ b/idl/IGCObject_DLocalSymtab.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "symtab", includes: [ "", "" diff --git a/idl/IGCObject_DSequenceExpr.json5 b/idl/IGCObject_DSequenceExpr.json5 index c3bd7458..1fc67e48 100644 --- a/idl/IGCObject_DSequenceExpr.json5 +++ b/idl/IGCObject_DSequenceExpr.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" diff --git a/idl/IGCObject_DUniqueString.json5 b/idl/IGCObject_DUniqueString.json5 index cb16d6a2..4f79e9de 100644 --- a/idl/IGCObject_DUniqueString.json5 +++ b/idl/IGCObject_DUniqueString.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" diff --git a/idl/IGCObject_DVarRef.json5 b/idl/IGCObject_DVarRef.json5 index 1a46f47e..6c1bad33 100644 --- a/idl/IGCObject_DVarRef.json5 +++ b/idl/IGCObject_DVarRef.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" diff --git a/idl/IGCObject_DVariable.json5 b/idl/IGCObject_DVariable.json5 index 84a47d01..6bea1dc3 100644 --- a/idl/IGCObject_DVariable.json5 +++ b/idl/IGCObject_DVariable.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" diff --git a/idl/IPrintable_DApplyExpr.json5 b/idl/IPrintable_DApplyExpr.json5 index 88a3fef7..f9d3f17d 100644 --- a/idl/IPrintable_DApplyExpr.json5 +++ b/idl/IPrintable_DApplyExpr.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DConstant.json5 b/idl/IPrintable_DConstant.json5 index 9e4e1ad0..ca9d7948 100644 --- a/idl/IPrintable_DConstant.json5 +++ b/idl/IPrintable_DConstant.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DDefineExpr.json5 b/idl/IPrintable_DDefineExpr.json5 index 89c2fdff..c706817d 100644 --- a/idl/IPrintable_DDefineExpr.json5 +++ b/idl/IPrintable_DDefineExpr.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DGlobalSymtab.json5 b/idl/IPrintable_DGlobalSymtab.json5 index 151f8a90..d0242e8c 100644 --- a/idl/IPrintable_DGlobalSymtab.json5 +++ b/idl/IPrintable_DGlobalSymtab.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "symtab", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DIfElseExpr.json5 b/idl/IPrintable_DIfElseExpr.json5 index 90f02307..208e7b06 100644 --- a/idl/IPrintable_DIfElseExpr.json5 +++ b/idl/IPrintable_DIfElseExpr.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DLambdaExpr.json5 b/idl/IPrintable_DLambdaExpr.json5 index 60e0397e..89b07d1c 100644 --- a/idl/IPrintable_DLambdaExpr.json5 +++ b/idl/IPrintable_DLambdaExpr.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DLocalSymtab.json5 b/idl/IPrintable_DLocalSymtab.json5 index 5d48e5f4..15087c3d 100644 --- a/idl/IPrintable_DLocalSymtab.json5 +++ b/idl/IPrintable_DLocalSymtab.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "symtab", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DSequenceExpr.json5 b/idl/IPrintable_DSequenceExpr.json5 index 1b45094f..0cfe76c9 100644 --- a/idl/IPrintable_DSequenceExpr.json5 +++ b/idl/IPrintable_DSequenceExpr.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DUniqueString.json5 b/idl/IPrintable_DUniqueString.json5 index d640ce9c..ba094879 100644 --- a/idl/IPrintable_DUniqueString.json5 +++ b/idl/IPrintable_DUniqueString.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVarRef.json5 b/idl/IPrintable_DVarRef.json5 index 0d73c1d9..106b41d1 100644 --- a/idl/IPrintable_DVarRef.json5 +++ b/idl/IPrintable_DVarRef.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" ], local_types: [ ], diff --git a/idl/IPrintable_DVariable.json5 b/idl/IPrintable_DVariable.json5 index 8e88cde0..779afd25 100644 --- a/idl/IPrintable_DVariable.json5 +++ b/idl/IPrintable_DVariable.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "detail", includes: [ "", "" ], local_types: [ ], diff --git a/idl/ISymbolTable_DGlobalSymtab.json5 b/idl/ISymbolTable_DGlobalSymtab.json5 index 8cc1035b..ff148a2f 100644 --- a/idl/ISymbolTable_DGlobalSymtab.json5 +++ b/idl/ISymbolTable_DGlobalSymtab.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "symtab", includes: [ ], local_types: [ ], namespace1: "xo", diff --git a/idl/ISymbolTable_DLocalSymtab.json5 b/idl/ISymbolTable_DLocalSymtab.json5 index ff46c622..7cfcd75f 100644 --- a/idl/ISymbolTable_DLocalSymtab.json5 +++ b/idl/ISymbolTable_DLocalSymtab.json5 @@ -1,6 +1,8 @@ { mode: "implementation", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "symtab", includes: [ ], local_types: [ ], namespace1: "xo", diff --git a/idl/SymbolTable.json5 b/idl/SymbolTable.json5 index 9cd6e45b..b299bfe7 100644 --- a/idl/SymbolTable.json5 +++ b/idl/SymbolTable.json5 @@ -1,6 +1,8 @@ { mode: "facet", output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "symtab", includes: [ "\"Binding.hpp\"", "\"DUniqueString.hpp\"" From ef7fc21287df316bb462d4dbbbbbb0736a03bd02 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Feb 2026 23:25:34 -0500 Subject: [PATCH 087/128] xo-reader2: utest with variable reference. Works ! --- src/expression2/Binding.cpp | 2 +- src/expression2/DGlobalSymtab.cpp | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/expression2/Binding.cpp b/src/expression2/Binding.cpp index 6802ba69..94be9b6b 100644 --- a/src/expression2/Binding.cpp +++ b/src/expression2/Binding.cpp @@ -27,7 +27,7 @@ namespace xo { Binding::print(std::ostream & os) const { if (i_link_ == c_link_global) { - os << "{path:global}"; + os << "{path:global:" << j_slot_ << "}"; } else if (i_link_ == c_link_sentinel) { os << "{path}"; } else { diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index 89d10f32..38809a38 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -69,6 +69,8 @@ namespace xo { DGlobalSymtab::upsert_variable(obj mm, DVariable * var) { + scope log(XO_DEBUG(true), std::string_view(*var->name())); + // It's possible there's already a global variable // with the same name. // @@ -78,6 +80,8 @@ namespace xo { DVariable * existing = this->lookup_variable(var->name()); if (existing) { + log && log("variable with this symbol already exists"); + if (existing == var) { // impossible, but.. noop, right? return; @@ -91,6 +95,8 @@ namespace xo { // (*vars_)[existing->path().j_slot()] = obj(var); } else { + log && log("variable is new"); + DArray::size_type n = vars_->size(); // NOTE: expansion of var_ array here is moot at present (Feb 2026), @@ -146,8 +152,7 @@ namespace xo { { assert(sym); - scope log(XO_DEBUG(true), "stub"); - log && log(xtag("sym", std::string_view(*sym))); + scope log(XO_DEBUG(true), std::string_view(*sym)); auto ix = map_->find(sym); From f777aeade0e9102db936c31723877a9f89ebeb52 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 17 Feb 2026 14:42:17 -0500 Subject: [PATCH 088/128] xo-interpreter2 stack: define-expr's work at top-level --- CMakeLists.txt | 11 +++ idl/IGCObject_DDefineExpr.json5 | 18 +++++ include/xo/expression2/DDefineExpr.hpp | 11 ++- include/xo/expression2/DGlobalSymtab.hpp | 4 ++ include/xo/expression2/DefineExpr.hpp | 2 +- .../define/IGCObject_DDefineExpr.hpp | 67 +++++++++++++++++++ src/expression2/CMakeLists.txt | 3 +- src/expression2/DDefineExpr.cpp | 32 ++++++++- src/expression2/IGCObject_DDefineExpr.cpp | 39 +++++++++++ .../expression2_register_facets.cpp | 9 +-- 10 files changed, 184 insertions(+), 12 deletions(-) create mode 100644 idl/IGCObject_DDefineExpr.json5 create mode 100644 include/xo/expression2/define/IGCObject_DDefineExpr.hpp create mode 100644 src/expression2/IGCObject_DDefineExpr.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 1b84df8d..c9180ad8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -230,6 +230,17 @@ xo_add_genfacetimpl( OUTPUT_IMPL_SUBDIR detail ) +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-defineexpr + FACET_PKG xo_gc + FACET GCObject + REPR DefineExpr + INPUT idl/IGCObject_DDefineExpr.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR define +) + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-defineexpr diff --git a/idl/IGCObject_DDefineExpr.json5 b/idl/IGCObject_DDefineExpr.json5 new file mode 100644 index 00000000..6b0eba68 --- /dev/null +++ b/idl/IGCObject_DDefineExpr.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "define", + includes: [ + "", + "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DDefineExpr", + using_doxygen: true, + repr: "DDefineExpr", + doc: [ "implement AGCObject for DDefineExpr" ], +} diff --git a/include/xo/expression2/DDefineExpr.hpp b/include/xo/expression2/DDefineExpr.hpp index 6b7716e3..6ad8494f 100644 --- a/include/xo/expression2/DDefineExpr.hpp +++ b/include/xo/expression2/DDefineExpr.hpp @@ -1,5 +1,5 @@ /** @file DDefineExpr.hpp -* + * * @author Roland Conybeare, Jan 2026 **/ @@ -23,6 +23,7 @@ namespace xo { class DDefineExpr { public: using ppindentinfo = xo::print::ppindentinfo; + using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -67,6 +68,14 @@ namespace xo { TypeDescr valuetype() const noexcept { return lhs_var_->typeref().td(); } void assign_valuetype(TypeDescr td) noexcept; + ///@} + /** @defgroup scm-defineexpr-gcobject-facet **/ + ///@{ + + std::size_t shallow_size() const noexcept; + DDefineExpr * shallow_copy(obj mm) const noexcept; + std::size_t forward_children(obj gc) noexcept; + ///@} /** @defgroup scm-defineexpr-printable-facet **/ ///@{ diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index 63a2a91f..5cd03fb2 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -32,6 +32,7 @@ namespace xo { using AAllocator = xo::mm::AAllocator; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; using ppindentinfo = xo::print::ppindentinfo; + using size_type = std::uint32_t; public: /** @defgroup scm-globalsymtab-ctors constructors **/ @@ -55,6 +56,9 @@ namespace xo { /** @defgroup scm-globalsymtab-access-methods access methods **/ ///@{ + size_type size() const noexcept { return map_->size(); } + size_type capacity() const noexcept { return map_->capacity(); } + /** visit symtab-owned memory pools; call visitor(info) for each **/ void visit_pools(const MemorySizeVisitor & visitor) const; diff --git a/include/xo/expression2/DefineExpr.hpp b/include/xo/expression2/DefineExpr.hpp index 37a77c03..4a0c42c2 100644 --- a/include/xo/expression2/DefineExpr.hpp +++ b/include/xo/expression2/DefineExpr.hpp @@ -7,7 +7,7 @@ #include "DDefineExpr.hpp" #include "detail/IExpression_DDefineExpr.hpp" -//#include "detail/IGCObject_DDefineExpr.hpp" +#include "define/IGCObject_DDefineExpr.hpp" #include "detail/IPrintable_DDefineExpr.hpp" /* end DefineExpr.hpp */ diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp new file mode 100644 index 00000000..216dd18b --- /dev/null +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -0,0 +1,67 @@ +/** @file IGCObject_DDefineExpr.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DDefineExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DDefineExpr.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include +#include +#include "DDefineExpr.hpp" + +namespace xo { namespace scm { class IGCObject_DDefineExpr; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DDefineExpr + **/ + class IGCObject_DDefineExpr { + public: + /** @defgroup scm-gcobject-ddefineexpr-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-ddefineexpr-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DDefineExpr & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DDefineExpr & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DDefineExpr & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 8aafa01a..f05cf2f1 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -9,7 +9,6 @@ set(SELF_SRCS DConstant.cpp DVariable.cpp DVarRef.cpp - DDefineExpr.cpp DApplyExpr.cpp TypeRef.cpp @@ -30,7 +29,9 @@ set(SELF_SRCS IGCObject_DVarRef.cpp IPrintable_DVarRef.cpp + DDefineExpr.cpp IExpression_DDefineExpr.cpp + IGCObject_DDefineExpr.cpp IPrintable_DDefineExpr.cpp IExpression_DApplyExpr.cpp diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index 961fbecc..aee6ccf9 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -4,13 +4,16 @@ **/ #include "DDefineExpr.hpp" -#include "detail/IPrintable_DVariable.hpp" +#include "Variable.hpp" +#include +#include #include #include #include #include namespace xo { + using xo::mm::poly_forward_inplace; using xo::print::APrintable; using xo::facet::FacetRegistry; using xo::facet::typeseq; @@ -68,10 +71,35 @@ namespace xo { } void - DDefineExpr::assign_rhs(obj x) { + DDefineExpr::assign_rhs(obj x) + { this->rhs_ = x; } + // ----- GCObject facet ----- + + std::size_t + DDefineExpr::shallow_size() const noexcept + { + return sizeof(*this); + } + + DDefineExpr * + DDefineExpr::shallow_copy(obj mm) const noexcept + { + return mm.std_copy_for(this); + } + + std::size_t + DDefineExpr::forward_children(obj gc) noexcept + { + gc.forward_inplace(&lhs_var_); + //gc.forward_inplace(&rhs_); // complicated - need to access via GCObject facet + poly_forward_inplace(gc, &rhs_); + + return this->shallow_size(); + } + bool DDefineExpr::pretty(const ppindentinfo & ppii) const { diff --git a/src/expression2/IGCObject_DDefineExpr.cpp b/src/expression2/IGCObject_DDefineExpr.cpp new file mode 100644 index 00000000..eb43932b --- /dev/null +++ b/src/expression2/IGCObject_DDefineExpr.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DDefineExpr.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DDefineExpr.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DDefineExpr.json5] +**/ + +#include "define/IGCObject_DDefineExpr.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DDefineExpr::shallow_size(const DDefineExpr & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DDefineExpr::shallow_copy(const DDefineExpr & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DDefineExpr::forward_children(DDefineExpr & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DDefineExpr.cpp */ diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index c563c9da..82bff638 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -6,17 +6,12 @@ #include "expression2_register_facets.hpp" #include -//#include -//#include - -#include -//#include -#include #include #include #include +#include #include #include #include @@ -74,7 +69,7 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); - //FacetRegistry::register_impl(); + FacetRegistry::register_impl(); FacetRegistry::register_impl(); FacetRegistry::register_impl(); From 1aa569c159070c04f4f0a792155d823feeefc0ba Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 18 Feb 2026 22:00:30 -0800 Subject: [PATCH 089/128] xo-interpreter2 stack: use xo-numeric/ to support op* --- utest/CMakeLists.txt | 1 + utest/DApplyExpr.test.cpp | 15 +++++++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index deb1d25a..07f10c3b 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -14,4 +14,5 @@ set(UTEST_SRCS xo_add_utest_executable(${UTEST_EXE} ${UTEST_SRCS}) xo_self_dependency(${UTEST_EXE} xo_expression2) +xo_dependency(${UTEST_EXE} xo_numeric) xo_external_target_dependency(${UTEST_EXE} Catch2 Catch2::Catch2) diff --git a/utest/DApplyExpr.test.cpp b/utest/DApplyExpr.test.cpp index f217d47e..1b922333 100644 --- a/utest/DApplyExpr.test.cpp +++ b/utest/DApplyExpr.test.cpp @@ -11,6 +11,8 @@ #include #include +#include + #include #include #include @@ -40,6 +42,7 @@ namespace ut { using xo::scm::DFloat; using xo::scm::AExpression; using xo::scm::TypeRef; + using xo::scm::NumericPrimitives; using xo::scm::Primitives; using xo::scm::DPrimitive_gco_2_gco_gco; using xo::mm::CollectorTypeRegistry; @@ -89,7 +92,7 @@ namespace ut { REQUIRE(ok); // wrap primitive as GCObject, then as expression - obj prim_gco = with_facet::mkobj(&Primitives::s_mul_gco_gco_pm); + obj prim_gco = with_facet::mkobj(&NumericPrimitives::s_mul_gco_gco_pm); obj fn_expr = DConstant::make(alloc, prim_gco); REQUIRE(fn_expr.data() != nullptr); @@ -128,7 +131,7 @@ namespace ut { bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); - obj prim_gco = with_facet::mkobj(&Primitives::s_mul_gco_gco_pm); + obj prim_gco = with_facet::mkobj(&NumericPrimitives::s_mul_gco_gco_pm); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); @@ -163,7 +166,7 @@ namespace ut { bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); - obj prim_gco = with_facet::mkobj(&Primitives::s_mul_gco_gco_pm); + obj prim_gco = with_facet::mkobj(&NumericPrimitives::s_mul_gco_gco_pm); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); @@ -198,7 +201,7 @@ namespace ut { bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); - obj prim_gco = with_facet::mkobj(&Primitives::s_mul_gco_gco_pm); + obj prim_gco = with_facet::mkobj(&NumericPrimitives::s_mul_gco_gco_pm); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); @@ -236,7 +239,7 @@ namespace ut { bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); - obj prim_gco = with_facet::mkobj(&Primitives::s_mul_gco_gco_pm); + obj prim_gco = with_facet::mkobj(&NumericPrimitives::s_mul_gco_gco_pm); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); @@ -280,7 +283,7 @@ namespace ut { bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); - obj prim_gco = with_facet::mkobj(&Primitives::s_mul_gco_gco_pm); + obj prim_gco = with_facet::mkobj(&NumericPrimitives::s_mul_gco_gco_pm); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); From 22af1b3279f26078e8345fe54e1844e11527915b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 27 Feb 2026 19:38:53 +1100 Subject: [PATCH 090/128] xo-cmake: setup to make share target available via cmake install --- cmake/xo_expression2Config.cmake.in | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/xo_expression2Config.cmake.in b/cmake/xo_expression2Config.cmake.in index 15ff18ff..ca2e2ccb 100644 --- a/cmake/xo_expression2Config.cmake.in +++ b/cmake/xo_expression2Config.cmake.in @@ -15,4 +15,5 @@ find_dependency(cmake) find_dependency(indentlog) include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Targets.cmake") +include("${CMAKE_CURRENT_LIST_DIR}/@PROJECT_NAME@Share.cmake") check_required_components("@PROJECT_NAME@") From 6c3514b3928bcbe87de0335ac82ebbdb445d88fb Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 27 Feb 2026 19:41:03 +1100 Subject: [PATCH 091/128] osx build: #include in _Any.cpp --- src/expression2/IExpression_Any.cpp | 1 + src/expression2/ISymbolTable_Any.cpp | 1 + 2 files changed, 2 insertions(+) diff --git a/src/expression2/IExpression_Any.cpp b/src/expression2/IExpression_Any.cpp index 9557e7e7..fe245c76 100644 --- a/src/expression2/IExpression_Any.cpp +++ b/src/expression2/IExpression_Any.cpp @@ -4,6 +4,7 @@ #include "detail/IExpression_Any.hpp" #include +#include namespace xo { namespace scm { diff --git a/src/expression2/ISymbolTable_Any.cpp b/src/expression2/ISymbolTable_Any.cpp index 95718429..31d324de 100644 --- a/src/expression2/ISymbolTable_Any.cpp +++ b/src/expression2/ISymbolTable_Any.cpp @@ -4,6 +4,7 @@ #include "symtab/ISymbolTable_Any.hpp" #include +#include namespace xo { namespace scm { From 041b9dc244292efae2c483fffdbc57c418beb23e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 4 Mar 2026 22:26:31 +1100 Subject: [PATCH 092/128] xo-gc xo-alloc2: move Collector faceet gc/ -> alloc2/ for levelling --- include/xo/expression2/DConstant.hpp | 4 ++-- include/xo/expression2/DIfElseExpr.hpp | 2 +- include/xo/expression2/DUniqueString.hpp | 17 ++--------------- .../define/IGCObject_DDefineExpr.hpp | 4 ++-- .../expression2/detail/IGCObject_DApplyExpr.hpp | 4 ++-- .../expression2/detail/IGCObject_DConstant.hpp | 4 ++-- .../detail/IGCObject_DIfElseExpr.hpp | 4 ++-- .../detail/IGCObject_DLambdaExpr.hpp | 4 ++-- .../detail/IGCObject_DSequenceExpr.hpp | 4 ++-- .../detail/IGCObject_DUniqueString.hpp | 4 ++-- .../xo/expression2/detail/IGCObject_DVarRef.hpp | 4 ++-- .../expression2/detail/IGCObject_DVariable.hpp | 4 ++-- .../expression2/expression2_register_facets.hpp | 2 +- .../expression2/expression2_register_types.hpp | 2 +- .../symtab/IGCObject_DGlobalSymtab.hpp | 4 ++-- .../symtab/IGCObject_DLocalSymtab.hpp | 4 ++-- src/expression2/DDefineExpr.cpp | 2 +- src/expression2/DGlobalSymtab.cpp | 2 +- src/expression2/DIfElseExpr.cpp | 2 +- src/expression2/DSequenceExpr.cpp | 2 +- src/expression2/DUniqueString.cpp | 10 ++++++++++ src/expression2/DVariable.cpp | 2 +- src/expression2/expression2_register_facets.cpp | 2 +- 23 files changed, 45 insertions(+), 48 deletions(-) diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp index 0c57f924..2c8b4a96 100644 --- a/include/xo/expression2/DConstant.hpp +++ b/include/xo/expression2/DConstant.hpp @@ -8,8 +8,8 @@ #include "Expression.hpp" #include "TypeRef.hpp" #include "exprtype.hpp" -#include -#include +#include +#include #include namespace xo { diff --git a/include/xo/expression2/DIfElseExpr.hpp b/include/xo/expression2/DIfElseExpr.hpp index 3b7b07e2..0cf71332 100644 --- a/include/xo/expression2/DIfElseExpr.hpp +++ b/include/xo/expression2/DIfElseExpr.hpp @@ -8,7 +8,7 @@ #include "Expression.hpp" #include "TypeRef.hpp" #include "exprtype.hpp" -#include +#include #include //#include #include diff --git a/include/xo/expression2/DUniqueString.hpp b/include/xo/expression2/DUniqueString.hpp index 30655b45..e43624bd 100644 --- a/include/xo/expression2/DUniqueString.hpp +++ b/include/xo/expression2/DUniqueString.hpp @@ -1,5 +1,5 @@ /** @file DUniqueString.hpp -* + * * @author Roland Conybeare, Jan 2026 **/ @@ -69,12 +69,7 @@ namespace xo { /** compare unique strings: return n with {n<0, n=0, n>0} * when @p lhs lexicographically {before, at, after} @p rhs **/ - static int compare(const DUniqueString & lhs, const DUniqueString & rhs) { - if (&lhs == &rhs) - return 0; - - return DString::compare(*(lhs._text()), *(rhs._text())); - } + static int compare(const DUniqueString & lhs, const DUniqueString & rhs); std::size_t hash() const noexcept { return _text()->hash(); } operator std::string_view() const noexcept { return std::string_view(*_text()); } @@ -124,14 +119,6 @@ namespace xo { ///@} friend class StringTable; - - private: -#ifdef NOPE - /** interned string. Note stringtable memory distinct from gc memory, - * so gc will not (and should not) traverse this pointer. - **/ - const DString * text_ = nullptr; -#endif }; /* since unique: just compare addresses */ diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp index 216dd18b..321ce4e9 100644 --- a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DDefineExpr.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp index 10b08c10..f0bf15ff 100644 --- a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DApplyExpr.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp index 871f9c91..da593190 100644 --- a/include/xo/expression2/detail/IGCObject_DConstant.hpp +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DConstant.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp index 6a47d9b8..20cea34f 100644 --- a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DIfElseExpr.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp index 7d1ba5b0..2f4e72e0 100644 --- a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DLambdaExpr.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index 1f6b8deb..51009ecd 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DSequenceExpr.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/expression2/detail/IGCObject_DUniqueString.hpp b/include/xo/expression2/detail/IGCObject_DUniqueString.hpp index 398e3eed..9968d6da 100644 --- a/include/xo/expression2/detail/IGCObject_DUniqueString.hpp +++ b/include/xo/expression2/detail/IGCObject_DUniqueString.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DUniqueString.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp index e991ebb8..487e2832 100644 --- a/include/xo/expression2/detail/IGCObject_DVarRef.hpp +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVarRef.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/expression2/detail/IGCObject_DVariable.hpp b/include/xo/expression2/detail/IGCObject_DVariable.hpp index 242f335f..4728746f 100644 --- a/include/xo/expression2/detail/IGCObject_DVariable.hpp +++ b/include/xo/expression2/detail/IGCObject_DVariable.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVariable.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/expression2/expression2_register_facets.hpp b/include/xo/expression2/expression2_register_facets.hpp index 95feeea5..1a559c72 100644 --- a/include/xo/expression2/expression2_register_facets.hpp +++ b/include/xo/expression2/expression2_register_facets.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include namespace xo { namespace scm { diff --git a/include/xo/expression2/expression2_register_types.hpp b/include/xo/expression2/expression2_register_types.hpp index 6c7cc959..58105eed 100644 --- a/include/xo/expression2/expression2_register_types.hpp +++ b/include/xo/expression2/expression2_register_types.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include namespace xo { namespace scm { diff --git a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp index 92149015..f136b513 100644 --- a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DGlobalSymtab.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp index 94b9e279..cc770261 100644 --- a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DLocalSymtab.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index aee6ccf9..aa1ea105 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -5,7 +5,7 @@ #include "DDefineExpr.hpp" #include "Variable.hpp" -#include +#include #include #include #include diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index 38809a38..95db6b26 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -8,7 +8,7 @@ #include #include #include -#include +#include #include #include diff --git a/src/expression2/DIfElseExpr.cpp b/src/expression2/DIfElseExpr.cpp index 6a0b053c..649a2482 100644 --- a/src/expression2/DIfElseExpr.cpp +++ b/src/expression2/DIfElseExpr.cpp @@ -5,7 +5,7 @@ #include "DIfElseExpr.hpp" #include "detail/IExpression_DIfElseExpr.hpp" -#include +#include #include #include #include diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index 22b097fb..fdc73b8e 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -7,7 +7,7 @@ #include "detail/IExpression_DSequenceExpr.hpp" #include #include -#include +#include #include #include #include diff --git a/src/expression2/DUniqueString.cpp b/src/expression2/DUniqueString.cpp index c0fa26db..98a7b33c 100644 --- a/src/expression2/DUniqueString.cpp +++ b/src/expression2/DUniqueString.cpp @@ -4,6 +4,7 @@ **/ #include "DUniqueString.hpp" +#include "DString.hpp" #include #include #include @@ -13,6 +14,15 @@ namespace xo { using xo::facet::typeseq; namespace scm { + int + DUniqueString::compare(const DUniqueString & lhs, const DUniqueString & rhs) + { + if (&lhs == &rhs) + return 0; + + return DString::compare(*(lhs._text()), *(rhs._text())); + } + DString * DUniqueString::_text() const noexcept { diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index ac051387..8fc201a5 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -5,8 +5,8 @@ #include "DVariable.hpp" #include "exprtype.hpp" -#include #include +#include namespace xo { using xo::mm::ACollector; diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 82bff638..a9edbc20 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -25,7 +25,7 @@ #include #include -#include +#include #include #include #include From 1c90ce2f10896caf2c81a79298b953caa8def773 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 5 Mar 2026 00:50:58 +1100 Subject: [PATCH 093/128] refactor: + xo-stringtable2 w/ DString impl --- include/xo/expression2/DUniqueString.hpp | 2 +- src/expression2/init_expression2.cpp | 2 +- utest/DApplyExpr.test.cpp | 8 ++++---- utest/DConstant.test.cpp | 6 ++---- utest/DDefineExpr.test.cpp | 8 ++++---- utest/DIfElseExpr.test.cpp | 8 ++++---- utest/DVariable.test.cpp | 6 ++---- utest/X1Collector.test.cpp | 10 +++------- 8 files changed, 21 insertions(+), 29 deletions(-) diff --git a/include/xo/expression2/DUniqueString.hpp b/include/xo/expression2/DUniqueString.hpp index e43624bd..9f56a9c9 100644 --- a/include/xo/expression2/DUniqueString.hpp +++ b/include/xo/expression2/DUniqueString.hpp @@ -5,7 +5,7 @@ #pragma once -#include +#include namespace xo { namespace scm { diff --git a/src/expression2/init_expression2.cpp b/src/expression2/init_expression2.cpp index 1ee5ec9e..0d107316 100644 --- a/src/expression2/init_expression2.cpp +++ b/src/expression2/init_expression2.cpp @@ -8,7 +8,7 @@ #include "expression2_register_types.hpp" #include -#include +#include namespace xo { using xo::scm::expression2_register_facets; diff --git a/utest/DApplyExpr.test.cpp b/utest/DApplyExpr.test.cpp index 1b922333..17b3dca6 100644 --- a/utest/DApplyExpr.test.cpp +++ b/utest/DApplyExpr.test.cpp @@ -20,10 +20,10 @@ #include #include -#include -#include -#include -#include +#include +#include +//#include +//#include #include #include diff --git a/utest/DConstant.test.cpp b/utest/DConstant.test.cpp index fd8e9b1b..a45d39d8 100644 --- a/utest/DConstant.test.cpp +++ b/utest/DConstant.test.cpp @@ -13,10 +13,8 @@ #include #include -#include -#include -#include -#include +#include +#include #include #include diff --git a/utest/DDefineExpr.test.cpp b/utest/DDefineExpr.test.cpp index 5f78891d..648af0f4 100644 --- a/utest/DDefineExpr.test.cpp +++ b/utest/DDefineExpr.test.cpp @@ -14,10 +14,10 @@ #include #include -#include -#include -#include -#include +#include +#include +//#include +//#include #include #include diff --git a/utest/DIfElseExpr.test.cpp b/utest/DIfElseExpr.test.cpp index 2dee2f26..4a7dcf70 100644 --- a/utest/DIfElseExpr.test.cpp +++ b/utest/DIfElseExpr.test.cpp @@ -15,10 +15,10 @@ #include #include -#include -#include -#include -#include +#include +#include +//#include +//#include #include #include diff --git a/utest/DVariable.test.cpp b/utest/DVariable.test.cpp index 9c26a7c4..51e80a33 100644 --- a/utest/DVariable.test.cpp +++ b/utest/DVariable.test.cpp @@ -9,10 +9,8 @@ #include #include -#include -#include -#include -#include +#include +#include #include #include diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index b872d877..08fb5ca9 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -12,14 +12,10 @@ #include #include #include -#include - -#include -#include - -#include -#include +#include +#include +#include #include #include From 9695a1ca75c391c97abee3e2529a02220fd60163 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 5 Mar 2026 13:02:12 +1100 Subject: [PATCH 094/128] xo-interpreter2 stack: refactor: string clases -> xo-stringtable2/ --- CMakeLists.txt | 24 --- idl/IGCObject_DUniqueString.json5 | 18 -- idl/IPrintable_DUniqueString.json5 | 16 -- include/xo/expression2/DUniqueString.hpp | 140 -------------- include/xo/expression2/StringTable.hpp | 65 ------- include/xo/expression2/UniqueString.hpp | 12 -- .../detail/IGCObject_DUniqueString.hpp | 67 ------- .../detail/IPrintable_DUniqueString.hpp | 62 ------- src/expression2/CMakeLists.txt | 6 - src/expression2/DUniqueString.cpp | 121 ------------ src/expression2/IGCObject_DUniqueString.cpp | 39 ---- src/expression2/IPrintable_DUniqueString.cpp | 28 --- src/expression2/StringTable.cpp | 173 ------------------ .../expression2_register_facets.cpp | 5 - .../expression2_register_types.cpp | 7 +- utest/CMakeLists.txt | 1 - utest/DDefineExpr.test.cpp | 16 +- utest/DVariable.test.cpp | 12 +- utest/StringTable.test.cpp | 161 ---------------- utest/X1Collector.test.cpp | 8 +- 20 files changed, 23 insertions(+), 958 deletions(-) delete mode 100644 idl/IGCObject_DUniqueString.json5 delete mode 100644 idl/IPrintable_DUniqueString.json5 delete mode 100644 include/xo/expression2/DUniqueString.hpp delete mode 100644 include/xo/expression2/StringTable.hpp delete mode 100644 include/xo/expression2/UniqueString.hpp delete mode 100644 include/xo/expression2/detail/IGCObject_DUniqueString.hpp delete mode 100644 include/xo/expression2/detail/IPrintable_DUniqueString.hpp delete mode 100644 src/expression2/DUniqueString.cpp delete mode 100644 src/expression2/IGCObject_DUniqueString.cpp delete mode 100644 src/expression2/IPrintable_DUniqueString.cpp delete mode 100644 src/expression2/StringTable.cpp delete mode 100644 utest/StringTable.test.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index c9180ad8..92652b90 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -394,30 +394,6 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- -# note: manual target; generated code committed to git -xo_add_genfacetimpl( - TARGET xo-expression2-facetimpl-gcobject-uniquestring - FACET_PKG xo_gc - FACET GCObject - REPR UniqueString - INPUT idl/IGCObject_DUniqueString.json5 - OUTPUT_HPP_DIR include/xo/expression2 - OUTPUT_IMPL_SUBDIR detail -) - -# note: manual target; generated code committed to git -xo_add_genfacetimpl( - TARGET xo-expression2-facetimpl-printable-uniquestring - FACET_PKG xo_printable2 - FACET Printable - REPR UniqueString - INPUT idl/IPrintable_DUniqueString.json5 - OUTPUT_HPP_DIR include/xo/expression2 - OUTPUT_IMPL_SUBDIR detail -) - -# ---------------------------------------------------------------- - xo_add_genfacet_all(xo-expression2-genfacet-all) # ---------------------------------------------------------------- diff --git a/idl/IGCObject_DUniqueString.json5 b/idl/IGCObject_DUniqueString.json5 deleted file mode 100644 index 4f79e9de..00000000 --- a/idl/IGCObject_DUniqueString.json5 +++ /dev/null @@ -1,18 +0,0 @@ -{ - mode: "implementation", - output_cpp_dir: "src/expression2", - output_hpp_dir: "include/xo/expression2", - output_impl_subdir: "detail", - includes: [ - "", - "" - ], - local_types: [ ], - namespace1: "xo", - namespace2: "scm", - facet_idl: "idl/GCObject.json5", - brief: "provide AGCObject interface for DUniqueString", - using_doxygen: true, - repr: "DUniqueString", - doc: [ "implement AGCObject for DUniqueString" ], -} diff --git a/idl/IPrintable_DUniqueString.json5 b/idl/IPrintable_DUniqueString.json5 deleted file mode 100644 index ba094879..00000000 --- a/idl/IPrintable_DUniqueString.json5 +++ /dev/null @@ -1,16 +0,0 @@ -{ - mode: "implementation", - output_cpp_dir: "src/expression2", - output_hpp_dir: "include/xo/expression2", - output_impl_subdir: "detail", - includes: [ "", - "" ], - local_types: [ ], - namespace1: "xo", - namespace2: "scm", - facet_idl: "idl/Printable.json5", - brief: "provide APrintable interface for DUniqueString", - using_doxygen: true, - repr: "DUniqueString", - doc: [ "implement APrintable for DUniqueString" ], -} diff --git a/include/xo/expression2/DUniqueString.hpp b/include/xo/expression2/DUniqueString.hpp deleted file mode 100644 index 9f56a9c9..00000000 --- a/include/xo/expression2/DUniqueString.hpp +++ /dev/null @@ -1,140 +0,0 @@ -/** @file DUniqueString.hpp - * - * @author Roland Conybeare, Jan 2026 - **/ - -#pragma once - -#include - -namespace xo { - namespace scm { - /** @class DUniqueString - * @brief unique immutable string - * - * A DUniqueString is an immutable string stored in a shared StringTable. - * Follows that DUniqueStrings at different memory locations - * have different contents. - * - * DUniqueString instances will be created by StringTable (see also). - * Application code will not allocate them directly. - * - * Needs to be gc-aware so that collector knows what to do when it encounters - * a obj with a DUnqiueString data pointer; such instances - * will not be allocated from GC memory - **/ - class DUniqueString { - public: - using AAllocator = xo::mm::AAllocator; - using ACollector = xo::mm::ACollector; - using size_type = DString::size_type; - using ppindentinfo = xo::print::ppindentinfo; - - /* Memory model for a DUniqueString allocated via xo allocator - * - * 0 8 16 20 24 24+z - * v v v v v v - * +---------------+-+-------------+-------+-------+-----------+ - * | header |u| padding | cap | size | text... \0| - * +---------------+-+-------------+-------+-------+-----------+ - * - * Legend - * header 8 byte allocation header - * u 1 byte DUniqueString placeholder (c++ insists) - * padding 7 bytes allocator-imposed padding to 8-byte alignment - * cap 4 bytes DString.capacity - * size 4 bytes DString.size - * text z bytes DString.size bytes of text (including null) - * In practice followed by padding to 8 byte - * alignment - */ - - /** @defgroup duniquestring-ctors constructors **/ - ///@{ - - /** not copyable **/ - DUniqueString(const DUniqueString &) = delete; - - ///@} - /** @defgroup duniquestring-methods methods **/ - ///@{ - - /** Available storage for this instance. - * For completeness' sake since uniquestring not modifiable - **/ - size_type capacity() const noexcept { return _text()->capacity(); } - size_type size() const noexcept { return _text()->size(); } - const char * chars() const noexcept { return _text()->chars(); } - - /** compare unique strings: return n with {n<0, n=0, n>0} - * when @p lhs lexicographically {before, at, after} @p rhs - **/ - static int compare(const DUniqueString & lhs, const DUniqueString & rhs); - - std::size_t hash() const noexcept { return _text()->hash(); } - operator std::string_view() const noexcept { return std::string_view(*_text()); } - /** not assignable **/ - DUniqueString & operator=(const DUniqueString &) = delete; - - ///@} - /** @defgroup duniquestring-printable-methods printable facet methods **/ - ///@{ - - bool pretty(const ppindentinfo & ppii) const; - - ///@} - /** @defgroup duniquestring-gcobject-methods gcobject facet methods **/ - ///@{ - - std::size_t shallow_size() const noexcept; - - /** clone unique string, using memory from allocator @p mm. **/ - DUniqueString * shallow_copy(obj mm) const noexcept; - - /** fixup child pointers (trivial for DUniqueString, no gc-owned children **/ - std::size_t forward_children(obj gc) noexcept; - - ///@} - - private: - /** @defgroup duniquestring-impl-methods implementation methods **/ - ///@{ - - /** default ctor **/ - DUniqueString() = default; - - /** DString containing actual string content immediately follows DUniqueString - * in memory; part of same alloc - **/ - DString * _text() const noexcept; - - //explicit DUniqueString(const DString * text) : text_{text} {} - - /** create instance using memory from @p mm, - * with string contents copied from @p sv - **/ - static DUniqueString * from_view(obj mm, - std::string_view sv); - - ///@} - - friend class StringTable; - }; - - /* since unique: just compare addresses */ - inline bool operator==(const DUniqueString & lhs, const DUniqueString & rhs) { - return (&lhs == &rhs); - } - - /* since unique: just compare addresses **/ - inline bool operator!=(const DUniqueString & lhs, const DUniqueString & rhs) { - return (&lhs != &rhs); - } - - inline bool operator<=(const DUniqueString & lhs, const DUniqueString & rhs) { - return (DUniqueString::compare(lhs, rhs) <= 0); - } - } /*namespace scm*/ -} /*namespace xo*/ - -/* end UniqueString.hpp */ diff --git a/include/xo/expression2/StringTable.hpp b/include/xo/expression2/StringTable.hpp deleted file mode 100644 index 8d0354c8..00000000 --- a/include/xo/expression2/StringTable.hpp +++ /dev/null @@ -1,65 +0,0 @@ -/** @file StringTable.hpp - * - * @author Roland Conybeare, Jan 2026 - **/ - -#pragma once - -#include "DUniqueString.hpp" -#include -#include -#include - -namespace xo { - namespace scm { - - /** @class StringTable - * @brief table containing a set of interned strings - * - * A table of strings referenced in schematika expressions - **/ - class StringTable { - public: - using DArena = xo::mm::DArena; - using MemorySizeVisitor = xo::mm::MemorySizeVisitor; - using StringMap = xo::map::DArenaHashMap; - using size_type = StringMap::size_type; - - public: - StringTable(size_type hint_max_capacity, - bool debug_flag = false); - - /** lookup interned string; nullptr if not present **/ - const DUniqueString * lookup(std::string_view key) const; - - /** return unique string with contents @p key. Idempotent! **/ - const DUniqueString * intern(std::string_view key); - - /** generate unique symbol -- guaranteed not to collide - * with existing symbol in this table. - **/ - const DUniqueString * gensym(std::string_view prefix); - - /** verify StringTable invariants. - * Act on failure according to policy @p p - **/ - bool verify_ok(verify_policy p = verify_policy::throw_only()) const; - - /** visit string-table memory pools, call visitor(info) for each **/ - void visit_pools(const MemorySizeVisitor & visitor) const; - - private: - /** allocate string storage in this arena; use DString to represent each string. - * Can't use DArenaVector b/c DString has variable size - **/ - DArena strings_; - /** map_[s] points to arena strings, i.e. members of @ref strings_ **/ - StringMap map_; - }; - - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end StringTable.hpp */ diff --git a/include/xo/expression2/UniqueString.hpp b/include/xo/expression2/UniqueString.hpp deleted file mode 100644 index 90cd1cd2..00000000 --- a/include/xo/expression2/UniqueString.hpp +++ /dev/null @@ -1,12 +0,0 @@ -/** @file UniqueString.hpp - * - * @author Roland Conybeare, Feb 2026 - **/ - -#pragma once - -#include "DUniqueString.hpp" -#include "detail/IGCObject_DUniqueString.hpp" -#include "detail/IPrintable_DUniqueString.hpp" - -/* end UniqueString.hpp */ diff --git a/include/xo/expression2/detail/IGCObject_DUniqueString.hpp b/include/xo/expression2/detail/IGCObject_DUniqueString.hpp deleted file mode 100644 index 9968d6da..00000000 --- a/include/xo/expression2/detail/IGCObject_DUniqueString.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/** @file IGCObject_DUniqueString.hpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IGCObject_DUniqueString.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_repr.hpp.j2] - * 3. idl for facet methods - * [idl/IGCObject_DUniqueString.json5] - **/ - -#pragma once - -#include "GCObject.hpp" -#include -#include -#include "DUniqueString.hpp" - -namespace xo { namespace scm { class IGCObject_DUniqueString; } } - -namespace xo { - namespace facet { - template <> - struct FacetImplementation - { - using ImplType = xo::mm::IGCObject_Xfer - ; - }; - } -} - -namespace xo { - namespace scm { - /** @class IGCObject_DUniqueString - **/ - class IGCObject_DUniqueString { - public: - /** @defgroup scm-gcobject-duniquestring-type-traits **/ - ///@{ - using size_type = xo::mm::AGCObject::size_type; - using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; - using Copaque = xo::mm::AGCObject::Copaque; - using Opaque = xo::mm::AGCObject::Opaque; - ///@} - /** @defgroup scm-gcobject-duniquestring-methods **/ - ///@{ - // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DUniqueString & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DUniqueString & self, obj mm) noexcept; - - // non-const methods - /** during GC: forward immdiate children **/ - static size_type forward_children(DUniqueString & self, obj gc) noexcept; - ///@} - }; - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end */ diff --git a/include/xo/expression2/detail/IPrintable_DUniqueString.hpp b/include/xo/expression2/detail/IPrintable_DUniqueString.hpp deleted file mode 100644 index a57039a8..00000000 --- a/include/xo/expression2/detail/IPrintable_DUniqueString.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/** @file IPrintable_DUniqueString.hpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IPrintable_DUniqueString.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_repr.hpp.j2] - * 3. idl for facet methods - * [idl/IPrintable_DUniqueString.json5] - **/ - -#pragma once - -#include "Printable.hpp" -#include -#include -#include "DUniqueString.hpp" - -namespace xo { namespace scm { class IPrintable_DUniqueString; } } - -namespace xo { - namespace facet { - template <> - struct FacetImplementation - { - using ImplType = xo::print::IPrintable_Xfer - ; - }; - } -} - -namespace xo { - namespace scm { - /** @class IPrintable_DUniqueString - **/ - class IPrintable_DUniqueString { - public: - /** @defgroup scm-printable-duniquestring-type-traits **/ - ///@{ - using ppindentinfo = xo::print::APrintable::ppindentinfo; - using Copaque = xo::print::APrintable::Copaque; - using Opaque = xo::print::APrintable::Opaque; - ///@} - /** @defgroup scm-printable-duniquestring-methods **/ - ///@{ - // const methods - /** Pretty-printing support for this object. -See [xo-indentlog/xo/indentlog/pretty.hpp] **/ - static bool pretty(const DUniqueString & self, const ppindentinfo & ppii); - - // non-const methods - ///@} - }; - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index f05cf2f1..d5bf81f4 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -63,12 +63,6 @@ set(SELF_SRCS IGCObject_DGlobalSymtab.cpp IPrintable_DGlobalSymtab.cpp - StringTable.cpp - - DUniqueString.cpp - IGCObject_DUniqueString.cpp - IPrintable_DUniqueString.cpp - ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) diff --git a/src/expression2/DUniqueString.cpp b/src/expression2/DUniqueString.cpp deleted file mode 100644 index 98a7b33c..00000000 --- a/src/expression2/DUniqueString.cpp +++ /dev/null @@ -1,121 +0,0 @@ -/** @file DUniqueString.cpp -* - * @author Roland Conybeare, Jan 2026 - **/ - -#include "DUniqueString.hpp" -#include "DString.hpp" -#include -#include -#include - -namespace xo { - using xo::mm::padding; - using xo::facet::typeseq; - - namespace scm { - int - DUniqueString::compare(const DUniqueString & lhs, const DUniqueString & rhs) - { - if (&lhs == &rhs) - return 0; - - return DString::compare(*(lhs._text()), *(rhs._text())); - } - - DString * - DUniqueString::_text() const noexcept - { - // location of paired DString is chosen - // by allocator (DArena, probably). - // - // In general allocator alignment more conservative - // than C++ alignment - // - // Remmebr also: although DUniqueString has zero members, - // C++ requires it to behave asif size at least 1 byte - // for iterator consistency - // (e.g. because c++ would support iterating over - // std::vector) - // - size_t offset = padding::with_padding(sizeof(*this)); - assert(offset > 0); - - return (DString *)(((std::byte *)this) + offset); - } - - bool - DUniqueString::pretty(const ppindentinfo & ppii) const - { - return _text()->pretty(ppii); - } - - DUniqueString * - DUniqueString::from_view(obj mm, - std::string_view sv) - { - scope log(XO_DEBUG(false)); - - /** fine point: choosing to allocate DUniqueString ahead of DString, - * so it comes first in bump allocator - **/ - - void * mem = mm.super_alloc(typeseq::id(), - sizeof(DUniqueString)); - DUniqueString * result = new (mem) DUniqueString(); - - /** allocated in memory immediate following @p result. - * This optimization saves us one pointer (8 bytes) in DUniqueString - * itself, plus one allocation header (8 bytes) for 16 bytes total - **/ - DString * text = DString::from_view_suballoc(mm, sv); - - log && log(xtag("result", result), xtag("result.text", result->_text()), xtag("text", text)); - - assert(text); - assert(text == result->_text()); - - /** must finish super-allocation before next alloc **/ - mm.sub_alloc(0, true); - - return result; - } - - size_t - DUniqueString::shallow_size() const noexcept - { - return sizeof(DUniqueString); - } - - DUniqueString * - DUniqueString::shallow_copy(obj mm) const noexcept - { - // well-posed, but not expected to be used. - assert(false); - - DUniqueString * copy = (DUniqueString *)mm.alloc_copy((std::byte *)this); - - if (copy) { - // Copy assignment not implemented in general - // *copy = *this; - // in this case *copy already has the same size as *this - - assert(size() <= capacity()); - - strncpy(copy->_text()->data(), - this->_text()->chars(), - this->size()); - } - - return copy; - } - - size_t - DUniqueString::forward_children(obj) noexcept - { - return shallow_size(); - } - } /*namespace scm*/ -} /*namespace xo*/ - -/* end DUniqueString.cpp */ diff --git a/src/expression2/IGCObject_DUniqueString.cpp b/src/expression2/IGCObject_DUniqueString.cpp deleted file mode 100644 index 8238990f..00000000 --- a/src/expression2/IGCObject_DUniqueString.cpp +++ /dev/null @@ -1,39 +0,0 @@ -/** @file IGCObject_DUniqueString.cpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IGCObject_DUniqueString.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] - * 3. idl for facet methods - * [idl/IGCObject_DUniqueString.json5] -**/ - -#include "detail/IGCObject_DUniqueString.hpp" - -namespace xo { - namespace scm { - auto - IGCObject_DUniqueString::shallow_size(const DUniqueString & self) noexcept -> size_type - { - return self.shallow_size(); - } - - auto - IGCObject_DUniqueString::shallow_copy(const DUniqueString & self, obj mm) noexcept -> Opaque - { - return self.shallow_copy(mm); - } - - auto - IGCObject_DUniqueString::forward_children(DUniqueString & self, obj gc) noexcept -> size_type - { - return self.forward_children(gc); - } - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end IGCObject_DUniqueString.cpp */ diff --git a/src/expression2/IPrintable_DUniqueString.cpp b/src/expression2/IPrintable_DUniqueString.cpp deleted file mode 100644 index 5f490bd9..00000000 --- a/src/expression2/IPrintable_DUniqueString.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/** @file IPrintable_DUniqueString.cpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IPrintable_DUniqueString.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_any.hpp.j2] - * 3. idl for facet methods - * [idl/IPrintable_DUniqueString.json5] -**/ - -#include "detail/IPrintable_DUniqueString.hpp" - -namespace xo { - namespace scm { - auto - IPrintable_DUniqueString::pretty(const DUniqueString & self, const ppindentinfo & ppii) -> bool - { - return self.pretty(ppii); - } - - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end IPrintable_DUniqueString.cpp */ diff --git a/src/expression2/StringTable.cpp b/src/expression2/StringTable.cpp deleted file mode 100644 index 2d23d03e..00000000 --- a/src/expression2/StringTable.cpp +++ /dev/null @@ -1,173 +0,0 @@ -/** @file StringTable.cpp -* - * @author Roland Conybeare, Jan 2026 - **/ - -#include "StringTable.hpp" -#include -#include - -namespace xo { - using xo::mm::ArenaConfig; - using xo::mm::AAllocator; - using xo::mm::MemorySizeInfo; - using xo::facet::with_facet; - using xo::facet::obj; - - namespace scm { - StringTable::StringTable(size_type hint_max_capacity, - bool debug_flag) - : strings_{DArena::map(ArenaConfig{.name_ = "strings", - .size_ = hint_max_capacity})}, - map_{"stringkeys", hint_max_capacity} - { - (void)debug_flag; - } - - const DUniqueString * - StringTable::lookup(std::string_view key) const - { - auto ix = map_.find(key); - - if (ix != map_.end()) - return ix->second; - - return nullptr; - } - - const DUniqueString * - StringTable::intern(std::string_view key) - { - // 1a. lookup key in map_. - // 1b. if present, return existing DString* - - auto ix = map_.find(key); - - if (ix != map_.end()) - return ix->second; - - // 2. otherwise need to add. - // - // 2d. return key2 address - - // 2a. allocate DUniqueString copy 'interned' of key in strings_ - auto mm = with_facet::mkobj(&strings_); - DUniqueString * interned = DUniqueString::from_view(mm, key); - - assert(interned); - if (interned) { - // 2b. make string_view from *interned - std::string_view interned_key = std::string_view(*interned); - - // interned_key has same lifetime as StringTable, - // we can use it in map_ - - // 2c. store address of 'interned' in map_ - auto & slot = this->map_[interned_key]; - - slot = interned; - - return slot; - } - - return nullptr; - } - - const DUniqueString * - StringTable::gensym(std::string_view prefix) - { - static std::size_t s_counter = 0; - - while (true) { - ++s_counter; - - char buf[80]; - assert(prefix.size() + 20 < sizeof(buf)); - - int n = snprintf(buf, sizeof(buf), - "%s:%lu", - prefix.data(), s_counter); - - if ((0 < n) && (std::size_t(n) < sizeof(buf))) - buf[n] = '\0'; - else - buf[sizeof(buf)-1] = '\0'; - - std::string_view sv(buf); - const DUniqueString * retval = this->lookup(sv); - if (!retval) { - /* not already in string view -> we have viable candidate */ - retval = this->intern(sv); - return retval; - } - } - } - - bool - StringTable::verify_ok(verify_policy policy) const - { - using xo::scope; - using xo::xtag; - - constexpr const char * c_self = "StringTable::verify_ok"; - scope log(XO_DEBUG(false)); - - /* ST1: underlying hash map passes its invariants */ - if (!map_.verify_ok(policy)) { - return policy.report_error(log, - c_self, ": map_.verify_ok failed"); - } - - /* ST2: for each entry, key points to value's string data */ - for (const auto & kv : map_) { - const std::string_view & key = kv.first; - const DUniqueString * value = kv.second; - - /* ST2.1: value is not null */ - if (value == nullptr) { - return policy.report_error(log, - c_self, ": null value in map", - xtag("key", key)); - } - - /* ST2.2: value lies within strings_ arena */ - if (!strings_.contains(value)) { - return policy.report_error(log, - c_self, ": value not in strings_ arena", - xtag("key", key), - xtag("value", (void*)value)); - } - - /* ST2.3: key.data() points to value's chars */ - if (key.data() != value->chars()) { - return policy.report_error(log, - c_self, ": key.data() != value->chars()", - xtag("key", key), - xtag("key.data()", (void*)key.data()), - xtag("value->chars()", (void*)value->chars())); - } - - /* ST2.4: key.size() == value->size() */ - if (key.size() != value->size()) { - return policy.report_error(log, - c_self, ": key.size() != value->size()", - xtag("key", key), - xtag("key.size()", key.size()), - xtag("value->size()", value->size())); - } - } - - return true; - } - - void - StringTable::visit_pools(const MemorySizeVisitor & visitor) const - { - strings_.visit_pools(visitor); - map_.visit_pools(visitor); - } - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end StringTable.cpp */ diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index a9edbc20..3cd9413d 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -5,8 +5,6 @@ #include "expression2_register_facets.hpp" -#include - #include #include #include @@ -43,9 +41,6 @@ namespace xo { { scope log(XO_DEBUG(true)); - FacetRegistry::register_impl(); - FacetRegistry::register_impl(); - // Expression // +- Constant // +- Variable diff --git a/src/expression2/expression2_register_types.cpp b/src/expression2/expression2_register_types.cpp index b3dd21f8..7a64eb1f 100644 --- a/src/expression2/expression2_register_types.cpp +++ b/src/expression2/expression2_register_types.cpp @@ -5,7 +5,8 @@ #include "expression2_register_types.hpp" -#include "detail/IGCObject_DConstant.hpp" +#include "Constant.hpp" +//#include "detail/IGCObject_DConstant.hpp" #include "detail/IGCObject_DVariable.hpp" //#include "detail/IGCObject_DDefineExpr.hpp" // when avail //#include "detail/IGCObject_DApplyExpr.hpp" // when avail @@ -13,7 +14,7 @@ #include "detail/IGCObject_DIfElseExpr.hpp" #include "detail/IGCObject_DSequenceExpr.hpp" //#include "detail/IGCObject_DLocalSymtab.hpp" // when avail -#include "detail/IGCObject_DUniqueString.hpp" +//#include "detail/IGCObject_DUniqueString.hpp" //#include "detail/IPrintable_DUniqueString.hpp" // when avail @@ -44,8 +45,6 @@ namespace xo { //ok &= gc.install_type(impl_for()); // when avail - ok &= gc.install_type(impl_for()); - return ok; } } diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index 07f10c3b..4273fa9a 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -3,7 +3,6 @@ set(UTEST_EXE utest.expression2) set(UTEST_SRCS expression2_utest_main.cpp - StringTable.test.cpp X1Collector.test.cpp DConstant.test.cpp DVariable.test.cpp diff --git a/utest/DDefineExpr.test.cpp b/utest/DDefineExpr.test.cpp index 648af0f4..184c7556 100644 --- a/utest/DDefineExpr.test.cpp +++ b/utest/DDefineExpr.test.cpp @@ -7,17 +7,17 @@ #include #include #include -#include -#include -#include +#include +//#include -#include -#include +#include +//#include + +#include + +#include #include -#include -//#include -//#include #include #include diff --git a/utest/DVariable.test.cpp b/utest/DVariable.test.cpp index 51e80a33..31f11301 100644 --- a/utest/DVariable.test.cpp +++ b/utest/DVariable.test.cpp @@ -4,17 +4,19 @@ **/ #include "init_expression2.hpp" -#include -#include -#include -#include +#include +//#include +//#include #include + +#include +#include + #include #include #include -#include #include diff --git a/utest/StringTable.test.cpp b/utest/StringTable.test.cpp deleted file mode 100644 index 66163c22..00000000 --- a/utest/StringTable.test.cpp +++ /dev/null @@ -1,161 +0,0 @@ -/** @file StringTable.test.cpp - * - * @author Roland Conybeare, Jan 2026 - **/ - -#include -#include -#include - -namespace xo { - using xo::scm::StringTable; - using xo::scm::DUniqueString; - //using xo::scm::DString; - - namespace ut { - TEST_CASE("StringTable-lookup-empty", "[expression2][StringTable]") - { - StringTable table(1024); - - // lookup on empty table returns nullptr - REQUIRE(table.lookup("foo") == nullptr); - REQUIRE(table.lookup("") == nullptr); - } - - TEST_CASE("StringTable-intern", "[expression2][StringTable]") - { - StringTable table(1024); - - const DUniqueString * s1 = table.intern("hello"); - - REQUIRE(s1 != nullptr); - REQUIRE(std::strcmp(s1->chars(), "hello") == 0); - REQUIRE(s1->size() == 5); - } - - TEST_CASE("StringTable-intern-idempotent", "[expression2][StringTable]") - { - StringTable table(1024); - - const DUniqueString * s1 = table.intern("hello"); - const DUniqueString * s2 = table.intern("hello"); - - // same key returns same pointer - REQUIRE(s1 != nullptr); - REQUIRE(s2 != nullptr); - REQUIRE(s1 == s2); - } - - TEST_CASE("StringTable-lookup-after-intern", "[expression2][StringTable]") - { - StringTable table(1024); - - REQUIRE(table.lookup("hello") == nullptr); - - const DUniqueString * s1 = table.intern("hello"); - - const DUniqueString * s2 = table.lookup("hello"); - - REQUIRE(s2 != nullptr); - REQUIRE(s1 == s2); - } - - TEST_CASE("StringTable-multiple-strings", "[expression2][StringTable]") - { - StringTable table(1024); - - const DUniqueString * s1 = table.intern("apple"); - const DUniqueString * s2 = table.intern("banana"); - const DUniqueString * s3 = table.intern("cherry"); - - // all different pointers - REQUIRE(s1 != s2); - REQUIRE(s2 != s3); - REQUIRE(s1 != s3); - - // correct contents - REQUIRE(std::strcmp(s1->chars(), "apple") == 0); - REQUIRE(std::strcmp(s2->chars(), "banana") == 0); - REQUIRE(std::strcmp(s3->chars(), "cherry") == 0); - - // lookup still works - REQUIRE(table.lookup("apple") == s1); - REQUIRE(table.lookup("banana") == s2); - REQUIRE(table.lookup("cherry") == s3); - REQUIRE(table.lookup("date") == nullptr); - } - - TEST_CASE("StringTable-intern-empty-string", "[expression2][StringTable]") - { - StringTable table(1024); - - const DUniqueString * s1 = table.intern(""); - - REQUIRE(s1 != nullptr); - REQUIRE(s1->size() == 0); - REQUIRE(s1->chars()[0] == '\0'); - - // idempotent for empty string too - const DUniqueString * s2 = table.intern(""); - REQUIRE(s1 == s2); - } - - TEST_CASE("StringTable-verify_ok", "[expression2][StringTable]") - { - StringTable table(4096); - - { - INFO("1. empty table"); - - // empty table passes verify_ok - REQUIRE(table.verify_ok()); - } - - // after interning strings, still passes - { - INFO("2. intern(hello)"); - - table.intern("hello"); - REQUIRE(table.verify_ok()); - } - - { - INFO("3. intern(world)"); - - table.intern("world"); - REQUIRE(table.verify_ok()); - } - - { - INFO("4. intern(foo)"); - - table.intern("foo"); - REQUIRE(table.verify_ok()); - } - - { - INFO("5. intern(bar)"); - - table.intern("bar"); - REQUIRE(table.verify_ok()); - } - - // idempotent intern doesn't break invariants - { - INFO("6. intern(hello)"); - - table.intern("hello"); - REQUIRE(table.verify_ok()); - } - - { - INFO("7. intern(world)"); - - table.intern("world"); - REQUIRE(table.verify_ok()); - } - } - } /*namespace ut*/ -} /*namespace xo*/ - -/* end StringTable.test.cpp */ diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index 08fb5ca9..9534667e 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -6,15 +6,17 @@ **/ #include "init_expression2.hpp" -#include "StringTable.hpp" -#include "detail/IGCObject_DUniqueString.hpp" #include #include #include -#include #include + +#include +#include +#include + #include #include From 5a141e09acfe0e72668d4a37e948bb996ff4e3a1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 07:49:14 -0500 Subject: [PATCH 095/128] xo-reader2 stack: expand symbol table to store typedefs + typedef utest + misc qol policy choices --- CMakeLists.txt | 44 ++++-- cmake/xo_expression2Config.cmake.in | 1 + idl/IGCObject_DTypename.json5 | 18 +++ idl/IPrintable_DTypename.json5 | 16 ++ include/xo/expression2/DGlobalSymtab.hpp | 46 ++++-- include/xo/expression2/DLambdaExpr.hpp | 2 +- include/xo/expression2/DLocalSymtab.hpp | 55 ++++--- include/xo/expression2/DSequenceExpr.hpp | 4 +- include/xo/expression2/DTypename.hpp | 77 +++++++++ include/xo/expression2/DVariable.hpp | 2 +- include/xo/expression2/TypeRef.hpp | 25 ++- include/xo/expression2/Typename.hpp | 12 ++ .../typename/IGCObject_DTypename.hpp | 65 ++++++++ .../typename/IPrintable_DTypename.hpp | 62 ++++++++ src/expression2/CMakeLists.txt | 5 + src/expression2/DApplyExpr.cpp | 7 + src/expression2/DConstant.cpp | 5 +- src/expression2/DGlobalSymtab.cpp | 120 +++++++++++--- src/expression2/DIfElseExpr.cpp | 8 +- src/expression2/DLambdaExpr.cpp | 10 +- src/expression2/DLocalSymtab.cpp | 146 +++++++++++------- src/expression2/DSequenceExpr.cpp | 18 ++- src/expression2/DTypename.cpp | 89 +++++++++++ src/expression2/DVariable.cpp | 7 +- src/expression2/IGCObject_DTypename.cpp | 39 +++++ src/expression2/IPrintable_DTypename.cpp | 28 ++++ src/expression2/TypeRef.cpp | 44 ++++++ .../expression2_register_facets.cpp | 14 +- .../expression2_register_types.cpp | 22 +-- 29 files changed, 841 insertions(+), 150 deletions(-) create mode 100644 idl/IGCObject_DTypename.json5 create mode 100644 idl/IPrintable_DTypename.json5 create mode 100644 include/xo/expression2/DTypename.hpp create mode 100644 include/xo/expression2/Typename.hpp create mode 100644 include/xo/expression2/typename/IGCObject_DTypename.hpp create mode 100644 include/xo/expression2/typename/IPrintable_DTypename.hpp create mode 100644 src/expression2/DTypename.cpp create mode 100644 src/expression2/IGCObject_DTypename.cpp create mode 100644 src/expression2/IPrintable_DTypename.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index 92652b90..1af09c58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -47,7 +47,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-localsymtab - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR LocalSymtab INPUT idl/IGCObject_DLocalSymtab.json5 @@ -82,7 +82,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-globalsymtab - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR GlobalSymtab INPUT idl/IGCObject_DGlobalSymtab.json5 @@ -128,7 +128,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-constant - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR Constant INPUT idl/IGCObject_DConstant.json5 @@ -163,7 +163,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-variable - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR Variable INPUT idl/IGCObject_DVariable.json5 @@ -184,6 +184,30 @@ xo_add_genfacetimpl( # ---------------------------------------------------------------- +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-gcobject-typename + FACET_PKG xo_alloc2 + FACET GCObject + REPR Typename + INPUT idl/IGCObject_DTypename.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR typename +) + +# note: manual target; generated code committed to git +xo_add_genfacetimpl( + TARGET xo-expression2-facetimpl-printable-typename + FACET_PKG xo_printable2 + FACET Printable + REPR Typename + INPUT idl/IPrintable_DTypename.json5 + OUTPUT_HPP_DIR include/xo/expression2 + OUTPUT_IMPL_SUBDIR typename +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-varref @@ -198,7 +222,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-varref - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR VarRef INPUT idl/IGCObject_DVarRef.json5 @@ -233,7 +257,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-defineexpr - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR DefineExpr INPUT idl/IGCObject_DDefineExpr.json5 @@ -268,7 +292,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-applyexpr - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR ApplyExpr INPUT idl/IGCObject_DApplyExpr.json5 @@ -303,7 +327,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-lambdaexpr - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR LambdaExpr INPUT idl/IGCObject_DLambdaExpr.json5 @@ -338,7 +362,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-ifelseexpr - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR IfElseExpr INPUT idl/IGCObject_DIfElseExpr.json5 @@ -373,7 +397,7 @@ xo_add_genfacetimpl( # note: manual target; generated code committed to git xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-sequenceexpr - FACET_PKG xo_gc + FACET_PKG xo_alloc2 FACET GCObject REPR SequenceExpr INPUT idl/IGCObject_DSequenceExpr.json5 diff --git a/cmake/xo_expression2Config.cmake.in b/cmake/xo_expression2Config.cmake.in index ca2e2ccb..c237d261 100644 --- a/cmake/xo_expression2Config.cmake.in +++ b/cmake/xo_expression2Config.cmake.in @@ -6,6 +6,7 @@ include(CMakeFindDependencyMacro) # must coordinate with xo_dependency() calls # in CMakeLists.txt # +find_dependency(xo_type) find_dependency(xo_gc) find_dependency(reflect) find_dependency(xo_procedure2) diff --git a/idl/IGCObject_DTypename.json5 b/idl/IGCObject_DTypename.json5 new file mode 100644 index 00000000..ae99ef9a --- /dev/null +++ b/idl/IGCObject_DTypename.json5 @@ -0,0 +1,18 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "typename", + includes: [ +// "", +// "" + ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/GCObject.json5", + brief: "provide AGCObject interface for DTypename", + using_doxygen: true, + repr: "DTypename", + doc: [ "implement AGCObject for DTypename" ], +} diff --git a/idl/IPrintable_DTypename.json5 b/idl/IPrintable_DTypename.json5 new file mode 100644 index 00000000..d11d8993 --- /dev/null +++ b/idl/IPrintable_DTypename.json5 @@ -0,0 +1,16 @@ +{ + mode: "implementation", + output_cpp_dir: "src/expression2", + output_hpp_dir: "include/xo/expression2", + output_impl_subdir: "typename", + includes: [ "", + "" ], + local_types: [ ], + namespace1: "xo", + namespace2: "scm", + facet_idl: "idl/Printable.json5", + brief: "provide APrintable interface for DTypename", + using_doxygen: true, + repr: "DTypename", + doc: [ "implement APrintable for DTypename" ], +} diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index 5cd03fb2..5fe1edb3 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -7,6 +7,7 @@ #include "Binding.hpp" #include "DVariable.hpp" +#include "DTypename.hpp" #include #include #include @@ -38,16 +39,18 @@ namespace xo { /** @defgroup scm-globalsymtab-ctors constructors **/ ///@{ - DGlobalSymtab(dp map, DArray * vars); + DGlobalSymtab(dp var_map, DArray * vars, + dp type_map, DArray * types); /** create instance. * Use memory from @p fixed_mm for @ref map_. * Use memory from @p mm for DGlobalSymtab instance. - * Hashmap configured per @p cfg. + * Hashmap for variables per @p var_cfg; for types per @p type_cfg. **/ static dp make(obj mm, obj fixed_mm, - const ArenaHashMapConfig & cfg); + const ArenaHashMapConfig & var_cfg, + const ArenaHashMapConfig & type_cfg); /** non-trivial destructor for @ref map_ **/ ~DGlobalSymtab() = default; @@ -56,8 +59,8 @@ namespace xo { /** @defgroup scm-globalsymtab-access-methods access methods **/ ///@{ - size_type size() const noexcept { return map_->size(); } - size_type capacity() const noexcept { return map_->capacity(); } + size_type n_vars() const noexcept { return var_map_->size(); } + size_type var_capacity() const noexcept { return var_map_->capacity(); } /** visit symtab-owned memory pools; call visitor(info) for each **/ void visit_pools(const MemorySizeVisitor & visitor) const; @@ -65,6 +68,9 @@ namespace xo { /** lookup global symbol with name @p sym **/ DVariable * lookup_variable(const DUniqueString * sym) const noexcept; + /** lookup global typename with name @p sym **/ + DTypename * lookup_typename(const DUniqueString * sym) const noexcept; + ///@} /** @defgroup scm-globalsymtab-general-methods general methods **/ ///@{ @@ -76,6 +82,13 @@ namespace xo { void upsert_variable(obj mm, DVariable * var); + /** update this symtab to associate typename @p type with @c type->name(). + * If there was a previous type with the same name, replace it with + * @p type. + **/ + void upsert_typename(obj mm, + DTypename * type); + ///@} /** @defgroup scm-globalsymtab-symboltable-facet symboltable facet **/ ///@{ @@ -104,20 +117,31 @@ namespace xo { ///@} private: - /** map symbols -> bindings. - * Minor point: storing offsets instead of Variables allows us to omit - * iterating over map elements during GC. Possible savings if map_ slots - * sparsely populated. + /** map variable symbol -> index into @ref vars_. + * Minor point: storing offsets instead of Variables allows us to: + * omit hash-map iteration during GC. + * Savings when map_ slots sparsely populated. **/ - dp map_; + dp var_map_; /** array of variables. * When S is a unique-string for a global symbol, then: - * 1. map_[S] is unique global index i(S) for S. + * 1. var_map_[S] is unique global index i(S) for S. * 2. vars_[i(S)] is variable-expr var(S) for S * 3. var(S)->name == S **/ DArray * vars_ = nullptr; + + /** map type name -> index values into @ref types_ **/ + dp type_map_; + + /** array of types. + * When T is a unique-string for a globally-defined type, then: + * 1. type_map_[T] is unique global index i(T) for T. + * 2. types_[i(T)] is type type(T) for T + * 3. type(T)->name == T + **/ + DArray * types_ = nullptr; }; } /*namespace scm*/ diff --git a/include/xo/expression2/DLambdaExpr.hpp b/include/xo/expression2/DLambdaExpr.hpp index 30ed2b74..a7de8044 100644 --- a/include/xo/expression2/DLambdaExpr.hpp +++ b/include/xo/expression2/DLambdaExpr.hpp @@ -62,7 +62,7 @@ namespace xo { ///@{ DLocalSymtab * local_symtab() const noexcept { return local_symtab_; } - size_type n_args() const noexcept { return local_symtab_->size(); } + size_type n_args() const noexcept { return local_symtab_->n_vars(); } obj body_expr() const noexcept { return body_expr_; } // get_free_variables() diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index f4073226..6e459035 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -8,9 +8,7 @@ #include "Binding.hpp" #include "DVariable.hpp" #include "DUniqueString.hpp" -//#include "exprtype.hpp" -//#include -//#include +#include namespace xo { namespace scm { @@ -19,14 +17,11 @@ namespace xo { **/ struct DLocalSymtab { public: -// using TaggedPtr = xo::reflect::TaggedPtr; -// using TypeDescr = xo::reflect::TypeDescr; -// using AGCObject = xo::mm::AGCObject; -// using typeseq = xo::reflect::typeseq; - + using DArray = xo::scm::DArray; using ppindentinfo = xo::print::ppindentinfo; using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; /* note: uint16_t would be fine too */ using size_type = std::uint32_t; @@ -46,32 +41,31 @@ namespace xo { /** @defgroup scm-lambdaexpr-constructors **/ ///@{ - /** empty instance with parent @p p and capacity for @p n slots. - * Caller must ensure that slots_[0..n) are actually addressable + /** empty instance with parent @p p, using arrays @p vars for variables + * and @p types for type definitions. **/ - DLocalSymtab(DLocalSymtab * p, size_type n); + DLocalSymtab(DLocalSymtab * p, DArray * nv, DArray * nt); /** scaffold empty symtab instance, - * with capacity for @p n slots, using memory from allocator @p mm + * capacity for @p nv vars and @p nt types, + * using memory from allocator @p mm. + * Symtab chains to parent @p p. **/ static DLocalSymtab * _make_empty(obj mm, DLocalSymtab * p, - size_type n); + size_type nv, + size_type nt); ///@} /** @defgroup scm-lambdaexpr-methods **/ ///@{ DLocalSymtab * parent() const noexcept { return parent_; } - size_type capacity() const noexcept { return capacity_; } - size_type size() const noexcept { return size_; } + //size_type capacity() const noexcept { return capacity_; } + size_type n_vars() const noexcept { return vars_->size(); } + size_type n_types() const noexcept { return types_->size(); } - DVariable * lookup_var(Binding ix) noexcept { - assert(ix.i_link() == 0); - assert(ix.j_slot() < static_cast(size_)); - - return slots_[ix.j_slot()].var_; - } + DVariable * lookup_var(Binding ix) noexcept; /** increase slot size (provided below capacity) to append * binding for one local variable. Local variable will be allocated @@ -81,6 +75,14 @@ namespace xo { const DUniqueString * name, TypeRef typeref); + /** increase slot size (provided below capacity) to append + * binding for one local type. Local type will be allocated + * from @p mm, named @p name, with type described by @p type. + **/ + void append_type(obj mm, + const DUniqueString * name, + obj type); + ///@} /** @defgroup xo-localsymtab-symboltable-facet symboltable facet**/ ///@{ @@ -110,12 +112,23 @@ namespace xo { private: /** parent symbol table from scoping surrounding this one **/ DLocalSymtab * parent_ = nullptr; + /** variables owned by (declared in) this symbol table + * vars_[i] is convertible to obj + **/ + DArray * vars_ = nullptr; + /** types owned by (defined in) this symbol table + * types_[i] is convertible to obj + **/ + DArray * types_ = nullptr; + +#ifdef OBSOLETE /** actual range of slots_[] array. Can use indices in [0,..,n) **/ size_type capacity_ = 0; /** number of slots in use **/ size_type size_ = 0; /** memory for names and bindings **/ Slot slots_[]; +#endif }; } /*namespace scm*/ } /*namespace xo*/ diff --git a/include/xo/expression2/DSequenceExpr.hpp b/include/xo/expression2/DSequenceExpr.hpp index c5bb6f16..39fa79d0 100644 --- a/include/xo/expression2/DSequenceExpr.hpp +++ b/include/xo/expression2/DSequenceExpr.hpp @@ -29,8 +29,8 @@ namespace xo { using ppindentinfo = xo::print::ppindentinfo; public: - DSequenceExpr() = default; - DSequenceExpr(DArray * xv) : expr_v_{xv} {} + DSequenceExpr() ; + DSequenceExpr(DArray * xv); /** create empty sequence using memory from @p mm **/ static obj make_empty(obj mm); diff --git a/include/xo/expression2/DTypename.hpp b/include/xo/expression2/DTypename.hpp new file mode 100644 index 00000000..1d9d0629 --- /dev/null +++ b/include/xo/expression2/DTypename.hpp @@ -0,0 +1,77 @@ +/** @file DTypename.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "DUniqueString.hpp" +#include +#include +#include + +namespace xo { + namespace scm { + + /** @class DTypename + * @brief Container for a named type + * + * Represents the result of syntax like + * 1. deftype Foo :: i64; + * 2. deftype FooAlias :: Foo; + **/ + class DTypename { + public: + using ppindentinfo = xo::print::ppindentinfo; + using ACollector = xo::mm::ACollector; + using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; + + public: + DTypename(const DUniqueString * name, + obj type); + + /** create instance + * @p mm memory allocator + * @p name type name + * @p type type definition + **/ + static DTypename * _make(obj mm, + const DUniqueString * name, + obj type); + /** create fop for new instance **/ + static obj make(obj mm, + const DUniqueString * name, + obj type); + + const DUniqueString * name() const noexcept { return name_; } + obj type() const noexcept { return type_; } + + void assign_name(const DUniqueString * name) { this->name_ = name; } + + + /** @defgroup scm-typename-gcobject-facet **/ + ///@{ + + size_t shallow_size() const noexcept; + DTypename * shallow_copy(obj mm) const noexcept; + size_t forward_children(obj gc) noexcept; + + ///@} + /** @defgroup scm-typename-printable-facet **/ + ///@{ + + bool pretty(const ppindentinfo & ppii) const; + + ///@} + + private: + /** symbol name **/ + const DUniqueString * name_ = nullptr; + /** type defintion. Everything but the name **/ + obj type_; + }; + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DTypename.hpp */ diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp index 29253097..329cf088 100644 --- a/include/xo/expression2/DVariable.hpp +++ b/include/xo/expression2/DVariable.hpp @@ -76,7 +76,7 @@ namespace xo { private: /** symbol name **/ - const DUniqueString * name_; + const DUniqueString * name_ = nullptr; /** variable value always has type consistent * with this description **/ diff --git a/include/xo/expression2/TypeRef.hpp b/include/xo/expression2/TypeRef.hpp index eecb438d..1342b4df 100644 --- a/include/xo/expression2/TypeRef.hpp +++ b/include/xo/expression2/TypeRef.hpp @@ -5,7 +5,9 @@ #pragma once +#include #include +#include #include #include @@ -23,17 +25,28 @@ namespace xo { using TypeDescr = xo::reflect::TypeDescr; using type_var = flatstring<20>; using prefix_type = flatstring<8>; + using ACollector = xo::mm::ACollector; using ppindentinfo = xo::print::ppindentinfo; public: TypeRef() = default; - TypeRef(const type_var & id, TypeDescr td); + TypeRef(const type_var & id, obj type); /** trivial typeref, where already resolved. * Require: @p td non-null **/ static TypeRef resolved(TypeDescr td); + /** trivial typeref, where already resolved **/ + static TypeRef resolved(obj type); + + /** if @p type is non-null + * -> type already resolved + * else + * -> generate unique typevar name, starting with @p prefix + **/ + static TypeRef dwim(prefix_type prefix, obj type); + /** if @p td is non-null * -> type is already resolved * @@ -59,9 +72,19 @@ namespace xo { /** pretty-printer support **/ bool pretty(const ppindentinfo & ppii) const; + /** gc support **/ + void forward_children(obj gc) noexcept; + + private: + TypeRef(const type_var & id, TypeDescr td); + private: /** unique (probably generated) name for type at this location **/ type_var id_; + + /** Type, when resolved **/ + obj type_; + /** Description for concrete type, once resolved. * May be null when this TypeRef created, * but expected to be immutable once established. diff --git a/include/xo/expression2/Typename.hpp b/include/xo/expression2/Typename.hpp new file mode 100644 index 00000000..69c90bab --- /dev/null +++ b/include/xo/expression2/Typename.hpp @@ -0,0 +1,12 @@ +/** @file Typename.hpp + * + * @author Roland Conybeare, Mar 2026 + **/ + +#pragma once + +#include "DTypename.hpp" +#include "typename/IGCObject_DTypename.hpp" +#include "typename/IPrintable_DTypename.hpp" + +/* end Typename.hpp */ diff --git a/include/xo/expression2/typename/IGCObject_DTypename.hpp b/include/xo/expression2/typename/IGCObject_DTypename.hpp new file mode 100644 index 00000000..f01740d4 --- /dev/null +++ b/include/xo/expression2/typename/IGCObject_DTypename.hpp @@ -0,0 +1,65 @@ +/** @file IGCObject_DTypename.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DTypename.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DTypename.json5] + **/ + +#pragma once + +#include "GCObject.hpp" +#include "DTypename.hpp" + +namespace xo { namespace scm { class IGCObject_DTypename; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::mm::IGCObject_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IGCObject_DTypename + **/ + class IGCObject_DTypename { + public: + /** @defgroup scm-gcobject-dtypename-type-traits **/ + ///@{ + using size_type = xo::mm::AGCObject::size_type; + using AAllocator = xo::mm::AGCObject::AAllocator; + using ACollector = xo::mm::AGCObject::ACollector; + using Copaque = xo::mm::AGCObject::Copaque; + using Opaque = xo::mm::AGCObject::Opaque; + ///@} + /** @defgroup scm-gcobject-dtypename-methods **/ + ///@{ + // const methods + /** memory consumption for this instance **/ + static size_type shallow_size(const DTypename & self) noexcept; + /** copy instance using allocator **/ + static Opaque shallow_copy(const DTypename & self, obj mm) noexcept; + + // non-const methods + /** during GC: forward immdiate children **/ + static size_type forward_children(DTypename & self, obj gc) noexcept; + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/typename/IPrintable_DTypename.hpp b/include/xo/expression2/typename/IPrintable_DTypename.hpp new file mode 100644 index 00000000..88504191 --- /dev/null +++ b/include/xo/expression2/typename/IPrintable_DTypename.hpp @@ -0,0 +1,62 @@ +/** @file IPrintable_DTypename.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DTypename.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_repr.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DTypename.json5] + **/ + +#pragma once + +#include "Printable.hpp" +#include +#include +#include "DTypename.hpp" + +namespace xo { namespace scm { class IPrintable_DTypename; } } + +namespace xo { + namespace facet { + template <> + struct FacetImplementation + { + using ImplType = xo::print::IPrintable_Xfer + ; + }; + } +} + +namespace xo { + namespace scm { + /** @class IPrintable_DTypename + **/ + class IPrintable_DTypename { + public: + /** @defgroup scm-printable-dtypename-type-traits **/ + ///@{ + using ppindentinfo = xo::print::APrintable::ppindentinfo; + using Copaque = xo::print::APrintable::Copaque; + using Opaque = xo::print::APrintable::Opaque; + ///@} + /** @defgroup scm-printable-dtypename-methods **/ + ///@{ + // const methods + /** Pretty-printing support for this object. +See [xo-indentlog/xo/indentlog/pretty.hpp] **/ + static bool pretty(const DTypename & self, const ppindentinfo & ppii); + + // non-const methods + ///@} + }; + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end */ \ No newline at end of file diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index d5bf81f4..42b491fc 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -63,11 +63,16 @@ set(SELF_SRCS IGCObject_DGlobalSymtab.cpp IPrintable_DGlobalSymtab.cpp + DTypename.cpp + IGCObject_DTypename.cpp + IPrintable_DTypename.cpp + ) xo_add_shared_library4(${SELF_LIB} ${PROJECT_NAME}Targets ${PROJECT_VERSION} 1 ${SELF_SRCS}) # note: deps here must also appear in cmake/xo_expression2Config.cmake.in xo_dependency(${SELF_LIB} xo_gc) +xo_dependency(${SELF_LIB} xo_type) xo_dependency(${SELF_LIB} reflect) xo_dependency(${SELF_LIB} xo_procedure2) xo_dependency(${SELF_LIB} xo_printable2) diff --git a/src/expression2/DApplyExpr.cpp b/src/expression2/DApplyExpr.cpp index d4e1fa55..784e4473 100644 --- a/src/expression2/DApplyExpr.cpp +++ b/src/expression2/DApplyExpr.cpp @@ -129,6 +129,13 @@ namespace xo { std::size_t DApplyExpr::forward_children(obj gc) noexcept { + typeref_.forward_children(gc); + + { + obj fn_gco = fn_.to_facet(); + gc.forward_inplace(fn_gco.iface(), (void **)&fn_.data_); + } + for (size_type i = 0; i < n_args_; ++i) { obj & arg = args_[i]; diff --git a/src/expression2/DConstant.cpp b/src/expression2/DConstant.cpp index f1f560be..53ab045e 100644 --- a/src/expression2/DConstant.cpp +++ b/src/expression2/DConstant.cpp @@ -91,7 +91,10 @@ namespace xo { std::size_t DConstant::forward_children(obj gc) noexcept { - gc.forward_inplace(value_.iface(), (void **)&(value_.data_)); + typeref_.forward_children(gc); + + gc.forward_inplace(&value_); + //gc.forward_inplace(value_.iface(), (void **)&(value_.data_)); return shallow_size(); } diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index 95db6b26..d7f52228 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -4,6 +4,8 @@ **/ #include "DGlobalSymtab.hpp" +#include "Typename.hpp" +#include "Binding.hpp" #include "DUniqueString.hpp" #include #include @@ -18,25 +20,40 @@ namespace xo { namespace scm { - DGlobalSymtab::DGlobalSymtab(dp map, - DArray * vars) - : map_{std::move(map)}, vars_{vars} + DGlobalSymtab::DGlobalSymtab(dp var_map, + DArray * vars, + dp type_map, + DArray * types) + : var_map_{std::move(var_map)}, vars_{vars}, + type_map_{std::move(type_map)}, types_{types} { } dp DGlobalSymtab::make(obj mm, obj aux_mm, - const ArenaHashMapConfig & cfg) + const ArenaHashMapConfig & var_cfg, + const ArenaHashMapConfig & type_cfg) { - auto map = dp::make(aux_mm, cfg); - assert(map); + /* note: using aux_mm for DArenaHashMap superstructure. + * {variable, type} storage allocated from mm. + */ + + auto var_map = dp::make(aux_mm, var_cfg); + assert(var_map); /* choosing same capacity for hash, vars */ - DArray * vars = DArray::empty(mm, map->capacity()); + DArray * vars = DArray::empty(mm, var_map->capacity()); assert(vars); - auto symtab = dp::make(mm, std::move(map), vars); + auto type_map = dp::make(aux_mm, type_cfg); + assert(type_map); + + DArray * types = DArray::empty(mm, type_map->capacity()); + + auto symtab = dp::make(mm, + std::move(var_map), vars, + std::move(type_map), types); assert(symtab); return symtab; @@ -45,8 +62,10 @@ namespace xo { void DGlobalSymtab::visit_pools(const MemorySizeVisitor & visitor) const { - if (map_) - map_->visit_pools(visitor); + if (var_map_) + var_map_->visit_pools(visitor); + if (type_map_) + type_map_->visit_pools(visitor); } DVariable * @@ -58,11 +77,11 @@ namespace xo { return nullptr; auto var_gco = obj::from((*vars_)[existing.j_slot()]); - auto var = var_gco.to_facet(); - assert(var.data()); + //auto var = var_gco.to_facet(); + //assert(var.data()); - return var.data(); + return var_gco.data(); } void @@ -93,6 +112,7 @@ namespace xo { // stash new definition (possibly has different type), // replacing previous one // + log && log("STUB: need write barrier"); (*vars_)[existing->path().j_slot()] = obj(var); } else { log && log("variable is new"); @@ -123,12 +143,70 @@ namespace xo { var->assign_path(binding); // need slot# in .map_ for this unique symbol - (*map_)[var->name()] = binding.j_slot(); + (*var_map_)[var->name()] = binding.j_slot(); vars_->push_back(obj(var)); } } + DTypename * + DGlobalSymtab::lookup_typename(const DUniqueString * sym) const noexcept + { + auto ix = type_map_->find(sym); + + if (ix == type_map_->end()) + return nullptr; + + Binding::slot_type i_slot = ix->second; + + auto tname_gco = obj::from((*types_)[i_slot]); + + return tname_gco.data(); + } + + void + DGlobalSymtab::upsert_typename(obj mm, + DTypename * tname) + { + scope log(XO_DEBUG(true), + std::string_view(*tname->name())); + + auto ix = type_map_->find(tname->name()); + + if (ix == type_map_->end()) { + log && log("typename is new"); + + DArray::size_type n = types_->size(); + + /** make sure types_ has room **/ + if (n == types_->capacity()) { + // DArray is out of room. + // Reallocate with more capacity + DArray * types_2x = DArray::copy(mm, types_, types_->capacity() * 2); + + if (!types_2x) { + assert(false); + + // in any case, we can't make progress + return; + } + + log && log("STUB: need write barrier"); + this->types_ = types_2x; + } + + (*type_map_)[tname->name()] = n; + + log && log("STUB: need write barrier"); + types_->push_back(obj(tname)); + } else { + Binding::slot_type i_slot = ix->second; + + log && log("STUB: need write barrier"); + (*types_)[i_slot] = obj(tname); + } + } + #ifdef NOT_USING // don't know if we need this path DVariable * DGlobalSymtab::establish_variable(obj mm, @@ -154,9 +232,9 @@ namespace xo { scope log(XO_DEBUG(true), std::string_view(*sym)); - auto ix = map_->find(sym); + auto ix = var_map_->find(sym); - if (ix == map_->end()) + if (ix == var_map_->end()) return Binding::null(); return Binding::global(ix->second); @@ -185,7 +263,8 @@ namespace xo { if (copy_mem) { DGlobalSymtab * self = const_cast(this); - return new (copy_mem) DGlobalSymtab(std::move(self->map_), vars_); + return new (copy_mem) DGlobalSymtab(std::move(self->var_map_), vars_, + std::move(self->type_map_), types_); } return nullptr; @@ -197,6 +276,7 @@ namespace xo { // map_ doesn't contain any gc-owned data, can skip gc.forward_inplace(&vars_); + gc.forward_inplace(&types_); return this->shallow_size(); } @@ -209,8 +289,10 @@ namespace xo { return ppii.pps()->pretty_struct (ppii, "DGlobalSymtab", - refrtag("nsym", vars_->size()), - refrtag("capacity", vars_->capacity())); + refrtag("nvar", vars_->size()), + refrtag("var_capacity", vars_->capacity()), + refrtag("ntype", types_->size()), + refrtag("type_capacity", types_->capacity())); } } /*namespace scm*/ diff --git a/src/expression2/DIfElseExpr.cpp b/src/expression2/DIfElseExpr.cpp index 649a2482..0db04f7e 100644 --- a/src/expression2/DIfElseExpr.cpp +++ b/src/expression2/DIfElseExpr.cpp @@ -102,17 +102,19 @@ namespace xo { std::size_t DIfElseExpr::forward_children(obj gc) noexcept { + typeref_.forward_children(gc); + // GC needs to locate AGCObject iface for each member. { - auto gco = FacetRegistry::instance().variant(test_); + auto gco = test_.to_facet(); gc.forward_inplace(gco.iface(), (void **)&(test_.data_)); } { - auto gco = FacetRegistry::instance().variant(when_true_); + auto gco = when_true_.to_facet(); gc.forward_inplace(gco.iface(), (void **)&(when_true_.data_)); } { - auto gco = FacetRegistry::instance().variant(when_false_); + auto gco = when_false_.to_facet(); gc.forward_inplace(gco.iface(), (void **)&(when_false_.data_)); } diff --git a/src/expression2/DLambdaExpr.cpp b/src/expression2/DLambdaExpr.cpp index 56d55c03..a45c1e32 100644 --- a/src/expression2/DLambdaExpr.cpp +++ b/src/expression2/DLambdaExpr.cpp @@ -95,7 +95,7 @@ namespace xo { std::vector arg_td_v; { - DLocalSymtab::size_type z = symtab->size(); + DLocalSymtab::size_type z = symtab->n_vars(); arg_td_v.reserve(z); @@ -152,7 +152,10 @@ namespace xo { std::size_t DLambdaExpr::forward_children(obj gc) noexcept { + typeref_.forward_children(gc); + { + //gc.forward_inplace(&name_); // doesn't compile for const ptr auto iface = xo::facet::impl_for(); gc.forward_inplace(&iface, (void **)(&name_)); } @@ -160,8 +163,9 @@ namespace xo { // type_name_str_ { - auto iface = xo::facet::impl_for(); - gc.forward_inplace(&iface, (void **)(&local_symtab_)); + gc.forward_inplace(&local_symtab_); + //auto iface = xo::facet::impl_for(); + //gc.forward_inplace(&iface, (void **)(&local_symtab_)); } { diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index cf9c8459..539d5d78 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -5,38 +5,52 @@ #include "LocalSymtab.hpp" #include "Variable.hpp" +#include "Typename.hpp" #include "DUniqueString.hpp" +#include #include +#include #include namespace xo { using xo::mm::AGCObject; using xo::print::APrintable; - using xo::facet::typeseq; + //using xo::facet::typeseq; using xo::print::ppstate; namespace scm { DLocalSymtab::DLocalSymtab(DLocalSymtab * p, - size_type n) : parent_{p}, - capacity_{n}, - size_{0} + DArray * vars, DArray * types) + : parent_{p}, vars_{vars}, types_{types} { - for (size_type i = 0; i < n; ++i) { - void * mem = &slots_[i]; - new (mem) Slot(); - } } DLocalSymtab * DLocalSymtab::_make_empty(obj mm, DLocalSymtab * p, - size_type n) + size_type nv, + size_type nt) { - void * mem = mm.alloc(typeseq::id(), - sizeof(DLocalSymtab) + (n * sizeof(Slot))); + void * mem = mm.alloc_for(); - return new (mem) DLocalSymtab(p, n); + DArray * vars = DArray::empty(mm, nv); + DArray * types = DArray::empty(mm, nt); + + return new (mem) DLocalSymtab(p, vars, types); + } + + DVariable * + DLocalSymtab::lookup_var(Binding ix) noexcept + { + assert(ix.i_link() == 0); + assert(ix.j_slot() < static_cast(vars_->size())); + + auto var = obj::from((*vars_)[ix.j_slot()]); + + assert(var); + + return var.data(); } Binding @@ -46,32 +60,50 @@ namespace xo { { assert(name); - if (size_ >= capacity_ || !name) { + if (vars_->size() >= vars_->capacity() || !name) { assert(false); return Binding::null(); } else { - size_type i_slot = (this->size_)++; - Binding binding = Binding::local(i_slot); - DVariable * var = DVariable::make(mm, name, typeref, binding); + //size_type i_slot = (this->size_)++; + Binding binding = Binding::local(vars_->size()); - this->slots_[i_slot] = Slot(var); + DVariable * var = DVariable::make(mm, name, typeref, binding); + vars_->push_back(obj(var)); return binding; } } + void + DLocalSymtab::append_type(obj mm, + const DUniqueString * name, + obj type) + { + assert(name); + + if (types_->size() >= types_->capacity() || !name) { + assert(false); + } else { + obj tname = DTypename::make(mm, name, type); + + types_->push_back(tname); + } + } + Binding DLocalSymtab::lookup_binding(const DUniqueString * sym) const noexcept { assert(sym); if (sym) { - for (size_type i = 0; i < size_; ++i) { - const Slot & slot = slots_[i]; + for (size_type i = 0, n = vars_->size(); i < n; ++i) { + auto var_i = obj::from((*vars_)[i]); - if (*sym == *(slot.var_->name())) - return slot.var_->path(); + assert(var_i); + + if (*sym == *(var_i->name())) + return var_i->path(); } } @@ -83,39 +115,21 @@ namespace xo { std::size_t DLocalSymtab::shallow_size() const noexcept { - return (sizeof(DLocalSymtab) + (capacity_ * sizeof(Slot))); + return sizeof(DLocalSymtab); } DLocalSymtab * DLocalSymtab::shallow_copy(obj mm) const noexcept { - DLocalSymtab * copy = (DLocalSymtab *)mm.alloc_copy((std::byte *)this); - - if (copy) { - *copy = *this; - - ::memcpy((void*)&(copy->slots_[0]), - (void*)&(slots_[0]), - capacity_ * sizeof(Slot)); - } - - return copy; + return mm.std_copy_for(this); } std::size_t DLocalSymtab::forward_children(obj gc) noexcept { - { - auto iface - = xo::facet::impl_for(); - gc.forward_inplace(&iface, (void **)(&parent_)); - } - - auto iface - = xo::facet::impl_for(); - for (size_type i = 0; i < size_; ++i) { - gc.forward_inplace(&iface, (void **)(&(slots_[i].var_))); - } + gc.forward_inplace(&parent_); + gc.forward_inplace(&vars_); + gc.forward_inplace(&types_); return shallow_size(); } @@ -127,45 +141,69 @@ namespace xo { { ppstate * pps = ppii.pps(); + (void)pps; + if (ppii.upto()) { /* perhaps print on one line */ if (!pps->print_upto("print_upto(xrefrtag("size", size_))) + + if (!pps->print_upto(xrefrtag("nvars", vars_->size()))) return false; - for (size_type i = 0; i < size_; ++i) { + for (size_type i = 0, n = vars_->size(); i arg_pr(const_cast(slots_[i].var_)); + obj arg_pr = (*vars_)[i].to_facet(); if (!pps->print_upto(xrefrtag(buf, arg_pr))) return false; } + if (!pps->print_upto(xrefrtag("ntypes", types_->size()))) + return false; + + for (size_type i = 0, n = types_->size(); i < n; ++i) { + char buf[32]; + snprintf(buf, sizeof(buf), "[%u]", i); + + obj type_pr = (*types_)[i].to_facet(); + + if (!pps->print_upto(xrefrtag(buf, type_pr))) + return false; + } + pps->write(">"); return true; } else { /* with line breaks */ pps->write("newline_pretty_tag(ppii.ci1(), "size", size_); + pps->newline_pretty_tag(ppii.ci1(), "nvars", vars_->size()); - for (size_type i = 0; i < size_; ++i) { + for (size_type i = 0, n = vars_->size(); i < n; ++i) { char buf[32]; snprintf(buf, sizeof(buf), "[%u]", i); - assert(slots_[i].var_); - - obj arg_pr(const_cast(slots_[i].var_)); + obj arg_pr = (*vars_)[i].to_facet(); pps->newline_pretty_tag(ppii.ci1(), buf, arg_pr); } + pps->newline_pretty_tag(ppii.ci1(), "ntypes", types_->size()); + + for (size_type i = 0, n = types_->size(); i < n; ++i) { + char buf[32]; + snprintf(buf, sizeof(buf), "[%u]", i); + + obj type_pr = (*types_)[i].to_facet(); + + pps->newline_pretty_tag(ppii.ci1(), buf, type_pr); + } + pps->write(">"); + return false; } } diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index fdc73b8e..141d4946 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -22,6 +22,12 @@ namespace xo { namespace scm { + DSequenceExpr::DSequenceExpr() = default; + + DSequenceExpr::DSequenceExpr(DArray * xv) + : expr_v_{xv} + {} + obj DSequenceExpr::make_empty(obj mm) { @@ -127,13 +133,13 @@ namespace xo { std::size_t DSequenceExpr::forward_children(obj gc) noexcept { - // WARNING. - // if this proves problematic, - // may resort to obj for expr_v_ member + typeref_.forward_children(gc); - auto iface = facet::impl_for(); - - gc.forward_inplace(&iface, (void**)&expr_v_); + { + //auto iface = facet::impl_for(); + //gc.forward_inplace(&iface, (void**)&expr_v_); + gc.forward_inplace(&expr_v_); + } return this->shallow_size(); } diff --git a/src/expression2/DTypename.cpp b/src/expression2/DTypename.cpp new file mode 100644 index 00000000..fd62336b --- /dev/null +++ b/src/expression2/DTypename.cpp @@ -0,0 +1,89 @@ +/** @file DTypename.cpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#include "Typename.hpp" +#include +#include +#include +#include +#include + +namespace xo { + using xo::mm::ACollector; + using xo::mm::AGCObject; + using xo::print::APrintable; + + namespace scm { + + DTypename * + DTypename::_make(obj mm, + const DUniqueString * name, + obj type) + { + void * mem = mm.alloc_for(); + + return new (mem) DTypename(name, type); + } + + obj + DTypename::make(obj mm, + const DUniqueString * name, + obj type) + { + return obj(_make(mm, name, type)); + } + + DTypename::DTypename(const DUniqueString * name, + obj type) + : name_{name}, type_{type} + {} + + size_t + DTypename::shallow_size() const noexcept + { + return sizeof(DTypename); + } + + DTypename * + DTypename::shallow_copy(obj mm) const noexcept + { + return mm.std_copy_for(this); + } + + size_t + DTypename::forward_children(obj gc) noexcept + { + gc.forward_inplace(const_cast(&name_)); + { + auto e = type_.to_facet(); + gc.forward_inplace(e.iface(), (void **)&(type_.data_)); + } + + return shallow_size(); + } + + bool + DTypename::pretty(const ppindentinfo & ppii) const + { + using xo::print::quot; + + auto name = (name_ + ? std::string_view(*name_) + : std::string_view("")); + + auto type_pr = type_.to_facet(); + + return ppii.pps()->pretty_struct + (ppii, + "DTypename" + , refrtag("name", quot(name)) + , refrtag("type", type_pr) + ); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end DTypename.cpp */ diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index 8fc201a5..092eb715 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -57,12 +57,9 @@ namespace xo { } size_t - DVariable::forward_children(obj) noexcept + DVariable::forward_children(obj gc) noexcept { - // nothing to collect. - // - DUniqueString never in GC space - // - TypeDescr not in GC space - // - path only integers + typeref_.forward_children(gc); return shallow_size(); } diff --git a/src/expression2/IGCObject_DTypename.cpp b/src/expression2/IGCObject_DTypename.cpp new file mode 100644 index 00000000..2b898fbf --- /dev/null +++ b/src/expression2/IGCObject_DTypename.cpp @@ -0,0 +1,39 @@ +/** @file IGCObject_DTypename.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IGCObject_DTypename.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IGCObject_DTypename.json5] +**/ + +#include "typename/IGCObject_DTypename.hpp" + +namespace xo { + namespace scm { + auto + IGCObject_DTypename::shallow_size(const DTypename & self) noexcept -> size_type + { + return self.shallow_size(); + } + + auto + IGCObject_DTypename::shallow_copy(const DTypename & self, obj mm) noexcept -> Opaque + { + return self.shallow_copy(mm); + } + + auto + IGCObject_DTypename::forward_children(DTypename & self, obj gc) noexcept -> size_type + { + return self.forward_children(gc); + } + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IGCObject_DTypename.cpp */ diff --git a/src/expression2/IPrintable_DTypename.cpp b/src/expression2/IPrintable_DTypename.cpp new file mode 100644 index 00000000..8d753b0e --- /dev/null +++ b/src/expression2/IPrintable_DTypename.cpp @@ -0,0 +1,28 @@ +/** @file IPrintable_DTypename.cpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/IPrintable_DTypename.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/IPrintable_DTypename.json5] +**/ + +#include "typename/IPrintable_DTypename.hpp" + +namespace xo { + namespace scm { + auto + IPrintable_DTypename::pretty(const DTypename & self, const ppindentinfo & ppii) -> bool + { + return self.pretty(ppii); + } + + + } /*namespace scm*/ +} /*namespace xo*/ + +/* end IPrintable_DTypename.cpp */ diff --git a/src/expression2/TypeRef.cpp b/src/expression2/TypeRef.cpp index 5ff1d258..4040cf13 100644 --- a/src/expression2/TypeRef.cpp +++ b/src/expression2/TypeRef.cpp @@ -4,16 +4,34 @@ **/ #include "TypeRef.hpp" +#include +#include #include #include #include namespace xo { + using xo::mm::AGCObject; + using xo::facet::FacetRegistry; + namespace scm { + TypeRef::TypeRef(const type_var & id, obj type) + : id_{id}, type_{type} + {} + TypeRef::TypeRef(const type_var & id, TypeDescr td) : id_{id}, td_{td} {} + TypeRef + TypeRef::resolved(obj type) + { + assert(type); + + type_var null; + return TypeRef(null, type); + } + TypeRef TypeRef::resolved(TypeDescr td) { @@ -23,6 +41,23 @@ namespace xo { return TypeRef(null, td); } + TypeRef + TypeRef::dwim(prefix_type prefix, obj type) + { + if (type) { + /* type already resolved + * -> we don't need a type variable name + */ + return TypeRef::resolved(type); + } else { + /* type is not resolved yet. + * -> give it a unique name, + * to seed unification + */ + return TypeRef(generate_unique(prefix), type); + } + } + TypeRef TypeRef::dwim(prefix_type prefix, TypeDescr td) { @@ -65,6 +100,15 @@ namespace xo { return (td_ != nullptr); } + void + TypeRef::forward_children(obj gc) noexcept + { + { + auto e = FacetRegistry::instance().variant(type_); + gc.forward_inplace(e.iface(), (void **)&(type_.data_)); + } + } + bool TypeRef::pretty(const ppindentinfo & ppii) const { diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/expression2_register_facets.cpp index 3cd9413d..1e68c771 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/expression2_register_facets.cpp @@ -5,11 +5,13 @@ #include "expression2_register_facets.hpp" -#include -#include -#include +//#include +//#include +//#include #include +#include +#include #include #include #include @@ -83,6 +85,11 @@ namespace xo { FacetRegistry::register_impl(); FacetRegistry::register_impl(); + // Typename + + FacetRegistry::register_impl(); + FacetRegistry::register_impl(); + // SymbolTable // +- LocalSymtab // \- GlobalSymtab @@ -103,6 +110,7 @@ namespace xo { log && log(xtag("DUniqueString.tseq", typeseq::id())); log && log(xtag("DDefineExpr.tseq", typeseq::id())); log && log(xtag("DVariable.tseq", typeseq::id())); + log && log(xtag("DTypename.tseq", typeseq::id())); log && log(xtag("DVarRef.tseq", typeseq::id())); log && log(xtag("DConstant.tseq", typeseq::id())); log && log(xtag("DApplyExpr.tseq", typeseq::id())); diff --git a/src/expression2/expression2_register_types.cpp b/src/expression2/expression2_register_types.cpp index 7a64eb1f..c62ea264 100644 --- a/src/expression2/expression2_register_types.cpp +++ b/src/expression2/expression2_register_types.cpp @@ -5,14 +5,17 @@ #include "expression2_register_types.hpp" +#include "DefineExpr.hpp" #include "Constant.hpp" -//#include "detail/IGCObject_DConstant.hpp" -#include "detail/IGCObject_DVariable.hpp" +#include "Variable.hpp" +#include "Typename.hpp" //#include "detail/IGCObject_DDefineExpr.hpp" // when avail //#include "detail/IGCObject_DApplyExpr.hpp" // when avail -//#include "detail/IGCObject_DLambdaExpr.hpp" // when avail -#include "detail/IGCObject_DIfElseExpr.hpp" -#include "detail/IGCObject_DSequenceExpr.hpp" +#include "LambdaExpr.hpp" +#include "IfElseExpr.hpp" +#include "SequenceExpr.hpp" +#include "LocalSymtab.hpp" +#include "GlobalSymtab.hpp" //#include "detail/IGCObject_DLocalSymtab.hpp" // when avail //#include "detail/IGCObject_DUniqueString.hpp" @@ -24,7 +27,6 @@ namespace xo { using xo::mm::ACollector; using xo::mm::AGCObject; using xo::facet::impl_for; - using xo::facet::typeseq; using xo::scope; namespace scm { @@ -37,13 +39,15 @@ namespace xo { ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); - //ok &= gc.install_type(impl_for()); // when avail + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); //ok &= gc.install_type(impl_for()); // when avail - //ok &= gc.install_type(impl_for()); // when avail + ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); - //ok &= gc.install_type(impl_for()); // when avail + ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); return ok; } From 3476557e1ed0f8fd5d23563b3b6ba93d3990d726 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 08:41:57 -0500 Subject: [PATCH 096/128] build: retiring REPR argument to xo_add_genfacetimpl() --- CMakeLists.txt | 64 +++++++++---------- .../define/IGCObject_DDefineExpr.hpp | 4 +- .../detail/IGCObject_DApplyExpr.hpp | 4 +- .../detail/IGCObject_DConstant.hpp | 4 +- .../detail/IGCObject_DIfElseExpr.hpp | 4 +- .../detail/IGCObject_DLambdaExpr.hpp | 4 +- .../detail/IGCObject_DSequenceExpr.hpp | 4 +- .../expression2/detail/IGCObject_DVarRef.hpp | 4 +- .../detail/IGCObject_DVariable.hpp | 4 +- .../symtab/IGCObject_DGlobalSymtab.hpp | 4 +- .../symtab/IGCObject_DLocalSymtab.hpp | 4 +- 11 files changed, 52 insertions(+), 52 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1af09c58..87f733bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -38,7 +38,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-symboltable-localsymtab FACET_PKG xo_expression2 FACET SymbolTable - REPR LocalSymtab +# REPR LocalSymtab INPUT idl/ISymbolTable_DLocalSymtab.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab @@ -49,7 +49,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-localsymtab FACET_PKG xo_alloc2 FACET GCObject - REPR LocalSymtab +# REPR LocalSymtab INPUT idl/IGCObject_DLocalSymtab.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab @@ -60,7 +60,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-localsymtab FACET_PKG xo_printable2 FACET Printable - REPR LocalSymtab +# REPR LocalSymtab INPUT idl/IPrintable_DLocalSymtab.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab @@ -73,7 +73,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-symboltable-globalsymtab FACET_PKG xo_expression2 FACET SymbolTable - REPR GlobalSymtab +# REPR GlobalSymtab INPUT idl/ISymbolTable_DGlobalSymtab.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab @@ -84,7 +84,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-globalsymtab FACET_PKG xo_alloc2 FACET GCObject - REPR GlobalSymtab +# REPR GlobalSymtab INPUT idl/IGCObject_DGlobalSymtab.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab @@ -95,7 +95,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-globalsymtab FACET_PKG xo_printable2 FACET Printable - REPR GlobalSymtab +# REPR GlobalSymtab INPUT idl/IPrintable_DGlobalSymtab.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab @@ -119,7 +119,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-constant FACET_PKG xo_expression2 FACET Expression - REPR Constant +# REPR Constant INPUT idl/IExpression_DConstant.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -130,7 +130,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-constant FACET_PKG xo_alloc2 FACET GCObject - REPR Constant +# REPR Constant INPUT idl/IGCObject_DConstant.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -141,7 +141,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-constant FACET_PKG xo_printable2 FACET Printable - REPR Constant +# REPR Constant INPUT idl/IPrintable_DConstant.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -154,7 +154,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-variable FACET_PKG xo_expression2 FACET Expression - REPR Variable +# REPR Variable INPUT idl/IExpression_DVariable.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -165,7 +165,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-variable FACET_PKG xo_alloc2 FACET GCObject - REPR Variable +# REPR Variable INPUT idl/IGCObject_DVariable.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -176,7 +176,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-variable FACET_PKG xo_printable2 FACET Printable - REPR Variable +# REPR Variable INPUT idl/IPrintable_DVariable.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -189,7 +189,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-typename FACET_PKG xo_alloc2 FACET GCObject - REPR Typename +# REPR Typename INPUT idl/IGCObject_DTypename.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR typename @@ -200,7 +200,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-typename FACET_PKG xo_printable2 FACET Printable - REPR Typename +# REPR Typename INPUT idl/IPrintable_DTypename.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR typename @@ -213,7 +213,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-varref FACET_PKG xo_expression2 FACET Expression - REPR VarRef +# REPR VarRef INPUT idl/IExpression_DVarRef.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -224,7 +224,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-varref FACET_PKG xo_alloc2 FACET GCObject - REPR VarRef +# REPR VarRef INPUT idl/IGCObject_DVarRef.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -235,7 +235,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-varref FACET_PKG xo_printable2 FACET Printable - REPR VarRef +# REPR VarRef INPUT idl/IPrintable_DVarRef.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -248,7 +248,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-defineexpr FACET_PKG xo_expression2 FACET Expression - REPR DefineExpr +# REPR DefineExpr INPUT idl/IExpression_DDefineExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -259,7 +259,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-defineexpr FACET_PKG xo_alloc2 FACET GCObject - REPR DefineExpr +# REPR DefineExpr INPUT idl/IGCObject_DDefineExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR define @@ -270,7 +270,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-defineexpr FACET_PKG xo_printable2 FACET Printable - REPR DefineExpr +# REPR DefineExpr INPUT idl/IPrintable_DDefineExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -283,7 +283,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-applyexpr FACET_PKG xo_expression2 FACET Expression - REPR ApplyExpr +# REPR ApplyExpr INPUT idl/IExpression_DApplyExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -294,7 +294,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-applyexpr FACET_PKG xo_alloc2 FACET GCObject - REPR ApplyExpr +# REPR ApplyExpr INPUT idl/IGCObject_DApplyExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -305,7 +305,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-applyexpr FACET_PKG xo_printable2 FACET Printable - REPR ApplyExpr +# REPR ApplyExpr INPUT idl/IPrintable_DApplyExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -318,7 +318,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-lambdaexpr FACET_PKG xo_expression2 FACET Expression - REPR LambdaExpr +# REPR LambdaExpr INPUT idl/IExpression_DLambdaExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -329,7 +329,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-lambdaexpr FACET_PKG xo_alloc2 FACET GCObject - REPR LambdaExpr +# REPR LambdaExpr INPUT idl/IGCObject_DLambdaExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -340,7 +340,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-lambdaexpr FACET_PKG xo_printable2 FACET Printable - REPR LambdaExpr +# REPR LambdaExpr INPUT idl/IPrintable_DLambdaExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -353,7 +353,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-ifelseexpr FACET_PKG xo_expression2 FACET Expression - REPR IfElseExpr +# REPR IfElseExpr INPUT idl/IExpression_DIfElseExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -364,7 +364,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-ifelseexpr FACET_PKG xo_alloc2 FACET GCObject - REPR IfElseExpr +# REPR IfElseExpr INPUT idl/IGCObject_DIfElseExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -375,7 +375,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-ifelseexpr FACET_PKG xo_printable2 FACET Printable - REPR IfElseExpr +# REPR IfElseExpr INPUT idl/IPrintable_DIfElseExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -388,7 +388,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-sequenceexpr FACET_PKG xo_expression2 FACET Expression - REPR SequenceExpr +# REPR SequenceExpr INPUT idl/IExpression_DSequenceExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -399,7 +399,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-sequenceexpr FACET_PKG xo_alloc2 FACET GCObject - REPR SequenceExpr +# REPR SequenceExpr INPUT idl/IGCObject_DSequenceExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail @@ -410,7 +410,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-sequenceexpr FACET_PKG xo_printable2 FACET Printable - REPR SequenceExpr +# REPR SequenceExpr INPUT idl/IPrintable_DSequenceExpr.json5 OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp index 321ce4e9..216dd18b 100644 --- a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DDefineExpr.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp index f0bf15ff..10b08c10 100644 --- a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DApplyExpr.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp index da593190..871f9c91 100644 --- a/include/xo/expression2/detail/IGCObject_DConstant.hpp +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DConstant.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp index 20cea34f..6a47d9b8 100644 --- a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DIfElseExpr.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp index 2f4e72e0..7d1ba5b0 100644 --- a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DLambdaExpr.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index 51009ecd..1f6b8deb 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DSequenceExpr.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp index 487e2832..e991ebb8 100644 --- a/include/xo/expression2/detail/IGCObject_DVarRef.hpp +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVarRef.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/detail/IGCObject_DVariable.hpp b/include/xo/expression2/detail/IGCObject_DVariable.hpp index 4728746f..242f335f 100644 --- a/include/xo/expression2/detail/IGCObject_DVariable.hpp +++ b/include/xo/expression2/detail/IGCObject_DVariable.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVariable.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp index f136b513..92149015 100644 --- a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DGlobalSymtab.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp index cc770261..94b9e279 100644 --- a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DLocalSymtab.hpp" @@ -64,4 +64,4 @@ namespace xo { } /*namespace scm*/ } /*namespace xo*/ -/* end */ +/* end */ \ No newline at end of file From 55ae44d3089fe32c18549d27fdf94f1c48d2af7b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 08:49:03 -0500 Subject: [PATCH 097/128] xo-interpreter2 stack: bugfix after GCObject facet location change --- idl/IGCObject_DApplyExpr.json5 | 2 +- idl/IGCObject_DConstant.json5 | 2 +- idl/IGCObject_DDefineExpr.json5 | 2 +- idl/IGCObject_DGlobalSymtab.json5 | 2 +- idl/IGCObject_DIfElseExpr.json5 | 2 +- idl/IGCObject_DLambdaExpr.json5 | 2 +- idl/IGCObject_DLocalSymtab.json5 | 2 +- idl/IGCObject_DSequenceExpr.json5 | 2 +- idl/IGCObject_DVarRef.json5 | 2 +- idl/IGCObject_DVariable.json5 | 2 +- include/xo/expression2/define/IGCObject_DDefineExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DApplyExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DConstant.hpp | 2 +- include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DVarRef.hpp | 2 +- include/xo/expression2/detail/IGCObject_DVariable.hpp | 2 +- include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp | 2 +- include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp | 2 +- 20 files changed, 20 insertions(+), 20 deletions(-) diff --git a/idl/IGCObject_DApplyExpr.json5 b/idl/IGCObject_DApplyExpr.json5 index 60f997c8..fd1d528a 100644 --- a/idl/IGCObject_DApplyExpr.json5 +++ b/idl/IGCObject_DApplyExpr.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/expression2", output_impl_subdir: "detail", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DConstant.json5 b/idl/IGCObject_DConstant.json5 index 961f39bb..5e598b95 100644 --- a/idl/IGCObject_DConstant.json5 +++ b/idl/IGCObject_DConstant.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/expression2", output_impl_subdir: "detail", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DDefineExpr.json5 b/idl/IGCObject_DDefineExpr.json5 index 6b0eba68..2509897b 100644 --- a/idl/IGCObject_DDefineExpr.json5 +++ b/idl/IGCObject_DDefineExpr.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/expression2", output_impl_subdir: "define", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DGlobalSymtab.json5 b/idl/IGCObject_DGlobalSymtab.json5 index ac779ec2..858a5eab 100644 --- a/idl/IGCObject_DGlobalSymtab.json5 +++ b/idl/IGCObject_DGlobalSymtab.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/expression2", output_impl_subdir: "symtab", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DIfElseExpr.json5 b/idl/IGCObject_DIfElseExpr.json5 index 6fb8c07a..bd0b183c 100644 --- a/idl/IGCObject_DIfElseExpr.json5 +++ b/idl/IGCObject_DIfElseExpr.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/expression2", output_impl_subdir: "detail", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DLambdaExpr.json5 b/idl/IGCObject_DLambdaExpr.json5 index a0f494ff..7913a6bc 100644 --- a/idl/IGCObject_DLambdaExpr.json5 +++ b/idl/IGCObject_DLambdaExpr.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/expression2", output_impl_subdir: "detail", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DLocalSymtab.json5 b/idl/IGCObject_DLocalSymtab.json5 index ec8260a0..807a229a 100644 --- a/idl/IGCObject_DLocalSymtab.json5 +++ b/idl/IGCObject_DLocalSymtab.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/expression2", output_impl_subdir: "symtab", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DSequenceExpr.json5 b/idl/IGCObject_DSequenceExpr.json5 index 1fc67e48..b8c06cbc 100644 --- a/idl/IGCObject_DSequenceExpr.json5 +++ b/idl/IGCObject_DSequenceExpr.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/expression2", output_impl_subdir: "detail", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DVarRef.json5 b/idl/IGCObject_DVarRef.json5 index 6c1bad33..2cbc4715 100644 --- a/idl/IGCObject_DVarRef.json5 +++ b/idl/IGCObject_DVarRef.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/expression2", output_impl_subdir: "detail", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/idl/IGCObject_DVariable.json5 b/idl/IGCObject_DVariable.json5 index 6bea1dc3..b9f27623 100644 --- a/idl/IGCObject_DVariable.json5 +++ b/idl/IGCObject_DVariable.json5 @@ -4,7 +4,7 @@ output_hpp_dir: "include/xo/expression2", output_impl_subdir: "detail", includes: [ - "", + "", "" ], local_types: [ ], diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp index 216dd18b..8e516773 100644 --- a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DDefineExpr.hpp" diff --git a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp index 10b08c10..effcd01c 100644 --- a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DApplyExpr.hpp" diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp index 871f9c91..608d4d6a 100644 --- a/include/xo/expression2/detail/IGCObject_DConstant.hpp +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DConstant.hpp" diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp index 6a47d9b8..63fdb6ee 100644 --- a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DIfElseExpr.hpp" diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp index 7d1ba5b0..91bb24da 100644 --- a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DLambdaExpr.hpp" diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index 1f6b8deb..20d21159 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DSequenceExpr.hpp" diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp index e991ebb8..228e74c0 100644 --- a/include/xo/expression2/detail/IGCObject_DVarRef.hpp +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVarRef.hpp" diff --git a/include/xo/expression2/detail/IGCObject_DVariable.hpp b/include/xo/expression2/detail/IGCObject_DVariable.hpp index 242f335f..0b23f630 100644 --- a/include/xo/expression2/detail/IGCObject_DVariable.hpp +++ b/include/xo/expression2/detail/IGCObject_DVariable.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DVariable.hpp" diff --git a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp index 92149015..fe487e1a 100644 --- a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DGlobalSymtab.hpp" diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp index 94b9e279..6c0ec0c7 100644 --- a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -14,7 +14,7 @@ #pragma once #include "GCObject.hpp" -#include +#include #include #include "DLocalSymtab.hpp" From b1a9e47615d09d7160f7d8524455c15cc676a697 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 09:39:20 -0500 Subject: [PATCH 098/128] xo-expression2: retire redundant OUTPUT_HPP_DIR in genfacetimpl --- CMakeLists.txt | 33 --------------------------------- 1 file changed, 33 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 87f733bb..c457eca8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,6 @@ xo_add_genfacetimpl( FACET SymbolTable # REPR LocalSymtab INPUT idl/ISymbolTable_DLocalSymtab.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab ) @@ -51,7 +50,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR LocalSymtab INPUT idl/IGCObject_DLocalSymtab.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab ) @@ -62,7 +60,6 @@ xo_add_genfacetimpl( FACET Printable # REPR LocalSymtab INPUT idl/IPrintable_DLocalSymtab.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab ) @@ -75,7 +72,6 @@ xo_add_genfacetimpl( FACET SymbolTable # REPR GlobalSymtab INPUT idl/ISymbolTable_DGlobalSymtab.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab ) @@ -86,7 +82,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR GlobalSymtab INPUT idl/IGCObject_DGlobalSymtab.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab ) @@ -97,7 +92,6 @@ xo_add_genfacetimpl( FACET Printable # REPR GlobalSymtab INPUT idl/IPrintable_DGlobalSymtab.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR symtab ) @@ -121,7 +115,6 @@ xo_add_genfacetimpl( FACET Expression # REPR Constant INPUT idl/IExpression_DConstant.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -132,7 +125,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR Constant INPUT idl/IGCObject_DConstant.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -143,7 +135,6 @@ xo_add_genfacetimpl( FACET Printable # REPR Constant INPUT idl/IPrintable_DConstant.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -156,7 +147,6 @@ xo_add_genfacetimpl( FACET Expression # REPR Variable INPUT idl/IExpression_DVariable.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -167,7 +157,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR Variable INPUT idl/IGCObject_DVariable.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -178,7 +167,6 @@ xo_add_genfacetimpl( FACET Printable # REPR Variable INPUT idl/IPrintable_DVariable.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -191,7 +179,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR Typename INPUT idl/IGCObject_DTypename.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR typename ) @@ -202,7 +189,6 @@ xo_add_genfacetimpl( FACET Printable # REPR Typename INPUT idl/IPrintable_DTypename.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR typename ) @@ -215,7 +201,6 @@ xo_add_genfacetimpl( FACET Expression # REPR VarRef INPUT idl/IExpression_DVarRef.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -226,7 +211,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR VarRef INPUT idl/IGCObject_DVarRef.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -237,7 +221,6 @@ xo_add_genfacetimpl( FACET Printable # REPR VarRef INPUT idl/IPrintable_DVarRef.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -250,7 +233,6 @@ xo_add_genfacetimpl( FACET Expression # REPR DefineExpr INPUT idl/IExpression_DDefineExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -261,7 +243,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR DefineExpr INPUT idl/IGCObject_DDefineExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR define ) @@ -272,7 +253,6 @@ xo_add_genfacetimpl( FACET Printable # REPR DefineExpr INPUT idl/IPrintable_DDefineExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -285,7 +265,6 @@ xo_add_genfacetimpl( FACET Expression # REPR ApplyExpr INPUT idl/IExpression_DApplyExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -296,7 +275,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR ApplyExpr INPUT idl/IGCObject_DApplyExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -307,7 +285,6 @@ xo_add_genfacetimpl( FACET Printable # REPR ApplyExpr INPUT idl/IPrintable_DApplyExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -320,7 +297,6 @@ xo_add_genfacetimpl( FACET Expression # REPR LambdaExpr INPUT idl/IExpression_DLambdaExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -331,7 +307,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR LambdaExpr INPUT idl/IGCObject_DLambdaExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -342,7 +317,6 @@ xo_add_genfacetimpl( FACET Printable # REPR LambdaExpr INPUT idl/IPrintable_DLambdaExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -355,7 +329,6 @@ xo_add_genfacetimpl( FACET Expression # REPR IfElseExpr INPUT idl/IExpression_DIfElseExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -366,7 +339,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR IfElseExpr INPUT idl/IGCObject_DIfElseExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -377,7 +349,6 @@ xo_add_genfacetimpl( FACET Printable # REPR IfElseExpr INPUT idl/IPrintable_DIfElseExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -390,7 +361,6 @@ xo_add_genfacetimpl( FACET Expression # REPR SequenceExpr INPUT idl/IExpression_DSequenceExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -399,9 +369,7 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-sequenceexpr FACET_PKG xo_alloc2 FACET GCObject -# REPR SequenceExpr INPUT idl/IGCObject_DSequenceExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) @@ -412,7 +380,6 @@ xo_add_genfacetimpl( FACET Printable # REPR SequenceExpr INPUT idl/IPrintable_DSequenceExpr.json5 - OUTPUT_HPP_DIR include/xo/expression2 OUTPUT_IMPL_SUBDIR detail ) From 160443199bfc2569c44c3f7610e27e02ff3b0f60 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 09:49:19 -0500 Subject: [PATCH 099/128] xo-expression2: drop redundant OUTPUT_IMPL_SUBDIR args --- CMakeLists.txt | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c457eca8..08f152b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -40,7 +40,6 @@ xo_add_genfacetimpl( FACET SymbolTable # REPR LocalSymtab INPUT idl/ISymbolTable_DLocalSymtab.json5 - OUTPUT_IMPL_SUBDIR symtab ) # note: manual target; generated code committed to git @@ -50,7 +49,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR LocalSymtab INPUT idl/IGCObject_DLocalSymtab.json5 - OUTPUT_IMPL_SUBDIR symtab ) # note: manual target; generated code committed to git @@ -60,7 +58,6 @@ xo_add_genfacetimpl( FACET Printable # REPR LocalSymtab INPUT idl/IPrintable_DLocalSymtab.json5 - OUTPUT_IMPL_SUBDIR symtab ) # ---------------------------------------------------------------- @@ -72,7 +69,6 @@ xo_add_genfacetimpl( FACET SymbolTable # REPR GlobalSymtab INPUT idl/ISymbolTable_DGlobalSymtab.json5 - OUTPUT_IMPL_SUBDIR symtab ) # note: manual target; generated code committed to git @@ -82,7 +78,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR GlobalSymtab INPUT idl/IGCObject_DGlobalSymtab.json5 - OUTPUT_IMPL_SUBDIR symtab ) # note: manual target; generated code committed to git @@ -92,7 +87,6 @@ xo_add_genfacetimpl( FACET Printable # REPR GlobalSymtab INPUT idl/IPrintable_DGlobalSymtab.json5 - OUTPUT_IMPL_SUBDIR symtab ) # ---------------------------------------------------------------- @@ -115,7 +109,6 @@ xo_add_genfacetimpl( FACET Expression # REPR Constant INPUT idl/IExpression_DConstant.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -125,7 +118,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR Constant INPUT idl/IGCObject_DConstant.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -135,7 +127,6 @@ xo_add_genfacetimpl( FACET Printable # REPR Constant INPUT idl/IPrintable_DConstant.json5 - OUTPUT_IMPL_SUBDIR detail ) # ---------------------------------------------------------------- @@ -147,7 +138,6 @@ xo_add_genfacetimpl( FACET Expression # REPR Variable INPUT idl/IExpression_DVariable.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -157,7 +147,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR Variable INPUT idl/IGCObject_DVariable.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -167,7 +156,6 @@ xo_add_genfacetimpl( FACET Printable # REPR Variable INPUT idl/IPrintable_DVariable.json5 - OUTPUT_IMPL_SUBDIR detail ) # ---------------------------------------------------------------- @@ -179,7 +167,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR Typename INPUT idl/IGCObject_DTypename.json5 - OUTPUT_IMPL_SUBDIR typename ) # note: manual target; generated code committed to git @@ -189,7 +176,6 @@ xo_add_genfacetimpl( FACET Printable # REPR Typename INPUT idl/IPrintable_DTypename.json5 - OUTPUT_IMPL_SUBDIR typename ) # ---------------------------------------------------------------- @@ -201,7 +187,6 @@ xo_add_genfacetimpl( FACET Expression # REPR VarRef INPUT idl/IExpression_DVarRef.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -211,7 +196,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR VarRef INPUT idl/IGCObject_DVarRef.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -221,7 +205,6 @@ xo_add_genfacetimpl( FACET Printable # REPR VarRef INPUT idl/IPrintable_DVarRef.json5 - OUTPUT_IMPL_SUBDIR detail ) # ---------------------------------------------------------------- @@ -233,7 +216,6 @@ xo_add_genfacetimpl( FACET Expression # REPR DefineExpr INPUT idl/IExpression_DDefineExpr.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -243,7 +225,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR DefineExpr INPUT idl/IGCObject_DDefineExpr.json5 - OUTPUT_IMPL_SUBDIR define ) # note: manual target; generated code committed to git @@ -253,7 +234,6 @@ xo_add_genfacetimpl( FACET Printable # REPR DefineExpr INPUT idl/IPrintable_DDefineExpr.json5 - OUTPUT_IMPL_SUBDIR detail ) # ---------------------------------------------------------------- @@ -265,7 +245,6 @@ xo_add_genfacetimpl( FACET Expression # REPR ApplyExpr INPUT idl/IExpression_DApplyExpr.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -275,7 +254,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR ApplyExpr INPUT idl/IGCObject_DApplyExpr.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -285,7 +263,6 @@ xo_add_genfacetimpl( FACET Printable # REPR ApplyExpr INPUT idl/IPrintable_DApplyExpr.json5 - OUTPUT_IMPL_SUBDIR detail ) # ---------------------------------------------------------------- @@ -297,7 +274,6 @@ xo_add_genfacetimpl( FACET Expression # REPR LambdaExpr INPUT idl/IExpression_DLambdaExpr.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -307,7 +283,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR LambdaExpr INPUT idl/IGCObject_DLambdaExpr.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -317,7 +292,6 @@ xo_add_genfacetimpl( FACET Printable # REPR LambdaExpr INPUT idl/IPrintable_DLambdaExpr.json5 - OUTPUT_IMPL_SUBDIR detail ) # ---------------------------------------------------------------- @@ -329,7 +303,6 @@ xo_add_genfacetimpl( FACET Expression # REPR IfElseExpr INPUT idl/IExpression_DIfElseExpr.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -339,7 +312,6 @@ xo_add_genfacetimpl( FACET GCObject # REPR IfElseExpr INPUT idl/IGCObject_DIfElseExpr.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -349,7 +321,6 @@ xo_add_genfacetimpl( FACET Printable # REPR IfElseExpr INPUT idl/IPrintable_DIfElseExpr.json5 - OUTPUT_IMPL_SUBDIR detail ) # ---------------------------------------------------------------- @@ -361,7 +332,6 @@ xo_add_genfacetimpl( FACET Expression # REPR SequenceExpr INPUT idl/IExpression_DSequenceExpr.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -370,7 +340,6 @@ xo_add_genfacetimpl( FACET_PKG xo_alloc2 FACET GCObject INPUT idl/IGCObject_DSequenceExpr.json5 - OUTPUT_IMPL_SUBDIR detail ) # note: manual target; generated code committed to git @@ -380,7 +349,6 @@ xo_add_genfacetimpl( FACET Printable # REPR SequenceExpr INPUT idl/IPrintable_DSequenceExpr.json5 - OUTPUT_IMPL_SUBDIR detail ) # ---------------------------------------------------------------- From 04faa7177e577df101a93b803b8626d146cb1919 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 09:50:44 -0500 Subject: [PATCH 100/128] cosmetic --- CMakeLists.txt | 4 ---- 1 file changed, 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08f152b2..3dc7c5da 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -310,7 +310,6 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-ifelseexpr FACET_PKG xo_alloc2 FACET GCObject -# REPR IfElseExpr INPUT idl/IGCObject_DIfElseExpr.json5 ) @@ -319,7 +318,6 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-ifelseexpr FACET_PKG xo_printable2 FACET Printable -# REPR IfElseExpr INPUT idl/IPrintable_DIfElseExpr.json5 ) @@ -330,7 +328,6 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-sequenceexpr FACET_PKG xo_expression2 FACET Expression -# REPR SequenceExpr INPUT idl/IExpression_DSequenceExpr.json5 ) @@ -347,7 +344,6 @@ xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-sequenceexpr FACET_PKG xo_printable2 FACET Printable -# REPR SequenceExpr INPUT idl/IPrintable_DSequenceExpr.json5 ) From 5f33b643c20f42e2d5e017158f6e7bb5895becc8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Wed, 11 Mar 2026 10:03:46 -0500 Subject: [PATCH 101/128] build: retire FACET argument to genfacetimpl --- CMakeLists.txt | 32 -------------------------------- 1 file changed, 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3dc7c5da..b6fb40d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,6 @@ xo_add_genfacet( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-symboltable-localsymtab FACET_PKG xo_expression2 - FACET SymbolTable # REPR LocalSymtab INPUT idl/ISymbolTable_DLocalSymtab.json5 ) @@ -46,7 +45,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-localsymtab FACET_PKG xo_alloc2 - FACET GCObject # REPR LocalSymtab INPUT idl/IGCObject_DLocalSymtab.json5 ) @@ -55,7 +53,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-localsymtab FACET_PKG xo_printable2 - FACET Printable # REPR LocalSymtab INPUT idl/IPrintable_DLocalSymtab.json5 ) @@ -66,7 +63,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-symboltable-globalsymtab FACET_PKG xo_expression2 - FACET SymbolTable # REPR GlobalSymtab INPUT idl/ISymbolTable_DGlobalSymtab.json5 ) @@ -75,7 +71,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-globalsymtab FACET_PKG xo_alloc2 - FACET GCObject # REPR GlobalSymtab INPUT idl/IGCObject_DGlobalSymtab.json5 ) @@ -84,7 +79,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-globalsymtab FACET_PKG xo_printable2 - FACET Printable # REPR GlobalSymtab INPUT idl/IPrintable_DGlobalSymtab.json5 ) @@ -106,7 +100,6 @@ xo_add_genfacet( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-constant FACET_PKG xo_expression2 - FACET Expression # REPR Constant INPUT idl/IExpression_DConstant.json5 ) @@ -115,7 +108,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-constant FACET_PKG xo_alloc2 - FACET GCObject # REPR Constant INPUT idl/IGCObject_DConstant.json5 ) @@ -124,7 +116,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-constant FACET_PKG xo_printable2 - FACET Printable # REPR Constant INPUT idl/IPrintable_DConstant.json5 ) @@ -135,7 +126,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-variable FACET_PKG xo_expression2 - FACET Expression # REPR Variable INPUT idl/IExpression_DVariable.json5 ) @@ -144,7 +134,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-variable FACET_PKG xo_alloc2 - FACET GCObject # REPR Variable INPUT idl/IGCObject_DVariable.json5 ) @@ -153,7 +142,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-variable FACET_PKG xo_printable2 - FACET Printable # REPR Variable INPUT idl/IPrintable_DVariable.json5 ) @@ -164,7 +152,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-typename FACET_PKG xo_alloc2 - FACET GCObject # REPR Typename INPUT idl/IGCObject_DTypename.json5 ) @@ -173,7 +160,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-typename FACET_PKG xo_printable2 - FACET Printable # REPR Typename INPUT idl/IPrintable_DTypename.json5 ) @@ -184,7 +170,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-varref FACET_PKG xo_expression2 - FACET Expression # REPR VarRef INPUT idl/IExpression_DVarRef.json5 ) @@ -193,7 +178,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-varref FACET_PKG xo_alloc2 - FACET GCObject # REPR VarRef INPUT idl/IGCObject_DVarRef.json5 ) @@ -202,7 +186,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-varref FACET_PKG xo_printable2 - FACET Printable # REPR VarRef INPUT idl/IPrintable_DVarRef.json5 ) @@ -213,7 +196,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-defineexpr FACET_PKG xo_expression2 - FACET Expression # REPR DefineExpr INPUT idl/IExpression_DDefineExpr.json5 ) @@ -222,7 +204,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-defineexpr FACET_PKG xo_alloc2 - FACET GCObject # REPR DefineExpr INPUT idl/IGCObject_DDefineExpr.json5 ) @@ -231,7 +212,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-defineexpr FACET_PKG xo_printable2 - FACET Printable # REPR DefineExpr INPUT idl/IPrintable_DDefineExpr.json5 ) @@ -242,7 +222,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-applyexpr FACET_PKG xo_expression2 - FACET Expression # REPR ApplyExpr INPUT idl/IExpression_DApplyExpr.json5 ) @@ -251,7 +230,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-applyexpr FACET_PKG xo_alloc2 - FACET GCObject # REPR ApplyExpr INPUT idl/IGCObject_DApplyExpr.json5 ) @@ -260,7 +238,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-applyexpr FACET_PKG xo_printable2 - FACET Printable # REPR ApplyExpr INPUT idl/IPrintable_DApplyExpr.json5 ) @@ -271,7 +248,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-lambdaexpr FACET_PKG xo_expression2 - FACET Expression # REPR LambdaExpr INPUT idl/IExpression_DLambdaExpr.json5 ) @@ -280,7 +256,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-lambdaexpr FACET_PKG xo_alloc2 - FACET GCObject # REPR LambdaExpr INPUT idl/IGCObject_DLambdaExpr.json5 ) @@ -289,7 +264,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-lambdaexpr FACET_PKG xo_printable2 - FACET Printable # REPR LambdaExpr INPUT idl/IPrintable_DLambdaExpr.json5 ) @@ -300,7 +274,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-ifelseexpr FACET_PKG xo_expression2 - FACET Expression # REPR IfElseExpr INPUT idl/IExpression_DIfElseExpr.json5 ) @@ -309,7 +282,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-ifelseexpr FACET_PKG xo_alloc2 - FACET GCObject INPUT idl/IGCObject_DIfElseExpr.json5 ) @@ -317,7 +289,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-ifelseexpr FACET_PKG xo_printable2 - FACET Printable INPUT idl/IPrintable_DIfElseExpr.json5 ) @@ -327,7 +298,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-expression-sequenceexpr FACET_PKG xo_expression2 - FACET Expression INPUT idl/IExpression_DSequenceExpr.json5 ) @@ -335,7 +305,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-gcobject-sequenceexpr FACET_PKG xo_alloc2 - FACET GCObject INPUT idl/IGCObject_DSequenceExpr.json5 ) @@ -343,7 +312,6 @@ xo_add_genfacetimpl( xo_add_genfacetimpl( TARGET xo-expression2-facetimpl-printable-sequenceexpr FACET_PKG xo_printable2 - FACET Printable INPUT idl/IPrintable_DSequenceExpr.json5 ) From 46c118fe29be585523e8ff6ac88fb11a68842485 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 12 Mar 2026 20:26:08 -0500 Subject: [PATCH 102/128] xo-interpreter2 stack: refactor + bugfix operator expr --- utest/DApplyExpr.test.cpp | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/utest/DApplyExpr.test.cpp b/utest/DApplyExpr.test.cpp index 17b3dca6..7854397d 100644 --- a/utest/DApplyExpr.test.cpp +++ b/utest/DApplyExpr.test.cpp @@ -92,7 +92,7 @@ namespace ut { REQUIRE(ok); // wrap primitive as GCObject, then as expression - obj prim_gco = with_facet::mkobj(&NumericPrimitives::s_mul_gco_gco_pm); + obj prim_gco = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc)); obj fn_expr = DConstant::make(alloc, prim_gco); REQUIRE(fn_expr.data() != nullptr); @@ -131,7 +131,8 @@ namespace ut { bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); - obj prim_gco = with_facet::mkobj(&NumericPrimitives::s_mul_gco_gco_pm); + obj prim_gco + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc)); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); @@ -166,7 +167,7 @@ namespace ut { bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); - obj prim_gco = with_facet::mkobj(&NumericPrimitives::s_mul_gco_gco_pm); + obj prim_gco = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc)); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); @@ -201,7 +202,7 @@ namespace ut { bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); - obj prim_gco = with_facet::mkobj(&NumericPrimitives::s_mul_gco_gco_pm); + obj prim_gco = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc)); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); @@ -283,7 +284,8 @@ namespace ut { bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); - obj prim_gco = with_facet::mkobj(&NumericPrimitives::s_mul_gco_gco_pm); + obj prim_gco + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc)); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); From 2713b82159627083448933b61a641949abd4942a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 12 Mar 2026 20:29:31 -0500 Subject: [PATCH 103/128] xo-expression2 utest: missed line for prev commit --- utest/DApplyExpr.test.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/utest/DApplyExpr.test.cpp b/utest/DApplyExpr.test.cpp index 7854397d..0f7f41ef 100644 --- a/utest/DApplyExpr.test.cpp +++ b/utest/DApplyExpr.test.cpp @@ -240,7 +240,8 @@ namespace ut { bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); - obj prim_gco = with_facet::mkobj(&NumericPrimitives::s_mul_gco_gco_pm); + obj prim_gco + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc)); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); From 48b010924dd0c8e6a39c67d9e6dda982065a4224 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 12 Mar 2026 20:39:34 -0500 Subject: [PATCH 104/128] xo-expression2: drop some debug --- src/expression2/DGlobalSymtab.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index d7f52228..65eea5a6 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -88,7 +88,7 @@ namespace xo { DGlobalSymtab::upsert_variable(obj mm, DVariable * var) { - scope log(XO_DEBUG(true), std::string_view(*var->name())); + scope log(XO_DEBUG(false), std::string_view(*var->name())); // It's possible there's already a global variable // with the same name. @@ -230,7 +230,7 @@ namespace xo { { assert(sym); - scope log(XO_DEBUG(true), std::string_view(*sym)); + scope log(XO_DEBUG(false), std::string_view(*sym)); auto ix = var_map_->find(sym); From 1075e166683c1b96c1a436fa58cad3712865c5d2 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 13:29:48 -0500 Subject: [PATCH 105/128] xo-numeric: type decoration for multiply --- utest/DApplyExpr.test.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/utest/DApplyExpr.test.cpp b/utest/DApplyExpr.test.cpp index 0f7f41ef..d3638da3 100644 --- a/utest/DApplyExpr.test.cpp +++ b/utest/DApplyExpr.test.cpp @@ -20,6 +20,8 @@ #include #include +#include + #include #include //#include @@ -45,6 +47,7 @@ namespace ut { using xo::scm::NumericPrimitives; using xo::scm::Primitives; using xo::scm::DPrimitive_gco_2_gco_gco; + using xo::scm::StringTable; using xo::mm::CollectorTypeRegistry; using xo::mm::AAllocator; using xo::mm::ACollector; @@ -87,12 +90,14 @@ namespace ut { DX1Collector gc(cfg); auto alloc = with_facet::mkobj(&gc); auto coll = with_facet::mkobj(&gc); + auto stbl = StringTable(1024 /*hint_max_capacity*/, false /*!debug_flag*/); bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); // wrap primitive as GCObject, then as expression - obj prim_gco = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc)); + obj prim_gco + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc, &stbl)); obj fn_expr = DConstant::make(alloc, prim_gco); REQUIRE(fn_expr.data() != nullptr); @@ -127,12 +132,13 @@ namespace ut { DX1Collector gc(cfg); auto alloc = with_facet::mkobj(&gc); auto coll = with_facet::mkobj(&gc); + auto stbl = StringTable(1024 /*hint_max_capacity*/, false /*!debug_flag*/); bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); obj prim_gco - = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc)); + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc, &stbl)); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); @@ -163,11 +169,13 @@ namespace ut { DX1Collector gc(cfg); auto alloc = with_facet::mkobj(&gc); auto coll = with_facet::mkobj(&gc); + auto stbl = StringTable(1024 /*hint_max_capacity*/, false /*!debug_flag*/); bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); - obj prim_gco = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc)); + obj prim_gco + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc, &stbl)); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); @@ -198,11 +206,13 @@ namespace ut { DX1Collector gc(cfg); auto alloc = with_facet::mkobj(&gc); auto coll = with_facet::mkobj(&gc); + auto stbl = StringTable(1024 /*hint_max_capacity*/, false /*!debug_flag*/); bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); - obj prim_gco = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc)); + obj prim_gco + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc, &stbl)); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); @@ -236,12 +246,13 @@ namespace ut { DX1Collector gc(cfg); auto alloc = with_facet::mkobj(&gc); auto coll = with_facet::mkobj(&gc); + auto stbl = StringTable(1024 /*hint_max_capacity*/, false /*!debug_flag*/); bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); obj prim_gco - = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc)); + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc, &stbl)); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); @@ -281,12 +292,13 @@ namespace ut { DX1Collector gc(cfg); auto alloc = with_facet::mkobj(&gc); auto coll = with_facet::mkobj(&gc); + auto stbl = StringTable(1024 /*hint_max_capacity*/, false /*!debug_flag*/); bool ok = CollectorTypeRegistry::instance().install_types(coll); REQUIRE(ok); obj prim_gco - = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc)); + = with_facet::mkobj(NumericPrimitives::make_multiply_pm(alloc, &stbl)); obj fn_expr = DConstant::make(alloc, prim_gco); obj val1 = DFloat::box(alloc, 3.0); From ba19c627e54ddf7d40112f258c56fbee39fe50c1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 16 Mar 2026 19:27:28 -0500 Subject: [PATCH 106/128] xo-expression2: streamline setup --- include/xo/expression2/SetupExpression2.hpp | 25 ++++++++ .../expression2_register_facets.hpp | 17 ------ .../expression2_register_types.hpp | 2 - src/expression2/CMakeLists.txt | 3 +- ...gister_facets.cpp => SetupExpression2.cpp} | 38 +++++++++---- .../expression2_register_types.cpp | 57 ------------------- src/expression2/init_expression2.cpp | 9 ++- 7 files changed, 58 insertions(+), 93 deletions(-) create mode 100644 include/xo/expression2/SetupExpression2.hpp delete mode 100644 include/xo/expression2/expression2_register_facets.hpp rename src/expression2/{expression2_register_facets.cpp => SetupExpression2.cpp} (80%) delete mode 100644 src/expression2/expression2_register_types.cpp diff --git a/include/xo/expression2/SetupExpression2.hpp b/include/xo/expression2/SetupExpression2.hpp new file mode 100644 index 00000000..819bdff6 --- /dev/null +++ b/include/xo/expression2/SetupExpression2.hpp @@ -0,0 +1,25 @@ +/** @file SetupExpression2.hpp + * + * @author Roland Conybeare, Jan 2026 + **/ + +#pragma once + +#include + +namespace xo { + namespace scm { + class SetupExpression2 { + public: + using ACollector = xo::mm::ACollector; + + public: + /** Register expression2 (facet,impl) combinations with FacetRegistry **/ + static bool register_facets(); + /** Register expression2 (facet,impl) combinations with FacetRegistry **/ + static bool register_types(obj gc); + }; + } +} + +/* end SetupExpression2.hpp */ diff --git a/include/xo/expression2/expression2_register_facets.hpp b/include/xo/expression2/expression2_register_facets.hpp deleted file mode 100644 index 1a559c72..00000000 --- a/include/xo/expression2/expression2_register_facets.hpp +++ /dev/null @@ -1,17 +0,0 @@ -/** @file expression2_register_facets.hpp - * - * @author Roland Conybeare, Jan 2026 - **/ - -#pragma once - -#include - -namespace xo { - namespace scm { - /** Register expression2 (facet,impl) combinations with FacetRegistry **/ - bool expression2_register_facets(); - } -} - -/* end expression2_register_facets.hpp */ diff --git a/include/xo/expression2/expression2_register_types.hpp b/include/xo/expression2/expression2_register_types.hpp index 58105eed..c19c3863 100644 --- a/include/xo/expression2/expression2_register_types.hpp +++ b/include/xo/expression2/expression2_register_types.hpp @@ -9,8 +9,6 @@ namespace xo { namespace scm { - /** Register expression2 (facet,impl) combinations with FacetRegistry **/ - bool expression2_register_types(obj gc); } } diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 42b491fc..574b9526 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -3,8 +3,7 @@ set(SELF_LIB xo_expression2) set(SELF_SRCS init_expression2.cpp - expression2_register_facets.cpp - expression2_register_types.cpp + SetupExpression2.cpp DConstant.cpp DVariable.cpp diff --git a/src/expression2/expression2_register_facets.cpp b/src/expression2/SetupExpression2.cpp similarity index 80% rename from src/expression2/expression2_register_facets.cpp rename to src/expression2/SetupExpression2.cpp index 1e68c771..5e86e795 100644 --- a/src/expression2/expression2_register_facets.cpp +++ b/src/expression2/SetupExpression2.cpp @@ -1,13 +1,9 @@ -/** @file expression2_register_facets.cpp +/** @file SetupExpression2.cpp * * @author Roland Conybeare, Jan 2026 **/ -#include "expression2_register_facets.hpp" - -//#include -//#include -//#include +#include "SetupExpression2.hpp" #include #include @@ -17,8 +13,8 @@ #include #include #include +#include -#include #include #include @@ -36,10 +32,11 @@ namespace xo { using xo::facet::FacetRegistry; using xo::facet::TypeRegistry; using xo::facet::typeseq; + using xo::facet::impl_for; namespace scm { bool - expression2_register_facets() + SetupExpression2::register_facets() { scope log(XO_DEBUG(true)); @@ -126,7 +123,28 @@ namespace xo { return true; } - } /*namespace scm*/ + + bool + SetupExpression2::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()); + //ok &= gc.install_type(impl_for()); // when avail + ok &= gc.install_type(impl_for()); + 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; + } } /*namespace scm*/ } /*namespace xo*/ -/* end expression2_register_facets.cpp */ +/* end SetupExpression2.cpp */ diff --git a/src/expression2/expression2_register_types.cpp b/src/expression2/expression2_register_types.cpp deleted file mode 100644 index c62ea264..00000000 --- a/src/expression2/expression2_register_types.cpp +++ /dev/null @@ -1,57 +0,0 @@ -/** @file expression2_register_types.cpp - * - * @author Roland Conybeare, Jan 2026 - **/ - -#include "expression2_register_types.hpp" - -#include "DefineExpr.hpp" -#include "Constant.hpp" -#include "Variable.hpp" -#include "Typename.hpp" -//#include "detail/IGCObject_DDefineExpr.hpp" // when avail -//#include "detail/IGCObject_DApplyExpr.hpp" // when avail -#include "LambdaExpr.hpp" -#include "IfElseExpr.hpp" -#include "SequenceExpr.hpp" -#include "LocalSymtab.hpp" -#include "GlobalSymtab.hpp" -//#include "detail/IGCObject_DLocalSymtab.hpp" // when avail -//#include "detail/IGCObject_DUniqueString.hpp" - -//#include "detail/IPrintable_DUniqueString.hpp" // when avail - -#include - -namespace xo { - using xo::mm::ACollector; - using xo::mm::AGCObject; - using xo::facet::impl_for; - using xo::scope; - - namespace scm { - bool - expression2_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()); - //ok &= gc.install_type(impl_for()); // when avail - ok &= gc.install_type(impl_for()); - 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; - } - } -} /*namespace xo*/ - -/* end expression2_register_types.cpp */ diff --git a/src/expression2/init_expression2.cpp b/src/expression2/init_expression2.cpp index 0d107316..a80d6625 100644 --- a/src/expression2/init_expression2.cpp +++ b/src/expression2/init_expression2.cpp @@ -4,23 +4,22 @@ **/ #include "init_expression2.hpp" -#include "expression2_register_facets.hpp" +#include "SetupExpression2.hpp" #include "expression2_register_types.hpp" #include #include namespace xo { - using xo::scm::expression2_register_facets; - using xo::scm::expression2_register_types; + using xo::scm::SetupExpression2; using xo::mm::CollectorTypeRegistry; void InitSubsys::init() { - expression2_register_facets(); + SetupExpression2::register_facets(); - CollectorTypeRegistry::instance().register_types(&expression2_register_types); + CollectorTypeRegistry::instance().register_types(&SetupExpression2::register_types); } InitEvidence From c38ab90cddf32f183137e265446baea45546d32e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 19 Mar 2026 11:34:07 -0400 Subject: [PATCH 107/128] xo-expression2: refactor: layout Variable support file locn --- idl/IExpression_DVariable.json5 | 4 ++-- idl/IGCObject_DVariable.json5 | 4 ++-- idl/IPrintable_DVariable.json5 | 4 ++-- include/xo/expression2/Variable.hpp | 6 +++--- .../{detail => variable}/IExpression_DVariable.hpp | 0 .../{detail => variable}/IGCObject_DVariable.hpp | 0 .../{detail => variable}/IPrintable_DVariable.hpp | 0 src/expression2/CMakeLists.txt | 8 ++++---- src/expression2/{ => facet}/IExpression_DVariable.cpp | 2 +- src/expression2/{ => facet}/IGCObject_DVariable.cpp | 2 +- src/expression2/{ => facet}/IPrintable_DVariable.cpp | 2 +- 11 files changed, 16 insertions(+), 16 deletions(-) rename include/xo/expression2/{detail => variable}/IExpression_DVariable.hpp (100%) rename include/xo/expression2/{detail => variable}/IGCObject_DVariable.hpp (100%) rename include/xo/expression2/{detail => variable}/IPrintable_DVariable.hpp (100%) rename src/expression2/{ => facet}/IExpression_DVariable.cpp (96%) rename src/expression2/{ => facet}/IGCObject_DVariable.cpp (95%) rename src/expression2/{ => facet}/IPrintable_DVariable.cpp (93%) diff --git a/idl/IExpression_DVariable.json5 b/idl/IExpression_DVariable.json5 index c68a9609..cfc0b599 100644 --- a/idl/IExpression_DVariable.json5 +++ b/idl/IExpression_DVariable.json5 @@ -1,8 +1,8 @@ { mode: "implementation", - output_cpp_dir: "src/expression2", + output_cpp_dir: "src/expression2/facet", output_hpp_dir: "include/xo/expression2", - output_impl_subdir: "detail", + output_impl_subdir: "variable", includes: [ "\"Expression.hpp\"" ], local_types: [ ], namespace1: "xo", diff --git a/idl/IGCObject_DVariable.json5 b/idl/IGCObject_DVariable.json5 index b9f27623..f589430f 100644 --- a/idl/IGCObject_DVariable.json5 +++ b/idl/IGCObject_DVariable.json5 @@ -1,8 +1,8 @@ { mode: "implementation", - output_cpp_dir: "src/expression2", + output_cpp_dir: "src/expression2/facet", output_hpp_dir: "include/xo/expression2", - output_impl_subdir: "detail", + output_impl_subdir: "variable", includes: [ "", "" diff --git a/idl/IPrintable_DVariable.json5 b/idl/IPrintable_DVariable.json5 index 779afd25..b300b7be 100644 --- a/idl/IPrintable_DVariable.json5 +++ b/idl/IPrintable_DVariable.json5 @@ -1,8 +1,8 @@ { mode: "implementation", - output_cpp_dir: "src/expression2", + output_cpp_dir: "src/expression2/facet", output_hpp_dir: "include/xo/expression2", - output_impl_subdir: "detail", + output_impl_subdir: "variable", includes: [ "", "" ], local_types: [ ], diff --git a/include/xo/expression2/Variable.hpp b/include/xo/expression2/Variable.hpp index 26ef649b..43141578 100644 --- a/include/xo/expression2/Variable.hpp +++ b/include/xo/expression2/Variable.hpp @@ -6,8 +6,8 @@ #pragma once #include "DVariable.hpp" -#include "detail/IExpression_DVariable.hpp" -#include "detail/IGCObject_DVariable.hpp" -#include "detail/IPrintable_DVariable.hpp" +#include "variable/IExpression_DVariable.hpp" +#include "variable/IGCObject_DVariable.hpp" +#include "variable/IPrintable_DVariable.hpp" /* end Variable.hpp */ diff --git a/include/xo/expression2/detail/IExpression_DVariable.hpp b/include/xo/expression2/variable/IExpression_DVariable.hpp similarity index 100% rename from include/xo/expression2/detail/IExpression_DVariable.hpp rename to include/xo/expression2/variable/IExpression_DVariable.hpp diff --git a/include/xo/expression2/detail/IGCObject_DVariable.hpp b/include/xo/expression2/variable/IGCObject_DVariable.hpp similarity index 100% rename from include/xo/expression2/detail/IGCObject_DVariable.hpp rename to include/xo/expression2/variable/IGCObject_DVariable.hpp diff --git a/include/xo/expression2/detail/IPrintable_DVariable.hpp b/include/xo/expression2/variable/IPrintable_DVariable.hpp similarity index 100% rename from include/xo/expression2/detail/IPrintable_DVariable.hpp rename to include/xo/expression2/variable/IPrintable_DVariable.hpp diff --git a/src/expression2/CMakeLists.txt b/src/expression2/CMakeLists.txt index 574b9526..6372ca28 100644 --- a/src/expression2/CMakeLists.txt +++ b/src/expression2/CMakeLists.txt @@ -6,7 +6,6 @@ set(SELF_SRCS SetupExpression2.cpp DConstant.cpp - DVariable.cpp DVarRef.cpp DApplyExpr.cpp @@ -20,9 +19,10 @@ set(SELF_SRCS IGCObject_DConstant.cpp IPrintable_DConstant.cpp - IExpression_DVariable.cpp - IGCObject_DVariable.cpp - IPrintable_DVariable.cpp + DVariable.cpp + facet/IExpression_DVariable.cpp + facet/IGCObject_DVariable.cpp + facet/IPrintable_DVariable.cpp IExpression_DVarRef.cpp IGCObject_DVarRef.cpp diff --git a/src/expression2/IExpression_DVariable.cpp b/src/expression2/facet/IExpression_DVariable.cpp similarity index 96% rename from src/expression2/IExpression_DVariable.cpp rename to src/expression2/facet/IExpression_DVariable.cpp index bea2a24e..49b9cfbc 100644 --- a/src/expression2/IExpression_DVariable.cpp +++ b/src/expression2/facet/IExpression_DVariable.cpp @@ -11,7 +11,7 @@ * [idl/IExpression_DVariable.json5] **/ -#include "detail/IExpression_DVariable.hpp" +#include "variable/IExpression_DVariable.hpp" namespace xo { namespace scm { diff --git a/src/expression2/IGCObject_DVariable.cpp b/src/expression2/facet/IGCObject_DVariable.cpp similarity index 95% rename from src/expression2/IGCObject_DVariable.cpp rename to src/expression2/facet/IGCObject_DVariable.cpp index ecc403ef..e0dc04f7 100644 --- a/src/expression2/IGCObject_DVariable.cpp +++ b/src/expression2/facet/IGCObject_DVariable.cpp @@ -11,7 +11,7 @@ * [idl/IGCObject_DVariable.json5] **/ -#include "detail/IGCObject_DVariable.hpp" +#include "variable/IGCObject_DVariable.hpp" namespace xo { namespace scm { diff --git a/src/expression2/IPrintable_DVariable.cpp b/src/expression2/facet/IPrintable_DVariable.cpp similarity index 93% rename from src/expression2/IPrintable_DVariable.cpp rename to src/expression2/facet/IPrintable_DVariable.cpp index 53364de5..e7dc3d07 100644 --- a/src/expression2/IPrintable_DVariable.cpp +++ b/src/expression2/facet/IPrintable_DVariable.cpp @@ -11,7 +11,7 @@ * [idl/IPrintable_DVariable.json5] **/ -#include "detail/IPrintable_DVariable.hpp" +#include "variable/IPrintable_DVariable.hpp" namespace xo { namespace scm { From ae167d70a3a0796f95931c1a4b5106f4eeee830f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Mar 2026 17:47:16 -0400 Subject: [PATCH 108/128] xo-expression2: streamline TypeRef.forward_children() --- src/expression2/TypeRef.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/expression2/TypeRef.cpp b/src/expression2/TypeRef.cpp index 4040cf13..72b476ef 100644 --- a/src/expression2/TypeRef.cpp +++ b/src/expression2/TypeRef.cpp @@ -4,6 +4,7 @@ **/ #include "TypeRef.hpp" +#include #include #include #include @@ -103,10 +104,12 @@ namespace xo { void TypeRef::forward_children(obj gc) noexcept { - { - auto e = FacetRegistry::instance().variant(type_); - gc.forward_inplace(e.iface(), (void **)&(type_.data_)); - } + gc.forward_pivot_inplace(&type_); + + //if (type_) { + // auto e = FacetRegistry::instance().variant(type_); + // gc.forward_inplace(e.iface(), (void **)&(type_.data_)); + //} } bool From f7e8fd5f655843b7b7d4bbcc936878ff8c0e5fd4 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 24 Mar 2026 22:11:25 -0400 Subject: [PATCH 109/128] xo-gc: + ACollector.assign_member() --- include/xo/expression2/DGlobalSymtab.hpp | 15 ++++++++--- src/expression2/DGlobalSymtab.cpp | 33 +++++++++++++++++------- 2 files changed, 35 insertions(+), 13 deletions(-) diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index 5fe1edb3..2f8b1e14 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -31,6 +31,7 @@ namespace xo { using repr_type = xo::map::DArenaHashMap; using ACollector = xo::mm::ACollector; using AAllocator = xo::mm::AAllocator; + using AGCObject = xo::mm::AGCObject; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; using ppindentinfo = xo::print::ppindentinfo; using size_type = std::uint32_t; @@ -47,10 +48,16 @@ namespace xo { * Use memory from @p mm for DGlobalSymtab instance. * Hashmap for variables per @p var_cfg; for types per @p type_cfg. **/ - static dp make(obj mm, - obj fixed_mm, - const ArenaHashMapConfig & var_cfg, - const ArenaHashMapConfig & type_cfg); + static DGlobalSymtab * _make(obj mm, + obj fixed_mm, + const ArenaHashMapConfig & var_cfg, + const ArenaHashMapConfig & type_cfg); + + /** like _make(..), but create fop **/ + static obj make(obj mm, + obj fixed_mm, + const ArenaHashMapConfig & var_cfg, + const ArenaHashMapConfig & type_cfg); /** non-trivial destructor for @ref map_ **/ ~DGlobalSymtab() = default; diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index 65eea5a6..158326ac 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -3,7 +3,7 @@ * @author Roland Conybeare, Jan 2026 **/ -#include "DGlobalSymtab.hpp" +#include "GlobalSymtab.hpp" #include "Typename.hpp" #include "Binding.hpp" #include "DUniqueString.hpp" @@ -29,11 +29,11 @@ namespace xo { { } - dp - DGlobalSymtab::make(obj mm, - obj aux_mm, - const ArenaHashMapConfig & var_cfg, - const ArenaHashMapConfig & type_cfg) + DGlobalSymtab * + DGlobalSymtab::_make(obj mm, + obj aux_mm, + const ArenaHashMapConfig & var_cfg, + const ArenaHashMapConfig & type_cfg) { /* note: using aux_mm for DArenaHashMap superstructure. * {variable, type} storage allocated from mm. @@ -51,14 +51,26 @@ namespace xo { DArray * types = DArray::empty(mm, type_map->capacity()); - auto symtab = dp::make(mm, - std::move(var_map), vars, - std::move(type_map), types); + void * mem = mm.alloc_for(); + + auto symtab = new (mem) DGlobalSymtab(std::move(var_map), + vars, + std::move(type_map), + types); assert(symtab); return symtab; } + obj + DGlobalSymtab::make(obj mm, + obj aux_mm, + const ArenaHashMapConfig & var_cfg, + const ArenaHashMapConfig & type_cfg) + { + return obj(_make(mm, aux_mm, var_cfg, type_cfg)); + } + void DGlobalSymtab::visit_pools(const MemorySizeVisitor & visitor) const { @@ -275,6 +287,9 @@ namespace xo { { // map_ doesn't contain any gc-owned data, can skip + static_assert(var_map_.is_gc_eligible() == false); + static_assert(type_map_.is_gc_eligible() == false); + gc.forward_inplace(&vars_); gc.forward_inplace(&types_); From 7a9167e42db026bccf96721aad7cc5c87d18a634 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Thu, 26 Mar 2026 15:05:30 -0400 Subject: [PATCH 110/128] xo-expression2: bugfix: missing type registration For collectable types DVarRef,DApplyExpr --- src/expression2/SetupExpression2.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/expression2/SetupExpression2.cpp b/src/expression2/SetupExpression2.cpp index 5e86e795..e43d01ec 100644 --- a/src/expression2/SetupExpression2.cpp +++ b/src/expression2/SetupExpression2.cpp @@ -134,8 +134,9 @@ namespace xo { ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); + ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); - //ok &= gc.install_type(impl_for()); // when avail + ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); ok &= gc.install_type(impl_for()); From c9d78372c8efa491fdda9a513b5ed8189751772c Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 28 Mar 2026 00:47:53 -0400 Subject: [PATCH 111/128] xo-expression2: retire OBSOLETE block --- include/xo/expression2/DLocalSymtab.hpp | 9 --------- 1 file changed, 9 deletions(-) diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index 6e459035..c5de7878 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -120,15 +120,6 @@ namespace xo { * types_[i] is convertible to obj **/ DArray * types_ = nullptr; - -#ifdef OBSOLETE - /** actual range of slots_[] array. Can use indices in [0,..,n) **/ - size_type capacity_ = 0; - /** number of slots in use **/ - size_type size_ = 0; - /** memory for names and bindings **/ - Slot slots_[]; -#endif }; } /*namespace scm*/ } /*namespace xo*/ From 34c87dc1e684a5ea18747f245d64e37fbb8289b3 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 28 Mar 2026 13:12:36 -0400 Subject: [PATCH 112/128] xo-expression2: DLambdaExpr: bugfix: GC suport for body_expr_ Was using &body_expr_ instead of &body_expr_.data_. Replace with less dangerous forward_pivot_inplace() convenience call --- src/expression2/DLambdaExpr.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/expression2/DLambdaExpr.cpp b/src/expression2/DLambdaExpr.cpp index a45c1e32..f5bdd576 100644 --- a/src/expression2/DLambdaExpr.cpp +++ b/src/expression2/DLambdaExpr.cpp @@ -169,8 +169,9 @@ namespace xo { } { - auto iface = body_expr_.to_facet().iface(); - gc.forward_inplace(iface, (void **)(&body_expr_)); + gc.forward_pivot_inplace(&body_expr_); + //auto iface = body_expr_.to_facet().iface(); + //gc.forward_inplace(iface, (void **)&(body_expr_.data_)); } // xxx free_var_set From 2c14d410decc743f0d0547a14bb766695fbe2edb Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 28 Mar 2026 13:21:48 -0400 Subject: [PATCH 113/128] xo-expression2: bugfix: DVarRef child forwarding. was passing member value instead of member address. Fix by using safer forward_inplace() convenience wrapper --- src/expression2/DVarRef.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/expression2/DVarRef.cpp b/src/expression2/DVarRef.cpp index afd9190e..df793c8a 100644 --- a/src/expression2/DVarRef.cpp +++ b/src/expression2/DVarRef.cpp @@ -78,9 +78,9 @@ namespace xo { std::size_t DVarRef::forward_children(obj gc) noexcept { - // TODO: this can be helper in RCollector interface - auto iface = xo::facet::impl_for(); - gc.forward_inplace(&iface, (void **)vardef_); + gc.forward_inplace(&vardef_); + //auto iface = xo::facet::impl_for(); + //gc.forward_inplace(&iface, (void **)vardef_.data_); // TODO: concept to indicate that no gc pointers in Binding From 53223b38ff4f0e6e26d643afe8c6b863dc766d55 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 28 Mar 2026 13:58:06 -0400 Subject: [PATCH 114/128] xo-expression2: streamline TypeRef + DSequenceExpr forwarding --- src/expression2/DSequenceExpr.cpp | 6 +----- src/expression2/TypeRef.cpp | 7 ++----- 2 files changed, 3 insertions(+), 10 deletions(-) diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index 141d4946..168bf198 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -135,11 +135,7 @@ namespace xo { { typeref_.forward_children(gc); - { - //auto iface = facet::impl_for(); - //gc.forward_inplace(&iface, (void**)&expr_v_); - gc.forward_inplace(&expr_v_); - } + gc.forward_inplace(&expr_v_); return this->shallow_size(); } diff --git a/src/expression2/TypeRef.cpp b/src/expression2/TypeRef.cpp index 72b476ef..b5baa88d 100644 --- a/src/expression2/TypeRef.cpp +++ b/src/expression2/TypeRef.cpp @@ -104,12 +104,9 @@ namespace xo { void TypeRef::forward_children(obj gc) noexcept { - gc.forward_pivot_inplace(&type_); + //scope log(XO_DEBUG(true), xtag("type", type_.data()), xtag("type.tseq", type_._typeseq())); - //if (type_) { - // auto e = FacetRegistry::instance().variant(type_); - // gc.forward_inplace(e.iface(), (void **)&(type_.data_)); - //} + gc.forward_pivot_inplace(&type_); } bool From d2aa0d0c55165e39087734d768115395632753f8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 14:38:14 -0400 Subject: [PATCH 115/128] refactor: make AGCObject.shallow_copy() non-const prep for moving to ACollector interface --- include/xo/expression2/DDefineExpr.hpp | 2 +- include/xo/expression2/DLocalSymtab.hpp | 2 +- include/xo/expression2/DTypename.hpp | 2 +- include/xo/expression2/define/IGCObject_DDefineExpr.hpp | 4 ++-- include/xo/expression2/detail/AExpression.hpp | 5 +++++ include/xo/expression2/detail/IGCObject_DApplyExpr.hpp | 4 ++-- include/xo/expression2/detail/IGCObject_DConstant.hpp | 4 ++-- include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp | 4 ++-- include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp | 4 ++-- include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp | 4 ++-- include/xo/expression2/detail/IGCObject_DVarRef.hpp | 4 ++-- include/xo/expression2/symtab/ASymbolTable.hpp | 5 +++++ include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp | 4 ++-- include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp | 4 ++-- include/xo/expression2/typename/IGCObject_DTypename.hpp | 4 ++-- include/xo/expression2/variable/IGCObject_DVariable.hpp | 4 ++-- src/expression2/DDefineExpr.cpp | 2 +- src/expression2/DLocalSymtab.cpp | 2 +- src/expression2/DTypename.cpp | 2 +- src/expression2/IGCObject_DApplyExpr.cpp | 3 +-- src/expression2/IGCObject_DConstant.cpp | 3 +-- src/expression2/IGCObject_DDefineExpr.cpp | 3 +-- src/expression2/IGCObject_DGlobalSymtab.cpp | 3 +-- src/expression2/IGCObject_DIfElseExpr.cpp | 3 +-- src/expression2/IGCObject_DLambdaExpr.cpp | 3 +-- src/expression2/IGCObject_DLocalSymtab.cpp | 3 +-- src/expression2/IGCObject_DSequenceExpr.cpp | 3 +-- src/expression2/IGCObject_DTypename.cpp | 3 +-- src/expression2/IGCObject_DVarRef.cpp | 3 +-- src/expression2/facet/IGCObject_DVariable.cpp | 3 +-- 30 files changed, 49 insertions(+), 50 deletions(-) diff --git a/include/xo/expression2/DDefineExpr.hpp b/include/xo/expression2/DDefineExpr.hpp index 6ad8494f..34a4baa5 100644 --- a/include/xo/expression2/DDefineExpr.hpp +++ b/include/xo/expression2/DDefineExpr.hpp @@ -73,7 +73,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DDefineExpr * shallow_copy(obj mm) const noexcept; + DDefineExpr * shallow_copy(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index c5de7878..0d32472b 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -98,7 +98,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DLocalSymtab * shallow_copy(obj mm) const noexcept; + DLocalSymtab * shallow_copy(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DTypename.hpp b/include/xo/expression2/DTypename.hpp index 1d9d0629..eeee5dbb 100644 --- a/include/xo/expression2/DTypename.hpp +++ b/include/xo/expression2/DTypename.hpp @@ -54,7 +54,7 @@ namespace xo { ///@{ size_t shallow_size() const noexcept; - DTypename * shallow_copy(obj mm) const noexcept; + DTypename * shallow_copy(obj mm) noexcept; size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp index 8e516773..cf4e3062 100644 --- a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DDefineExpr & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DDefineExpr & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DDefineExpr & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DDefineExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/AExpression.hpp b/include/xo/expression2/detail/AExpression.hpp index 96d68a65..e615fb46 100644 --- a/include/xo/expression2/detail/AExpression.hpp +++ b/include/xo/expression2/detail/AExpression.hpp @@ -48,6 +48,11 @@ public: /** @defgroup scm-expression-methods **/ ///@{ // const methods + /** An uninitialized AExpression 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/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp index effcd01c..a1675363 100644 --- a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DApplyExpr & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DApplyExpr & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DApplyExpr & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DApplyExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp index 608d4d6a..68404957 100644 --- a/include/xo/expression2/detail/IGCObject_DConstant.hpp +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DConstant & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DConstant & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DConstant & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DConstant & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp index 63fdb6ee..1e1fcca5 100644 --- a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DIfElseExpr & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DIfElseExpr & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DIfElseExpr & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DIfElseExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp index 91bb24da..f33e9ed7 100644 --- a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DLambdaExpr & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DLambdaExpr & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DLambdaExpr & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DLambdaExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index 20d21159..7648aab3 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DSequenceExpr & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DSequenceExpr & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DSequenceExpr & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DSequenceExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp index 228e74c0..c5ca5f19 100644 --- a/include/xo/expression2/detail/IGCObject_DVarRef.hpp +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DVarRef & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DVarRef & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DVarRef & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVarRef & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/symtab/ASymbolTable.hpp b/include/xo/expression2/symtab/ASymbolTable.hpp index 59cf246f..40349861 100644 --- a/include/xo/expression2/symtab/ASymbolTable.hpp +++ b/include/xo/expression2/symtab/ASymbolTable.hpp @@ -45,6 +45,11 @@ public: /** @defgroup scm-symboltable-methods **/ ///@{ // const methods + /** An uninitialized ASymbolTable 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/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp index fe487e1a..cf444eb8 100644 --- a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DGlobalSymtab & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DGlobalSymtab & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DGlobalSymtab & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DGlobalSymtab & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp index 6c0ec0c7..d91f214a 100644 --- a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DLocalSymtab & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DLocalSymtab & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DLocalSymtab & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DLocalSymtab & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/typename/IGCObject_DTypename.hpp b/include/xo/expression2/typename/IGCObject_DTypename.hpp index f01740d4..d2302a6f 100644 --- a/include/xo/expression2/typename/IGCObject_DTypename.hpp +++ b/include/xo/expression2/typename/IGCObject_DTypename.hpp @@ -50,10 +50,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DTypename & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DTypename & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DTypename & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DTypename & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/variable/IGCObject_DVariable.hpp b/include/xo/expression2/variable/IGCObject_DVariable.hpp index 0b23f630..1bdb2a0f 100644 --- a/include/xo/expression2/variable/IGCObject_DVariable.hpp +++ b/include/xo/expression2/variable/IGCObject_DVariable.hpp @@ -52,10 +52,10 @@ namespace xo { // const methods /** memory consumption for this instance **/ static size_type shallow_size(const DVariable & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DVariable & self, obj mm) noexcept; // non-const methods + /** copy instance using allocator **/ + static Opaque shallow_copy(DVariable & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVariable & self, obj gc) noexcept; ///@} diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index aa1ea105..e5ec63b0 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -85,7 +85,7 @@ namespace xo { } DDefineExpr * - DDefineExpr::shallow_copy(obj mm) const noexcept + DDefineExpr::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index 539d5d78..14dd9262 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -119,7 +119,7 @@ namespace xo { } DLocalSymtab * - DLocalSymtab::shallow_copy(obj mm) const noexcept + DLocalSymtab::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/expression2/DTypename.cpp b/src/expression2/DTypename.cpp index fd62336b..36c9e74f 100644 --- a/src/expression2/DTypename.cpp +++ b/src/expression2/DTypename.cpp @@ -47,7 +47,7 @@ namespace xo { } DTypename * - DTypename::shallow_copy(obj mm) const noexcept + DTypename::shallow_copy(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/expression2/IGCObject_DApplyExpr.cpp b/src/expression2/IGCObject_DApplyExpr.cpp index ad6571e0..fe587a2d 100644 --- a/src/expression2/IGCObject_DApplyExpr.cpp +++ b/src/expression2/IGCObject_DApplyExpr.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DApplyExpr::shallow_copy(const DApplyExpr & self, obj mm) noexcept -> Opaque + IGCObject_DApplyExpr::shallow_copy(DApplyExpr & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DApplyExpr::forward_children(DApplyExpr & self, obj gc) noexcept -> size_type { diff --git a/src/expression2/IGCObject_DConstant.cpp b/src/expression2/IGCObject_DConstant.cpp index ea3be262..73453419 100644 --- a/src/expression2/IGCObject_DConstant.cpp +++ b/src/expression2/IGCObject_DConstant.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DConstant::shallow_copy(const DConstant & self, obj mm) noexcept -> Opaque + IGCObject_DConstant::shallow_copy(DConstant & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DConstant::forward_children(DConstant & self, obj gc) noexcept -> size_type { diff --git a/src/expression2/IGCObject_DDefineExpr.cpp b/src/expression2/IGCObject_DDefineExpr.cpp index eb43932b..ffbd4bc8 100644 --- a/src/expression2/IGCObject_DDefineExpr.cpp +++ b/src/expression2/IGCObject_DDefineExpr.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DDefineExpr::shallow_copy(const DDefineExpr & self, obj mm) noexcept -> Opaque + IGCObject_DDefineExpr::shallow_copy(DDefineExpr & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DDefineExpr::forward_children(DDefineExpr & self, obj gc) noexcept -> size_type { diff --git a/src/expression2/IGCObject_DGlobalSymtab.cpp b/src/expression2/IGCObject_DGlobalSymtab.cpp index d59e6bbf..f88060cb 100644 --- a/src/expression2/IGCObject_DGlobalSymtab.cpp +++ b/src/expression2/IGCObject_DGlobalSymtab.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DGlobalSymtab::shallow_copy(const DGlobalSymtab & self, obj mm) noexcept -> Opaque + IGCObject_DGlobalSymtab::shallow_copy(DGlobalSymtab & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DGlobalSymtab::forward_children(DGlobalSymtab & self, obj gc) noexcept -> size_type { diff --git a/src/expression2/IGCObject_DIfElseExpr.cpp b/src/expression2/IGCObject_DIfElseExpr.cpp index 8a0f03d5..a861dbc4 100644 --- a/src/expression2/IGCObject_DIfElseExpr.cpp +++ b/src/expression2/IGCObject_DIfElseExpr.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DIfElseExpr::shallow_copy(const DIfElseExpr & self, obj mm) noexcept -> Opaque + IGCObject_DIfElseExpr::shallow_copy(DIfElseExpr & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DIfElseExpr::forward_children(DIfElseExpr & self, obj gc) noexcept -> size_type { diff --git a/src/expression2/IGCObject_DLambdaExpr.cpp b/src/expression2/IGCObject_DLambdaExpr.cpp index c7724cd5..be64dab3 100644 --- a/src/expression2/IGCObject_DLambdaExpr.cpp +++ b/src/expression2/IGCObject_DLambdaExpr.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DLambdaExpr::shallow_copy(const DLambdaExpr & self, obj mm) noexcept -> Opaque + IGCObject_DLambdaExpr::shallow_copy(DLambdaExpr & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DLambdaExpr::forward_children(DLambdaExpr & self, obj gc) noexcept -> size_type { diff --git a/src/expression2/IGCObject_DLocalSymtab.cpp b/src/expression2/IGCObject_DLocalSymtab.cpp index ca96d3b6..eb3e06c3 100644 --- a/src/expression2/IGCObject_DLocalSymtab.cpp +++ b/src/expression2/IGCObject_DLocalSymtab.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DLocalSymtab::shallow_copy(const DLocalSymtab & self, obj mm) noexcept -> Opaque + IGCObject_DLocalSymtab::shallow_copy(DLocalSymtab & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DLocalSymtab::forward_children(DLocalSymtab & self, obj gc) noexcept -> size_type { diff --git a/src/expression2/IGCObject_DSequenceExpr.cpp b/src/expression2/IGCObject_DSequenceExpr.cpp index 54ad1bd5..bbcf9084 100644 --- a/src/expression2/IGCObject_DSequenceExpr.cpp +++ b/src/expression2/IGCObject_DSequenceExpr.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DSequenceExpr::shallow_copy(const DSequenceExpr & self, obj mm) noexcept -> Opaque + IGCObject_DSequenceExpr::shallow_copy(DSequenceExpr & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DSequenceExpr::forward_children(DSequenceExpr & self, obj gc) noexcept -> size_type { diff --git a/src/expression2/IGCObject_DTypename.cpp b/src/expression2/IGCObject_DTypename.cpp index 2b898fbf..f9c40e81 100644 --- a/src/expression2/IGCObject_DTypename.cpp +++ b/src/expression2/IGCObject_DTypename.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DTypename::shallow_copy(const DTypename & self, obj mm) noexcept -> Opaque + IGCObject_DTypename::shallow_copy(DTypename & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DTypename::forward_children(DTypename & self, obj gc) noexcept -> size_type { diff --git a/src/expression2/IGCObject_DVarRef.cpp b/src/expression2/IGCObject_DVarRef.cpp index 61596baa..788e0a00 100644 --- a/src/expression2/IGCObject_DVarRef.cpp +++ b/src/expression2/IGCObject_DVarRef.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DVarRef::shallow_copy(const DVarRef & self, obj mm) noexcept -> Opaque + IGCObject_DVarRef::shallow_copy(DVarRef & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DVarRef::forward_children(DVarRef & self, obj gc) noexcept -> size_type { diff --git a/src/expression2/facet/IGCObject_DVariable.cpp b/src/expression2/facet/IGCObject_DVariable.cpp index e0dc04f7..0bf7915d 100644 --- a/src/expression2/facet/IGCObject_DVariable.cpp +++ b/src/expression2/facet/IGCObject_DVariable.cpp @@ -22,11 +22,10 @@ namespace xo { } auto - IGCObject_DVariable::shallow_copy(const DVariable & self, obj mm) noexcept -> Opaque + IGCObject_DVariable::shallow_copy(DVariable & self, obj mm) noexcept -> Opaque { return self.shallow_copy(mm); } - auto IGCObject_DVariable::forward_children(DVariable & self, obj gc) noexcept -> size_type { From 2003c3c6f996a981aabfa92dbdde896dca704a1f Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 15:00:53 -0400 Subject: [PATCH 116/128] refactor: rename GCObject.shallow_copy -> shallow_move resolve conflict since relying on move constructor in std_copy_for --- include/xo/expression2/DApplyExpr.hpp | 2 +- include/xo/expression2/DConstant.hpp | 2 +- include/xo/expression2/DDefineExpr.hpp | 2 +- include/xo/expression2/DGlobalSymtab.hpp | 2 +- include/xo/expression2/DIfElseExpr.hpp | 2 +- include/xo/expression2/DLambdaExpr.hpp | 2 +- include/xo/expression2/DLocalSymtab.hpp | 2 +- include/xo/expression2/DSequenceExpr.hpp | 2 +- include/xo/expression2/DTypename.hpp | 2 +- include/xo/expression2/DVarRef.hpp | 2 +- include/xo/expression2/DVariable.hpp | 2 +- include/xo/expression2/define/IGCObject_DDefineExpr.hpp | 4 ++-- include/xo/expression2/detail/IGCObject_DApplyExpr.hpp | 4 ++-- include/xo/expression2/detail/IGCObject_DConstant.hpp | 4 ++-- include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp | 4 ++-- include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp | 4 ++-- include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp | 4 ++-- include/xo/expression2/detail/IGCObject_DVarRef.hpp | 4 ++-- include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp | 4 ++-- include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp | 4 ++-- include/xo/expression2/typename/IGCObject_DTypename.hpp | 4 ++-- include/xo/expression2/variable/IGCObject_DVariable.hpp | 4 ++-- src/expression2/DApplyExpr.cpp | 2 +- src/expression2/DConstant.cpp | 2 +- src/expression2/DDefineExpr.cpp | 2 +- src/expression2/DGlobalSymtab.cpp | 2 +- src/expression2/DIfElseExpr.cpp | 2 +- src/expression2/DLambdaExpr.cpp | 2 +- src/expression2/DLocalSymtab.cpp | 2 +- src/expression2/DSequenceExpr.cpp | 2 +- src/expression2/DTypename.cpp | 2 +- src/expression2/DVarRef.cpp | 2 +- src/expression2/DVariable.cpp | 2 +- src/expression2/IGCObject_DApplyExpr.cpp | 4 ++-- src/expression2/IGCObject_DConstant.cpp | 4 ++-- src/expression2/IGCObject_DDefineExpr.cpp | 4 ++-- src/expression2/IGCObject_DGlobalSymtab.cpp | 4 ++-- src/expression2/IGCObject_DIfElseExpr.cpp | 4 ++-- src/expression2/IGCObject_DLambdaExpr.cpp | 4 ++-- src/expression2/IGCObject_DLocalSymtab.cpp | 4 ++-- src/expression2/IGCObject_DSequenceExpr.cpp | 4 ++-- src/expression2/IGCObject_DTypename.cpp | 4 ++-- src/expression2/IGCObject_DVarRef.cpp | 4 ++-- src/expression2/facet/IGCObject_DVariable.cpp | 4 ++-- 44 files changed, 66 insertions(+), 66 deletions(-) diff --git a/include/xo/expression2/DApplyExpr.hpp b/include/xo/expression2/DApplyExpr.hpp index 94bcea73..072567c1 100644 --- a/include/xo/expression2/DApplyExpr.hpp +++ b/include/xo/expression2/DApplyExpr.hpp @@ -83,7 +83,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DApplyExpr * shallow_copy(obj mm) const noexcept; + DApplyExpr * shallow_move(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp index 2c8b4a96..da557fc9 100644 --- a/include/xo/expression2/DConstant.hpp +++ b/include/xo/expression2/DConstant.hpp @@ -63,7 +63,7 @@ namespace xo { ///@{ size_t shallow_size() const noexcept; - DConstant * shallow_copy(obj mm) const noexcept; + DConstant * shallow_move(obj mm) const noexcept; size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DDefineExpr.hpp b/include/xo/expression2/DDefineExpr.hpp index 34a4baa5..b2cd7ed6 100644 --- a/include/xo/expression2/DDefineExpr.hpp +++ b/include/xo/expression2/DDefineExpr.hpp @@ -73,7 +73,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DDefineExpr * shallow_copy(obj mm) noexcept; + DDefineExpr * shallow_move(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index 2f8b1e14..9ce29a6e 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -111,7 +111,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DGlobalSymtab * shallow_copy(obj mm) const noexcept; + DGlobalSymtab * shallow_move(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DIfElseExpr.hpp b/include/xo/expression2/DIfElseExpr.hpp index 0cf71332..1f04ced0 100644 --- a/include/xo/expression2/DIfElseExpr.hpp +++ b/include/xo/expression2/DIfElseExpr.hpp @@ -99,7 +99,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DIfElseExpr * shallow_copy(obj mm) const noexcept; + DIfElseExpr * shallow_move(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DLambdaExpr.hpp b/include/xo/expression2/DLambdaExpr.hpp index a7de8044..58495395 100644 --- a/include/xo/expression2/DLambdaExpr.hpp +++ b/include/xo/expression2/DLambdaExpr.hpp @@ -85,7 +85,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DLambdaExpr * shallow_copy(obj mm) const noexcept; + DLambdaExpr * shallow_move(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index 0d32472b..dbaad170 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -98,7 +98,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DLocalSymtab * shallow_copy(obj mm) noexcept; + DLocalSymtab * shallow_move(obj mm) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DSequenceExpr.hpp b/include/xo/expression2/DSequenceExpr.hpp index 39fa79d0..c70f5e72 100644 --- a/include/xo/expression2/DSequenceExpr.hpp +++ b/include/xo/expression2/DSequenceExpr.hpp @@ -73,7 +73,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DSequenceExpr * shallow_copy(obj mm) const noexcept; + DSequenceExpr * shallow_move(obj mm) const noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DTypename.hpp b/include/xo/expression2/DTypename.hpp index eeee5dbb..667082ad 100644 --- a/include/xo/expression2/DTypename.hpp +++ b/include/xo/expression2/DTypename.hpp @@ -54,7 +54,7 @@ namespace xo { ///@{ size_t shallow_size() const noexcept; - DTypename * shallow_copy(obj mm) noexcept; + DTypename * shallow_move(obj mm) noexcept; size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DVarRef.hpp b/include/xo/expression2/DVarRef.hpp index d4a230b3..26305923 100644 --- a/include/xo/expression2/DVarRef.hpp +++ b/include/xo/expression2/DVarRef.hpp @@ -55,7 +55,7 @@ namespace xo { ///@{ size_t shallow_size() const noexcept; - DVarRef * shallow_copy(obj mm) const noexcept; + DVarRef * shallow_move(obj mm) const noexcept; size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp index 329cf088..1b4f31d2 100644 --- a/include/xo/expression2/DVariable.hpp +++ b/include/xo/expression2/DVariable.hpp @@ -63,7 +63,7 @@ namespace xo { ///@{ size_t shallow_size() const noexcept; - DVariable * shallow_copy(obj mm) const noexcept; + DVariable * shallow_move(obj mm) const noexcept; size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp index cf4e3062..df303b98 100644 --- a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DDefineExpr & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DDefineExpr & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DDefineExpr & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DDefineExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp index a1675363..c0b0f35b 100644 --- a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DApplyExpr & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DApplyExpr & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DApplyExpr & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DApplyExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp index 68404957..35bfbaa2 100644 --- a/include/xo/expression2/detail/IGCObject_DConstant.hpp +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DConstant & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DConstant & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DConstant & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DConstant & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp index 1e1fcca5..5f9cf68e 100644 --- a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DIfElseExpr & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DIfElseExpr & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DIfElseExpr & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DIfElseExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp index f33e9ed7..f44d2ac8 100644 --- a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DLambdaExpr & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DLambdaExpr & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DLambdaExpr & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DLambdaExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index 7648aab3..df29b94f 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DSequenceExpr & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DSequenceExpr & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DSequenceExpr & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DSequenceExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp index c5ca5f19..d002c5c9 100644 --- a/include/xo/expression2/detail/IGCObject_DVarRef.hpp +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DVarRef & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DVarRef & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DVarRef & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVarRef & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp index cf444eb8..f2a64385 100644 --- a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DGlobalSymtab & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DGlobalSymtab & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DGlobalSymtab & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DGlobalSymtab & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp index d91f214a..a5c0cd04 100644 --- a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DLocalSymtab & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DLocalSymtab & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DLocalSymtab & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DLocalSymtab & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/typename/IGCObject_DTypename.hpp b/include/xo/expression2/typename/IGCObject_DTypename.hpp index d2302a6f..45781a2e 100644 --- a/include/xo/expression2/typename/IGCObject_DTypename.hpp +++ b/include/xo/expression2/typename/IGCObject_DTypename.hpp @@ -52,8 +52,8 @@ namespace xo { static size_type shallow_size(const DTypename & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DTypename & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DTypename & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DTypename & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/variable/IGCObject_DVariable.hpp b/include/xo/expression2/variable/IGCObject_DVariable.hpp index 1bdb2a0f..9621d0f3 100644 --- a/include/xo/expression2/variable/IGCObject_DVariable.hpp +++ b/include/xo/expression2/variable/IGCObject_DVariable.hpp @@ -54,8 +54,8 @@ namespace xo { static size_type shallow_size(const DVariable & self) noexcept; // non-const methods - /** copy instance using allocator **/ - static Opaque shallow_copy(DVariable & self, obj mm) noexcept; + /** move instance using allocator **/ + static Opaque shallow_move(DVariable & self, obj mm) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVariable & self, obj gc) noexcept; ///@} diff --git a/src/expression2/DApplyExpr.cpp b/src/expression2/DApplyExpr.cpp index 784e4473..80f25139 100644 --- a/src/expression2/DApplyExpr.cpp +++ b/src/expression2/DApplyExpr.cpp @@ -110,7 +110,7 @@ namespace xo { } DApplyExpr * - DApplyExpr::shallow_copy(obj mm) const noexcept { + DApplyExpr::shallow_move(obj mm) const noexcept { DApplyExpr * copy = (DApplyExpr *)mm.alloc_copy((std::byte *)this); if (copy) { diff --git a/src/expression2/DConstant.cpp b/src/expression2/DConstant.cpp index 53ab045e..ea7a3d9f 100644 --- a/src/expression2/DConstant.cpp +++ b/src/expression2/DConstant.cpp @@ -78,7 +78,7 @@ namespace xo { } DConstant * - DConstant::shallow_copy(obj mm) const noexcept + DConstant::shallow_move(obj mm) const noexcept { DConstant * copy = (DConstant *)mm.alloc_copy((std::byte *)this); diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index e5ec63b0..014da87c 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -85,7 +85,7 @@ namespace xo { } DDefineExpr * - DDefineExpr::shallow_copy(obj mm) noexcept + DDefineExpr::shallow_move(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index 158326ac..2ea5b2ec 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -261,7 +261,7 @@ namespace xo { } DGlobalSymtab * - DGlobalSymtab::shallow_copy(obj mm) const noexcept + DGlobalSymtab::shallow_move(obj mm) const noexcept { /** can't use std_copy_for because of non-copyable dp * diff --git a/src/expression2/DIfElseExpr.cpp b/src/expression2/DIfElseExpr.cpp index 0db04f7e..42d09fbb 100644 --- a/src/expression2/DIfElseExpr.cpp +++ b/src/expression2/DIfElseExpr.cpp @@ -89,7 +89,7 @@ namespace xo { } DIfElseExpr * - DIfElseExpr::shallow_copy(obj mm) const noexcept + DIfElseExpr::shallow_move(obj mm) const noexcept { DIfElseExpr * copy = (DIfElseExpr *)mm.alloc_copy((std::byte *)this); diff --git a/src/expression2/DLambdaExpr.cpp b/src/expression2/DLambdaExpr.cpp index f5bdd576..ebec0d40 100644 --- a/src/expression2/DLambdaExpr.cpp +++ b/src/expression2/DLambdaExpr.cpp @@ -140,7 +140,7 @@ namespace xo { } DLambdaExpr * - DLambdaExpr::shallow_copy(obj mm) const noexcept { + DLambdaExpr::shallow_move(obj mm) const noexcept { DLambdaExpr * copy = (DLambdaExpr *)mm.alloc_copy((std::byte *)this); if (copy) { diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index 14dd9262..cf021038 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -119,7 +119,7 @@ namespace xo { } DLocalSymtab * - DLocalSymtab::shallow_copy(obj mm) noexcept + DLocalSymtab::shallow_move(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index 168bf198..39dcc999 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -120,7 +120,7 @@ namespace xo { } DSequenceExpr * - DSequenceExpr::shallow_copy(obj mm) const noexcept + DSequenceExpr::shallow_move(obj mm) const noexcept { DSequenceExpr * copy = (DSequenceExpr *)mm.alloc_copy((std::byte *)this); diff --git a/src/expression2/DTypename.cpp b/src/expression2/DTypename.cpp index 36c9e74f..e02b483e 100644 --- a/src/expression2/DTypename.cpp +++ b/src/expression2/DTypename.cpp @@ -47,7 +47,7 @@ namespace xo { } DTypename * - DTypename::shallow_copy(obj mm) noexcept + DTypename::shallow_move(obj mm) noexcept { return mm.std_copy_for(this); } diff --git a/src/expression2/DVarRef.cpp b/src/expression2/DVarRef.cpp index df793c8a..e2866c23 100644 --- a/src/expression2/DVarRef.cpp +++ b/src/expression2/DVarRef.cpp @@ -65,7 +65,7 @@ namespace xo { } DVarRef * - DVarRef::shallow_copy(obj mm) const noexcept + DVarRef::shallow_move(obj mm) const noexcept { DVarRef * copy = (DVarRef *)mm.alloc_copy((std::byte *)this); diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index 092eb715..1b986c0b 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -45,7 +45,7 @@ namespace xo { } DVariable * - DVariable::shallow_copy(obj mm) const noexcept + DVariable::shallow_move(obj mm) const noexcept { DVariable * copy = (DVariable *)mm.alloc_copy((std::byte *)this); diff --git a/src/expression2/IGCObject_DApplyExpr.cpp b/src/expression2/IGCObject_DApplyExpr.cpp index fe587a2d..28375cce 100644 --- a/src/expression2/IGCObject_DApplyExpr.cpp +++ b/src/expression2/IGCObject_DApplyExpr.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DApplyExpr::shallow_copy(DApplyExpr & self, obj mm) noexcept -> Opaque + IGCObject_DApplyExpr::shallow_move(DApplyExpr & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DApplyExpr::forward_children(DApplyExpr & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DConstant.cpp b/src/expression2/IGCObject_DConstant.cpp index 73453419..dff013b1 100644 --- a/src/expression2/IGCObject_DConstant.cpp +++ b/src/expression2/IGCObject_DConstant.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DConstant::shallow_copy(DConstant & self, obj mm) noexcept -> Opaque + IGCObject_DConstant::shallow_move(DConstant & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DConstant::forward_children(DConstant & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DDefineExpr.cpp b/src/expression2/IGCObject_DDefineExpr.cpp index ffbd4bc8..5adf8fc6 100644 --- a/src/expression2/IGCObject_DDefineExpr.cpp +++ b/src/expression2/IGCObject_DDefineExpr.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DDefineExpr::shallow_copy(DDefineExpr & self, obj mm) noexcept -> Opaque + IGCObject_DDefineExpr::shallow_move(DDefineExpr & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DDefineExpr::forward_children(DDefineExpr & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DGlobalSymtab.cpp b/src/expression2/IGCObject_DGlobalSymtab.cpp index f88060cb..005e3ad3 100644 --- a/src/expression2/IGCObject_DGlobalSymtab.cpp +++ b/src/expression2/IGCObject_DGlobalSymtab.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DGlobalSymtab::shallow_copy(DGlobalSymtab & self, obj mm) noexcept -> Opaque + IGCObject_DGlobalSymtab::shallow_move(DGlobalSymtab & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DGlobalSymtab::forward_children(DGlobalSymtab & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DIfElseExpr.cpp b/src/expression2/IGCObject_DIfElseExpr.cpp index a861dbc4..9c28f2e0 100644 --- a/src/expression2/IGCObject_DIfElseExpr.cpp +++ b/src/expression2/IGCObject_DIfElseExpr.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DIfElseExpr::shallow_copy(DIfElseExpr & self, obj mm) noexcept -> Opaque + IGCObject_DIfElseExpr::shallow_move(DIfElseExpr & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DIfElseExpr::forward_children(DIfElseExpr & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DLambdaExpr.cpp b/src/expression2/IGCObject_DLambdaExpr.cpp index be64dab3..bfe386a2 100644 --- a/src/expression2/IGCObject_DLambdaExpr.cpp +++ b/src/expression2/IGCObject_DLambdaExpr.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DLambdaExpr::shallow_copy(DLambdaExpr & self, obj mm) noexcept -> Opaque + IGCObject_DLambdaExpr::shallow_move(DLambdaExpr & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DLambdaExpr::forward_children(DLambdaExpr & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DLocalSymtab.cpp b/src/expression2/IGCObject_DLocalSymtab.cpp index eb3e06c3..7078db9a 100644 --- a/src/expression2/IGCObject_DLocalSymtab.cpp +++ b/src/expression2/IGCObject_DLocalSymtab.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DLocalSymtab::shallow_copy(DLocalSymtab & self, obj mm) noexcept -> Opaque + IGCObject_DLocalSymtab::shallow_move(DLocalSymtab & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DLocalSymtab::forward_children(DLocalSymtab & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DSequenceExpr.cpp b/src/expression2/IGCObject_DSequenceExpr.cpp index bbcf9084..446a78bb 100644 --- a/src/expression2/IGCObject_DSequenceExpr.cpp +++ b/src/expression2/IGCObject_DSequenceExpr.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DSequenceExpr::shallow_copy(DSequenceExpr & self, obj mm) noexcept -> Opaque + IGCObject_DSequenceExpr::shallow_move(DSequenceExpr & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DSequenceExpr::forward_children(DSequenceExpr & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DTypename.cpp b/src/expression2/IGCObject_DTypename.cpp index f9c40e81..154a8b4a 100644 --- a/src/expression2/IGCObject_DTypename.cpp +++ b/src/expression2/IGCObject_DTypename.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DTypename::shallow_copy(DTypename & self, obj mm) noexcept -> Opaque + IGCObject_DTypename::shallow_move(DTypename & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DTypename::forward_children(DTypename & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DVarRef.cpp b/src/expression2/IGCObject_DVarRef.cpp index 788e0a00..b6b5e077 100644 --- a/src/expression2/IGCObject_DVarRef.cpp +++ b/src/expression2/IGCObject_DVarRef.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVarRef::shallow_copy(DVarRef & self, obj mm) noexcept -> Opaque + IGCObject_DVarRef::shallow_move(DVarRef & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DVarRef::forward_children(DVarRef & self, obj gc) noexcept -> size_type diff --git a/src/expression2/facet/IGCObject_DVariable.cpp b/src/expression2/facet/IGCObject_DVariable.cpp index 0bf7915d..8a49292b 100644 --- a/src/expression2/facet/IGCObject_DVariable.cpp +++ b/src/expression2/facet/IGCObject_DVariable.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVariable::shallow_copy(DVariable & self, obj mm) noexcept -> Opaque + IGCObject_DVariable::shallow_move(DVariable & self, obj mm) noexcept -> Opaque { - return self.shallow_copy(mm); + return self.shallow_move(mm); } auto IGCObject_DVariable::forward_children(DVariable & self, obj gc) noexcept -> size_type From d16f2a04849a064dc85bd27da0c0420c44c28bdf Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 16:33:35 -0400 Subject: [PATCH 117/128] refactor: rename shallow_copy -> shallow_move + streamline Use RCollector.std_copy_for where appropriate --- include/xo/expression2/DApplyExpr.hpp | 2 +- include/xo/expression2/DConstant.hpp | 2 +- include/xo/expression2/DDefineExpr.hpp | 2 +- include/xo/expression2/DGlobalSymtab.hpp | 5 ++++- include/xo/expression2/DIfElseExpr.hpp | 2 +- include/xo/expression2/DLambdaExpr.hpp | 2 +- include/xo/expression2/DLocalSymtab.hpp | 2 +- include/xo/expression2/DSequenceExpr.hpp | 2 +- include/xo/expression2/DTypename.hpp | 2 +- include/xo/expression2/DVarRef.hpp | 2 +- include/xo/expression2/DVariable.hpp | 2 +- .../define/IGCObject_DDefineExpr.hpp | 2 +- .../detail/IGCObject_DApplyExpr.hpp | 2 +- .../detail/IGCObject_DConstant.hpp | 2 +- .../detail/IGCObject_DIfElseExpr.hpp | 2 +- .../detail/IGCObject_DLambdaExpr.hpp | 2 +- .../detail/IGCObject_DSequenceExpr.hpp | 2 +- .../expression2/detail/IGCObject_DVarRef.hpp | 2 +- .../symtab/IGCObject_DGlobalSymtab.hpp | 2 +- .../symtab/IGCObject_DLocalSymtab.hpp | 2 +- .../typename/IGCObject_DTypename.hpp | 2 +- .../variable/IGCObject_DVariable.hpp | 2 +- src/expression2/DApplyExpr.cpp | 7 +++++-- src/expression2/DConstant.cpp | 9 ++------- src/expression2/DDefineExpr.cpp | 4 ++-- src/expression2/DGlobalSymtab.cpp | 20 ++----------------- src/expression2/DIfElseExpr.cpp | 9 ++------- src/expression2/DLambdaExpr.cpp | 10 ++-------- src/expression2/DLocalSymtab.cpp | 4 ++-- src/expression2/DSequenceExpr.cpp | 9 ++------- src/expression2/DTypename.cpp | 4 ++-- src/expression2/DVarRef.cpp | 9 ++------- src/expression2/DVariable.cpp | 10 ++-------- src/expression2/IGCObject_DApplyExpr.cpp | 4 ++-- src/expression2/IGCObject_DConstant.cpp | 4 ++-- src/expression2/IGCObject_DDefineExpr.cpp | 4 ++-- src/expression2/IGCObject_DGlobalSymtab.cpp | 4 ++-- src/expression2/IGCObject_DIfElseExpr.cpp | 4 ++-- src/expression2/IGCObject_DLambdaExpr.cpp | 4 ++-- src/expression2/IGCObject_DLocalSymtab.cpp | 4 ++-- src/expression2/IGCObject_DSequenceExpr.cpp | 4 ++-- src/expression2/IGCObject_DTypename.cpp | 4 ++-- src/expression2/IGCObject_DVarRef.cpp | 4 ++-- src/expression2/facet/IGCObject_DVariable.cpp | 4 ++-- 44 files changed, 72 insertions(+), 114 deletions(-) diff --git a/include/xo/expression2/DApplyExpr.hpp b/include/xo/expression2/DApplyExpr.hpp index 072567c1..b4119def 100644 --- a/include/xo/expression2/DApplyExpr.hpp +++ b/include/xo/expression2/DApplyExpr.hpp @@ -83,7 +83,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DApplyExpr * shallow_move(obj mm) const noexcept; + DApplyExpr * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp index da557fc9..e78440ad 100644 --- a/include/xo/expression2/DConstant.hpp +++ b/include/xo/expression2/DConstant.hpp @@ -63,7 +63,7 @@ namespace xo { ///@{ size_t shallow_size() const noexcept; - DConstant * shallow_move(obj mm) const noexcept; + DConstant * shallow_move(obj gc) noexcept; size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DDefineExpr.hpp b/include/xo/expression2/DDefineExpr.hpp index b2cd7ed6..1e20c530 100644 --- a/include/xo/expression2/DDefineExpr.hpp +++ b/include/xo/expression2/DDefineExpr.hpp @@ -73,7 +73,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DDefineExpr * shallow_move(obj mm) noexcept; + DDefineExpr * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index 9ce29a6e..c6fcdcf1 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -43,6 +43,9 @@ namespace xo { DGlobalSymtab(dp var_map, DArray * vars, dp type_map, DArray * types); + /** move constructor (needed because dp<> deletes copy ctor) **/ + DGlobalSymtab(DGlobalSymtab && other) = default; + /** create instance. * Use memory from @p fixed_mm for @ref map_. * Use memory from @p mm for DGlobalSymtab instance. @@ -111,7 +114,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DGlobalSymtab * shallow_move(obj mm) const noexcept; + DGlobalSymtab * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DIfElseExpr.hpp b/include/xo/expression2/DIfElseExpr.hpp index 1f04ced0..8ffee429 100644 --- a/include/xo/expression2/DIfElseExpr.hpp +++ b/include/xo/expression2/DIfElseExpr.hpp @@ -99,7 +99,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DIfElseExpr * shallow_move(obj mm) const noexcept; + DIfElseExpr * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DLambdaExpr.hpp b/include/xo/expression2/DLambdaExpr.hpp index 58495395..0d8d2391 100644 --- a/include/xo/expression2/DLambdaExpr.hpp +++ b/include/xo/expression2/DLambdaExpr.hpp @@ -85,7 +85,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DLambdaExpr * shallow_move(obj mm) const noexcept; + DLambdaExpr * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index dbaad170..b2843cb9 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -98,7 +98,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DLocalSymtab * shallow_move(obj mm) noexcept; + DLocalSymtab * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DSequenceExpr.hpp b/include/xo/expression2/DSequenceExpr.hpp index c70f5e72..f876cfac 100644 --- a/include/xo/expression2/DSequenceExpr.hpp +++ b/include/xo/expression2/DSequenceExpr.hpp @@ -73,7 +73,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DSequenceExpr * shallow_move(obj mm) const noexcept; + DSequenceExpr * shallow_move(obj gc) noexcept; std::size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DTypename.hpp b/include/xo/expression2/DTypename.hpp index 667082ad..7bd30931 100644 --- a/include/xo/expression2/DTypename.hpp +++ b/include/xo/expression2/DTypename.hpp @@ -54,7 +54,7 @@ namespace xo { ///@{ size_t shallow_size() const noexcept; - DTypename * shallow_move(obj mm) noexcept; + DTypename * shallow_move(obj gc) noexcept; size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DVarRef.hpp b/include/xo/expression2/DVarRef.hpp index 26305923..65abddb2 100644 --- a/include/xo/expression2/DVarRef.hpp +++ b/include/xo/expression2/DVarRef.hpp @@ -55,7 +55,7 @@ namespace xo { ///@{ size_t shallow_size() const noexcept; - DVarRef * shallow_move(obj mm) const noexcept; + DVarRef * shallow_move(obj gc) noexcept; size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp index 1b4f31d2..12abae94 100644 --- a/include/xo/expression2/DVariable.hpp +++ b/include/xo/expression2/DVariable.hpp @@ -63,7 +63,7 @@ namespace xo { ///@{ size_t shallow_size() const noexcept; - DVariable * shallow_move(obj mm) const noexcept; + DVariable * shallow_move(obj gc) noexcept; size_t forward_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp index df303b98..b2c45805 100644 --- a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DDefineExpr & self, obj mm) noexcept; + static Opaque shallow_move(DDefineExpr & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DDefineExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp index c0b0f35b..75eac694 100644 --- a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DApplyExpr & self, obj mm) noexcept; + static Opaque shallow_move(DApplyExpr & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DApplyExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp index 35bfbaa2..9cb72026 100644 --- a/include/xo/expression2/detail/IGCObject_DConstant.hpp +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DConstant & self, obj mm) noexcept; + static Opaque shallow_move(DConstant & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DConstant & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp index 5f9cf68e..e7d6fcfd 100644 --- a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DIfElseExpr & self, obj mm) noexcept; + static Opaque shallow_move(DIfElseExpr & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DIfElseExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp index f44d2ac8..6cf2cd6c 100644 --- a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DLambdaExpr & self, obj mm) noexcept; + static Opaque shallow_move(DLambdaExpr & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DLambdaExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index df29b94f..9a9b3f9d 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DSequenceExpr & self, obj mm) noexcept; + static Opaque shallow_move(DSequenceExpr & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DSequenceExpr & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp index d002c5c9..3ca237b6 100644 --- a/include/xo/expression2/detail/IGCObject_DVarRef.hpp +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DVarRef & self, obj mm) noexcept; + static Opaque shallow_move(DVarRef & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVarRef & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp index f2a64385..43436ac8 100644 --- a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DGlobalSymtab & self, obj mm) noexcept; + static Opaque shallow_move(DGlobalSymtab & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DGlobalSymtab & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp index a5c0cd04..c8b9cca1 100644 --- a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DLocalSymtab & self, obj mm) noexcept; + static Opaque shallow_move(DLocalSymtab & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DLocalSymtab & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/typename/IGCObject_DTypename.hpp b/include/xo/expression2/typename/IGCObject_DTypename.hpp index 45781a2e..d002a847 100644 --- a/include/xo/expression2/typename/IGCObject_DTypename.hpp +++ b/include/xo/expression2/typename/IGCObject_DTypename.hpp @@ -53,7 +53,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DTypename & self, obj mm) noexcept; + static Opaque shallow_move(DTypename & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DTypename & self, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/variable/IGCObject_DVariable.hpp b/include/xo/expression2/variable/IGCObject_DVariable.hpp index 9621d0f3..5fd34c21 100644 --- a/include/xo/expression2/variable/IGCObject_DVariable.hpp +++ b/include/xo/expression2/variable/IGCObject_DVariable.hpp @@ -55,7 +55,7 @@ namespace xo { // non-const methods /** move instance using allocator **/ - static Opaque shallow_move(DVariable & self, obj mm) noexcept; + static Opaque shallow_move(DVariable & self, obj gc) noexcept; /** during GC: forward immdiate children **/ static size_type forward_children(DVariable & self, obj gc) noexcept; ///@} diff --git a/src/expression2/DApplyExpr.cpp b/src/expression2/DApplyExpr.cpp index 80f25139..9683d459 100644 --- a/src/expression2/DApplyExpr.cpp +++ b/src/expression2/DApplyExpr.cpp @@ -110,8 +110,11 @@ namespace xo { } DApplyExpr * - DApplyExpr::shallow_move(obj mm) const noexcept { - DApplyExpr * copy = (DApplyExpr *)mm.alloc_copy((std::byte *)this); + DApplyExpr::shallow_move(obj gc) noexcept { + // note: not using ACollector.std_copy_for() here, + // flexible array -> not move-constructible + + DApplyExpr * copy = (DApplyExpr *)gc.alloc_copy_for(this); if (copy) { copy->typeref_ = typeref_; diff --git a/src/expression2/DConstant.cpp b/src/expression2/DConstant.cpp index ea7a3d9f..420431bc 100644 --- a/src/expression2/DConstant.cpp +++ b/src/expression2/DConstant.cpp @@ -78,14 +78,9 @@ namespace xo { } DConstant * - DConstant::shallow_move(obj mm) const noexcept + DConstant::shallow_move(obj gc) noexcept { - DConstant * copy = (DConstant *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } std::size_t diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index 014da87c..e324b528 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -85,9 +85,9 @@ namespace xo { } DDefineExpr * - DDefineExpr::shallow_move(obj mm) noexcept + DDefineExpr::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } std::size_t diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index 2ea5b2ec..8d0f74cf 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -261,25 +261,9 @@ namespace xo { } DGlobalSymtab * - DGlobalSymtab::shallow_move(obj mm) const noexcept + DGlobalSymtab::shallow_move(obj gc) noexcept { - /** can't use std_copy_for because of non-copyable dp - * - * TODO: rename to shallow_move() throughout, and have std_copy_for() - * -> std_move_for() - * - **/ - - void * copy_mem = mm.alloc_copy_for(this); - - if (copy_mem) { - DGlobalSymtab * self = const_cast(this); - - return new (copy_mem) DGlobalSymtab(std::move(self->var_map_), vars_, - std::move(self->type_map_), types_); - } - - return nullptr; + return gc.std_copy_for(this); } std::size_t diff --git a/src/expression2/DIfElseExpr.cpp b/src/expression2/DIfElseExpr.cpp index 42d09fbb..3fb71682 100644 --- a/src/expression2/DIfElseExpr.cpp +++ b/src/expression2/DIfElseExpr.cpp @@ -89,14 +89,9 @@ namespace xo { } DIfElseExpr * - DIfElseExpr::shallow_move(obj mm) const noexcept + DIfElseExpr::shallow_move(obj gc) noexcept { - DIfElseExpr * copy = (DIfElseExpr *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } std::size_t diff --git a/src/expression2/DLambdaExpr.cpp b/src/expression2/DLambdaExpr.cpp index ebec0d40..4919840b 100644 --- a/src/expression2/DLambdaExpr.cpp +++ b/src/expression2/DLambdaExpr.cpp @@ -140,14 +140,8 @@ namespace xo { } DLambdaExpr * - DLambdaExpr::shallow_move(obj mm) const noexcept { - DLambdaExpr * copy = (DLambdaExpr *)mm.alloc_copy((std::byte *)this); - - if (copy) { - *copy = *this; - } - - return copy; + DLambdaExpr::shallow_move(obj gc) noexcept { + return gc.std_copy_for(this); } std::size_t diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index cf021038..d1c4930c 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -119,9 +119,9 @@ namespace xo { } DLocalSymtab * - DLocalSymtab::shallow_move(obj mm) noexcept + DLocalSymtab::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } std::size_t diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index 39dcc999..33149785 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -120,14 +120,9 @@ namespace xo { } DSequenceExpr * - DSequenceExpr::shallow_move(obj mm) const noexcept + DSequenceExpr::shallow_move(obj gc) noexcept { - DSequenceExpr * copy = (DSequenceExpr *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } std::size_t diff --git a/src/expression2/DTypename.cpp b/src/expression2/DTypename.cpp index e02b483e..81509949 100644 --- a/src/expression2/DTypename.cpp +++ b/src/expression2/DTypename.cpp @@ -47,9 +47,9 @@ namespace xo { } DTypename * - DTypename::shallow_move(obj mm) noexcept + DTypename::shallow_move(obj gc) noexcept { - return mm.std_copy_for(this); + return gc.std_copy_for(this); } size_t diff --git a/src/expression2/DVarRef.cpp b/src/expression2/DVarRef.cpp index e2866c23..186fa29a 100644 --- a/src/expression2/DVarRef.cpp +++ b/src/expression2/DVarRef.cpp @@ -65,14 +65,9 @@ namespace xo { } DVarRef * - DVarRef::shallow_move(obj mm) const noexcept + DVarRef::shallow_move(obj gc) noexcept { - DVarRef * copy = (DVarRef *)mm.alloc_copy((std::byte *)this); - - if (copy) - *copy = *this; - - return copy; + return gc.std_copy_for(this); } std::size_t diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index 1b986c0b..f11000aa 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -45,15 +45,9 @@ namespace xo { } DVariable * - DVariable::shallow_move(obj mm) const noexcept + DVariable::shallow_move(obj gc) noexcept { - DVariable * copy = (DVariable *)mm.alloc_copy((std::byte *)this); - - if (copy) { - *copy = *this; - } - - return copy; + return gc.std_copy_for(this); } size_t diff --git a/src/expression2/IGCObject_DApplyExpr.cpp b/src/expression2/IGCObject_DApplyExpr.cpp index 28375cce..2a731c0b 100644 --- a/src/expression2/IGCObject_DApplyExpr.cpp +++ b/src/expression2/IGCObject_DApplyExpr.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DApplyExpr::shallow_move(DApplyExpr & self, obj mm) noexcept -> Opaque + IGCObject_DApplyExpr::shallow_move(DApplyExpr & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DApplyExpr::forward_children(DApplyExpr & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DConstant.cpp b/src/expression2/IGCObject_DConstant.cpp index dff013b1..ae5a701f 100644 --- a/src/expression2/IGCObject_DConstant.cpp +++ b/src/expression2/IGCObject_DConstant.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DConstant::shallow_move(DConstant & self, obj mm) noexcept -> Opaque + IGCObject_DConstant::shallow_move(DConstant & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DConstant::forward_children(DConstant & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DDefineExpr.cpp b/src/expression2/IGCObject_DDefineExpr.cpp index 5adf8fc6..1e2c3bb8 100644 --- a/src/expression2/IGCObject_DDefineExpr.cpp +++ b/src/expression2/IGCObject_DDefineExpr.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DDefineExpr::shallow_move(DDefineExpr & self, obj mm) noexcept -> Opaque + IGCObject_DDefineExpr::shallow_move(DDefineExpr & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DDefineExpr::forward_children(DDefineExpr & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DGlobalSymtab.cpp b/src/expression2/IGCObject_DGlobalSymtab.cpp index 005e3ad3..3f596d01 100644 --- a/src/expression2/IGCObject_DGlobalSymtab.cpp +++ b/src/expression2/IGCObject_DGlobalSymtab.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DGlobalSymtab::shallow_move(DGlobalSymtab & self, obj mm) noexcept -> Opaque + IGCObject_DGlobalSymtab::shallow_move(DGlobalSymtab & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DGlobalSymtab::forward_children(DGlobalSymtab & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DIfElseExpr.cpp b/src/expression2/IGCObject_DIfElseExpr.cpp index 9c28f2e0..240906f2 100644 --- a/src/expression2/IGCObject_DIfElseExpr.cpp +++ b/src/expression2/IGCObject_DIfElseExpr.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DIfElseExpr::shallow_move(DIfElseExpr & self, obj mm) noexcept -> Opaque + IGCObject_DIfElseExpr::shallow_move(DIfElseExpr & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DIfElseExpr::forward_children(DIfElseExpr & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DLambdaExpr.cpp b/src/expression2/IGCObject_DLambdaExpr.cpp index bfe386a2..c0a95847 100644 --- a/src/expression2/IGCObject_DLambdaExpr.cpp +++ b/src/expression2/IGCObject_DLambdaExpr.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DLambdaExpr::shallow_move(DLambdaExpr & self, obj mm) noexcept -> Opaque + IGCObject_DLambdaExpr::shallow_move(DLambdaExpr & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DLambdaExpr::forward_children(DLambdaExpr & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DLocalSymtab.cpp b/src/expression2/IGCObject_DLocalSymtab.cpp index 7078db9a..02941925 100644 --- a/src/expression2/IGCObject_DLocalSymtab.cpp +++ b/src/expression2/IGCObject_DLocalSymtab.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DLocalSymtab::shallow_move(DLocalSymtab & self, obj mm) noexcept -> Opaque + IGCObject_DLocalSymtab::shallow_move(DLocalSymtab & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DLocalSymtab::forward_children(DLocalSymtab & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DSequenceExpr.cpp b/src/expression2/IGCObject_DSequenceExpr.cpp index 446a78bb..93af6f10 100644 --- a/src/expression2/IGCObject_DSequenceExpr.cpp +++ b/src/expression2/IGCObject_DSequenceExpr.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DSequenceExpr::shallow_move(DSequenceExpr & self, obj mm) noexcept -> Opaque + IGCObject_DSequenceExpr::shallow_move(DSequenceExpr & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DSequenceExpr::forward_children(DSequenceExpr & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DTypename.cpp b/src/expression2/IGCObject_DTypename.cpp index 154a8b4a..58df5bff 100644 --- a/src/expression2/IGCObject_DTypename.cpp +++ b/src/expression2/IGCObject_DTypename.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DTypename::shallow_move(DTypename & self, obj mm) noexcept -> Opaque + IGCObject_DTypename::shallow_move(DTypename & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DTypename::forward_children(DTypename & self, obj gc) noexcept -> size_type diff --git a/src/expression2/IGCObject_DVarRef.cpp b/src/expression2/IGCObject_DVarRef.cpp index b6b5e077..64967c9b 100644 --- a/src/expression2/IGCObject_DVarRef.cpp +++ b/src/expression2/IGCObject_DVarRef.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVarRef::shallow_move(DVarRef & self, obj mm) noexcept -> Opaque + IGCObject_DVarRef::shallow_move(DVarRef & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DVarRef::forward_children(DVarRef & self, obj gc) noexcept -> size_type diff --git a/src/expression2/facet/IGCObject_DVariable.cpp b/src/expression2/facet/IGCObject_DVariable.cpp index 8a49292b..d418145c 100644 --- a/src/expression2/facet/IGCObject_DVariable.cpp +++ b/src/expression2/facet/IGCObject_DVariable.cpp @@ -22,9 +22,9 @@ namespace xo { } auto - IGCObject_DVariable::shallow_move(DVariable & self, obj mm) noexcept -> Opaque + IGCObject_DVariable::shallow_move(DVariable & self, obj gc) noexcept -> Opaque { - return self.shallow_move(mm); + return self.shallow_move(gc); } auto IGCObject_DVariable::forward_children(DVariable & self, obj gc) noexcept -> size_type From 489222311f922321404dc40f639f73bfd8a03ca8 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 16:37:17 -0400 Subject: [PATCH 118/128] refactor: rename RCollector.std_copy_for -> std_move_for --- src/expression2/DConstant.cpp | 2 +- src/expression2/DDefineExpr.cpp | 2 +- src/expression2/DGlobalSymtab.cpp | 2 +- src/expression2/DIfElseExpr.cpp | 2 +- src/expression2/DLambdaExpr.cpp | 2 +- src/expression2/DLocalSymtab.cpp | 2 +- src/expression2/DSequenceExpr.cpp | 2 +- src/expression2/DTypename.cpp | 2 +- src/expression2/DVarRef.cpp | 2 +- src/expression2/DVariable.cpp | 2 +- 10 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/expression2/DConstant.cpp b/src/expression2/DConstant.cpp index 420431bc..46d4cbe9 100644 --- a/src/expression2/DConstant.cpp +++ b/src/expression2/DConstant.cpp @@ -80,7 +80,7 @@ namespace xo { DConstant * DConstant::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index e324b528..b25a655d 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -87,7 +87,7 @@ namespace xo { DDefineExpr * DDefineExpr::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index 8d0f74cf..58275e54 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -263,7 +263,7 @@ namespace xo { DGlobalSymtab * DGlobalSymtab::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/expression2/DIfElseExpr.cpp b/src/expression2/DIfElseExpr.cpp index 3fb71682..81efee1e 100644 --- a/src/expression2/DIfElseExpr.cpp +++ b/src/expression2/DIfElseExpr.cpp @@ -91,7 +91,7 @@ namespace xo { DIfElseExpr * DIfElseExpr::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/expression2/DLambdaExpr.cpp b/src/expression2/DLambdaExpr.cpp index 4919840b..8069cd3c 100644 --- a/src/expression2/DLambdaExpr.cpp +++ b/src/expression2/DLambdaExpr.cpp @@ -141,7 +141,7 @@ namespace xo { DLambdaExpr * DLambdaExpr::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index d1c4930c..60cdd2e2 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -121,7 +121,7 @@ namespace xo { DLocalSymtab * DLocalSymtab::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index 33149785..ed03affc 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -122,7 +122,7 @@ namespace xo { DSequenceExpr * DSequenceExpr::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/expression2/DTypename.cpp b/src/expression2/DTypename.cpp index 81509949..c9f56cf1 100644 --- a/src/expression2/DTypename.cpp +++ b/src/expression2/DTypename.cpp @@ -49,7 +49,7 @@ namespace xo { DTypename * DTypename::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } size_t diff --git a/src/expression2/DVarRef.cpp b/src/expression2/DVarRef.cpp index 186fa29a..3b9b2638 100644 --- a/src/expression2/DVarRef.cpp +++ b/src/expression2/DVarRef.cpp @@ -67,7 +67,7 @@ namespace xo { DVarRef * DVarRef::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } std::size_t diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index f11000aa..68a87f67 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -47,7 +47,7 @@ namespace xo { DVariable * DVariable::shallow_move(obj gc) noexcept { - return gc.std_copy_for(this); + return gc.std_move_for(this); } size_t From 6b8ac3dcd23c2ff599b72a515f8ac3ad12187573 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 16:54:46 -0400 Subject: [PATCH 119/128] refactor: void return type for Collector.forward_children() --- include/xo/expression2/DGlobalSymtab.hpp | 2 +- include/xo/expression2/define/IGCObject_DDefineExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DApplyExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DConstant.hpp | 2 +- include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DVarRef.hpp | 2 +- include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp | 2 +- include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp | 2 +- include/xo/expression2/typename/IGCObject_DTypename.hpp | 2 +- include/xo/expression2/variable/IGCObject_DVariable.hpp | 2 +- src/expression2/DGlobalSymtab.cpp | 8 ++++++++ src/expression2/IGCObject_DApplyExpr.cpp | 4 ++-- src/expression2/IGCObject_DConstant.cpp | 4 ++-- src/expression2/IGCObject_DDefineExpr.cpp | 4 ++-- src/expression2/IGCObject_DGlobalSymtab.cpp | 4 ++-- src/expression2/IGCObject_DIfElseExpr.cpp | 4 ++-- src/expression2/IGCObject_DLambdaExpr.cpp | 4 ++-- src/expression2/IGCObject_DLocalSymtab.cpp | 4 ++-- src/expression2/IGCObject_DSequenceExpr.cpp | 4 ++-- src/expression2/IGCObject_DTypename.cpp | 4 ++-- src/expression2/IGCObject_DVarRef.cpp | 4 ++-- src/expression2/facet/IGCObject_DVariable.cpp | 4 ++-- 24 files changed, 42 insertions(+), 34 deletions(-) diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index c6fcdcf1..782e48f7 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -44,7 +44,7 @@ namespace xo { dp type_map, DArray * types); /** move constructor (needed because dp<> deletes copy ctor) **/ - DGlobalSymtab(DGlobalSymtab && other) = default; + DGlobalSymtab(DGlobalSymtab && other); /** create instance. * Use memory from @p fixed_mm for @ref map_. diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp index b2c45805..e01e7be7 100644 --- a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DDefineExpr & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DDefineExpr & self, obj gc) noexcept; + static void forward_children(DDefineExpr & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp index 75eac694..b85665c8 100644 --- a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DApplyExpr & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DApplyExpr & self, obj gc) noexcept; + static void forward_children(DApplyExpr & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp index 9cb72026..91bf9638 100644 --- a/include/xo/expression2/detail/IGCObject_DConstant.hpp +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DConstant & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DConstant & self, obj gc) noexcept; + static void forward_children(DConstant & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp index e7d6fcfd..59aae40f 100644 --- a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DIfElseExpr & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DIfElseExpr & self, obj gc) noexcept; + static void forward_children(DIfElseExpr & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp index 6cf2cd6c..2351256d 100644 --- a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DLambdaExpr & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DLambdaExpr & self, obj gc) noexcept; + static void forward_children(DLambdaExpr & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index 9a9b3f9d..c3fba848 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DSequenceExpr & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DSequenceExpr & self, obj gc) noexcept; + static void forward_children(DSequenceExpr & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp index 3ca237b6..97b0f3d6 100644 --- a/include/xo/expression2/detail/IGCObject_DVarRef.hpp +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DVarRef & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DVarRef & self, obj gc) noexcept; + static void forward_children(DVarRef & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp index 43436ac8..5de0f0da 100644 --- a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DGlobalSymtab & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DGlobalSymtab & self, obj gc) noexcept; + static void forward_children(DGlobalSymtab & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp index c8b9cca1..6b9d81a1 100644 --- a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DLocalSymtab & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DLocalSymtab & self, obj gc) noexcept; + static void forward_children(DLocalSymtab & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/expression2/typename/IGCObject_DTypename.hpp b/include/xo/expression2/typename/IGCObject_DTypename.hpp index d002a847..5e94f460 100644 --- a/include/xo/expression2/typename/IGCObject_DTypename.hpp +++ b/include/xo/expression2/typename/IGCObject_DTypename.hpp @@ -55,7 +55,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DTypename & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DTypename & self, obj gc) noexcept; + static void forward_children(DTypename & self, obj gc) noexcept; ///@} }; diff --git a/include/xo/expression2/variable/IGCObject_DVariable.hpp b/include/xo/expression2/variable/IGCObject_DVariable.hpp index 5fd34c21..f7745ca9 100644 --- a/include/xo/expression2/variable/IGCObject_DVariable.hpp +++ b/include/xo/expression2/variable/IGCObject_DVariable.hpp @@ -57,7 +57,7 @@ namespace xo { /** move instance using allocator **/ static Opaque shallow_move(DVariable & self, obj gc) noexcept; /** during GC: forward immdiate children **/ - static size_type forward_children(DVariable & self, obj gc) noexcept; + static void forward_children(DVariable & self, obj gc) noexcept; ///@} }; diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index 58275e54..c125fb98 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -29,6 +29,14 @@ namespace xo { { } + DGlobalSymtab::DGlobalSymtab(DGlobalSymtab && other) + : var_map_{std::move(other.var_map_)}, + vars_{std::move(other.vars_)}, + type_map_{std::move(other.type_map_)}, + types_{std::move(other.types_)} + { + } + DGlobalSymtab * DGlobalSymtab::_make(obj mm, obj aux_mm, diff --git a/src/expression2/IGCObject_DApplyExpr.cpp b/src/expression2/IGCObject_DApplyExpr.cpp index 2a731c0b..d891b9de 100644 --- a/src/expression2/IGCObject_DApplyExpr.cpp +++ b/src/expression2/IGCObject_DApplyExpr.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DApplyExpr::forward_children(DApplyExpr & self, obj gc) noexcept -> size_type + IGCObject_DApplyExpr::forward_children(DApplyExpr & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DConstant.cpp b/src/expression2/IGCObject_DConstant.cpp index ae5a701f..256ba991 100644 --- a/src/expression2/IGCObject_DConstant.cpp +++ b/src/expression2/IGCObject_DConstant.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DConstant::forward_children(DConstant & self, obj gc) noexcept -> size_type + IGCObject_DConstant::forward_children(DConstant & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DDefineExpr.cpp b/src/expression2/IGCObject_DDefineExpr.cpp index 1e2c3bb8..b10d3ecd 100644 --- a/src/expression2/IGCObject_DDefineExpr.cpp +++ b/src/expression2/IGCObject_DDefineExpr.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DDefineExpr::forward_children(DDefineExpr & self, obj gc) noexcept -> size_type + IGCObject_DDefineExpr::forward_children(DDefineExpr & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DGlobalSymtab.cpp b/src/expression2/IGCObject_DGlobalSymtab.cpp index 3f596d01..70f541d3 100644 --- a/src/expression2/IGCObject_DGlobalSymtab.cpp +++ b/src/expression2/IGCObject_DGlobalSymtab.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DGlobalSymtab::forward_children(DGlobalSymtab & self, obj gc) noexcept -> size_type + IGCObject_DGlobalSymtab::forward_children(DGlobalSymtab & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DIfElseExpr.cpp b/src/expression2/IGCObject_DIfElseExpr.cpp index 240906f2..05e997cf 100644 --- a/src/expression2/IGCObject_DIfElseExpr.cpp +++ b/src/expression2/IGCObject_DIfElseExpr.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DIfElseExpr::forward_children(DIfElseExpr & self, obj gc) noexcept -> size_type + IGCObject_DIfElseExpr::forward_children(DIfElseExpr & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DLambdaExpr.cpp b/src/expression2/IGCObject_DLambdaExpr.cpp index c0a95847..0999c696 100644 --- a/src/expression2/IGCObject_DLambdaExpr.cpp +++ b/src/expression2/IGCObject_DLambdaExpr.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DLambdaExpr::forward_children(DLambdaExpr & self, obj gc) noexcept -> size_type + IGCObject_DLambdaExpr::forward_children(DLambdaExpr & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DLocalSymtab.cpp b/src/expression2/IGCObject_DLocalSymtab.cpp index 02941925..bf6d3b51 100644 --- a/src/expression2/IGCObject_DLocalSymtab.cpp +++ b/src/expression2/IGCObject_DLocalSymtab.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DLocalSymtab::forward_children(DLocalSymtab & self, obj gc) noexcept -> size_type + IGCObject_DLocalSymtab::forward_children(DLocalSymtab & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DSequenceExpr.cpp b/src/expression2/IGCObject_DSequenceExpr.cpp index 93af6f10..9ba1cab8 100644 --- a/src/expression2/IGCObject_DSequenceExpr.cpp +++ b/src/expression2/IGCObject_DSequenceExpr.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DSequenceExpr::forward_children(DSequenceExpr & self, obj gc) noexcept -> size_type + IGCObject_DSequenceExpr::forward_children(DSequenceExpr & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DTypename.cpp b/src/expression2/IGCObject_DTypename.cpp index 58df5bff..76bf837f 100644 --- a/src/expression2/IGCObject_DTypename.cpp +++ b/src/expression2/IGCObject_DTypename.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DTypename::forward_children(DTypename & self, obj gc) noexcept -> size_type + IGCObject_DTypename::forward_children(DTypename & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DVarRef.cpp b/src/expression2/IGCObject_DVarRef.cpp index 64967c9b..e9869fdf 100644 --- a/src/expression2/IGCObject_DVarRef.cpp +++ b/src/expression2/IGCObject_DVarRef.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVarRef::forward_children(DVarRef & self, obj gc) noexcept -> size_type + IGCObject_DVarRef::forward_children(DVarRef & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ diff --git a/src/expression2/facet/IGCObject_DVariable.cpp b/src/expression2/facet/IGCObject_DVariable.cpp index d418145c..657ce453 100644 --- a/src/expression2/facet/IGCObject_DVariable.cpp +++ b/src/expression2/facet/IGCObject_DVariable.cpp @@ -27,9 +27,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVariable::forward_children(DVariable & self, obj gc) noexcept -> size_type + IGCObject_DVariable::forward_children(DVariable & self, obj gc) noexcept -> void { - return self.forward_children(gc); + self.forward_children(gc); } } /*namespace scm*/ From c3af7633832bc5413240c3c3bc8c444f0eb443c1 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 17:30:03 -0400 Subject: [PATCH 120/128] refactor: retire GCObject.shallow_size() Not needed. Rely on size stored in gc-owned object header --- include/xo/expression2/define/IGCObject_DDefineExpr.hpp | 2 -- include/xo/expression2/detail/IGCObject_DApplyExpr.hpp | 2 -- include/xo/expression2/detail/IGCObject_DConstant.hpp | 2 -- include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp | 2 -- include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp | 2 -- include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp | 2 -- include/xo/expression2/detail/IGCObject_DVarRef.hpp | 2 -- include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp | 2 -- include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp | 2 -- include/xo/expression2/typename/IGCObject_DTypename.hpp | 2 -- include/xo/expression2/variable/IGCObject_DVariable.hpp | 2 -- src/expression2/IGCObject_DApplyExpr.cpp | 6 ------ src/expression2/IGCObject_DConstant.cpp | 6 ------ src/expression2/IGCObject_DDefineExpr.cpp | 6 ------ src/expression2/IGCObject_DGlobalSymtab.cpp | 6 ------ src/expression2/IGCObject_DIfElseExpr.cpp | 6 ------ src/expression2/IGCObject_DLambdaExpr.cpp | 6 ------ src/expression2/IGCObject_DLocalSymtab.cpp | 6 ------ src/expression2/IGCObject_DSequenceExpr.cpp | 6 ------ src/expression2/IGCObject_DTypename.cpp | 6 ------ src/expression2/IGCObject_DVarRef.cpp | 6 ------ src/expression2/facet/IGCObject_DVariable.cpp | 6 ------ 22 files changed, 88 deletions(-) diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp index e01e7be7..c0e774c8 100644 --- a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-ddefineexpr-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DDefineExpr & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp index b85665c8..477a9b77 100644 --- a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dapplyexpr-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DApplyExpr & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp index 91bf9638..6d631c74 100644 --- a/include/xo/expression2/detail/IGCObject_DConstant.hpp +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dconstant-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DConstant & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp index 59aae40f..c4917774 100644 --- a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-difelseexpr-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DIfElseExpr & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp index 2351256d..6a484b28 100644 --- a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dlambdaexpr-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DLambdaExpr & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index c3fba848..0bcf1f90 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dsequenceexpr-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DSequenceExpr & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp index 97b0f3d6..91c1888c 100644 --- a/include/xo/expression2/detail/IGCObject_DVarRef.hpp +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dvarref-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DVarRef & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp index 5de0f0da..692be2fc 100644 --- a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dglobalsymtab-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DGlobalSymtab & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp index 6b9d81a1..42de5a79 100644 --- a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dlocalsymtab-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DLocalSymtab & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/expression2/typename/IGCObject_DTypename.hpp b/include/xo/expression2/typename/IGCObject_DTypename.hpp index 5e94f460..3ed445aa 100644 --- a/include/xo/expression2/typename/IGCObject_DTypename.hpp +++ b/include/xo/expression2/typename/IGCObject_DTypename.hpp @@ -48,8 +48,6 @@ namespace xo { /** @defgroup scm-gcobject-dtypename-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DTypename & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/include/xo/expression2/variable/IGCObject_DVariable.hpp b/include/xo/expression2/variable/IGCObject_DVariable.hpp index f7745ca9..84c224cd 100644 --- a/include/xo/expression2/variable/IGCObject_DVariable.hpp +++ b/include/xo/expression2/variable/IGCObject_DVariable.hpp @@ -50,8 +50,6 @@ namespace xo { /** @defgroup scm-gcobject-dvariable-methods **/ ///@{ // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DVariable & self) noexcept; // non-const methods /** move instance using allocator **/ diff --git a/src/expression2/IGCObject_DApplyExpr.cpp b/src/expression2/IGCObject_DApplyExpr.cpp index d891b9de..56fdda92 100644 --- a/src/expression2/IGCObject_DApplyExpr.cpp +++ b/src/expression2/IGCObject_DApplyExpr.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DApplyExpr::shallow_size(const DApplyExpr & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DApplyExpr::shallow_move(DApplyExpr & self, obj gc) noexcept -> Opaque { diff --git a/src/expression2/IGCObject_DConstant.cpp b/src/expression2/IGCObject_DConstant.cpp index 256ba991..62bf0fd7 100644 --- a/src/expression2/IGCObject_DConstant.cpp +++ b/src/expression2/IGCObject_DConstant.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DConstant::shallow_size(const DConstant & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DConstant::shallow_move(DConstant & self, obj gc) noexcept -> Opaque { diff --git a/src/expression2/IGCObject_DDefineExpr.cpp b/src/expression2/IGCObject_DDefineExpr.cpp index b10d3ecd..91c83d67 100644 --- a/src/expression2/IGCObject_DDefineExpr.cpp +++ b/src/expression2/IGCObject_DDefineExpr.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DDefineExpr::shallow_size(const DDefineExpr & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DDefineExpr::shallow_move(DDefineExpr & self, obj gc) noexcept -> Opaque { diff --git a/src/expression2/IGCObject_DGlobalSymtab.cpp b/src/expression2/IGCObject_DGlobalSymtab.cpp index 70f541d3..9f9549ae 100644 --- a/src/expression2/IGCObject_DGlobalSymtab.cpp +++ b/src/expression2/IGCObject_DGlobalSymtab.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DGlobalSymtab::shallow_size(const DGlobalSymtab & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DGlobalSymtab::shallow_move(DGlobalSymtab & self, obj gc) noexcept -> Opaque { diff --git a/src/expression2/IGCObject_DIfElseExpr.cpp b/src/expression2/IGCObject_DIfElseExpr.cpp index 05e997cf..532cad21 100644 --- a/src/expression2/IGCObject_DIfElseExpr.cpp +++ b/src/expression2/IGCObject_DIfElseExpr.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DIfElseExpr::shallow_size(const DIfElseExpr & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DIfElseExpr::shallow_move(DIfElseExpr & self, obj gc) noexcept -> Opaque { diff --git a/src/expression2/IGCObject_DLambdaExpr.cpp b/src/expression2/IGCObject_DLambdaExpr.cpp index 0999c696..b6045e90 100644 --- a/src/expression2/IGCObject_DLambdaExpr.cpp +++ b/src/expression2/IGCObject_DLambdaExpr.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DLambdaExpr::shallow_size(const DLambdaExpr & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DLambdaExpr::shallow_move(DLambdaExpr & self, obj gc) noexcept -> Opaque { diff --git a/src/expression2/IGCObject_DLocalSymtab.cpp b/src/expression2/IGCObject_DLocalSymtab.cpp index bf6d3b51..df9bc0b7 100644 --- a/src/expression2/IGCObject_DLocalSymtab.cpp +++ b/src/expression2/IGCObject_DLocalSymtab.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DLocalSymtab::shallow_size(const DLocalSymtab & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DLocalSymtab::shallow_move(DLocalSymtab & self, obj gc) noexcept -> Opaque { diff --git a/src/expression2/IGCObject_DSequenceExpr.cpp b/src/expression2/IGCObject_DSequenceExpr.cpp index 9ba1cab8..36efcbfe 100644 --- a/src/expression2/IGCObject_DSequenceExpr.cpp +++ b/src/expression2/IGCObject_DSequenceExpr.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DSequenceExpr::shallow_size(const DSequenceExpr & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DSequenceExpr::shallow_move(DSequenceExpr & self, obj gc) noexcept -> Opaque { diff --git a/src/expression2/IGCObject_DTypename.cpp b/src/expression2/IGCObject_DTypename.cpp index 76bf837f..246b7bd5 100644 --- a/src/expression2/IGCObject_DTypename.cpp +++ b/src/expression2/IGCObject_DTypename.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DTypename::shallow_size(const DTypename & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DTypename::shallow_move(DTypename & self, obj gc) noexcept -> Opaque { diff --git a/src/expression2/IGCObject_DVarRef.cpp b/src/expression2/IGCObject_DVarRef.cpp index e9869fdf..fc0934fd 100644 --- a/src/expression2/IGCObject_DVarRef.cpp +++ b/src/expression2/IGCObject_DVarRef.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DVarRef::shallow_size(const DVarRef & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DVarRef::shallow_move(DVarRef & self, obj gc) noexcept -> Opaque { diff --git a/src/expression2/facet/IGCObject_DVariable.cpp b/src/expression2/facet/IGCObject_DVariable.cpp index 657ce453..7b2103d6 100644 --- a/src/expression2/facet/IGCObject_DVariable.cpp +++ b/src/expression2/facet/IGCObject_DVariable.cpp @@ -15,12 +15,6 @@ namespace xo { namespace scm { - auto - IGCObject_DVariable::shallow_size(const DVariable & self) noexcept -> size_type - { - return self.shallow_size(); - } - auto IGCObject_DVariable::shallow_move(DVariable & self, obj gc) noexcept -> Opaque { From fdc3054c7cad065144538aea4db283cc51a06f78 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 5 Apr 2026 23:53:02 -0400 Subject: [PATCH 121/128] refactor: + narrower interface for gc pointer forwarding add AGCObjectVisitor, instead of requiring ACollector. --- include/xo/expression2/DApplyExpr.hpp | 4 ++- include/xo/expression2/DConstant.hpp | 6 ++-- include/xo/expression2/DDefineExpr.hpp | 4 ++- include/xo/expression2/DGlobalSymtab.hpp | 7 +++-- include/xo/expression2/DIfElseExpr.hpp | 6 ++-- include/xo/expression2/DLambdaExpr.hpp | 4 ++- include/xo/expression2/DLocalSymtab.hpp | 7 +++-- include/xo/expression2/DSequenceExpr.hpp | 4 ++- include/xo/expression2/DTypename.hpp | 6 ++-- include/xo/expression2/DVarRef.hpp | 4 ++- include/xo/expression2/DVariable.hpp | 4 ++- include/xo/expression2/TypeRef.hpp | 4 ++- .../define/IGCObject_DDefineExpr.hpp | 7 +++-- .../detail/IGCObject_DApplyExpr.hpp | 7 +++-- .../detail/IGCObject_DConstant.hpp | 7 +++-- .../detail/IGCObject_DIfElseExpr.hpp | 7 +++-- .../detail/IGCObject_DLambdaExpr.hpp | 7 +++-- .../detail/IGCObject_DSequenceExpr.hpp | 7 +++-- .../expression2/detail/IGCObject_DVarRef.hpp | 7 +++-- .../symtab/IGCObject_DGlobalSymtab.hpp | 7 +++-- .../symtab/IGCObject_DLocalSymtab.hpp | 7 +++-- .../typename/IGCObject_DTypename.hpp | 7 +++-- .../variable/IGCObject_DVariable.hpp | 7 +++-- src/expression2/DApplyExpr.cpp | 20 ++++++------- src/expression2/DConstant.cpp | 11 +++---- src/expression2/DDefineExpr.cpp | 10 +++---- src/expression2/DGlobalSymtab.cpp | 16 +++------- src/expression2/DIfElseExpr.cpp | 23 ++++++++------- src/expression2/DLambdaExpr.cpp | 29 +++++++++---------- src/expression2/DLocalSymtab.cpp | 18 ++++-------- src/expression2/DSequenceExpr.cpp | 10 +++---- src/expression2/DTypename.cpp | 14 ++++----- src/expression2/DVarRef.cpp | 8 ++--- src/expression2/DVariable.cpp | 8 ++--- src/expression2/IGCObject_DApplyExpr.cpp | 4 +-- src/expression2/IGCObject_DConstant.cpp | 4 +-- src/expression2/IGCObject_DDefineExpr.cpp | 4 +-- src/expression2/IGCObject_DGlobalSymtab.cpp | 4 +-- src/expression2/IGCObject_DIfElseExpr.cpp | 4 +-- src/expression2/IGCObject_DLambdaExpr.cpp | 4 +-- src/expression2/IGCObject_DLocalSymtab.cpp | 4 +-- src/expression2/IGCObject_DSequenceExpr.cpp | 4 +-- src/expression2/IGCObject_DTypename.cpp | 4 +-- src/expression2/IGCObject_DVarRef.cpp | 4 +-- src/expression2/TypeRef.cpp | 4 +-- src/expression2/facet/IGCObject_DVariable.cpp | 4 +-- 46 files changed, 187 insertions(+), 165 deletions(-) diff --git a/include/xo/expression2/DApplyExpr.hpp b/include/xo/expression2/DApplyExpr.hpp index b4119def..0042d561 100644 --- a/include/xo/expression2/DApplyExpr.hpp +++ b/include/xo/expression2/DApplyExpr.hpp @@ -8,6 +8,7 @@ #include "Expression.hpp" #include "TypeRef.hpp" #include "exprtype.hpp" +#include #include #include #include @@ -21,6 +22,7 @@ namespace xo { class DApplyExpr { public: using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; using ppindentinfo = xo::print::ppindentinfo; @@ -84,7 +86,7 @@ namespace xo { std::size_t shallow_size() const noexcept; DApplyExpr * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-applyexpr-printable-facet **/ diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp index e78440ad..2c878ea9 100644 --- a/include/xo/expression2/DConstant.hpp +++ b/include/xo/expression2/DConstant.hpp @@ -10,6 +10,7 @@ #include "exprtype.hpp" #include #include +#include #include namespace xo { @@ -22,8 +23,9 @@ namespace xo { using TaggedPtr = xo::reflect::TaggedPtr; using TypeDescr = xo::reflect::TypeDescr; using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using AAllocator = xo::mm::AAllocator; using typeseq = xo::reflect::typeseq; using ppindentinfo = xo::print::ppindentinfo; @@ -64,7 +66,7 @@ namespace xo { size_t shallow_size() const noexcept; DConstant * shallow_move(obj gc) noexcept; - size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-constant-printable-facet **/ diff --git a/include/xo/expression2/DDefineExpr.hpp b/include/xo/expression2/DDefineExpr.hpp index 1e20c530..f1528531 100644 --- a/include/xo/expression2/DDefineExpr.hpp +++ b/include/xo/expression2/DDefineExpr.hpp @@ -8,6 +8,7 @@ #include "Expression.hpp" #include "DVariable.hpp" #include +#include #include namespace xo { @@ -24,6 +25,7 @@ namespace xo { public: using ppindentinfo = xo::print::ppindentinfo; using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -74,7 +76,7 @@ namespace xo { std::size_t shallow_size() const noexcept; DDefineExpr * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-defineexpr-printable-facet **/ diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index 782e48f7..a24c0bdc 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -9,6 +9,7 @@ #include "DVariable.hpp" #include "DTypename.hpp" #include +#include #include #include @@ -30,8 +31,9 @@ namespace xo { using ArenaHashMapConfig = xo::map::ArenaHashMapConfig; using repr_type = xo::map::DArenaHashMap; using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using AAllocator = xo::mm::AAllocator; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; using ppindentinfo = xo::print::ppindentinfo; using size_type = std::uint32_t; @@ -113,9 +115,8 @@ namespace xo { /** @defgroup scm-globalsymtab-gcobject-facet gcobject facet **/ ///@{ - std::size_t shallow_size() const noexcept; DGlobalSymtab * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-globalsymtab-printable-facet printable facet **/ diff --git a/include/xo/expression2/DIfElseExpr.hpp b/include/xo/expression2/DIfElseExpr.hpp index 8ffee429..b27c9ade 100644 --- a/include/xo/expression2/DIfElseExpr.hpp +++ b/include/xo/expression2/DIfElseExpr.hpp @@ -9,10 +9,9 @@ #include "TypeRef.hpp" #include "exprtype.hpp" #include +#include #include -//#include #include -//#include namespace xo { namespace scm { @@ -23,6 +22,7 @@ namespace xo { class DIfElseExpr { public: using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; using ppindentinfo = xo::print::ppindentinfo; @@ -100,7 +100,7 @@ namespace xo { std::size_t shallow_size() const noexcept; DIfElseExpr * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DLambdaExpr.hpp b/include/xo/expression2/DLambdaExpr.hpp index 0d8d2391..2a507497 100644 --- a/include/xo/expression2/DLambdaExpr.hpp +++ b/include/xo/expression2/DLambdaExpr.hpp @@ -10,6 +10,7 @@ #include "exprtype.hpp" #include "DLocalSymtab.hpp" #include "DString.hpp" +#include #include namespace xo { @@ -21,6 +22,7 @@ namespace xo { class DLambdaExpr { public: using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; using ppindentinfo = xo::print::ppindentinfo; @@ -86,7 +88,7 @@ namespace xo { std::size_t shallow_size() const noexcept; DLambdaExpr * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-lambdaexpr-printable-facet **/ diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index b2843cb9..f389c3ea 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -9,6 +9,7 @@ #include "DVariable.hpp" #include "DUniqueString.hpp" #include +#include namespace xo { namespace scm { @@ -20,8 +21,9 @@ namespace xo { using DArray = xo::scm::DArray; using ppindentinfo = xo::print::ppindentinfo; using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; using AGCObject = xo::mm::AGCObject; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using AAllocator = xo::mm::AAllocator; /* note: uint16_t would be fine too */ using size_type = std::uint32_t; @@ -97,9 +99,8 @@ namespace xo { /** @defgroup xo-localsymtab-gcobject-facet gcobject facet **/ ///@{ - std::size_t shallow_size() const noexcept; DLocalSymtab * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup xo-localsymtab-printable-facet printable facet **/ diff --git a/include/xo/expression2/DSequenceExpr.hpp b/include/xo/expression2/DSequenceExpr.hpp index f876cfac..76a8bec0 100644 --- a/include/xo/expression2/DSequenceExpr.hpp +++ b/include/xo/expression2/DSequenceExpr.hpp @@ -8,6 +8,7 @@ #include "Expression.hpp" #include "TypeRef.hpp" #include +#include namespace xo { namespace scm { @@ -23,6 +24,7 @@ namespace xo { class DSequenceExpr { public: using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; using size_type = DArray::size_type; @@ -74,7 +76,7 @@ namespace xo { std::size_t shallow_size() const noexcept; DSequenceExpr * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DTypename.hpp b/include/xo/expression2/DTypename.hpp index 7bd30931..2e35c9e3 100644 --- a/include/xo/expression2/DTypename.hpp +++ b/include/xo/expression2/DTypename.hpp @@ -7,6 +7,7 @@ #include "DUniqueString.hpp" #include +#include #include #include @@ -24,8 +25,9 @@ namespace xo { public: using ppindentinfo = xo::print::ppindentinfo; using ACollector = xo::mm::ACollector; - using AAllocator = xo::mm::AAllocator; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; + using AAllocator = xo::mm::AAllocator; public: DTypename(const DUniqueString * name, @@ -55,7 +57,7 @@ namespace xo { size_t shallow_size() const noexcept; DTypename * shallow_move(obj gc) noexcept; - size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-typename-printable-facet **/ diff --git a/include/xo/expression2/DVarRef.hpp b/include/xo/expression2/DVarRef.hpp index 65abddb2..db85d558 100644 --- a/include/xo/expression2/DVarRef.hpp +++ b/include/xo/expression2/DVarRef.hpp @@ -6,6 +6,7 @@ #pragma once #include "Variable.hpp" +#include namespace xo { namespace scm { @@ -21,6 +22,7 @@ namespace xo { public: using ppindentinfo = xo::print::ppindentinfo; using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -56,7 +58,7 @@ namespace xo { size_t shallow_size() const noexcept; DVarRef * shallow_move(obj gc) noexcept; - size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-variable-printable-facet **/ diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp index 12abae94..2e74fbcc 100644 --- a/include/xo/expression2/DVariable.hpp +++ b/include/xo/expression2/DVariable.hpp @@ -9,6 +9,7 @@ #include "Binding.hpp" #include "TypeRef.hpp" #include "exprtype.hpp" +#include #include #include @@ -22,6 +23,7 @@ namespace xo { public: using ppindentinfo = xo::print::ppindentinfo; using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -64,7 +66,7 @@ namespace xo { size_t shallow_size() const noexcept; DVariable * shallow_move(obj gc) noexcept; - size_t forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; ///@} /** @defgroup scm-variable-printable-facet **/ diff --git a/include/xo/expression2/TypeRef.hpp b/include/xo/expression2/TypeRef.hpp index 1342b4df..f56028ba 100644 --- a/include/xo/expression2/TypeRef.hpp +++ b/include/xo/expression2/TypeRef.hpp @@ -8,6 +8,7 @@ #include #include #include +#include #include #include @@ -26,6 +27,7 @@ namespace xo { using type_var = flatstring<20>; using prefix_type = flatstring<8>; using ACollector = xo::mm::ACollector; + using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using ppindentinfo = xo::print::ppindentinfo; public: @@ -73,7 +75,7 @@ namespace xo { bool pretty(const ppindentinfo & ppii) const; /** gc support **/ - void forward_children(obj gc) noexcept; + void visit_gco_children(obj gc) noexcept; private: TypeRef(const type_var & id, TypeDescr td); diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp index c0e774c8..adb18480 100644 --- a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DDefineExpr & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DDefineExpr & 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(DDefineExpr & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp index 477a9b77..86047bd7 100644 --- a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DApplyExpr & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DApplyExpr & 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(DApplyExpr & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp index 6d631c74..823d0de9 100644 --- a/include/xo/expression2/detail/IGCObject_DConstant.hpp +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DConstant & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DConstant & 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(DConstant & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp index c4917774..13d0e3e4 100644 --- a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DIfElseExpr & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DIfElseExpr & 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(DIfElseExpr & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp index 6a484b28..077b0e3a 100644 --- a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DLambdaExpr & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DLambdaExpr & 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(DLambdaExpr & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index 0bcf1f90..8d86241b 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DSequenceExpr & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DSequenceExpr & 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(DSequenceExpr & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp index 91c1888c..71489ef4 100644 --- a/include/xo/expression2/detail/IGCObject_DVarRef.hpp +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DVarRef & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DVarRef & 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(DVarRef & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp index 692be2fc..48cf1d7c 100644 --- a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DGlobalSymtab & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DGlobalSymtab & 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(DGlobalSymtab & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp index 42de5a79..82717f96 100644 --- a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DLocalSymtab & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DLocalSymtab & 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(DLocalSymtab & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/typename/IGCObject_DTypename.hpp b/include/xo/expression2/typename/IGCObject_DTypename.hpp index 3ed445aa..8c72100b 100644 --- a/include/xo/expression2/typename/IGCObject_DTypename.hpp +++ b/include/xo/expression2/typename/IGCObject_DTypename.hpp @@ -42,6 +42,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -52,8 +53,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DTypename & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DTypename & 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(DTypename & self, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/variable/IGCObject_DVariable.hpp b/include/xo/expression2/variable/IGCObject_DVariable.hpp index 84c224cd..d04f3588 100644 --- a/include/xo/expression2/variable/IGCObject_DVariable.hpp +++ b/include/xo/expression2/variable/IGCObject_DVariable.hpp @@ -44,6 +44,7 @@ namespace xo { using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; + using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -54,8 +55,10 @@ namespace xo { // non-const methods /** move instance using allocator **/ static Opaque shallow_move(DVariable & self, obj gc) noexcept; - /** during GC: forward immdiate children **/ - static void forward_children(DVariable & 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(DVariable & self, obj fn) noexcept; ///@} }; diff --git a/src/expression2/DApplyExpr.cpp b/src/expression2/DApplyExpr.cpp index 9683d459..18b9b60a 100644 --- a/src/expression2/DApplyExpr.cpp +++ b/src/expression2/DApplyExpr.cpp @@ -129,27 +129,25 @@ namespace xo { return copy; } - std::size_t - DApplyExpr::forward_children(obj gc) noexcept + void + DApplyExpr::visit_gco_children(obj gc) noexcept { - typeref_.forward_children(gc); + typeref_.visit_gco_children(gc); { - obj fn_gco = fn_.to_facet(); - gc.forward_inplace(fn_gco.iface(), (void **)&fn_.data_); + gc.visit_poly_child(&fn_); + //obj fn_gco = fn_.to_facet(); + //gc.forward_inplace(fn_gco.iface(), (void **)&fn_.data_); } for (size_type i = 0; i < n_args_; ++i) { obj & arg = args_[i]; // runtime poly here - obj arg_gco = arg.to_facet(); - - // need the data address within *this - gc.forward_inplace(arg_gco.iface(), (void **)(&arg.data_)); + gc.visit_poly_child(&arg); + //obj arg_gco = arg.to_facet(); + //gc.forward_inplace(arg_gco.iface(), (void **)(&arg.data_)); } - - return shallow_size(); } // ----- printable facet ----- diff --git a/src/expression2/DConstant.cpp b/src/expression2/DConstant.cpp index 46d4cbe9..bbf86183 100644 --- a/src/expression2/DConstant.cpp +++ b/src/expression2/DConstant.cpp @@ -83,15 +83,12 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DConstant::forward_children(obj gc) noexcept + void + DConstant::visit_gco_children(obj gc) noexcept { - typeref_.forward_children(gc); + typeref_.visit_gco_children(gc); - gc.forward_inplace(&value_); - //gc.forward_inplace(value_.iface(), (void **)&(value_.data_)); - - return shallow_size(); + gc.visit_child(&value_); } bool diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index b25a655d..69ce84e0 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -90,14 +90,12 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DDefineExpr::forward_children(obj gc) noexcept + void + DDefineExpr::visit_gco_children(obj gc) noexcept { - gc.forward_inplace(&lhs_var_); + gc.visit_child(&lhs_var_); //gc.forward_inplace(&rhs_); // complicated - need to access via GCObject facet - poly_forward_inplace(gc, &rhs_); - - return this->shallow_size(); + gc.visit_poly_child(&rhs_); } bool diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index c125fb98..10f65ea2 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -262,30 +262,22 @@ namespace xo { // ----- gcobject facet ----- - std::size_t - DGlobalSymtab::shallow_size() const noexcept - { - return sizeof(DGlobalSymtab); - } - DGlobalSymtab * DGlobalSymtab::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - std::size_t - DGlobalSymtab::forward_children(obj gc) noexcept + void + DGlobalSymtab::visit_gco_children(obj gc) noexcept { // map_ doesn't contain any gc-owned data, can skip static_assert(var_map_.is_gc_eligible() == false); static_assert(type_map_.is_gc_eligible() == false); - gc.forward_inplace(&vars_); - gc.forward_inplace(&types_); - - return this->shallow_size(); + gc.visit_child(&vars_); + gc.visit_child(&types_); } // ----- printable facet ----- diff --git a/src/expression2/DIfElseExpr.cpp b/src/expression2/DIfElseExpr.cpp index 81efee1e..c44a7ebd 100644 --- a/src/expression2/DIfElseExpr.cpp +++ b/src/expression2/DIfElseExpr.cpp @@ -94,26 +94,27 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DIfElseExpr::forward_children(obj gc) noexcept + void + DIfElseExpr::visit_gco_children(obj gc) noexcept { - typeref_.forward_children(gc); + typeref_.visit_gco_children(gc); // GC needs to locate AGCObject iface for each member. { - auto gco = test_.to_facet(); - gc.forward_inplace(gco.iface(), (void **)&(test_.data_)); + gc.visit_poly_child(&test_); + //auto gco = test_.to_facet(); + //gc.forward_inplace(gco.iface(), (void **)&(test_.data_)); } { - auto gco = when_true_.to_facet(); - gc.forward_inplace(gco.iface(), (void **)&(when_true_.data_)); + gc.visit_poly_child(&when_true_); + //auto gco = when_true_.to_facet(); + //gc.forward_inplace(gco.iface(), (void **)&(when_true_.data_)); } { - auto gco = when_false_.to_facet(); - gc.forward_inplace(gco.iface(), (void **)&(when_false_.data_)); + gc.visit_poly_child(&when_false_); + //auto gco = when_false_.to_facet(); + //gc.forward_inplace(gco.iface(), (void **)&(when_false_.data_)); } - - return shallow_size(); } // ----- printable facet ----- diff --git a/src/expression2/DLambdaExpr.cpp b/src/expression2/DLambdaExpr.cpp index 8069cd3c..349ccd99 100644 --- a/src/expression2/DLambdaExpr.cpp +++ b/src/expression2/DLambdaExpr.cpp @@ -13,6 +13,7 @@ namespace xo { using xo::mm::AGCObject; + using xo::mm::AGCObjectVisitor; using xo::print::APrintable; using xo::facet::FacetRegistry; using xo::reflect::TypeDescr; @@ -144,36 +145,32 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DLambdaExpr::forward_children(obj gc) noexcept { - typeref_.forward_children(gc); + void + DLambdaExpr::visit_gco_children(obj gc) noexcept { + typeref_.visit_gco_children(gc); - { - //gc.forward_inplace(&name_); // doesn't compile for const ptr - auto iface = xo::facet::impl_for(); - gc.forward_inplace(&iface, (void **)(&name_)); - } + gc.visit_child(&name_); + //{ + // auto iface = xo::facet::impl_for(); + // gc.forward_inplace(&iface, (void **)(&name_)); + //} // type_name_str_ { - gc.forward_inplace(&local_symtab_); - //auto iface = xo::facet::impl_for(); - //gc.forward_inplace(&iface, (void **)(&local_symtab_)); + gc.visit_child(&local_symtab_); + //gc.forward_inplace(&local_symtab_); } { - gc.forward_pivot_inplace(&body_expr_); - //auto iface = body_expr_.to_facet().iface(); - //gc.forward_inplace(iface, (void **)&(body_expr_.data_)); + gc.visit_poly_child(&body_expr_); + //gc.forward_pivot_inplace(&body_expr_); } // xxx free_var_set // xxx captured_var_set // xxx layer_var_map // xxx nested_lambda_map - - return shallow_size(); } bool diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index 60cdd2e2..017fb1d7 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -112,26 +112,18 @@ namespace xo { // ----- gcobject facet ----- - std::size_t - DLocalSymtab::shallow_size() const noexcept - { - return sizeof(DLocalSymtab); - } - DLocalSymtab * DLocalSymtab::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - std::size_t - DLocalSymtab::forward_children(obj gc) noexcept + void + DLocalSymtab::visit_gco_children(obj gc) noexcept { - gc.forward_inplace(&parent_); - gc.forward_inplace(&vars_); - gc.forward_inplace(&types_); - - return shallow_size(); + gc.visit_child(&parent_); + gc.visit_child(&vars_); + gc.visit_child(&types_); } // ----- printable facet ----- diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index ed03affc..2dc153f0 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -125,14 +125,12 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DSequenceExpr::forward_children(obj gc) noexcept + void + DSequenceExpr::visit_gco_children(obj gc) noexcept { - typeref_.forward_children(gc); + typeref_.visit_gco_children(gc); - gc.forward_inplace(&expr_v_); - - return this->shallow_size(); + gc.visit_child(&expr_v_); } } /*namespace scm*/ diff --git a/src/expression2/DTypename.cpp b/src/expression2/DTypename.cpp index c9f56cf1..15e7dbdb 100644 --- a/src/expression2/DTypename.cpp +++ b/src/expression2/DTypename.cpp @@ -52,16 +52,16 @@ namespace xo { return gc.std_move_for(this); } - size_t - DTypename::forward_children(obj gc) noexcept + void + DTypename::visit_gco_children(obj gc) noexcept { - gc.forward_inplace(const_cast(&name_)); + gc.visit_child(&name_); + //gc.forward_inplace(const_cast(&name_)); { - auto e = type_.to_facet(); - gc.forward_inplace(e.iface(), (void **)&(type_.data_)); + gc.visit_poly_child(&type_); + //auto e = type_.to_facet(); + //gc.forward_inplace(e.iface(), (void **)&(type_.data_)); } - - return shallow_size(); } bool diff --git a/src/expression2/DVarRef.cpp b/src/expression2/DVarRef.cpp index 3b9b2638..6cdea4e5 100644 --- a/src/expression2/DVarRef.cpp +++ b/src/expression2/DVarRef.cpp @@ -70,16 +70,14 @@ namespace xo { return gc.std_move_for(this); } - std::size_t - DVarRef::forward_children(obj gc) noexcept + void + DVarRef::visit_gco_children(obj gc) noexcept { - gc.forward_inplace(&vardef_); + gc.visit_child(&vardef_); //auto iface = xo::facet::impl_for(); //gc.forward_inplace(&iface, (void **)vardef_.data_); // TODO: concept to indicate that no gc pointers in Binding - - return shallow_size(); } // printable facet diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index 68a87f67..9ab2f8bd 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -50,12 +50,10 @@ namespace xo { return gc.std_move_for(this); } - size_t - DVariable::forward_children(obj gc) noexcept + void + DVariable::visit_gco_children(obj gc) noexcept { - typeref_.forward_children(gc); - - return shallow_size(); + typeref_.visit_gco_children(gc); } bool diff --git a/src/expression2/IGCObject_DApplyExpr.cpp b/src/expression2/IGCObject_DApplyExpr.cpp index 56fdda92..9b5fc735 100644 --- a/src/expression2/IGCObject_DApplyExpr.cpp +++ b/src/expression2/IGCObject_DApplyExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DApplyExpr::forward_children(DApplyExpr & self, obj gc) noexcept -> void + IGCObject_DApplyExpr::visit_gco_children(DApplyExpr & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DConstant.cpp b/src/expression2/IGCObject_DConstant.cpp index 62bf0fd7..3e350102 100644 --- a/src/expression2/IGCObject_DConstant.cpp +++ b/src/expression2/IGCObject_DConstant.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DConstant::forward_children(DConstant & self, obj gc) noexcept -> void + IGCObject_DConstant::visit_gco_children(DConstant & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DDefineExpr.cpp b/src/expression2/IGCObject_DDefineExpr.cpp index 91c83d67..34c59e93 100644 --- a/src/expression2/IGCObject_DDefineExpr.cpp +++ b/src/expression2/IGCObject_DDefineExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DDefineExpr::forward_children(DDefineExpr & self, obj gc) noexcept -> void + IGCObject_DDefineExpr::visit_gco_children(DDefineExpr & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DGlobalSymtab.cpp b/src/expression2/IGCObject_DGlobalSymtab.cpp index 9f9549ae..1e78de47 100644 --- a/src/expression2/IGCObject_DGlobalSymtab.cpp +++ b/src/expression2/IGCObject_DGlobalSymtab.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DGlobalSymtab::forward_children(DGlobalSymtab & self, obj gc) noexcept -> void + IGCObject_DGlobalSymtab::visit_gco_children(DGlobalSymtab & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DIfElseExpr.cpp b/src/expression2/IGCObject_DIfElseExpr.cpp index 532cad21..0db6f160 100644 --- a/src/expression2/IGCObject_DIfElseExpr.cpp +++ b/src/expression2/IGCObject_DIfElseExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DIfElseExpr::forward_children(DIfElseExpr & self, obj gc) noexcept -> void + IGCObject_DIfElseExpr::visit_gco_children(DIfElseExpr & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DLambdaExpr.cpp b/src/expression2/IGCObject_DLambdaExpr.cpp index b6045e90..a9ad37aa 100644 --- a/src/expression2/IGCObject_DLambdaExpr.cpp +++ b/src/expression2/IGCObject_DLambdaExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DLambdaExpr::forward_children(DLambdaExpr & self, obj gc) noexcept -> void + IGCObject_DLambdaExpr::visit_gco_children(DLambdaExpr & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DLocalSymtab.cpp b/src/expression2/IGCObject_DLocalSymtab.cpp index df9bc0b7..7384e17a 100644 --- a/src/expression2/IGCObject_DLocalSymtab.cpp +++ b/src/expression2/IGCObject_DLocalSymtab.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DLocalSymtab::forward_children(DLocalSymtab & self, obj gc) noexcept -> void + IGCObject_DLocalSymtab::visit_gco_children(DLocalSymtab & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DSequenceExpr.cpp b/src/expression2/IGCObject_DSequenceExpr.cpp index 36efcbfe..8660f506 100644 --- a/src/expression2/IGCObject_DSequenceExpr.cpp +++ b/src/expression2/IGCObject_DSequenceExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DSequenceExpr::forward_children(DSequenceExpr & self, obj gc) noexcept -> void + IGCObject_DSequenceExpr::visit_gco_children(DSequenceExpr & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DTypename.cpp b/src/expression2/IGCObject_DTypename.cpp index 246b7bd5..478b2005 100644 --- a/src/expression2/IGCObject_DTypename.cpp +++ b/src/expression2/IGCObject_DTypename.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DTypename::forward_children(DTypename & self, obj gc) noexcept -> void + IGCObject_DTypename::visit_gco_children(DTypename & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DVarRef.cpp b/src/expression2/IGCObject_DVarRef.cpp index fc0934fd..7035db1e 100644 --- a/src/expression2/IGCObject_DVarRef.cpp +++ b/src/expression2/IGCObject_DVarRef.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVarRef::forward_children(DVarRef & self, obj gc) noexcept -> void + IGCObject_DVarRef::visit_gco_children(DVarRef & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ diff --git a/src/expression2/TypeRef.cpp b/src/expression2/TypeRef.cpp index b5baa88d..961ae148 100644 --- a/src/expression2/TypeRef.cpp +++ b/src/expression2/TypeRef.cpp @@ -102,11 +102,11 @@ namespace xo { } void - TypeRef::forward_children(obj gc) noexcept + TypeRef::visit_gco_children(obj gc) noexcept { //scope log(XO_DEBUG(true), xtag("type", type_.data()), xtag("type.tseq", type_._typeseq())); - gc.forward_pivot_inplace(&type_); + gc.visit_poly_child(&type_); } bool diff --git a/src/expression2/facet/IGCObject_DVariable.cpp b/src/expression2/facet/IGCObject_DVariable.cpp index 7b2103d6..a6370f56 100644 --- a/src/expression2/facet/IGCObject_DVariable.cpp +++ b/src/expression2/facet/IGCObject_DVariable.cpp @@ -21,9 +21,9 @@ namespace xo { return self.shallow_move(gc); } auto - IGCObject_DVariable::forward_children(DVariable & self, obj gc) noexcept -> void + IGCObject_DVariable::visit_gco_children(DVariable & self, obj fn) noexcept -> void { - self.forward_children(gc); + self.visit_gco_children(fn); } } /*namespace scm*/ From f9f28220996bfab3ede1cf2ff5fbd5c20ef4aa0b Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 6 Apr 2026 00:11:08 -0400 Subject: [PATCH 122/128] refactor: make shallow_move() available from AGCObjectVisitor --- include/xo/expression2/define/IGCObject_DDefineExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DApplyExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DConstant.hpp | 2 +- include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp | 2 +- include/xo/expression2/detail/IGCObject_DVarRef.hpp | 2 +- include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp | 2 +- include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp | 2 +- include/xo/expression2/typename/IGCObject_DTypename.hpp | 2 +- include/xo/expression2/variable/IGCObject_DVariable.hpp | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp index adb18480..8cb5fe13 100644 --- a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DDefineExpr & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp index 86047bd7..068f9b12 100644 --- a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DApplyExpr & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp index 823d0de9..a909f00f 100644 --- a/include/xo/expression2/detail/IGCObject_DConstant.hpp +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DConstant & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp index 13d0e3e4..ca0d078a 100644 --- a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DIfElseExpr & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp index 077b0e3a..bd13504d 100644 --- a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DLambdaExpr & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index 8d86241b..2801853a 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DSequenceExpr & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp index 71489ef4..74693209 100644 --- a/include/xo/expression2/detail/IGCObject_DVarRef.hpp +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DVarRef & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp index 48cf1d7c..a1aebbc4 100644 --- a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DGlobalSymtab & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp index 82717f96..61d159b2 100644 --- a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DLocalSymtab & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/expression2/typename/IGCObject_DTypename.hpp b/include/xo/expression2/typename/IGCObject_DTypename.hpp index 8c72100b..fbf46356 100644 --- a/include/xo/expression2/typename/IGCObject_DTypename.hpp +++ b/include/xo/expression2/typename/IGCObject_DTypename.hpp @@ -51,7 +51,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DTypename & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place diff --git a/include/xo/expression2/variable/IGCObject_DVariable.hpp b/include/xo/expression2/variable/IGCObject_DVariable.hpp index d04f3588..1bf0b86c 100644 --- a/include/xo/expression2/variable/IGCObject_DVariable.hpp +++ b/include/xo/expression2/variable/IGCObject_DVariable.hpp @@ -53,7 +53,7 @@ namespace xo { // const methods // non-const methods - /** move instance using allocator **/ + /** move instance using collector **/ static Opaque shallow_move(DVariable & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place From 997d3d8264e85918ddbdab0bf91ea6b31beda345 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 6 Apr 2026 15:21:48 -0400 Subject: [PATCH 123/128] refactor: use GCObjectVisitor api w/ gco_shallow_move --- include/xo/expression2/DApplyExpr.hpp | 5 ++--- include/xo/expression2/DConstant.hpp | 7 +++---- include/xo/expression2/DDefineExpr.hpp | 3 +-- include/xo/expression2/DGlobalSymtab.hpp | 4 ++-- include/xo/expression2/DIfElseExpr.hpp | 7 +++---- include/xo/expression2/DLambdaExpr.hpp | 4 ++-- include/xo/expression2/DLocalSymtab.hpp | 4 ++-- include/xo/expression2/DSequenceExpr.hpp | 5 ++--- include/xo/expression2/DTypename.hpp | 5 ++--- include/xo/expression2/DVarRef.hpp | 5 ++--- include/xo/expression2/DVariable.hpp | 5 ++--- include/xo/expression2/define/IGCObject_DDefineExpr.hpp | 5 +++-- include/xo/expression2/detail/IGCObject_DApplyExpr.hpp | 5 +++-- include/xo/expression2/detail/IGCObject_DConstant.hpp | 5 +++-- include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp | 5 +++-- include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp | 5 +++-- include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp | 5 +++-- include/xo/expression2/detail/IGCObject_DVarRef.hpp | 5 +++-- include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp | 5 +++-- include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp | 5 +++-- include/xo/expression2/typename/IGCObject_DTypename.hpp | 5 +++-- include/xo/expression2/variable/IGCObject_DVariable.hpp | 5 +++-- src/expression2/DApplyExpr.cpp | 7 +------ src/expression2/DConstant.cpp | 8 +------- src/expression2/DDefineExpr.cpp | 8 +------- src/expression2/DGlobalSymtab.cpp | 2 +- src/expression2/DIfElseExpr.cpp | 8 +------- src/expression2/DLambdaExpr.cpp | 2 +- src/expression2/DLocalSymtab.cpp | 2 +- src/expression2/DSequenceExpr.cpp | 8 +------- src/expression2/DTypename.cpp | 8 +------- src/expression2/DVarRef.cpp | 8 +------- src/expression2/DVariable.cpp | 8 +------- src/expression2/IGCObject_DApplyExpr.cpp | 4 ++-- src/expression2/IGCObject_DConstant.cpp | 4 ++-- src/expression2/IGCObject_DDefineExpr.cpp | 4 ++-- src/expression2/IGCObject_DGlobalSymtab.cpp | 4 ++-- src/expression2/IGCObject_DIfElseExpr.cpp | 4 ++-- src/expression2/IGCObject_DLambdaExpr.cpp | 4 ++-- src/expression2/IGCObject_DLocalSymtab.cpp | 4 ++-- src/expression2/IGCObject_DSequenceExpr.cpp | 4 ++-- src/expression2/IGCObject_DTypename.cpp | 4 ++-- src/expression2/IGCObject_DVarRef.cpp | 4 ++-- src/expression2/facet/IGCObject_DVariable.cpp | 4 ++-- 44 files changed, 89 insertions(+), 133 deletions(-) diff --git a/include/xo/expression2/DApplyExpr.hpp b/include/xo/expression2/DApplyExpr.hpp index 0042d561..bc5cdc47 100644 --- a/include/xo/expression2/DApplyExpr.hpp +++ b/include/xo/expression2/DApplyExpr.hpp @@ -21,7 +21,7 @@ namespace xo { **/ class DApplyExpr { public: - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -84,8 +84,7 @@ namespace xo { /** @defgroup scm-applyexpr-gcobject-facet **/ ///@{ - std::size_t shallow_size() const noexcept; - DApplyExpr * shallow_move(obj gc) noexcept; + DApplyExpr * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp index 2c878ea9..e81a7b2d 100644 --- a/include/xo/expression2/DConstant.hpp +++ b/include/xo/expression2/DConstant.hpp @@ -8,7 +8,7 @@ #include "Expression.hpp" #include "TypeRef.hpp" #include "exprtype.hpp" -#include +//#include #include #include #include @@ -22,7 +22,7 @@ namespace xo { public: using TaggedPtr = xo::reflect::TaggedPtr; using TypeDescr = xo::reflect::TypeDescr; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; @@ -64,8 +64,7 @@ namespace xo { /** @defgroup scm-constant-gcobject-facet **/ ///@{ - size_t shallow_size() const noexcept; - DConstant * shallow_move(obj gc) noexcept; + DConstant * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DDefineExpr.hpp b/include/xo/expression2/DDefineExpr.hpp index f1528531..474a4122 100644 --- a/include/xo/expression2/DDefineExpr.hpp +++ b/include/xo/expression2/DDefineExpr.hpp @@ -74,8 +74,7 @@ namespace xo { /** @defgroup scm-defineexpr-gcobject-facet **/ ///@{ - std::size_t shallow_size() const noexcept; - DDefineExpr * shallow_move(obj gc) noexcept; + DDefineExpr * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index a24c0bdc..b3840a69 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -30,7 +30,7 @@ namespace xo { using value_type = Binding; using ArenaHashMapConfig = xo::map::ArenaHashMapConfig; using repr_type = xo::map::DArenaHashMap; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; @@ -115,7 +115,7 @@ namespace xo { /** @defgroup scm-globalsymtab-gcobject-facet gcobject facet **/ ///@{ - DGlobalSymtab * shallow_move(obj gc) noexcept; + DGlobalSymtab * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DIfElseExpr.hpp b/include/xo/expression2/DIfElseExpr.hpp index b27c9ade..04a354dd 100644 --- a/include/xo/expression2/DIfElseExpr.hpp +++ b/include/xo/expression2/DIfElseExpr.hpp @@ -8,7 +8,7 @@ #include "Expression.hpp" #include "TypeRef.hpp" #include "exprtype.hpp" -#include +//#include #include #include #include @@ -21,7 +21,7 @@ namespace xo { **/ class DIfElseExpr { public: - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -98,8 +98,7 @@ namespace xo { /** @defgroup scm-ifelseexpr-gcobject-facet **/ ///@{ - std::size_t shallow_size() const noexcept; - DIfElseExpr * shallow_move(obj gc) noexcept; + DIfElseExpr * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DLambdaExpr.hpp b/include/xo/expression2/DLambdaExpr.hpp index 2a507497..e4b0296d 100644 --- a/include/xo/expression2/DLambdaExpr.hpp +++ b/include/xo/expression2/DLambdaExpr.hpp @@ -21,7 +21,7 @@ namespace xo { **/ class DLambdaExpr { public: - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -87,7 +87,7 @@ namespace xo { ///@{ std::size_t shallow_size() const noexcept; - DLambdaExpr * shallow_move(obj gc) noexcept; + DLambdaExpr * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index f389c3ea..081742b0 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -20,7 +20,7 @@ namespace xo { public: using DArray = xo::scm::DArray; using ppindentinfo = xo::print::ppindentinfo; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; @@ -99,7 +99,7 @@ namespace xo { /** @defgroup xo-localsymtab-gcobject-facet gcobject facet **/ ///@{ - DLocalSymtab * shallow_move(obj gc) noexcept; + DLocalSymtab * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DSequenceExpr.hpp b/include/xo/expression2/DSequenceExpr.hpp index 76a8bec0..4a103e0e 100644 --- a/include/xo/expression2/DSequenceExpr.hpp +++ b/include/xo/expression2/DSequenceExpr.hpp @@ -23,7 +23,7 @@ namespace xo { **/ class DSequenceExpr { public: - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -74,8 +74,7 @@ namespace xo { /** @defgroup scm-sequenceexpr-gcobject-facet gcobject facet methods **/ ///@{ - std::size_t shallow_size() const noexcept; - DSequenceExpr * shallow_move(obj gc) noexcept; + DSequenceExpr * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DTypename.hpp b/include/xo/expression2/DTypename.hpp index 2e35c9e3..7ddacd21 100644 --- a/include/xo/expression2/DTypename.hpp +++ b/include/xo/expression2/DTypename.hpp @@ -24,7 +24,7 @@ namespace xo { class DTypename { public: using ppindentinfo = xo::print::ppindentinfo; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; using AAllocator = xo::mm::AAllocator; @@ -55,8 +55,7 @@ namespace xo { /** @defgroup scm-typename-gcobject-facet **/ ///@{ - size_t shallow_size() const noexcept; - DTypename * shallow_move(obj gc) noexcept; + DTypename * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DVarRef.hpp b/include/xo/expression2/DVarRef.hpp index db85d558..002e511a 100644 --- a/include/xo/expression2/DVarRef.hpp +++ b/include/xo/expression2/DVarRef.hpp @@ -21,7 +21,7 @@ namespace xo { class DVarRef { public: using ppindentinfo = xo::print::ppindentinfo; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -56,8 +56,7 @@ namespace xo { /** @defgroup scm-variable-gcobject-facet **/ ///@{ - size_t shallow_size() const noexcept; - DVarRef * shallow_move(obj gc) noexcept; + DVarRef * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp index 2e74fbcc..5813ae1b 100644 --- a/include/xo/expression2/DVariable.hpp +++ b/include/xo/expression2/DVariable.hpp @@ -22,7 +22,7 @@ namespace xo { class DVariable { public: using ppindentinfo = xo::print::ppindentinfo; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -64,8 +64,7 @@ namespace xo { /** @defgroup scm-variable-gcobject-facet **/ ///@{ - size_t shallow_size() const noexcept; - DVariable * shallow_move(obj gc) noexcept; + DVariable * gco_shallow_move(obj gc) noexcept; void visit_gco_children(obj gc) noexcept; ///@} diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp index 8cb5fe13..6a233f92 100644 --- a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DDefineExpr & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DDefineExpr & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp index 068f9b12..399d9398 100644 --- a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DApplyExpr & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DApplyExpr & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp index a909f00f..b2e624be 100644 --- a/include/xo/expression2/detail/IGCObject_DConstant.hpp +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DConstant & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DConstant & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp index ca0d078a..80a49f22 100644 --- a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DIfElseExpr & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DIfElseExpr & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp index bd13504d..5decc2a0 100644 --- a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DLambdaExpr & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DLambdaExpr & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index 2801853a..54bab050 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DSequenceExpr & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DSequenceExpr & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp index 74693209..98c65aab 100644 --- a/include/xo/expression2/detail/IGCObject_DVarRef.hpp +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DVarRef & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DVarRef & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp index a1aebbc4..334c0ea9 100644 --- a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DGlobalSymtab & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DGlobalSymtab & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp index 61d159b2..c7890a79 100644 --- a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DLocalSymtab & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DLocalSymtab & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/expression2/typename/IGCObject_DTypename.hpp b/include/xo/expression2/typename/IGCObject_DTypename.hpp index fbf46356..e8946864 100644 --- a/include/xo/expression2/typename/IGCObject_DTypename.hpp +++ b/include/xo/expression2/typename/IGCObject_DTypename.hpp @@ -51,8 +51,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DTypename & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DTypename & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/include/xo/expression2/variable/IGCObject_DVariable.hpp b/include/xo/expression2/variable/IGCObject_DVariable.hpp index 1bf0b86c..3a31f155 100644 --- a/include/xo/expression2/variable/IGCObject_DVariable.hpp +++ b/include/xo/expression2/variable/IGCObject_DVariable.hpp @@ -53,8 +53,9 @@ namespace xo { // const methods // non-const methods - /** move instance using collector **/ - static Opaque shallow_move(DVariable & self, obj gc) noexcept; + /** move instance using object visitor. +Arguably abusing the word 'visitor' here **/ + static Opaque gco_shallow_move(DVariable & self, obj gc) noexcept; /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ diff --git a/src/expression2/DApplyExpr.cpp b/src/expression2/DApplyExpr.cpp index 18b9b60a..2776b438 100644 --- a/src/expression2/DApplyExpr.cpp +++ b/src/expression2/DApplyExpr.cpp @@ -104,13 +104,8 @@ namespace xo { // ----- gcobject facet ----- - std::size_t - DApplyExpr::shallow_size() const noexcept { - return sizeof(DApplyExpr) + (n_args_ * sizeof(obj)); - } - DApplyExpr * - DApplyExpr::shallow_move(obj gc) noexcept { + DApplyExpr::gco_shallow_move(obj gc) noexcept { // note: not using ACollector.std_copy_for() here, // flexible array -> not move-constructible diff --git a/src/expression2/DConstant.cpp b/src/expression2/DConstant.cpp index bbf86183..19805cb5 100644 --- a/src/expression2/DConstant.cpp +++ b/src/expression2/DConstant.cpp @@ -71,14 +71,8 @@ namespace xo { return nullptr; } - std::size_t - DConstant::shallow_size() const noexcept - { - return sizeof(DConstant); - } - DConstant * - DConstant::shallow_move(obj gc) noexcept + DConstant::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index 69ce84e0..ba481805 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -78,14 +78,8 @@ namespace xo { // ----- GCObject facet ----- - std::size_t - DDefineExpr::shallow_size() const noexcept - { - return sizeof(*this); - } - DDefineExpr * - DDefineExpr::shallow_move(obj gc) noexcept + DDefineExpr::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index 10f65ea2..f5df4a4c 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -263,7 +263,7 @@ namespace xo { // ----- gcobject facet ----- DGlobalSymtab * - DGlobalSymtab::shallow_move(obj gc) noexcept + DGlobalSymtab::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/expression2/DIfElseExpr.cpp b/src/expression2/DIfElseExpr.cpp index c44a7ebd..b8758387 100644 --- a/src/expression2/DIfElseExpr.cpp +++ b/src/expression2/DIfElseExpr.cpp @@ -82,14 +82,8 @@ namespace xo { // GCObject facet - std::size_t - DIfElseExpr::shallow_size() const noexcept - { - return sizeof(DIfElseExpr); - } - DIfElseExpr * - DIfElseExpr::shallow_move(obj gc) noexcept + DIfElseExpr::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/expression2/DLambdaExpr.cpp b/src/expression2/DLambdaExpr.cpp index 349ccd99..c73ccc8a 100644 --- a/src/expression2/DLambdaExpr.cpp +++ b/src/expression2/DLambdaExpr.cpp @@ -141,7 +141,7 @@ namespace xo { } DLambdaExpr * - DLambdaExpr::shallow_move(obj gc) noexcept { + DLambdaExpr::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index 017fb1d7..1fa1afd8 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -113,7 +113,7 @@ namespace xo { // ----- gcobject facet ----- DLocalSymtab * - DLocalSymtab::shallow_move(obj gc) noexcept + DLocalSymtab::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index 2dc153f0..a180a5fb 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -113,14 +113,8 @@ namespace xo { // gc hooks for IGCObject_DSequenceExpr - std::size_t - DSequenceExpr::shallow_size() const noexcept - { - return sizeof(DSequenceExpr); - } - DSequenceExpr * - DSequenceExpr::shallow_move(obj gc) noexcept + DSequenceExpr::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/expression2/DTypename.cpp b/src/expression2/DTypename.cpp index 15e7dbdb..da73f28f 100644 --- a/src/expression2/DTypename.cpp +++ b/src/expression2/DTypename.cpp @@ -40,14 +40,8 @@ namespace xo { : name_{name}, type_{type} {} - size_t - DTypename::shallow_size() const noexcept - { - return sizeof(DTypename); - } - DTypename * - DTypename::shallow_move(obj gc) noexcept + DTypename::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/expression2/DVarRef.cpp b/src/expression2/DVarRef.cpp index 6cdea4e5..57a39153 100644 --- a/src/expression2/DVarRef.cpp +++ b/src/expression2/DVarRef.cpp @@ -58,14 +58,8 @@ namespace xo { // gcobject facet - std::size_t - DVarRef::shallow_size() const noexcept - { - return sizeof(DVarRef); - } - DVarRef * - DVarRef::shallow_move(obj gc) noexcept + DVarRef::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index 9ab2f8bd..209764cd 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -38,14 +38,8 @@ namespace xo { typeref_.resolve(td); } - size_t - DVariable::shallow_size() const noexcept - { - return sizeof(DVariable); - } - DVariable * - DVariable::shallow_move(obj gc) noexcept + DVariable::gco_shallow_move(obj gc) noexcept { return gc.std_move_for(this); } diff --git a/src/expression2/IGCObject_DApplyExpr.cpp b/src/expression2/IGCObject_DApplyExpr.cpp index 9b5fc735..d2574d64 100644 --- a/src/expression2/IGCObject_DApplyExpr.cpp +++ b/src/expression2/IGCObject_DApplyExpr.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DApplyExpr::shallow_move(DApplyExpr & self, obj gc) noexcept -> Opaque + IGCObject_DApplyExpr::gco_shallow_move(DApplyExpr & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DApplyExpr::visit_gco_children(DApplyExpr & self, obj fn) noexcept -> void diff --git a/src/expression2/IGCObject_DConstant.cpp b/src/expression2/IGCObject_DConstant.cpp index 3e350102..be6f583d 100644 --- a/src/expression2/IGCObject_DConstant.cpp +++ b/src/expression2/IGCObject_DConstant.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DConstant::shallow_move(DConstant & self, obj gc) noexcept -> Opaque + IGCObject_DConstant::gco_shallow_move(DConstant & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DConstant::visit_gco_children(DConstant & self, obj fn) noexcept -> void diff --git a/src/expression2/IGCObject_DDefineExpr.cpp b/src/expression2/IGCObject_DDefineExpr.cpp index 34c59e93..f2ea0747 100644 --- a/src/expression2/IGCObject_DDefineExpr.cpp +++ b/src/expression2/IGCObject_DDefineExpr.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DDefineExpr::shallow_move(DDefineExpr & self, obj gc) noexcept -> Opaque + IGCObject_DDefineExpr::gco_shallow_move(DDefineExpr & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DDefineExpr::visit_gco_children(DDefineExpr & self, obj fn) noexcept -> void diff --git a/src/expression2/IGCObject_DGlobalSymtab.cpp b/src/expression2/IGCObject_DGlobalSymtab.cpp index 1e78de47..3070a26c 100644 --- a/src/expression2/IGCObject_DGlobalSymtab.cpp +++ b/src/expression2/IGCObject_DGlobalSymtab.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DGlobalSymtab::shallow_move(DGlobalSymtab & self, obj gc) noexcept -> Opaque + IGCObject_DGlobalSymtab::gco_shallow_move(DGlobalSymtab & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DGlobalSymtab::visit_gco_children(DGlobalSymtab & self, obj fn) noexcept -> void diff --git a/src/expression2/IGCObject_DIfElseExpr.cpp b/src/expression2/IGCObject_DIfElseExpr.cpp index 0db6f160..6f788e03 100644 --- a/src/expression2/IGCObject_DIfElseExpr.cpp +++ b/src/expression2/IGCObject_DIfElseExpr.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DIfElseExpr::shallow_move(DIfElseExpr & self, obj gc) noexcept -> Opaque + IGCObject_DIfElseExpr::gco_shallow_move(DIfElseExpr & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DIfElseExpr::visit_gco_children(DIfElseExpr & self, obj fn) noexcept -> void diff --git a/src/expression2/IGCObject_DLambdaExpr.cpp b/src/expression2/IGCObject_DLambdaExpr.cpp index a9ad37aa..b4706c56 100644 --- a/src/expression2/IGCObject_DLambdaExpr.cpp +++ b/src/expression2/IGCObject_DLambdaExpr.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DLambdaExpr::shallow_move(DLambdaExpr & self, obj gc) noexcept -> Opaque + IGCObject_DLambdaExpr::gco_shallow_move(DLambdaExpr & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DLambdaExpr::visit_gco_children(DLambdaExpr & self, obj fn) noexcept -> void diff --git a/src/expression2/IGCObject_DLocalSymtab.cpp b/src/expression2/IGCObject_DLocalSymtab.cpp index 7384e17a..5e37d826 100644 --- a/src/expression2/IGCObject_DLocalSymtab.cpp +++ b/src/expression2/IGCObject_DLocalSymtab.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DLocalSymtab::shallow_move(DLocalSymtab & self, obj gc) noexcept -> Opaque + IGCObject_DLocalSymtab::gco_shallow_move(DLocalSymtab & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DLocalSymtab::visit_gco_children(DLocalSymtab & self, obj fn) noexcept -> void diff --git a/src/expression2/IGCObject_DSequenceExpr.cpp b/src/expression2/IGCObject_DSequenceExpr.cpp index 8660f506..1f92c2e2 100644 --- a/src/expression2/IGCObject_DSequenceExpr.cpp +++ b/src/expression2/IGCObject_DSequenceExpr.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DSequenceExpr::shallow_move(DSequenceExpr & self, obj gc) noexcept -> Opaque + IGCObject_DSequenceExpr::gco_shallow_move(DSequenceExpr & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DSequenceExpr::visit_gco_children(DSequenceExpr & self, obj fn) noexcept -> void diff --git a/src/expression2/IGCObject_DTypename.cpp b/src/expression2/IGCObject_DTypename.cpp index 478b2005..ca21870a 100644 --- a/src/expression2/IGCObject_DTypename.cpp +++ b/src/expression2/IGCObject_DTypename.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DTypename::shallow_move(DTypename & self, obj gc) noexcept -> Opaque + IGCObject_DTypename::gco_shallow_move(DTypename & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DTypename::visit_gco_children(DTypename & self, obj fn) noexcept -> void diff --git a/src/expression2/IGCObject_DVarRef.cpp b/src/expression2/IGCObject_DVarRef.cpp index 7035db1e..68d6e1d2 100644 --- a/src/expression2/IGCObject_DVarRef.cpp +++ b/src/expression2/IGCObject_DVarRef.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DVarRef::shallow_move(DVarRef & self, obj gc) noexcept -> Opaque + IGCObject_DVarRef::gco_shallow_move(DVarRef & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DVarRef::visit_gco_children(DVarRef & self, obj fn) noexcept -> void diff --git a/src/expression2/facet/IGCObject_DVariable.cpp b/src/expression2/facet/IGCObject_DVariable.cpp index a6370f56..0a91bfb2 100644 --- a/src/expression2/facet/IGCObject_DVariable.cpp +++ b/src/expression2/facet/IGCObject_DVariable.cpp @@ -16,9 +16,9 @@ namespace xo { namespace scm { auto - IGCObject_DVariable::shallow_move(DVariable & self, obj gc) noexcept -> Opaque + IGCObject_DVariable::gco_shallow_move(DVariable & self, obj gc) noexcept -> Opaque { - return self.shallow_move(gc); + return self.gco_shallow_move(gc); } auto IGCObject_DVariable::visit_gco_children(DVariable & self, obj fn) noexcept -> void From 822af3a246f0c189114bd780cb7a3613d567a04a Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 10 Apr 2026 01:10:03 -0400 Subject: [PATCH 124/128] xo-interpreter2 stack: + reason arg to visit_gco_children() Helps streamline DX1Collector in xo-gc/. Want both forward and verify entry points for the same representation. --- include/xo/expression2/DApplyExpr.hpp | 4 ++-- include/xo/expression2/DConstant.hpp | 5 ++-- include/xo/expression2/DDefineExpr.hpp | 3 ++- include/xo/expression2/DGlobalSymtab.hpp | 4 ++-- include/xo/expression2/DIfElseExpr.hpp | 5 ++-- include/xo/expression2/DLambdaExpr.hpp | 4 ++-- include/xo/expression2/DLocalSymtab.hpp | 4 ++-- include/xo/expression2/DSequenceExpr.hpp | 4 ++-- include/xo/expression2/DTypename.hpp | 4 ++-- include/xo/expression2/DVarRef.hpp | 4 ++-- include/xo/expression2/DVariable.hpp | 4 ++-- include/xo/expression2/TypeRef.hpp | 4 ++-- .../define/IGCObject_DDefineExpr.hpp | 3 ++- .../detail/IGCObject_DApplyExpr.hpp | 3 ++- .../detail/IGCObject_DConstant.hpp | 3 ++- .../detail/IGCObject_DIfElseExpr.hpp | 3 ++- .../detail/IGCObject_DLambdaExpr.hpp | 3 ++- .../detail/IGCObject_DSequenceExpr.hpp | 3 ++- .../expression2/detail/IGCObject_DVarRef.hpp | 3 ++- .../symtab/IGCObject_DGlobalSymtab.hpp | 3 ++- .../symtab/IGCObject_DLocalSymtab.hpp | 3 ++- .../typename/IGCObject_DTypename.hpp | 3 ++- .../variable/IGCObject_DVariable.hpp | 3 ++- src/expression2/DApplyExpr.cpp | 15 ++++-------- src/expression2/DConstant.cpp | 11 +++++---- src/expression2/DDefineExpr.cpp | 11 ++++----- src/expression2/DGlobalSymtab.cpp | 13 ++++++++--- src/expression2/DIfElseExpr.cpp | 23 +++++-------------- src/expression2/DLambdaExpr.cpp | 23 +++++-------------- src/expression2/DLocalSymtab.cpp | 9 ++++---- src/expression2/DSequenceExpr.cpp | 6 ++--- src/expression2/DTypename.cpp | 12 ++++------ src/expression2/DVarRef.cpp | 5 ++-- src/expression2/DVariable.cpp | 5 ++-- src/expression2/IGCObject_DApplyExpr.cpp | 4 ++-- src/expression2/IGCObject_DConstant.cpp | 4 ++-- src/expression2/IGCObject_DDefineExpr.cpp | 4 ++-- src/expression2/IGCObject_DGlobalSymtab.cpp | 4 ++-- src/expression2/IGCObject_DIfElseExpr.cpp | 4 ++-- src/expression2/IGCObject_DLambdaExpr.cpp | 4 ++-- src/expression2/IGCObject_DLocalSymtab.cpp | 4 ++-- src/expression2/IGCObject_DSequenceExpr.cpp | 4 ++-- src/expression2/IGCObject_DTypename.cpp | 4 ++-- src/expression2/IGCObject_DVarRef.cpp | 4 ++-- src/expression2/TypeRef.cpp | 7 +++--- src/expression2/facet/IGCObject_DVariable.cpp | 4 ++-- 46 files changed, 124 insertions(+), 142 deletions(-) diff --git a/include/xo/expression2/DApplyExpr.hpp b/include/xo/expression2/DApplyExpr.hpp index bc5cdc47..cb0be70f 100644 --- a/include/xo/expression2/DApplyExpr.hpp +++ b/include/xo/expression2/DApplyExpr.hpp @@ -21,8 +21,8 @@ namespace xo { **/ class DApplyExpr { public: - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; using ppindentinfo = xo::print::ppindentinfo; @@ -85,7 +85,7 @@ namespace xo { ///@{ DApplyExpr * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** @defgroup scm-applyexpr-printable-facet **/ diff --git a/include/xo/expression2/DConstant.hpp b/include/xo/expression2/DConstant.hpp index e81a7b2d..bf901537 100644 --- a/include/xo/expression2/DConstant.hpp +++ b/include/xo/expression2/DConstant.hpp @@ -8,7 +8,6 @@ #include "Expression.hpp" #include "TypeRef.hpp" #include "exprtype.hpp" -//#include #include #include #include @@ -22,8 +21,8 @@ namespace xo { public: using TaggedPtr = xo::reflect::TaggedPtr; using TypeDescr = xo::reflect::TypeDescr; - //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; + using VisitReason = xo::mm::VisitReason; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; using typeseq = xo::reflect::typeseq; @@ -65,7 +64,7 @@ namespace xo { ///@{ DConstant * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** @defgroup scm-constant-printable-facet **/ diff --git a/include/xo/expression2/DDefineExpr.hpp b/include/xo/expression2/DDefineExpr.hpp index 474a4122..3f0071fd 100644 --- a/include/xo/expression2/DDefineExpr.hpp +++ b/include/xo/expression2/DDefineExpr.hpp @@ -26,6 +26,7 @@ namespace xo { using ppindentinfo = xo::print::ppindentinfo; using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -75,7 +76,7 @@ namespace xo { ///@{ DDefineExpr * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** @defgroup scm-defineexpr-printable-facet **/ diff --git a/include/xo/expression2/DGlobalSymtab.hpp b/include/xo/expression2/DGlobalSymtab.hpp index b3840a69..4a7fdf93 100644 --- a/include/xo/expression2/DGlobalSymtab.hpp +++ b/include/xo/expression2/DGlobalSymtab.hpp @@ -30,9 +30,9 @@ namespace xo { using value_type = Binding; using ArenaHashMapConfig = xo::map::ArenaHashMapConfig; using repr_type = xo::map::DArenaHashMap; - //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using MemorySizeVisitor = xo::mm::MemorySizeVisitor; using ppindentinfo = xo::print::ppindentinfo; @@ -116,7 +116,7 @@ namespace xo { ///@{ DGlobalSymtab * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** @defgroup scm-globalsymtab-printable-facet printable facet **/ diff --git a/include/xo/expression2/DIfElseExpr.hpp b/include/xo/expression2/DIfElseExpr.hpp index 04a354dd..bc83ccd4 100644 --- a/include/xo/expression2/DIfElseExpr.hpp +++ b/include/xo/expression2/DIfElseExpr.hpp @@ -8,7 +8,6 @@ #include "Expression.hpp" #include "TypeRef.hpp" #include "exprtype.hpp" -//#include #include #include #include @@ -21,8 +20,8 @@ namespace xo { **/ class DIfElseExpr { public: - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; using ppindentinfo = xo::print::ppindentinfo; @@ -99,7 +98,7 @@ namespace xo { ///@{ DIfElseExpr * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DLambdaExpr.hpp b/include/xo/expression2/DLambdaExpr.hpp index e4b0296d..b7fc76a8 100644 --- a/include/xo/expression2/DLambdaExpr.hpp +++ b/include/xo/expression2/DLambdaExpr.hpp @@ -21,8 +21,8 @@ namespace xo { **/ class DLambdaExpr { public: - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; using ppindentinfo = xo::print::ppindentinfo; @@ -88,7 +88,7 @@ namespace xo { std::size_t shallow_size() const noexcept; DLambdaExpr * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** @defgroup scm-lambdaexpr-printable-facet **/ diff --git a/include/xo/expression2/DLocalSymtab.hpp b/include/xo/expression2/DLocalSymtab.hpp index 081742b0..b658bbd5 100644 --- a/include/xo/expression2/DLocalSymtab.hpp +++ b/include/xo/expression2/DLocalSymtab.hpp @@ -20,8 +20,8 @@ namespace xo { public: using DArray = xo::scm::DArray; using ppindentinfo = xo::print::ppindentinfo; - //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; + using VisitReason = xo::mm::VisitReason; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AAllocator = xo::mm::AAllocator; /* note: uint16_t would be fine too */ @@ -100,7 +100,7 @@ namespace xo { ///@{ DLocalSymtab * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** @defgroup xo-localsymtab-printable-facet printable facet **/ diff --git a/include/xo/expression2/DSequenceExpr.hpp b/include/xo/expression2/DSequenceExpr.hpp index 4a103e0e..e919ae13 100644 --- a/include/xo/expression2/DSequenceExpr.hpp +++ b/include/xo/expression2/DSequenceExpr.hpp @@ -23,8 +23,8 @@ namespace xo { **/ class DSequenceExpr { public: - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; using size_type = DArray::size_type; @@ -75,7 +75,7 @@ namespace xo { ///@{ DSequenceExpr * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} diff --git a/include/xo/expression2/DTypename.hpp b/include/xo/expression2/DTypename.hpp index 7ddacd21..64ec86bc 100644 --- a/include/xo/expression2/DTypename.hpp +++ b/include/xo/expression2/DTypename.hpp @@ -24,8 +24,8 @@ namespace xo { class DTypename { public: using ppindentinfo = xo::print::ppindentinfo; - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AGCObject = xo::mm::AGCObject; using AAllocator = xo::mm::AAllocator; @@ -56,7 +56,7 @@ namespace xo { ///@{ DTypename * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** @defgroup scm-typename-printable-facet **/ diff --git a/include/xo/expression2/DVarRef.hpp b/include/xo/expression2/DVarRef.hpp index 002e511a..93224199 100644 --- a/include/xo/expression2/DVarRef.hpp +++ b/include/xo/expression2/DVarRef.hpp @@ -21,8 +21,8 @@ namespace xo { class DVarRef { public: using ppindentinfo = xo::print::ppindentinfo; - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -57,7 +57,7 @@ namespace xo { ///@{ DVarRef * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** @defgroup scm-variable-printable-facet **/ diff --git a/include/xo/expression2/DVariable.hpp b/include/xo/expression2/DVariable.hpp index 5813ae1b..158ef842 100644 --- a/include/xo/expression2/DVariable.hpp +++ b/include/xo/expression2/DVariable.hpp @@ -22,8 +22,8 @@ namespace xo { class DVariable { public: using ppindentinfo = xo::print::ppindentinfo; - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; using TypeDescr = xo::reflect::TypeDescr; @@ -65,7 +65,7 @@ namespace xo { ///@{ DVariable * gco_shallow_move(obj gc) noexcept; - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; ///@} /** @defgroup scm-variable-printable-facet **/ diff --git a/include/xo/expression2/TypeRef.hpp b/include/xo/expression2/TypeRef.hpp index f56028ba..c93158fb 100644 --- a/include/xo/expression2/TypeRef.hpp +++ b/include/xo/expression2/TypeRef.hpp @@ -26,8 +26,8 @@ namespace xo { using TypeDescr = xo::reflect::TypeDescr; using type_var = flatstring<20>; using prefix_type = flatstring<8>; - using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; + using VisitReason = xo::mm::VisitReason; using ppindentinfo = xo::print::ppindentinfo; public: @@ -75,7 +75,7 @@ namespace xo { bool pretty(const ppindentinfo & ppii) const; /** gc support **/ - void visit_gco_children(obj gc) noexcept; + void visit_gco_children(VisitReason reason, obj gc) noexcept; private: TypeRef(const type_var & id, TypeDescr td); diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp index 6a233f92..c07c8e4e 100644 --- a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DDefineExpr & self, obj fn) noexcept; + static void visit_gco_children(DDefineExpr & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp index 399d9398..a1a2fac4 100644 --- a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DApplyExpr & self, obj fn) noexcept; + static void visit_gco_children(DApplyExpr & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp index b2e624be..82783948 100644 --- a/include/xo/expression2/detail/IGCObject_DConstant.hpp +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DConstant & self, obj fn) noexcept; + static void visit_gco_children(DConstant & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp index 80a49f22..3156fe58 100644 --- a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DIfElseExpr & self, obj fn) noexcept; + static void visit_gco_children(DIfElseExpr & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp index 5decc2a0..ec4faded 100644 --- a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DLambdaExpr & self, obj fn) noexcept; + static void visit_gco_children(DLambdaExpr & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index 54bab050..1b927e01 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DSequenceExpr & self, obj fn) noexcept; + static void visit_gco_children(DSequenceExpr & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp index 98c65aab..085999f9 100644 --- a/include/xo/expression2/detail/IGCObject_DVarRef.hpp +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DVarRef & self, obj fn) noexcept; + static void visit_gco_children(DVarRef & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp index 334c0ea9..ee24adfb 100644 --- a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DGlobalSymtab & self, obj fn) noexcept; + static void visit_gco_children(DGlobalSymtab & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp index c7890a79..cbd98904 100644 --- a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DLocalSymtab & self, obj fn) noexcept; + static void visit_gco_children(DLocalSymtab & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/typename/IGCObject_DTypename.hpp b/include/xo/expression2/typename/IGCObject_DTypename.hpp index e8946864..cdd91734 100644 --- a/include/xo/expression2/typename/IGCObject_DTypename.hpp +++ b/include/xo/expression2/typename/IGCObject_DTypename.hpp @@ -43,6 +43,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -57,7 +58,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DTypename & self, obj fn) noexcept; + static void visit_gco_children(DTypename & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/include/xo/expression2/variable/IGCObject_DVariable.hpp b/include/xo/expression2/variable/IGCObject_DVariable.hpp index 3a31f155..9e173090 100644 --- a/include/xo/expression2/variable/IGCObject_DVariable.hpp +++ b/include/xo/expression2/variable/IGCObject_DVariable.hpp @@ -45,6 +45,7 @@ namespace xo { using AAllocator = xo::mm::AGCObject::AAllocator; using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; + using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; using Opaque = xo::mm::AGCObject::Opaque; ///@} @@ -59,7 +60,7 @@ Arguably abusing the word 'visitor' here **/ /** Invoke fn.visit_child(iface,data) for each child GCObject pointer. Context: provides address of data pointer so it can be updated in place when @p fn invokes garbage collector reentry point **/ - static void visit_gco_children(DVariable & self, obj fn) noexcept; + static void visit_gco_children(DVariable & self, VisitReason reason, obj fn) noexcept; ///@} }; diff --git a/src/expression2/DApplyExpr.cpp b/src/expression2/DApplyExpr.cpp index 2776b438..0f9a5c5c 100644 --- a/src/expression2/DApplyExpr.cpp +++ b/src/expression2/DApplyExpr.cpp @@ -125,23 +125,16 @@ namespace xo { } void - DApplyExpr::visit_gco_children(obj gc) noexcept + DApplyExpr::visit_gco_children(VisitReason reason, obj gc) noexcept { - typeref_.visit_gco_children(gc); + typeref_.visit_gco_children(reason, gc); - { - gc.visit_poly_child(&fn_); - //obj fn_gco = fn_.to_facet(); - //gc.forward_inplace(fn_gco.iface(), (void **)&fn_.data_); - } + gc.visit_poly_child(reason, &fn_); for (size_type i = 0; i < n_args_; ++i) { obj & arg = args_[i]; - // runtime poly here - gc.visit_poly_child(&arg); - //obj arg_gco = arg.to_facet(); - //gc.forward_inplace(arg_gco.iface(), (void **)(&arg.data_)); + gc.visit_poly_child(reason, &arg); } } diff --git a/src/expression2/DConstant.cpp b/src/expression2/DConstant.cpp index 19805cb5..441d24a0 100644 --- a/src/expression2/DConstant.cpp +++ b/src/expression2/DConstant.cpp @@ -3,8 +3,8 @@ * @author Roland Conybeare, Jan 2026 **/ -#include "DConstant.hpp" -#include "detail/IExpression_DConstant.hpp" +#include "Constant.hpp" +//#include "detail/IExpression_DConstant.hpp" #include "TypeDescr.hpp" #include #include @@ -78,11 +78,12 @@ namespace xo { } void - DConstant::visit_gco_children(obj gc) noexcept + DConstant::visit_gco_children(VisitReason reason, + obj gc) noexcept { - typeref_.visit_gco_children(gc); + typeref_.visit_gco_children(reason, gc); - gc.visit_child(&value_); + gc.visit_child(reason, &value_); } bool diff --git a/src/expression2/DDefineExpr.cpp b/src/expression2/DDefineExpr.cpp index ba481805..7bcf817b 100644 --- a/src/expression2/DDefineExpr.cpp +++ b/src/expression2/DDefineExpr.cpp @@ -85,11 +85,11 @@ namespace xo { } void - DDefineExpr::visit_gco_children(obj gc) noexcept + DDefineExpr::visit_gco_children(VisitReason reason, + obj gc) noexcept { - gc.visit_child(&lhs_var_); - //gc.forward_inplace(&rhs_); // complicated - need to access via GCObject facet - gc.visit_poly_child(&rhs_); + gc.visit_child(reason, &lhs_var_); + gc.visit_poly_child(reason, &rhs_); } bool @@ -104,9 +104,6 @@ namespace xo { if (lhs_var_) assert(lhs.data()); - (void)lhs; - (void)rhs; - if (rhs_) assert(rhs.data()); diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index f5df4a4c..7b6bd760 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -269,15 +269,22 @@ namespace xo { } void - DGlobalSymtab::visit_gco_children(obj gc) noexcept + DGlobalSymtab::visit_gco_children(VisitReason reason, + obj gc) noexcept { // map_ doesn't contain any gc-owned data, can skip +#ifdef __APPLE__ + // clang not recognizing these as comptime eligible + assert(var_map_.is_gc_eligible() == false); + assert(type_map_.is_gc_eligible() == false); +#else static_assert(var_map_.is_gc_eligible() == false); static_assert(type_map_.is_gc_eligible() == false); +#endif - gc.visit_child(&vars_); - gc.visit_child(&types_); + gc.visit_child(reason, &vars_); + gc.visit_child(reason, &types_); } // ----- printable facet ----- diff --git a/src/expression2/DIfElseExpr.cpp b/src/expression2/DIfElseExpr.cpp index b8758387..6042104b 100644 --- a/src/expression2/DIfElseExpr.cpp +++ b/src/expression2/DIfElseExpr.cpp @@ -89,26 +89,15 @@ namespace xo { } void - DIfElseExpr::visit_gco_children(obj gc) noexcept + DIfElseExpr::visit_gco_children(VisitReason reason, + obj gc) noexcept { - typeref_.visit_gco_children(gc); + typeref_.visit_gco_children(reason, gc); // GC needs to locate AGCObject iface for each member. - { - gc.visit_poly_child(&test_); - //auto gco = test_.to_facet(); - //gc.forward_inplace(gco.iface(), (void **)&(test_.data_)); - } - { - gc.visit_poly_child(&when_true_); - //auto gco = when_true_.to_facet(); - //gc.forward_inplace(gco.iface(), (void **)&(when_true_.data_)); - } - { - gc.visit_poly_child(&when_false_); - //auto gco = when_false_.to_facet(); - //gc.forward_inplace(gco.iface(), (void **)&(when_false_.data_)); - } + gc.visit_poly_child(reason, &test_); + gc.visit_poly_child(reason, &when_true_); + gc.visit_poly_child(reason, &when_false_); } // ----- printable facet ----- diff --git a/src/expression2/DLambdaExpr.cpp b/src/expression2/DLambdaExpr.cpp index c73ccc8a..1b512b0c 100644 --- a/src/expression2/DLambdaExpr.cpp +++ b/src/expression2/DLambdaExpr.cpp @@ -146,26 +146,15 @@ namespace xo { } void - DLambdaExpr::visit_gco_children(obj gc) noexcept { - typeref_.visit_gco_children(gc); - - gc.visit_child(&name_); - //{ - // auto iface = xo::facet::impl_for(); - // gc.forward_inplace(&iface, (void **)(&name_)); - //} + DLambdaExpr::visit_gco_children(VisitReason reason, + obj gc) noexcept { + typeref_.visit_gco_children(reason, gc); + gc.visit_child(reason, &name_); // type_name_str_ - { - gc.visit_child(&local_symtab_); - //gc.forward_inplace(&local_symtab_); - } - - { - gc.visit_poly_child(&body_expr_); - //gc.forward_pivot_inplace(&body_expr_); - } + gc.visit_child(reason, &local_symtab_); + gc.visit_poly_child(reason, &body_expr_); // xxx free_var_set // xxx captured_var_set diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index 1fa1afd8..9d85a97c 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -119,11 +119,12 @@ namespace xo { } void - DLocalSymtab::visit_gco_children(obj gc) noexcept + DLocalSymtab::visit_gco_children(VisitReason reason, + obj gc) noexcept { - gc.visit_child(&parent_); - gc.visit_child(&vars_); - gc.visit_child(&types_); + gc.visit_child(reason, &parent_); + gc.visit_child(reason, &vars_); + gc.visit_child(reason, &types_); } // ----- printable facet ----- diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index a180a5fb..8fdfcf9b 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -120,11 +120,11 @@ namespace xo { } void - DSequenceExpr::visit_gco_children(obj gc) noexcept + DSequenceExpr::visit_gco_children(VisitReason reason, obj gc) noexcept { - typeref_.visit_gco_children(gc); + typeref_.visit_gco_children(reason, gc); - gc.visit_child(&expr_v_); + gc.visit_child(reason, &expr_v_); } } /*namespace scm*/ diff --git a/src/expression2/DTypename.cpp b/src/expression2/DTypename.cpp index da73f28f..c8debab9 100644 --- a/src/expression2/DTypename.cpp +++ b/src/expression2/DTypename.cpp @@ -47,15 +47,11 @@ namespace xo { } void - DTypename::visit_gco_children(obj gc) noexcept + DTypename::visit_gco_children(VisitReason reason, + obj gc) noexcept { - gc.visit_child(&name_); - //gc.forward_inplace(const_cast(&name_)); - { - gc.visit_poly_child(&type_); - //auto e = type_.to_facet(); - //gc.forward_inplace(e.iface(), (void **)&(type_.data_)); - } + gc.visit_child(reason, &name_); + gc.visit_poly_child(reason, &type_); } bool diff --git a/src/expression2/DVarRef.cpp b/src/expression2/DVarRef.cpp index 57a39153..b73efe10 100644 --- a/src/expression2/DVarRef.cpp +++ b/src/expression2/DVarRef.cpp @@ -65,9 +65,10 @@ namespace xo { } void - DVarRef::visit_gco_children(obj gc) noexcept + DVarRef::visit_gco_children(VisitReason reason, + obj gc) noexcept { - gc.visit_child(&vardef_); + gc.visit_child(reason, &vardef_); //auto iface = xo::facet::impl_for(); //gc.forward_inplace(&iface, (void **)vardef_.data_); diff --git a/src/expression2/DVariable.cpp b/src/expression2/DVariable.cpp index 209764cd..066aeb50 100644 --- a/src/expression2/DVariable.cpp +++ b/src/expression2/DVariable.cpp @@ -9,7 +9,6 @@ #include namespace xo { - using xo::mm::ACollector; using xo::facet::typeseq; namespace scm { @@ -45,9 +44,9 @@ namespace xo { } void - DVariable::visit_gco_children(obj gc) noexcept + DVariable::visit_gco_children(VisitReason reason, obj gc) noexcept { - typeref_.visit_gco_children(gc); + typeref_.visit_gco_children(reason, gc); } bool diff --git a/src/expression2/IGCObject_DApplyExpr.cpp b/src/expression2/IGCObject_DApplyExpr.cpp index d2574d64..610b675b 100644 --- a/src/expression2/IGCObject_DApplyExpr.cpp +++ b/src/expression2/IGCObject_DApplyExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DApplyExpr::visit_gco_children(DApplyExpr & self, obj fn) noexcept -> void + IGCObject_DApplyExpr::visit_gco_children(DApplyExpr & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DConstant.cpp b/src/expression2/IGCObject_DConstant.cpp index be6f583d..20c71341 100644 --- a/src/expression2/IGCObject_DConstant.cpp +++ b/src/expression2/IGCObject_DConstant.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DConstant::visit_gco_children(DConstant & self, obj fn) noexcept -> void + IGCObject_DConstant::visit_gco_children(DConstant & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DDefineExpr.cpp b/src/expression2/IGCObject_DDefineExpr.cpp index f2ea0747..8540ab25 100644 --- a/src/expression2/IGCObject_DDefineExpr.cpp +++ b/src/expression2/IGCObject_DDefineExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DDefineExpr::visit_gco_children(DDefineExpr & self, obj fn) noexcept -> void + IGCObject_DDefineExpr::visit_gco_children(DDefineExpr & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DGlobalSymtab.cpp b/src/expression2/IGCObject_DGlobalSymtab.cpp index 3070a26c..01153218 100644 --- a/src/expression2/IGCObject_DGlobalSymtab.cpp +++ b/src/expression2/IGCObject_DGlobalSymtab.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DGlobalSymtab::visit_gco_children(DGlobalSymtab & self, obj fn) noexcept -> void + IGCObject_DGlobalSymtab::visit_gco_children(DGlobalSymtab & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DIfElseExpr.cpp b/src/expression2/IGCObject_DIfElseExpr.cpp index 6f788e03..22878fea 100644 --- a/src/expression2/IGCObject_DIfElseExpr.cpp +++ b/src/expression2/IGCObject_DIfElseExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DIfElseExpr::visit_gco_children(DIfElseExpr & self, obj fn) noexcept -> void + IGCObject_DIfElseExpr::visit_gco_children(DIfElseExpr & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DLambdaExpr.cpp b/src/expression2/IGCObject_DLambdaExpr.cpp index b4706c56..05bd85a0 100644 --- a/src/expression2/IGCObject_DLambdaExpr.cpp +++ b/src/expression2/IGCObject_DLambdaExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DLambdaExpr::visit_gco_children(DLambdaExpr & self, obj fn) noexcept -> void + IGCObject_DLambdaExpr::visit_gco_children(DLambdaExpr & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DLocalSymtab.cpp b/src/expression2/IGCObject_DLocalSymtab.cpp index 5e37d826..7ccadca0 100644 --- a/src/expression2/IGCObject_DLocalSymtab.cpp +++ b/src/expression2/IGCObject_DLocalSymtab.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DLocalSymtab::visit_gco_children(DLocalSymtab & self, obj fn) noexcept -> void + IGCObject_DLocalSymtab::visit_gco_children(DLocalSymtab & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DSequenceExpr.cpp b/src/expression2/IGCObject_DSequenceExpr.cpp index 1f92c2e2..0cc84faa 100644 --- a/src/expression2/IGCObject_DSequenceExpr.cpp +++ b/src/expression2/IGCObject_DSequenceExpr.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DSequenceExpr::visit_gco_children(DSequenceExpr & self, obj fn) noexcept -> void + IGCObject_DSequenceExpr::visit_gco_children(DSequenceExpr & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DTypename.cpp b/src/expression2/IGCObject_DTypename.cpp index ca21870a..accbfc6e 100644 --- a/src/expression2/IGCObject_DTypename.cpp +++ b/src/expression2/IGCObject_DTypename.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DTypename::visit_gco_children(DTypename & self, obj fn) noexcept -> void + IGCObject_DTypename::visit_gco_children(DTypename & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/expression2/IGCObject_DVarRef.cpp b/src/expression2/IGCObject_DVarRef.cpp index 68d6e1d2..e169c37f 100644 --- a/src/expression2/IGCObject_DVarRef.cpp +++ b/src/expression2/IGCObject_DVarRef.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DVarRef::visit_gco_children(DVarRef & self, obj fn) noexcept -> void + IGCObject_DVarRef::visit_gco_children(DVarRef & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ diff --git a/src/expression2/TypeRef.cpp b/src/expression2/TypeRef.cpp index 961ae148..e3178b7f 100644 --- a/src/expression2/TypeRef.cpp +++ b/src/expression2/TypeRef.cpp @@ -102,11 +102,10 @@ namespace xo { } void - TypeRef::visit_gco_children(obj gc) noexcept + TypeRef::visit_gco_children(VisitReason reason, + obj gc) noexcept { - //scope log(XO_DEBUG(true), xtag("type", type_.data()), xtag("type.tseq", type_._typeseq())); - - gc.visit_poly_child(&type_); + gc.visit_poly_child(reason, &type_); } bool diff --git a/src/expression2/facet/IGCObject_DVariable.cpp b/src/expression2/facet/IGCObject_DVariable.cpp index 0a91bfb2..8734ca7a 100644 --- a/src/expression2/facet/IGCObject_DVariable.cpp +++ b/src/expression2/facet/IGCObject_DVariable.cpp @@ -21,9 +21,9 @@ namespace xo { return self.gco_shallow_move(gc); } auto - IGCObject_DVariable::visit_gco_children(DVariable & self, obj fn) noexcept -> void + IGCObject_DVariable::visit_gco_children(DVariable & self, VisitReason reason, obj fn) noexcept -> void { - self.visit_gco_children(fn); + self.visit_gco_children(reason, fn); } } /*namespace scm*/ From aedb1a1648ffd1a8a2620d53e240a920c9453d43 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Tue, 28 Apr 2026 23:17:00 -0400 Subject: [PATCH 125/128] xo-object2: obj argument to DArray::push_back() --- src/expression2/DGlobalSymtab.cpp | 16 +++++++++++----- src/expression2/DLocalSymtab.cpp | 13 ++++++++----- src/expression2/DSequenceExpr.cpp | 17 ++++++++++------- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index 7b6bd760..d927288a 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -16,6 +16,7 @@ namespace xo { using xo::map::DArenaHashMap; + using xo::mm::ACollector; using xo::mm::AGCObject; namespace scm { @@ -51,13 +52,13 @@ namespace xo { assert(var_map); /* choosing same capacity for hash, vars */ - DArray * vars = DArray::empty(mm, var_map->capacity()); + DArray * vars = DArray::_empty(mm, var_map->capacity()); assert(vars); auto type_map = dp::make(aux_mm, type_cfg); assert(type_map); - DArray * types = DArray::empty(mm, type_map->capacity()); + DArray * types = DArray::_empty(mm, type_map->capacity()); void * mem = mm.alloc_for(); @@ -110,6 +111,8 @@ namespace xo { { scope log(XO_DEBUG(false), std::string_view(*var->name())); + auto gc = mm.try_to_facet(); + // It's possible there's already a global variable // with the same name. // @@ -165,7 +168,7 @@ namespace xo { // need slot# in .map_ for this unique symbol (*var_map_)[var->name()] = binding.j_slot(); - vars_->push_back(obj(var)); + vars_->push_back(gc, obj(var)); } } @@ -191,6 +194,8 @@ namespace xo { scope log(XO_DEBUG(true), std::string_view(*tname->name())); + auto gc = mm.try_to_facet(); + auto ix = type_map_->find(tname->name()); if (ix == type_map_->end()) { @@ -218,12 +223,13 @@ namespace xo { (*type_map_)[tname->name()] = n; log && log("STUB: need write barrier"); - types_->push_back(obj(tname)); + types_->push_back(gc, obj(tname)); } else { Binding::slot_type i_slot = ix->second; log && log("STUB: need write barrier"); - (*types_)[i_slot] = obj(tname); + types_->assign_at(gc, i_slot, + obj(tname)); } } diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index 9d85a97c..c5bf6e1e 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -13,9 +13,9 @@ #include namespace xo { + using xo::mm::ACollector; using xo::mm::AGCObject; using xo::print::APrintable; - //using xo::facet::typeseq; using xo::print::ppstate; namespace scm { @@ -34,8 +34,8 @@ namespace xo { { void * mem = mm.alloc_for(); - DArray * vars = DArray::empty(mm, nv); - DArray * types = DArray::empty(mm, nt); + DArray * vars = DArray::_empty(mm, nv); + DArray * types = DArray::_empty(mm, nt); return new (mem) DLocalSymtab(p, vars, types); } @@ -69,7 +69,9 @@ namespace xo { Binding binding = Binding::local(vars_->size()); DVariable * var = DVariable::make(mm, name, typeref, binding); - vars_->push_back(obj(var)); + + auto gc = mm.try_to_facet(); + vars_->push_back(gc, obj(var)); return binding; } @@ -87,7 +89,8 @@ namespace xo { } else { obj tname = DTypename::make(mm, name, type); - types_->push_back(tname); + auto gc = mm.try_to_facet(); + types_->push_back(gc, tname); } } diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index 8fdfcf9b..bfece9e6 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -15,6 +15,7 @@ #include namespace xo { + using xo::mm::ACollector; using xo::mm::AGCObject; using xo::print::APrintable; using xo::facet::FacetRegistry; @@ -47,8 +48,8 @@ namespace xo { /** allocate 2nd, so it comes after DSequenceExpr in * memory. This may later allow realloc **/ - DArray * expr_v = DArray::empty(mm, - c_hint_capacity); + DArray * expr_v = DArray::_empty(mm, + c_hint_capacity); expr->expr_v_ = expr_v; @@ -73,23 +74,25 @@ namespace xo { DSequenceExpr::push_back(obj mm, obj expr) { + // null gc -> no write barrier + obj gc = mm.try_to_facet(); + if (expr_v_->size() == expr_v_->capacity()) { /* reallocate+expand */ DArray * expr_2x_v - = DArray::empty(mm, 2 * expr_v_->capacity()); + = DArray::_empty(mm, 2 * expr_v_->capacity()); for (size_type i = 0, z = expr_v_->size(); i < z; ++i) { - expr_2x_v->push_back((*expr_2x_v)[i]); + expr_2x_v->push_back(gc, (*expr_2x_v)[i]); } this->expr_v_ = expr_2x_v; } - obj expr_gco - = FacetRegistry::instance().variant(expr); + obj expr_gco = expr.to_facet(); - this->expr_v_->push_back(expr_gco); + this->expr_v_->push_back(gc, expr_gco); } void From ca79d06be410256ea9af871bc35634ed71c7f392 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 1 May 2026 19:54:26 -0400 Subject: [PATCH 126/128] refactor focusing on xo-alloc2/ xo-gc/ write-barrier ability to inform allocator of gco->gco mutation, via AAllocator i/face. --- src/expression2/DGlobalSymtab.cpp | 15 +++++++++------ src/expression2/DLocalSymtab.cpp | 8 ++++---- src/expression2/DSequenceExpr.cpp | 10 ++++------ 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index d927288a..30878f4d 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -111,7 +111,7 @@ namespace xo { { scope log(XO_DEBUG(false), std::string_view(*var->name())); - auto gc = mm.try_to_facet(); + //auto gc = mm.try_to_facet(); // It's possible there's already a global variable // with the same name. @@ -136,7 +136,10 @@ namespace xo { // replacing previous one // log && log("STUB: need write barrier"); - (*vars_)[existing->path().j_slot()] = obj(var); + vars_->assign_at(mm, + existing->path().j_slot(), + obj(var)); + //(*vars_)[existing->path().j_slot()] = obj(var); } else { log && log("variable is new"); @@ -168,7 +171,7 @@ namespace xo { // need slot# in .map_ for this unique symbol (*var_map_)[var->name()] = binding.j_slot(); - vars_->push_back(gc, obj(var)); + vars_->push_back(mm, obj(var)); } } @@ -194,7 +197,7 @@ namespace xo { scope log(XO_DEBUG(true), std::string_view(*tname->name())); - auto gc = mm.try_to_facet(); + //auto gc = mm.try_to_facet(); auto ix = type_map_->find(tname->name()); @@ -223,12 +226,12 @@ namespace xo { (*type_map_)[tname->name()] = n; log && log("STUB: need write barrier"); - types_->push_back(gc, obj(tname)); + types_->push_back(mm, obj(tname)); } else { Binding::slot_type i_slot = ix->second; log && log("STUB: need write barrier"); - types_->assign_at(gc, i_slot, + types_->assign_at(mm, i_slot, obj(tname)); } } diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index c5bf6e1e..c8b5b1fd 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -70,8 +70,8 @@ namespace xo { DVariable * var = DVariable::make(mm, name, typeref, binding); - auto gc = mm.try_to_facet(); - vars_->push_back(gc, obj(var)); + //auto gc = mm.try_to_facet(); + vars_->push_back(mm, obj(var)); return binding; } @@ -89,8 +89,8 @@ namespace xo { } else { obj tname = DTypename::make(mm, name, type); - auto gc = mm.try_to_facet(); - types_->push_back(gc, tname); + //auto gc = mm.try_to_facet(); + types_->push_back(mm, tname); } } diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index bfece9e6..bdff6270 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -5,8 +5,7 @@ #include "DSequenceExpr.hpp" #include "detail/IExpression_DSequenceExpr.hpp" -#include -#include +#include #include #include #include @@ -15,7 +14,6 @@ #include namespace xo { - using xo::mm::ACollector; using xo::mm::AGCObject; using xo::print::APrintable; using xo::facet::FacetRegistry; @@ -75,7 +73,7 @@ namespace xo { obj expr) { // null gc -> no write barrier - obj gc = mm.try_to_facet(); + //obj gc = mm.try_to_facet(); if (expr_v_->size() == expr_v_->capacity()) { /* reallocate+expand */ @@ -84,7 +82,7 @@ namespace xo { = DArray::_empty(mm, 2 * expr_v_->capacity()); for (size_type i = 0, z = expr_v_->size(); i < z; ++i) { - expr_2x_v->push_back(gc, (*expr_2x_v)[i]); + expr_2x_v->push_back(mm, (*expr_2x_v)[i]); } this->expr_v_ = expr_2x_v; @@ -92,7 +90,7 @@ namespace xo { obj expr_gco = expr.to_facet(); - this->expr_v_->push_back(gc, expr_gco); + this->expr_v_->push_back(mm, expr_gco); } void From 6ca592808826575a1a8432fc5f10fda34abf65ac Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 2 May 2026 13:49:29 -0400 Subject: [PATCH 127/128] xo-gc stack: refactor + streamline. Retiring unused Collector typealiases. Fix #include topology. Fix/improve write barrier setup. --- include/xo/expression2/define/IGCObject_DDefineExpr.hpp | 1 - include/xo/expression2/detail/IExpression_Xfer.hpp | 8 ++++++++ include/xo/expression2/detail/IGCObject_DApplyExpr.hpp | 1 - include/xo/expression2/detail/IGCObject_DConstant.hpp | 1 - include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp | 1 - include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp | 1 - include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp | 1 - include/xo/expression2/detail/IGCObject_DVarRef.hpp | 1 - include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp | 1 - include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp | 1 - include/xo/expression2/symtab/ISymbolTable_Xfer.hpp | 8 ++++++++ include/xo/expression2/typename/IGCObject_DTypename.hpp | 1 - include/xo/expression2/variable/IGCObject_DVariable.hpp | 1 - 13 files changed, 16 insertions(+), 11 deletions(-) diff --git a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp index c07c8e4e..e98403fe 100644 --- a/include/xo/expression2/define/IGCObject_DDefineExpr.hpp +++ b/include/xo/expression2/define/IGCObject_DDefineExpr.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/expression2/detail/IExpression_Xfer.hpp b/include/xo/expression2/detail/IExpression_Xfer.hpp index 095e21ed..c1e78815 100644 --- a/include/xo/expression2/detail/IExpression_Xfer.hpp +++ b/include/xo/expression2/detail/IExpression_Xfer.hpp @@ -9,10 +9,18 @@ * [iface_facet_any.hpp.j2] * 3. idl for facet methods * [idl/Expression.json5] + * + * variables: + * {facet_hpp_fname} -> Expression.hpp + * {impl_hpp_subdir} -> detail + * {facet_ns1} -> xo + * {facet_detail_subdir} -> detail + * {abstract_facet_fname} -> AExpression.hpp **/ #pragma once +#include "AExpression.hpp" #include "TypeRef.hpp" #include "exprtype.hpp" #include diff --git a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp index a1a2fac4..9ce7cdda 100644 --- a/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DApplyExpr.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/expression2/detail/IGCObject_DConstant.hpp b/include/xo/expression2/detail/IGCObject_DConstant.hpp index 82783948..f5c9de84 100644 --- a/include/xo/expression2/detail/IGCObject_DConstant.hpp +++ b/include/xo/expression2/detail/IGCObject_DConstant.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp index 3156fe58..ad5862a2 100644 --- a/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DIfElseExpr.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp index ec4faded..71b37d58 100644 --- a/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DLambdaExpr.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp index 1b927e01..d11f6341 100644 --- a/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp +++ b/include/xo/expression2/detail/IGCObject_DSequenceExpr.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/expression2/detail/IGCObject_DVarRef.hpp b/include/xo/expression2/detail/IGCObject_DVarRef.hpp index 085999f9..9b3172d8 100644 --- a/include/xo/expression2/detail/IGCObject_DVarRef.hpp +++ b/include/xo/expression2/detail/IGCObject_DVarRef.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp index ee24adfb..0731ab56 100644 --- a/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DGlobalSymtab.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp index cbd98904..92226d63 100644 --- a/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp +++ b/include/xo/expression2/symtab/IGCObject_DLocalSymtab.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp b/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp index db81237f..03b32ada 100644 --- a/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp +++ b/include/xo/expression2/symtab/ISymbolTable_Xfer.hpp @@ -9,10 +9,18 @@ * [iface_facet_any.hpp.j2] * 3. idl for facet methods * [idl/SymbolTable.json5] + * + * variables: + * {facet_hpp_fname} -> SymbolTable.hpp + * {impl_hpp_subdir} -> symtab + * {facet_ns1} -> xo + * {facet_detail_subdir} -> symtab + * {abstract_facet_fname} -> ASymbolTable.hpp **/ #pragma once +#include "ASymbolTable.hpp" #include "Binding.hpp" #include "DUniqueString.hpp" diff --git a/include/xo/expression2/typename/IGCObject_DTypename.hpp b/include/xo/expression2/typename/IGCObject_DTypename.hpp index cdd91734..14c0f336 100644 --- a/include/xo/expression2/typename/IGCObject_DTypename.hpp +++ b/include/xo/expression2/typename/IGCObject_DTypename.hpp @@ -41,7 +41,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; diff --git a/include/xo/expression2/variable/IGCObject_DVariable.hpp b/include/xo/expression2/variable/IGCObject_DVariable.hpp index 9e173090..fbb60525 100644 --- a/include/xo/expression2/variable/IGCObject_DVariable.hpp +++ b/include/xo/expression2/variable/IGCObject_DVariable.hpp @@ -43,7 +43,6 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; From 7ddeaaeea5eb22c9b809860335c4478ba5abc693 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 2 May 2026 13:58:22 -0400 Subject: [PATCH 128/128] tidy: drop stale ACollector comments --- src/expression2/DGlobalSymtab.cpp | 4 ---- src/expression2/DLocalSymtab.cpp | 2 -- src/expression2/DSequenceExpr.cpp | 3 --- 3 files changed, 9 deletions(-) diff --git a/src/expression2/DGlobalSymtab.cpp b/src/expression2/DGlobalSymtab.cpp index 30878f4d..f4704fa6 100644 --- a/src/expression2/DGlobalSymtab.cpp +++ b/src/expression2/DGlobalSymtab.cpp @@ -111,8 +111,6 @@ namespace xo { { scope log(XO_DEBUG(false), std::string_view(*var->name())); - //auto gc = mm.try_to_facet(); - // It's possible there's already a global variable // with the same name. // @@ -197,8 +195,6 @@ namespace xo { scope log(XO_DEBUG(true), std::string_view(*tname->name())); - //auto gc = mm.try_to_facet(); - auto ix = type_map_->find(tname->name()); if (ix == type_map_->end()) { diff --git a/src/expression2/DLocalSymtab.cpp b/src/expression2/DLocalSymtab.cpp index c8b5b1fd..1cb69b84 100644 --- a/src/expression2/DLocalSymtab.cpp +++ b/src/expression2/DLocalSymtab.cpp @@ -70,7 +70,6 @@ namespace xo { DVariable * var = DVariable::make(mm, name, typeref, binding); - //auto gc = mm.try_to_facet(); vars_->push_back(mm, obj(var)); return binding; @@ -89,7 +88,6 @@ namespace xo { } else { obj tname = DTypename::make(mm, name, type); - //auto gc = mm.try_to_facet(); types_->push_back(mm, tname); } } diff --git a/src/expression2/DSequenceExpr.cpp b/src/expression2/DSequenceExpr.cpp index bdff6270..fd55a114 100644 --- a/src/expression2/DSequenceExpr.cpp +++ b/src/expression2/DSequenceExpr.cpp @@ -72,9 +72,6 @@ namespace xo { DSequenceExpr::push_back(obj mm, obj expr) { - // null gc -> no write barrier - //obj gc = mm.try_to_facet(); - if (expr_v_->size() == expr_v_->capacity()) { /* reallocate+expand */