xo-interpreter2 stack: support op!= + trial numeric refactor
This commit is contained in:
parent
243ad12869
commit
77c5f625ff
12 changed files with 161 additions and 14 deletions
|
|
@ -30,6 +30,8 @@ namespace xo {
|
|||
|
||||
static obj<AGCObject> cmp_equal(obj<ARuntimeContext> rcx,
|
||||
DFloat * x, DInteger * y);
|
||||
static obj<AGCObject> cmp_notequal(obj<ARuntimeContext> rcx,
|
||||
DFloat * x, DInteger * y);
|
||||
};
|
||||
|
||||
class IntegerFloatOps {
|
||||
|
|
@ -48,6 +50,8 @@ namespace xo {
|
|||
|
||||
static obj<AGCObject> cmp_equal(obj<ARuntimeContext> rcx,
|
||||
DInteger * x, DFloat * y);
|
||||
static obj<AGCObject> cmp_notequal(obj<ARuntimeContext> rcx,
|
||||
DInteger * x, DFloat * y);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,8 @@ namespace xo {
|
|||
|
||||
static obj<AGCObject> cmp_equal(obj<ARuntimeContext> rcx,
|
||||
DFloat * x, DFloat * y);
|
||||
static obj<AGCObject> cmp_notequal(obj<ARuntimeContext> rcx,
|
||||
DFloat * x, DFloat * y);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,6 +31,8 @@ namespace xo {
|
|||
|
||||
static obj<AGCObject> cmp_equal(obj<ARuntimeContext> rcx,
|
||||
DInteger * x, DInteger * y);
|
||||
static obj<AGCObject> cmp_notequal(obj<ARuntimeContext> rcx,
|
||||
DInteger * x, DInteger * y);
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,7 @@ namespace xo {
|
|||
using typeseq = xo::reflect::typeseq;
|
||||
using KeyType = std::pair<typeseq, typeseq>;
|
||||
using MappedType = AnonymizedNumericOps;
|
||||
using BinaryOp = AnonymizedNumericOps::BinaryOp;
|
||||
|
||||
/** hash function for key_type **/
|
||||
struct KeyHash {
|
||||
|
|
@ -58,6 +59,16 @@ namespace xo {
|
|||
return s_instance;
|
||||
}
|
||||
|
||||
/** multi-dispatch driver.
|
||||
* Invoke @p member_ptr in AnonymizedNumericOps
|
||||
**/
|
||||
static obj<AGCObject> dispatch(obj<ARuntimeContext> rcx,
|
||||
const char * caller,
|
||||
const char * error_headline,
|
||||
BinaryOp AnonymizedNumericOps::* member_ptr,
|
||||
obj<AGCObject> x,
|
||||
obj<AGCObject> y);
|
||||
|
||||
/** multiply w/ runtime polymorphism (double-dispatch)
|
||||
**/
|
||||
static obj<AGCObject> multiply(obj<ARuntimeContext> rcx,
|
||||
|
|
@ -87,6 +98,11 @@ namespace xo {
|
|||
obj<AGCObject> x,
|
||||
obj<AGCObject> y);
|
||||
|
||||
/** compare two numeric values for inequality **/
|
||||
static obj<AGCObject> cmp_notequal(obj<ARuntimeContext> rcx,
|
||||
obj<AGCObject> x,
|
||||
obj<AGCObject> y);
|
||||
|
||||
/** report memory use for owned arenas to @p visitor **/
|
||||
void visit_pools(const MemorySizeVisitor & visitor);
|
||||
|
||||
|
|
@ -100,7 +116,8 @@ namespace xo {
|
|||
typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl div_fn,
|
||||
typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl add_fn,
|
||||
typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl sub_fn,
|
||||
typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl cmpeq_fn) {
|
||||
typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl cmpeq_fn,
|
||||
typename NumericOps<DRepr1, DRepr2>::BinaryOp_Impl cmpne_fn) {
|
||||
|
||||
KeyType key(typeseq::id<DRepr1>().seqno(),
|
||||
typeseq::id<DRepr2>().seqno());
|
||||
|
|
@ -111,7 +128,8 @@ namespace xo {
|
|||
div_fn,
|
||||
add_fn,
|
||||
sub_fn,
|
||||
cmpeq_fn);
|
||||
cmpeq_fn,
|
||||
cmpne_fn);
|
||||
}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -26,9 +26,10 @@ namespace xo {
|
|||
BinaryOp divide,
|
||||
BinaryOp add,
|
||||
BinaryOp subtract,
|
||||
BinaryOp cmpeq)
|
||||
BinaryOp cmpeq,
|
||||
BinaryOp cmpne)
|
||||
: multiply_{multiply}, divide_{divide}, add_{add}, subtract_{subtract},
|
||||
cmpeq_{cmpeq} {}
|
||||
cmpeq_{cmpeq}, cmpne_{cmpne} {}
|
||||
|
||||
BinaryOp multiply_ = nullptr;
|
||||
BinaryOp divide_ = nullptr;
|
||||
|
|
@ -37,6 +38,8 @@ namespace xo {
|
|||
|
||||
/** compare numerics for equality **/
|
||||
BinaryOp cmpeq_ = nullptr;
|
||||
/** compare numerics for inequality **/
|
||||
BinaryOp cmpne_ = nullptr;
|
||||
};
|
||||
|
||||
template <typename DRepr1, typename DRepr2>
|
||||
|
|
@ -52,12 +55,14 @@ namespace xo {
|
|||
BinaryOp_Impl divide,
|
||||
BinaryOp_Impl add,
|
||||
BinaryOp_Impl subtract,
|
||||
BinaryOp_Impl cmpeq) {
|
||||
BinaryOp_Impl cmpeq,
|
||||
BinaryOp_Impl cmpne) {
|
||||
return AnonymizedNumericOps(reinterpret_cast<BinaryOp_Anon>(multiply),
|
||||
reinterpret_cast<BinaryOp_Anon>(divide),
|
||||
reinterpret_cast<BinaryOp_Anon>(add),
|
||||
reinterpret_cast<BinaryOp_Anon>(subtract),
|
||||
reinterpret_cast<BinaryOp_Anon>(cmpeq));
|
||||
reinterpret_cast<BinaryOp_Anon>(cmpeq),
|
||||
reinterpret_cast<BinaryOp_Anon>(cmpne));
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@ namespace xo {
|
|||
|
||||
/** polymorphic (in both arguments) compare (==) **/
|
||||
static DPrimitive_gco_2_gco_gco s_cmpeq_gco_gco_pm;
|
||||
/** polymorphic (in both arguments) compare (!=) **/
|
||||
static DPrimitive_gco_2_gco_gco s_cmpne_gco_gco_pm;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue