xo-numeric: attach type to numeric primitives
This commit is contained in:
parent
9fda81bd04
commit
a66cd3cf91
5 changed files with 134 additions and 37 deletions
|
|
@ -20,26 +20,34 @@ namespace xo {
|
|||
/** polymorphic (in both arguments1) multiply **/
|
||||
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);
|
||||
static DPrimitive_gco_2_gco_gco * make_divide_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
/** polymorphic (in both arguments) add **/
|
||||
static DPrimitive_gco_2_gco_gco * make_add_pm(obj<AAllocator> mm);
|
||||
static DPrimitive_gco_2_gco_gco * make_add_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
/** polymorphic (in both arguments) subtract **/
|
||||
static DPrimitive_gco_2_gco_gco * make_subtract_pm(obj<AAllocator> mm);
|
||||
static DPrimitive_gco_2_gco_gco * make_subtract_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
|
||||
/** polymorphic (in both arguments) compare (==) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpeq_pm(obj<AAllocator> mm);
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpeq_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
/** polymorphic (in both arguments) compare (!=) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpne_pm(obj<AAllocator> mm);
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpne_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
/** polymorphic (in both arguments) compare (<) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmplt_pm(obj<AAllocator> mm);
|
||||
static DPrimitive_gco_2_gco_gco * make_cmplt_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
/** polymorphic (in both arguments) compare (<=) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmple_pm(obj<AAllocator> mm);
|
||||
static DPrimitive_gco_2_gco_gco * make_cmple_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
/** polymorphic (in both arguments) compare (>) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpgt_pm(obj<AAllocator> mm);
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpgt_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
/** polymorphic (in both arguments) compare (>=) **/
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpge_pm(obj<AAllocator> mm);
|
||||
static DPrimitive_gco_2_gco_gco * make_cmpge_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -34,65 +34,143 @@ namespace xo {
|
|||
}
|
||||
|
||||
DPrimitive_gco_2_gco_gco *
|
||||
NumericPrimitives::make_divide_pm(obj<AAllocator> mm)
|
||||
NumericPrimitives::make_divide_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl)
|
||||
{
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_div",
|
||||
(void)stbl;
|
||||
|
||||
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, "_div", pm_ty,
|
||||
&NumericDispatch::divide);
|
||||
}
|
||||
|
||||
DPrimitive_gco_2_gco_gco *
|
||||
NumericPrimitives::make_add_pm(obj<AAllocator> mm)
|
||||
NumericPrimitives::make_add_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl)
|
||||
{
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_add",
|
||||
(void)stbl;
|
||||
|
||||
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, "_add", pm_ty,
|
||||
&NumericDispatch::add);
|
||||
}
|
||||
|
||||
DPrimitive_gco_2_gco_gco *
|
||||
NumericPrimitives::make_subtract_pm(obj<AAllocator> mm)
|
||||
NumericPrimitives::make_subtract_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl)
|
||||
{
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_sub",
|
||||
(void)stbl;
|
||||
|
||||
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, "_sub", pm_ty,
|
||||
&NumericDispatch::subtract);
|
||||
}
|
||||
|
||||
DPrimitive_gco_2_gco_gco *
|
||||
NumericPrimitives::make_cmpeq_pm(obj<AAllocator> mm)
|
||||
NumericPrimitives::make_cmpeq_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl)
|
||||
{
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpeq",
|
||||
(void)stbl;
|
||||
|
||||
auto booleic_ty = DAtomicType::make(mm, Metatype::t_booleic());
|
||||
auto numeric_ty = DAtomicType::make(mm, Metatype::t_numeric());
|
||||
// #op==: numeric x numeric -> booleic
|
||||
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,
|
||||
&NumericDispatch::cmp_equal);
|
||||
}
|
||||
|
||||
DPrimitive_gco_2_gco_gco *
|
||||
NumericPrimitives::make_cmpne_pm(obj<AAllocator> mm)
|
||||
NumericPrimitives::make_cmpne_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl)
|
||||
{
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpne",
|
||||
(void)stbl;
|
||||
|
||||
auto booleic_ty = DAtomicType::make(mm, Metatype::t_booleic());
|
||||
auto numeric_ty = DAtomicType::make(mm, Metatype::t_numeric());
|
||||
// #op!=: numeric x numeric -> booleic
|
||||
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,
|
||||
&NumericDispatch::cmp_notequal);
|
||||
}
|
||||
|
||||
DPrimitive_gco_2_gco_gco *
|
||||
NumericPrimitives::make_cmplt_pm(obj<AAllocator> mm)
|
||||
NumericPrimitives::make_cmplt_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl)
|
||||
{
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmplt",
|
||||
(void)stbl;
|
||||
|
||||
auto booleic_ty = DAtomicType::make(mm, Metatype::t_booleic());
|
||||
auto numeric_ty = DAtomicType::make(mm, Metatype::t_numeric());
|
||||
// #op!=: numeric x numeric -> booleic
|
||||
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,
|
||||
&NumericDispatch::cmp_less);
|
||||
}
|
||||
|
||||
DPrimitive_gco_2_gco_gco *
|
||||
NumericPrimitives::make_cmple_pm(obj<AAllocator> mm)
|
||||
NumericPrimitives::make_cmple_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl)
|
||||
{
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmple",
|
||||
(void)stbl;
|
||||
|
||||
auto booleic_ty = DAtomicType::make(mm, Metatype::t_booleic());
|
||||
auto numeric_ty = DAtomicType::make(mm, Metatype::t_numeric());
|
||||
// #op!=: numeric x numeric -> booleic
|
||||
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,
|
||||
&NumericDispatch::cmp_lessequal);
|
||||
}
|
||||
|
||||
DPrimitive_gco_2_gco_gco *
|
||||
NumericPrimitives::make_cmpgt_pm(obj<AAllocator> mm)
|
||||
NumericPrimitives::make_cmpgt_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl)
|
||||
{
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpgt",
|
||||
(void)stbl;
|
||||
|
||||
auto booleic_ty = DAtomicType::make(mm, Metatype::t_booleic());
|
||||
auto numeric_ty = DAtomicType::make(mm, Metatype::t_numeric());
|
||||
// #op!=: numeric x numeric -> booleic
|
||||
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,
|
||||
&NumericDispatch::cmp_greater);
|
||||
}
|
||||
|
||||
DPrimitive_gco_2_gco_gco *
|
||||
NumericPrimitives::make_cmpge_pm(obj<AAllocator> mm)
|
||||
NumericPrimitives::make_cmpge_pm(obj<AAllocator> mm,
|
||||
StringTable * stbl)
|
||||
{
|
||||
return DPrimitive_gco_2_gco_gco::_make(mm, "_cmpge",
|
||||
(void)stbl;
|
||||
|
||||
auto booleic_ty = DAtomicType::make(mm, Metatype::t_booleic());
|
||||
auto numeric_ty = DAtomicType::make(mm, Metatype::t_numeric());
|
||||
// #op!=: numeric x numeric -> booleic
|
||||
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,
|
||||
&NumericDispatch::cmp_greatequal);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ namespace xo {
|
|||
}
|
||||
}
|
||||
|
||||
#ifdef OBSOLETE
|
||||
bool install_aux(InstallSink sink,
|
||||
obj<AAllocator> mm,
|
||||
std::string_view name,
|
||||
|
|
@ -46,6 +47,7 @@ namespace xo {
|
|||
return true;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -62,30 +64,32 @@ namespace xo {
|
|||
NumericPrimitives::make_multiply_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_divide_pm(mm),
|
||||
NumericPrimitives::make_divide_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_add_pm(mm),
|
||||
NumericPrimitives::make_add_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_subtract_pm(mm),
|
||||
NumericPrimitives::make_subtract_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_cmpeq_pm(mm),
|
||||
NumericPrimitives::make_cmpeq_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_cmpne_pm(mm),
|
||||
NumericPrimitives::make_cmpne_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_cmplt_pm(mm),
|
||||
NumericPrimitives::make_cmplt_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_cmple_pm(mm),
|
||||
NumericPrimitives::make_cmple_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink, mm, "_cmpgt", &NumericDispatch::cmp_greater,
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_cmpgt_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
ok = ok & install_aux(sink, mm, "_cmpge", &NumericDispatch::cmp_greatequal,
|
||||
ok = ok & install_aux(sink,
|
||||
NumericPrimitives::make_cmpge_pm(mm, stbl),
|
||||
flags & InstallFlags::f_essential);
|
||||
|
||||
return ok;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue