Compare commits
10 commits
dc43feece0
...
5f2de0ad5a
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f2de0ad5a | |||
| 4dc6739167 | |||
| 5950a45483 | |||
| 9e88672ad4 | |||
| d288c4ff1e | |||
| 4601e824bc | |||
| b3fbddcf3e | |||
| 335c04a834 | |||
| f4d00d9e17 | |||
| 884a6074d7 |
13 changed files with 245 additions and 251 deletions
|
|
@ -17,34 +17,62 @@ namespace xo {
|
|||
using AAllocator = xo::mm::AAllocator;
|
||||
|
||||
public:
|
||||
/** name for multiply primitive. Used for op* **/
|
||||
static constexpr const char * c_multiply_pm_name = "_mul";
|
||||
/** polymorphic (in both arguments1) multiply **/
|
||||
static DPrimitive_gco_2_gco_gco * make_multiply_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for divide primitives. Used for op/ **/
|
||||
static constexpr const char * c_divide_pm_name = "_div";
|
||||
/** polymorphic (in both arguments) divide **/
|
||||
static DPrimitive_gco_2_gco_gco * make_divide_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for add primitives. Used for op+ **/
|
||||
static constexpr const char * c_add_pm_name = "_add";
|
||||
/** polymorphic (in both arguments) add **/
|
||||
static DPrimitive_gco_2_gco_gco * make_add_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for sub primitives. Used for op- **/
|
||||
static constexpr const char * c_sub_pm_name = "_sub";
|
||||
/** polymorphic (in both arguments) subtract **/
|
||||
static DPrimitive_gco_2_gco_gco * make_subtract_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for equality-comparison primitive. Used for op== **/
|
||||
static constexpr const char * c_cmpeq_pm_name = "_cmpeq";
|
||||
/** polymorphic (in both arguments) compare (==) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpeq_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for inequality-comparison prmitive. Used for op!= **/
|
||||
static constexpr const char * c_cmpne_pm_name = "_cmpne";
|
||||
/** polymorphic (in both arguments) compare (!=) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpne_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for less-comparison primitive. Used for op< **/
|
||||
static constexpr const char * c_cmplt_pm_name = "_cmplt";
|
||||
/** polymorphic (in both arguments) compare (<) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmplt_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for lesser-or-equal-comparison primitive. Used for op<= **/
|
||||
static constexpr const char * c_cmple_pm_name = "_cmple";
|
||||
/** polymorphic (in both arguments) compare (<=) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmple_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for greater-comparison primitive. Used for op> **/
|
||||
static constexpr const char * c_cmpgt_pm_name = "_cmpgt";
|
||||
/** polymorphic (in both arguments) compare (>) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpgt_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** name for greater-or-equal-comparison primitive. Used for op>= **/
|
||||
static constexpr const char * c_cmpge_pm_name = "_cmpge";
|
||||
/** polymorphic (in both arguments) compare (>=) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpge_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
|
|
|||
25
include/xo/numeric/SetupNumeric.hpp
Normal file
25
include/xo/numeric/SetupNumeric.hpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
/** @file SetupNumeric.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Feb 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "PrimitiveRegistry.hpp"
|
||||
#include <xo/alloc2/Collector.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** Setup numeric facet dispatch **/
|
||||
struct SetupNumeric {
|
||||
public:
|
||||
static bool register_facets();
|
||||
/** Register primitive factories with primitive registry **/
|
||||
static bool register_primitives(obj<ARuntimeContext> rcx,
|
||||
InstallSink sink,
|
||||
InstallFlags flags);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/* end SetupNumeric.hpp */
|
||||
|
|
@ -42,6 +42,11 @@ public:
|
|||
/** @defgroup scm-numeric-methods **/
|
||||
///@{
|
||||
// const methods
|
||||
/** An uninitialized ANumeric instance will have zero vtable pointer (per {linux,osx} abi).
|
||||
* Use case for this is narrow. We go to some lengths to avoid null vtable pointers. For example
|
||||
* obj<AFacet> will have non-null vtable (via IFacet_Any) with all methods terminating.
|
||||
**/
|
||||
bool _has_null_vptr() const noexcept { return *reinterpret_cast<const void * const *>(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 **/
|
||||
|
|
|
|||
|
|
@ -9,10 +9,18 @@
|
|||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/Numeric.json5]
|
||||
*
|
||||
* variables:
|
||||
* {facet_hpp_fname} -> Numeric.hpp
|
||||
* {impl_hpp_subdir} -> detail
|
||||
* {facet_ns1} -> xo
|
||||
* {facet_detail_subdir} -> detail
|
||||
* {abstract_facet_fname} -> ANumeric.hpp
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ANumeric.hpp"
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ public:
|
|||
///@{
|
||||
|
||||
// explicit injected content
|
||||
static obj<ANumeric> multiply(obj<ANumeric> lhs, obj<ANumeric> rhs);
|
||||
|
||||
// builtin methods
|
||||
typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); }
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
/** @file numeric_register_facets.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Feb 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** Setup numeric facet dispatch **/
|
||||
bool numeric_register_facets();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/* end numeric_register_facets.hpp */
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
/** @file numeric_register_primitives.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Mar 2026
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "PrimitiveRegistry.hpp"
|
||||
#include <xo/alloc2/Collector.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
/** Register primitive factories with primitive registry **/
|
||||
bool numeric_register_primitives(obj<ARuntimeContext> rcx,
|
||||
//obj<xo::mm::AAllocator> mm,
|
||||
//StringTable * stbl,
|
||||
InstallSink sink,
|
||||
InstallFlags flags);
|
||||
}
|
||||
}
|
||||
|
||||
/* end numeric_register_primitives.hpp */
|
||||
|
|
@ -3,8 +3,7 @@
|
|||
set(SELF_LIB xo_numeric)
|
||||
set(SELF_SRCS
|
||||
init_numeric.cpp
|
||||
numeric_register_facets.cpp
|
||||
numeric_register_primitives.cpp
|
||||
SetupNumeric.cpp
|
||||
NumericPrimitives.cpp
|
||||
NumericDispatch.cpp
|
||||
INumeric_Any.cpp
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, numeric_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_mul", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_multiply_pm_name, pm_ty,
|
||||
&NumericDispatch::multiply);
|
||||
}
|
||||
|
||||
|
|
@ -44,7 +44,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, numeric_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_div", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_divide_pm_name, pm_ty,
|
||||
&NumericDispatch::divide);
|
||||
}
|
||||
|
||||
|
|
@ -59,7 +59,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, numeric_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_add", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_add_pm_name, pm_ty,
|
||||
&NumericDispatch::add);
|
||||
}
|
||||
|
||||
|
|
@ -74,7 +74,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, numeric_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_sub", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_sub_pm_name, pm_ty,
|
||||
&NumericDispatch::subtract);
|
||||
}
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpeq", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_cmpeq_pm_name, pm_ty,
|
||||
&NumericDispatch::cmp_equal);
|
||||
}
|
||||
|
||||
|
|
@ -106,7 +106,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpne", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_cmpne_pm_name, pm_ty,
|
||||
&NumericDispatch::cmp_notequal);
|
||||
}
|
||||
|
||||
|
|
@ -122,7 +122,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmplt", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_cmplt_pm_name, pm_ty,
|
||||
&NumericDispatch::cmp_less);
|
||||
}
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmple", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_cmple_pm_name, pm_ty,
|
||||
&NumericDispatch::cmp_lessequal);
|
||||
}
|
||||
|
||||
|
|
@ -154,7 +154,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpgt", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_cmpgt_pm_name, pm_ty,
|
||||
&NumericDispatch::cmp_greater);
|
||||
}
|
||||
|
||||
|
|
@ -170,7 +170,7 @@ namespace xo {
|
|||
auto pm_ty = obj<AType,DFunctionType>
|
||||
(DFunctionType::_make(mm, booleic_ty, numeric_ty, numeric_ty));
|
||||
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpge", pm_ty,
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, c_cmpge_pm_name, pm_ty,
|
||||
&NumericDispatch::cmp_greatequal);
|
||||
}
|
||||
|
||||
|
|
|
|||
162
src/numeric/SetupNumeric.cpp
Normal file
162
src/numeric/SetupNumeric.cpp
Normal file
|
|
@ -0,0 +1,162 @@
|
|||
/** @file SetupNumeric.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Mar 2026
|
||||
**/
|
||||
|
||||
#include "SetupNumeric.hpp"
|
||||
#include "NumericDispatch.hpp"
|
||||
#include "Numeric.hpp"
|
||||
#include "NumericPrimitives.hpp"
|
||||
#include "NumericDispatch.hpp"
|
||||
|
||||
#include "FloatIntegerOps.hpp"
|
||||
#include "FloatOps.hpp"
|
||||
#include "float/INumeric_DFloat.hpp"
|
||||
|
||||
#include "IntegerOps.hpp"
|
||||
#include "integer/INumeric_DInteger.hpp"
|
||||
|
||||
#include <xo/procedure2/Primitive_gco_2_gco_gco.hpp>
|
||||
|
||||
#include <xo/object2/DFloat.hpp>
|
||||
#include <xo/object2/Integer.hpp>
|
||||
|
||||
#include <xo/facet/FacetRegistry.hpp>
|
||||
#include <xo/reflectutil/typeseq.hpp>
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::mm::AAllocator;
|
||||
using xo::facet::FacetRegistry;
|
||||
using xo::reflect::typeseq;
|
||||
|
||||
namespace scm {
|
||||
bool
|
||||
SetupNumeric::register_facets()
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
FacetRegistry::register_impl<ANumeric, DInteger>();
|
||||
|
||||
NumericDispatch::instance().register_impl<DFloat, DFloat>
|
||||
(&FloatOps::multiply,
|
||||
&FloatOps::divide,
|
||||
&FloatOps::add,
|
||||
&FloatOps::subtract,
|
||||
&FloatOps::cmp_equal,
|
||||
&FloatOps::cmp_notequal,
|
||||
&FloatOps::cmp_less,
|
||||
&FloatOps::cmp_lessequal,
|
||||
&FloatOps::cmp_greater,
|
||||
&FloatOps::cmp_greatequal);
|
||||
|
||||
NumericDispatch::instance().register_impl<DFloat, DInteger>
|
||||
(&FloatIntegerOps::multiply,
|
||||
&FloatIntegerOps::divide,
|
||||
&FloatIntegerOps::add,
|
||||
&FloatIntegerOps::subtract,
|
||||
&FloatIntegerOps::cmp_equal,
|
||||
&FloatIntegerOps::cmp_notequal,
|
||||
&FloatIntegerOps::cmp_less,
|
||||
&FloatIntegerOps::cmp_lessequal,
|
||||
&FloatIntegerOps::cmp_greater,
|
||||
&FloatIntegerOps::cmp_greatequal);
|
||||
|
||||
NumericDispatch::instance().register_impl<DInteger, DFloat>
|
||||
(&IntegerFloatOps::multiply,
|
||||
&IntegerFloatOps::divide,
|
||||
&IntegerFloatOps::add,
|
||||
&IntegerFloatOps::subtract,
|
||||
&IntegerFloatOps::cmp_equal,
|
||||
&IntegerFloatOps::cmp_notequal,
|
||||
&IntegerFloatOps::cmp_less,
|
||||
&IntegerFloatOps::cmp_lessequal,
|
||||
&IntegerFloatOps::cmp_greater,
|
||||
&IntegerFloatOps::cmp_greatequal);
|
||||
|
||||
NumericDispatch::instance().register_impl<DInteger, DInteger>
|
||||
(&IntegerOps::multiply,
|
||||
&IntegerOps::divide,
|
||||
&IntegerOps::add,
|
||||
&IntegerOps::subtract,
|
||||
&IntegerOps::cmp_equal,
|
||||
&IntegerOps::cmp_notequal,
|
||||
&IntegerOps::cmp_less,
|
||||
&IntegerOps::cmp_lessequal,
|
||||
&IntegerOps::cmp_greater,
|
||||
&IntegerOps::cmp_greatequal);
|
||||
|
||||
log && log(xtag("ANumeric.tseq", typeseq::id<ANumeric>()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool
|
||||
SetupNumeric::register_primitives(obj<ARuntimeContext> rcx,
|
||||
InstallSink sink,
|
||||
InstallFlags flags)
|
||||
{
|
||||
obj<AAllocator> mm = rcx.allocator();
|
||||
StringTable * stbl = rcx.stringtable();
|
||||
|
||||
scope log(XO_DEBUG(false));
|
||||
|
||||
bool ok = true;
|
||||
|
||||
/* "_mul" */
|
||||
ok = ok & (PrimitiveRegistry::install_aux
|
||||
(sink,
|
||||
NumericPrimitives::make_multiply_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential));
|
||||
/* "_div" */
|
||||
ok = ok & (PrimitiveRegistry::install_aux
|
||||
(sink,
|
||||
NumericPrimitives::make_divide_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential));
|
||||
/* "_add" */
|
||||
ok = ok & (PrimitiveRegistry::install_aux
|
||||
(sink,
|
||||
NumericPrimitives::make_add_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential));
|
||||
/* "_sub" */
|
||||
ok = ok & (PrimitiveRegistry::install_aux
|
||||
(sink,
|
||||
NumericPrimitives::make_subtract_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential));
|
||||
/* "_cmpeq" */
|
||||
ok = ok & (PrimitiveRegistry::install_aux
|
||||
(sink,
|
||||
NumericPrimitives::make_cmpeq_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential));
|
||||
/* "_cmpne" */
|
||||
ok = ok & (PrimitiveRegistry::install_aux
|
||||
(sink,
|
||||
NumericPrimitives::make_cmpne_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential));
|
||||
/* "_cmplt" */
|
||||
ok = ok & (PrimitiveRegistry::install_aux
|
||||
(sink,
|
||||
NumericPrimitives::make_cmplt_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential));
|
||||
/* "_cmple" */
|
||||
ok = ok & (PrimitiveRegistry::install_aux
|
||||
(sink,
|
||||
NumericPrimitives::make_cmple_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential));
|
||||
/* "_cmpgt" */
|
||||
ok = ok & (PrimitiveRegistry::install_aux
|
||||
(sink,
|
||||
NumericPrimitives::make_cmpgt_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential));
|
||||
/* "_cmpge" */
|
||||
ok = ok & (PrimitiveRegistry::install_aux
|
||||
(sink,
|
||||
NumericPrimitives::make_cmpge_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential));
|
||||
|
||||
return ok;
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end SetupNumeric.cpp */
|
||||
|
|
@ -4,22 +4,21 @@
|
|||
**/
|
||||
|
||||
#include "init_numeric.hpp"
|
||||
#include "SetupNumeric.hpp"
|
||||
#include <xo/procedure2/init_procedure2.hpp>
|
||||
#include "Subsystem.hpp"
|
||||
#include "numeric_register_facets.hpp"
|
||||
#include "numeric_register_primitives.hpp"
|
||||
|
||||
namespace xo {
|
||||
using xo::scm::numeric_register_facets;
|
||||
using xo::scm::numeric_register_primitives;
|
||||
using xo::scm::SetupNumeric;
|
||||
//using xo::scm::numeric_register_primitives;
|
||||
using xo::scm::PrimitiveRegistry;
|
||||
|
||||
void
|
||||
InitSubsys<S_numeric_tag>::init()
|
||||
{
|
||||
numeric_register_facets();
|
||||
SetupNumeric::register_facets();
|
||||
|
||||
PrimitiveRegistry::instance().register_primitives(&numeric_register_primitives);
|
||||
PrimitiveRegistry::instance().register_primitives(&SetupNumeric::register_primitives);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,93 +0,0 @@
|
|||
/** @file numeric_register_facets.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Feb 2026
|
||||
**/
|
||||
|
||||
#include "numeric_register_facets.hpp"
|
||||
#include "NumericDispatch.hpp"
|
||||
#include "Numeric.hpp"
|
||||
|
||||
#include "FloatIntegerOps.hpp"
|
||||
#include "FloatOps.hpp"
|
||||
#include "float/INumeric_DFloat.hpp"
|
||||
|
||||
#include "IntegerOps.hpp"
|
||||
#include "integer/INumeric_DInteger.hpp"
|
||||
|
||||
#include <xo/object2/DFloat.hpp>
|
||||
#include <xo/object2/Integer.hpp>
|
||||
|
||||
#include <xo/facet/FacetRegistry.hpp>
|
||||
#include <xo/reflectutil/typeseq.hpp>
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::facet::FacetRegistry;
|
||||
using xo::reflect::typeseq;
|
||||
|
||||
namespace scm {
|
||||
|
||||
bool
|
||||
numeric_register_facets()
|
||||
{
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
FacetRegistry::register_impl<ANumeric, DInteger>();
|
||||
|
||||
NumericDispatch::instance().register_impl<DFloat, DFloat>
|
||||
(&FloatOps::multiply,
|
||||
&FloatOps::divide,
|
||||
&FloatOps::add,
|
||||
&FloatOps::subtract,
|
||||
&FloatOps::cmp_equal,
|
||||
&FloatOps::cmp_notequal,
|
||||
&FloatOps::cmp_less,
|
||||
&FloatOps::cmp_lessequal,
|
||||
&FloatOps::cmp_greater,
|
||||
&FloatOps::cmp_greatequal);
|
||||
|
||||
NumericDispatch::instance().register_impl<DFloat, DInteger>
|
||||
(&FloatIntegerOps::multiply,
|
||||
&FloatIntegerOps::divide,
|
||||
&FloatIntegerOps::add,
|
||||
&FloatIntegerOps::subtract,
|
||||
&FloatIntegerOps::cmp_equal,
|
||||
&FloatIntegerOps::cmp_notequal,
|
||||
&FloatIntegerOps::cmp_less,
|
||||
&FloatIntegerOps::cmp_lessequal,
|
||||
&FloatIntegerOps::cmp_greater,
|
||||
&FloatIntegerOps::cmp_greatequal);
|
||||
|
||||
NumericDispatch::instance().register_impl<DInteger, DFloat>
|
||||
(&IntegerFloatOps::multiply,
|
||||
&IntegerFloatOps::divide,
|
||||
&IntegerFloatOps::add,
|
||||
&IntegerFloatOps::subtract,
|
||||
&IntegerFloatOps::cmp_equal,
|
||||
&IntegerFloatOps::cmp_notequal,
|
||||
&IntegerFloatOps::cmp_less,
|
||||
&IntegerFloatOps::cmp_lessequal,
|
||||
&IntegerFloatOps::cmp_greater,
|
||||
&IntegerFloatOps::cmp_greatequal);
|
||||
|
||||
NumericDispatch::instance().register_impl<DInteger, DInteger>
|
||||
(&IntegerOps::multiply,
|
||||
&IntegerOps::divide,
|
||||
&IntegerOps::add,
|
||||
&IntegerOps::subtract,
|
||||
&IntegerOps::cmp_equal,
|
||||
&IntegerOps::cmp_notequal,
|
||||
&IntegerOps::cmp_less,
|
||||
&IntegerOps::cmp_lessequal,
|
||||
&IntegerOps::cmp_greater,
|
||||
&IntegerOps::cmp_greatequal);
|
||||
|
||||
log && log(xtag("ANumeric.tseq", typeseq::id<ANumeric>()));
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end numeric_register_facets.cpp */
|
||||
|
|
@ -1,102 +0,0 @@
|
|||
/** @file numeric_register_primitives.cpp
|
||||
*
|
||||
* @author Roland Conybeare, Mar 2026
|
||||
**/
|
||||
|
||||
#include "numeric_register_primitives.hpp"
|
||||
#include "NumericPrimitives.hpp"
|
||||
#include "NumericDispatch.hpp"
|
||||
#include <xo/procedure2/Primitive_gco_2_gco_gco.hpp>
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::mm::AAllocator;
|
||||
using xo::scope;
|
||||
|
||||
namespace scm {
|
||||
namespace {
|
||||
bool install_aux(InstallSink sink,
|
||||
DPrimitive_gco_2_gco_gco * pm,
|
||||
InstallFlags flags)
|
||||
{
|
||||
if (flags != InstallFlags::f_none) {
|
||||
return sink(pm->name(),
|
||||
pm->fn_td(),
|
||||
obj<AProcedure,DPrimitive_gco_2_gco_gco>(pm),
|
||||
flags);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef OBSOLETE
|
||||
bool install_aux(InstallSink sink,
|
||||
obj<AAllocator> mm,
|
||||
std::string_view name,
|
||||
obj<AGCObject> (*impl)(obj<ARuntimeContext> rcx,
|
||||
obj<AGCObject> x,
|
||||
obj<AGCObject> y),
|
||||
InstallFlags flags)
|
||||
{
|
||||
if (flags != InstallFlags::f_none) {
|
||||
auto pm
|
||||
= DPrimitive_gco_2_gco_gco::_make(mm, name, impl);
|
||||
|
||||
return install_aux(sink, pm, flags);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
numeric_register_primitives(obj<ARuntimeContext> rcx,
|
||||
//obj<AAllocator> mm, StringTable * stbl,
|
||||
InstallSink sink, InstallFlags flags)
|
||||
{
|
||||
obj<AAllocator> mm = rcx.allocator();
|
||||
StringTable * stbl = rcx.stringtable();
|
||||
|
||||
scope log(XO_DEBUG(true));
|
||||
|
||||
bool ok = true;
|
||||
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_multiply_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_divide_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_add_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_subtract_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_cmpeq_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_cmpne_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_cmplt_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_cmple_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_cmpgt_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_cmpge_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
|
||||
return ok;
|
||||
}
|
||||
}
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end numeric_register_primitives.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue