xo-reader2: + op> support

This commit is contained in:
Roland Conybeare 2026-03-13 00:15:29 -05:00
commit c500a98722
11 changed files with 78 additions and 7 deletions

View file

@ -36,6 +36,8 @@ namespace xo {
DFloat * x, DInteger * y); DFloat * x, DInteger * y);
static obj<AGCObject> cmp_lessequal(obj<ARuntimeContext> rcx, static obj<AGCObject> cmp_lessequal(obj<ARuntimeContext> rcx,
DFloat * x, DInteger * y); DFloat * x, DInteger * y);
static obj<AGCObject> cmp_greater(obj<ARuntimeContext> rcx,
DFloat * x, DInteger * y);
static obj<AGCObject> cmp_greatequal(obj<ARuntimeContext> rcx, static obj<AGCObject> cmp_greatequal(obj<ARuntimeContext> rcx,
DFloat * x, DInteger * y); DFloat * x, DInteger * y);
}; };
@ -62,6 +64,8 @@ namespace xo {
DInteger * x, DFloat * y); DInteger * x, DFloat * y);
static obj<AGCObject> cmp_lessequal(obj<ARuntimeContext> rcx, static obj<AGCObject> cmp_lessequal(obj<ARuntimeContext> rcx,
DInteger * x, DFloat * y); DInteger * x, DFloat * y);
static obj<AGCObject> cmp_greater(obj<ARuntimeContext> rcx,
DInteger * x, DFloat * y);
static obj<AGCObject> cmp_greatequal(obj<ARuntimeContext> rcx, static obj<AGCObject> cmp_greatequal(obj<ARuntimeContext> rcx,
DInteger * x, DFloat * y); DInteger * x, DFloat * y);
}; };

View file

@ -35,6 +35,8 @@ namespace xo {
DFloat * x, DFloat * y); DFloat * x, DFloat * y);
static obj<AGCObject> cmp_lessequal(obj<ARuntimeContext> rcx, static obj<AGCObject> cmp_lessequal(obj<ARuntimeContext> rcx,
DFloat * x, DFloat * y); DFloat * x, DFloat * y);
static obj<AGCObject> cmp_greater(obj<ARuntimeContext> rcx,
DFloat * x, DFloat * y);
static obj<AGCObject> cmp_greatequal(obj<ARuntimeContext> rcx, static obj<AGCObject> cmp_greatequal(obj<ARuntimeContext> rcx,
DFloat * x, DFloat * y); DFloat * x, DFloat * y);
}; };

View file

@ -37,6 +37,8 @@ namespace xo {
DInteger * x, DInteger * y); DInteger * x, DInteger * y);
static obj<AGCObject> cmp_lessequal(obj<ARuntimeContext> rcx, static obj<AGCObject> cmp_lessequal(obj<ARuntimeContext> rcx,
DInteger * x, DInteger * y); DInteger * x, DInteger * y);
static obj<AGCObject> cmp_greater(obj<ARuntimeContext> rcx,
DInteger * x, DInteger * y);
static obj<AGCObject> cmp_greatequal(obj<ARuntimeContext> rcx, static obj<AGCObject> cmp_greatequal(obj<ARuntimeContext> rcx,
DInteger * x, DInteger * y); DInteger * x, DInteger * y);

View file

@ -93,27 +93,32 @@ namespace xo {
obj<AGCObject> x, obj<AGCObject> x,
obj<AGCObject> y); obj<AGCObject> y);
/** compare two numeric values for equality **/ /** compare two numeric values for equality (==) **/
static obj<AGCObject> cmp_equal(obj<ARuntimeContext> rcx, static obj<AGCObject> cmp_equal(obj<ARuntimeContext> rcx,
obj<AGCObject> x, obj<AGCObject> x,
obj<AGCObject> y); obj<AGCObject> y);
/** compare two numeric values for inequality **/ /** compare two numeric values for inequality (!~=) **/
static obj<AGCObject> cmp_notequal(obj<ARuntimeContext> rcx, static obj<AGCObject> cmp_notequal(obj<ARuntimeContext> rcx,
obj<AGCObject> x, obj<AGCObject> x,
obj<AGCObject> y); obj<AGCObject> y);
/** compare two numeric values for less **/ /** compare two numeric values for less (<) **/
static obj<AGCObject> cmp_less(obj<ARuntimeContext> rcx, static obj<AGCObject> cmp_less(obj<ARuntimeContext> rcx,
obj<AGCObject> x, obj<AGCObject> x,
obj<AGCObject> y); obj<AGCObject> y);
/** compare two numeric values for less-or-equal **/ /** compare two numeric values for less-or-equal (<=) **/
static obj<AGCObject> cmp_lessequal(obj<ARuntimeContext> rcx, static obj<AGCObject> cmp_lessequal(obj<ARuntimeContext> rcx,
obj<AGCObject> x, obj<AGCObject> x,
obj<AGCObject> y); obj<AGCObject> y);
/** compare two numeric values for greater-or-equal **/ /** compare two numeric values for greater (>) **/
static obj<AGCObject> cmp_greater(obj<ARuntimeContext> rcx,
obj<AGCObject> x,
obj<AGCObject> y);
/** compare two numeric values for greater-or-equal (>=) **/
static obj<AGCObject> cmp_greatequal(obj<ARuntimeContext> rcx, static obj<AGCObject> cmp_greatequal(obj<ARuntimeContext> rcx,
obj<AGCObject> x, obj<AGCObject> x,
obj<AGCObject> y); obj<AGCObject> y);
@ -135,6 +140,7 @@ namespace xo {
typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl cmpne_fn, typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl cmpne_fn,
typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl cmplt_fn, typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl cmplt_fn,
typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl cmple_fn, typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl cmple_fn,
typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl cmpgt_fn,
typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl cmpge_fn) { typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl cmpge_fn) {
KeyType key(typeseq::id<DRepr1>().seqno(), KeyType key(typeseq::id<DRepr1>().seqno(),
@ -150,6 +156,7 @@ namespace xo {
cmpne_fn, cmpne_fn,
cmplt_fn, cmplt_fn,
cmple_fn, cmple_fn,
cmpgt_fn,
cmpge_fn); cmpge_fn);
} }

View file

@ -30,9 +30,12 @@ namespace xo {
BinaryOp cmpne, BinaryOp cmpne,
BinaryOp cmplt, BinaryOp cmplt,
BinaryOp cmple, BinaryOp cmple,
BinaryOp cmpgt,
BinaryOp cmpge) BinaryOp cmpge)
: multiply_{multiply}, divide_{divide}, add_{add}, subtract_{subtract}, : multiply_{multiply}, divide_{divide}, add_{add}, subtract_{subtract},
cmpeq_{cmpeq}, cmpne_{cmpne}, cmplt_{cmplt}, cmple_{cmple}, cmpge_{cmpge} {} cmpeq_{cmpeq}, cmpne_{cmpne},
cmplt_{cmplt}, cmple_{cmple},
cmpgt_{cmpgt}, cmpge_{cmpge} {}
BinaryOp multiply_ = nullptr; BinaryOp multiply_ = nullptr;
BinaryOp divide_ = nullptr; BinaryOp divide_ = nullptr;
@ -47,6 +50,8 @@ namespace xo {
BinaryOp cmplt_ = nullptr; BinaryOp cmplt_ = nullptr;
/** compare numerics (<=) **/ /** compare numerics (<=) **/
BinaryOp cmple_ = nullptr; BinaryOp cmple_ = nullptr;
/** compare numerics (>) **/
BinaryOp cmpgt_ = nullptr;
/** compare numerics (>=) **/ /** compare numerics (>=) **/
BinaryOp cmpge_ = nullptr; BinaryOp cmpge_ = nullptr;
}; };
@ -68,6 +73,7 @@ namespace xo {
BinaryOp_Impl cmpne, BinaryOp_Impl cmpne,
BinaryOp_Impl cmplt, BinaryOp_Impl cmplt,
BinaryOp_Impl cmple, BinaryOp_Impl cmple,
BinaryOp_Impl cmpgt,
BinaryOp_Impl cmpge) { BinaryOp_Impl cmpge) {
return AnonymizedNumericOps(reinterpret_cast<BinaryOp_Anon>(multiply), return AnonymizedNumericOps(reinterpret_cast<BinaryOp_Anon>(multiply),
reinterpret_cast<BinaryOp_Anon>(divide), reinterpret_cast<BinaryOp_Anon>(divide),
@ -77,6 +83,7 @@ namespace xo {
reinterpret_cast<BinaryOp_Anon>(cmpne), reinterpret_cast<BinaryOp_Anon>(cmpne),
reinterpret_cast<BinaryOp_Anon>(cmplt), reinterpret_cast<BinaryOp_Anon>(cmplt),
reinterpret_cast<BinaryOp_Anon>(cmple), reinterpret_cast<BinaryOp_Anon>(cmple),
reinterpret_cast<BinaryOp_Anon>(cmpgt),
reinterpret_cast<BinaryOp_Anon>(cmpge)); reinterpret_cast<BinaryOp_Anon>(cmpge));
} }
}; };

View file

@ -74,6 +74,14 @@ namespace xo {
x->value() <= DFloat::value_type(y->value())); x->value() <= DFloat::value_type(y->value()));
} }
obj<AGCObject>
FloatIntegerOps::cmp_greater(obj<ARuntimeContext> rcx,
DFloat * x, DInteger * y)
{
return DBoolean::box<AGCObject>(rcx.allocator(),
x->value() > DFloat::value_type(y->value()));
}
obj<AGCObject> obj<AGCObject>
FloatIntegerOps::cmp_greatequal(obj<ARuntimeContext> rcx, FloatIntegerOps::cmp_greatequal(obj<ARuntimeContext> rcx,
DFloat * x, DInteger * y) DFloat * x, DInteger * y)
@ -144,6 +152,14 @@ namespace xo {
DFloat::value_type(x->value()) <= y->value()); DFloat::value_type(x->value()) <= y->value());
} }
obj<AGCObject>
IntegerFloatOps::cmp_greater(obj<ARuntimeContext> rcx,
DInteger * x, DFloat * y)
{
return DBoolean::box<AGCObject>(rcx.allocator(),
DFloat::value_type(x->value()) > y->value());
}
obj<AGCObject> obj<AGCObject>
IntegerFloatOps::cmp_greatequal(obj<ARuntimeContext> rcx, IntegerFloatOps::cmp_greatequal(obj<ARuntimeContext> rcx,
DInteger * x, DFloat * y) DInteger * x, DFloat * y)

View file

@ -75,6 +75,14 @@ namespace xo {
x->value() <= y->value()); x->value() <= y->value());
} }
obj<AGCObject>
FloatOps::cmp_greater(obj<ARuntimeContext> rcx,
DFloat * x, DFloat * y)
{
return DBoolean::box<AGCObject>(rcx.allocator(),
x->value() > y->value());
}
obj<AGCObject> obj<AGCObject>
FloatOps::cmp_greatequal(obj<ARuntimeContext> rcx, FloatOps::cmp_greatequal(obj<ARuntimeContext> rcx,
DFloat * x, DFloat * y) DFloat * x, DFloat * y)

View file

@ -69,6 +69,13 @@ namespace xo {
return DBoolean::box<AGCObject>(rcx.allocator(), x->value() <= y->value()); return DBoolean::box<AGCObject>(rcx.allocator(), x->value() <= y->value());
} }
obj<AGCObject>
IntegerOps::cmp_greater(obj<ARuntimeContext> rcx,
DInteger * x, DInteger * y)
{
return DBoolean::box<AGCObject>(rcx.allocator(), x->value() > y->value());
}
obj<AGCObject> obj<AGCObject>
IntegerOps::cmp_greatequal(obj<ARuntimeContext> rcx, IntegerOps::cmp_greatequal(obj<ARuntimeContext> rcx,
DInteger * x, DInteger * y) DInteger * x, DInteger * y)

View file

@ -162,13 +162,25 @@ namespace xo {
x, y); x, y);
} }
obj<AGCObject>
NumericDispatch::cmp_greater(obj<ARuntimeContext> rcx,
obj<AGCObject> x,
obj<AGCObject> y)
{
return dispatch(rcx,
"NumericDispatch::cmp_greater",
"incomparable types in x>y",
&AnonymizedNumericOps::cmpgt_,
x, y);
}
obj<AGCObject> obj<AGCObject>
NumericDispatch::cmp_greatequal(obj<ARuntimeContext> rcx, NumericDispatch::cmp_greatequal(obj<ARuntimeContext> rcx,
obj<AGCObject> x, obj<AGCObject> x,
obj<AGCObject> y) obj<AGCObject> y)
{ {
return dispatch(rcx, return dispatch(rcx,
"NumericDispatch::cmp_great", "NumericDispatch::cmp_greatequal",
"incomparable types in x>=y", "incomparable types in x>=y",
&AnonymizedNumericOps::cmpge_, &AnonymizedNumericOps::cmpge_,
x, y); x, y);

View file

@ -43,6 +43,7 @@ namespace xo {
&FloatOps::cmp_notequal, &FloatOps::cmp_notequal,
&FloatOps::cmp_less, &FloatOps::cmp_less,
&FloatOps::cmp_lessequal, &FloatOps::cmp_lessequal,
&FloatOps::cmp_greater,
&FloatOps::cmp_greatequal); &FloatOps::cmp_greatequal);
NumericDispatch::instance().register_impl<DFloat, DInteger> NumericDispatch::instance().register_impl<DFloat, DInteger>
@ -54,6 +55,7 @@ namespace xo {
&FloatIntegerOps::cmp_notequal, &FloatIntegerOps::cmp_notequal,
&FloatIntegerOps::cmp_less, &FloatIntegerOps::cmp_less,
&FloatIntegerOps::cmp_lessequal, &FloatIntegerOps::cmp_lessequal,
&FloatIntegerOps::cmp_greater,
&FloatIntegerOps::cmp_greatequal); &FloatIntegerOps::cmp_greatequal);
NumericDispatch::instance().register_impl<DInteger, DFloat> NumericDispatch::instance().register_impl<DInteger, DFloat>
@ -65,6 +67,7 @@ namespace xo {
&IntegerFloatOps::cmp_notequal, &IntegerFloatOps::cmp_notequal,
&IntegerFloatOps::cmp_less, &IntegerFloatOps::cmp_less,
&IntegerFloatOps::cmp_lessequal, &IntegerFloatOps::cmp_lessequal,
&IntegerFloatOps::cmp_greater,
&IntegerFloatOps::cmp_greatequal); &IntegerFloatOps::cmp_greatequal);
NumericDispatch::instance().register_impl<DInteger, DInteger> NumericDispatch::instance().register_impl<DInteger, DInteger>
@ -76,6 +79,7 @@ namespace xo {
&IntegerOps::cmp_notequal, &IntegerOps::cmp_notequal,
&IntegerOps::cmp_less, &IntegerOps::cmp_less,
&IntegerOps::cmp_lessequal, &IntegerOps::cmp_lessequal,
&IntegerOps::cmp_greater,
&IntegerOps::cmp_greatequal); &IntegerOps::cmp_greatequal);
log && log(xtag("ANumeric.tseq", typeseq::id<ANumeric>())); log && log(xtag("ANumeric.tseq", typeseq::id<ANumeric>()));

View file

@ -74,6 +74,8 @@ namespace xo {
flags & InstallFlags::f_essential); flags & InstallFlags::f_essential);
ok = ok & install_aux(sink, mm, "_cmple", &NumericDispatch::cmp_lessequal, ok = ok & install_aux(sink, mm, "_cmple", &NumericDispatch::cmp_lessequal,
flags & InstallFlags::f_essential); flags & InstallFlags::f_essential);
ok = ok & install_aux(sink, mm, "_cmpgt", &NumericDispatch::cmp_greater,
flags & InstallFlags::f_essential);
ok = ok & install_aux(sink, mm, "_cmpge", &NumericDispatch::cmp_greatequal, ok = ok & install_aux(sink, mm, "_cmpge", &NumericDispatch::cmp_greatequal,
flags & InstallFlags::f_essential); flags & InstallFlags::f_essential);