xo-numeric: attach type to numeric primitives
This commit is contained in:
parent
940cfb963a
commit
4039926d33
3 changed files with 127 additions and 37 deletions
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue