4b5b20d9e37edadcfa8220f517d140c6a55776a3
2 #include "compatibility.hh"
8 class RemainderPrim
: public xtended
13 RemainderPrim() : xtended("remainder") {}
15 virtual unsigned int arity () { return 2; }
17 virtual bool needCache () { return true; }
19 virtual Type
infereSigType (const vector
<Type
>& args
)
21 assert (args
.size() == arity());
22 return castInterval(floatCast(args
[0]|args
[1]), interval()); // temporary rule !!!
25 virtual void sigVisit (Tree sig
, sigvisitor
* visitor
) {}
27 virtual int infereSigOrder (const vector
<int>& args
) {
28 assert (args
.size() == arity());
29 return max(args
[0], args
[1]);
33 virtual Tree
computeSigOutput (const vector
<Tree
>& args
) {
35 assert (args
.size() == arity());
36 if (isNum(args
[0],n
) & isNum(args
[1],m
)) {
37 return tree(remainder(double(n
), double(m
)));
39 return tree(symbol(), args
[0], args
[1]);
43 virtual string
generateCode (Klass
* klass
, const vector
<string
>& args
, const vector
<Type
>& types
)
45 assert (args
.size() == arity());
46 assert (types
.size() == arity());
48 return subst("remainder$2($0,$1)", args
[0], args
[1], isuffix());
51 virtual string
generateLateq (Lateq
* lateq
, const vector
<string
>& args
, const vector
<Type
>& types
)
53 assert (args
.size() == arity());
54 assert (types
.size() == arity());
56 return subst("$0\\pmod{$1}", args
[0], args
[1]); // Same as fmodprim.cpp.
62 xtended
* gRemainderPrim
= new RemainderPrim();