diff --git a/xo-expression2/utest/DApplyExpr.test.cpp b/xo-expression2/utest/DApplyExpr.test.cpp index 0f7f41ef..d3638da3 100644 --- a/xo-expression2/utest/DApplyExpr.test.cpp +++ b/xo-expression2/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); diff --git a/xo-numeric/include/xo/numeric/NumericPrimitives.hpp b/xo-numeric/include/xo/numeric/NumericPrimitives.hpp index 54201f59..8a1cd33d 100644 --- a/xo-numeric/include/xo/numeric/NumericPrimitives.hpp +++ b/xo-numeric/include/xo/numeric/NumericPrimitives.hpp @@ -18,7 +18,8 @@ namespace xo { public: /** polymorphic (in both arguments1) multiply **/ - static DPrimitive_gco_2_gco_gco * make_multiply_pm(obj mm); + static DPrimitive_gco_2_gco_gco * make_multiply_pm(obj mm, + StringTable * stbl); /** polymorphic (in both arguments) divide **/ static DPrimitive_gco_2_gco_gco * make_divide_pm(obj mm); diff --git a/xo-numeric/src/numeric/NumericPrimitives.cpp b/xo-numeric/src/numeric/NumericPrimitives.cpp index 9ef0b979..aeb7d8fb 100644 --- a/xo-numeric/src/numeric/NumericPrimitives.cpp +++ b/xo-numeric/src/numeric/NumericPrimitives.cpp @@ -5,6 +5,8 @@ #include "NumericPrimitives.hpp" #include "NumericDispatch.hpp" +#include +#include namespace xo { using xo::mm::AAllocator; @@ -13,9 +15,21 @@ namespace xo { namespace scm { DPrimitive_gco_2_gco_gco * - NumericPrimitives::make_multiply_pm(obj mm) + NumericPrimitives::make_multiply_pm(obj 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 + (DFunctionType::_make(mm, numeric_ty, numeric_ty, numeric_ty)); + + return DPrimitive_gco_2_gco_gco::_make(mm, "_mul", pm_ty, &NumericDispatch::multiply); } diff --git a/xo-numeric/src/numeric/numeric_register_primitives.cpp b/xo-numeric/src/numeric/numeric_register_primitives.cpp index aa4a24d0..20eb5967 100644 --- a/xo-numeric/src/numeric/numeric_register_primitives.cpp +++ b/xo-numeric/src/numeric/numeric_register_primitives.cpp @@ -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),