xo-numeric: type decoration for multiply

This commit is contained in:
Roland Conybeare 2026-03-16 13:29:48 -05:00
commit 940cfb963a
3 changed files with 19 additions and 4 deletions

View file

@ -18,7 +18,8 @@ namespace xo {
public:
/** polymorphic (in both arguments1) multiply **/
static DPrimitive_gco_2_gco_gco * make_multiply_pm(obj<AAllocator> mm);
static DPrimitive_gco_2_gco_gco * make_multiply_pm(obj<AAllocator> mm,
StringTable * stbl);
/** polymorphic (in both arguments) divide **/
static DPrimitive_gco_2_gco_gco * make_divide_pm(obj<AAllocator> mm);

View file

@ -5,6 +5,8 @@
#include "NumericPrimitives.hpp"
#include "NumericDispatch.hpp"
#include <xo/type/AtomicType.hpp>
#include <xo/type/FunctionType.hpp>
namespace xo {
using xo::mm::AAllocator;
@ -13,9 +15,21 @@ namespace xo {
namespace scm {
DPrimitive_gco_2_gco_gco *
NumericPrimitives::make_multiply_pm(obj<AAllocator> mm)
NumericPrimitives::make_multiply_pm(obj<AAllocator> mm,
StringTable * stbl)
{
return DPrimitive_gco_2_gco_gco::_make(mm, "_mul",
(void)stbl;
// TODO: want to expand this to record schedule based on argument types.
//
// e.g. f64 x f64 -> f64
auto numeric_ty = DAtomicType::make(mm, Metatype::t_numeric());
// #op+: numeric x numeric -> numeric
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,
&NumericDispatch::multiply);
}

View file

@ -59,7 +59,7 @@ namespace xo {
bool ok = true;
ok = ok & install_aux(sink,
NumericPrimitives::make_multiply_pm(mm),
NumericPrimitives::make_multiply_pm(mm, stbl),
flags & InstallFlags::f_essential);
ok = ok & install_aux(sink,
NumericPrimitives::make_divide_pm(mm),