7 class FmodPrim
: public xtended
12 FmodPrim() : xtended("fmodf") {}
14 virtual unsigned int arity () { return 2; }
16 virtual bool needCache () { return true; }
18 virtual Type
infereSigType (const vector
<Type
>& args
)
20 assert (args
.size() == arity());
21 return floatCast(args
[0]|args
[1]);
24 virtual void sigVisit (Tree sig
, sigvisitor
* visitor
) {}
26 virtual int infereSigOrder (const vector
<int>& args
) {
27 assert (args
.size() == arity());
28 return max(args
[0], args
[1]);
32 virtual Tree
computeSigOutput (const vector
<Tree
>& args
) {
34 assert (args
.size() == arity());
35 if (isNum(args
[0],n
) & isNum(args
[1],m
)) {
36 return tree(fmod(double(n
), double(m
)));
38 return tree(symbol(), args
[0], args
[1]);
42 virtual string
generateCode (Klass
* klass
, const vector
<string
>& args
, const vector
<Type
>& types
)
44 assert (args
.size() == arity());
45 assert (types
.size() == arity());
47 return subst("fmod$2($0,$1)", args
[0], args
[1], isuffix());
50 virtual string
generateLateq (Lateq
* lateq
, const vector
<string
>& args
, const vector
<Type
>& types
)
52 assert (args
.size() == arity());
53 assert (types
.size() == arity());
55 return subst("$0\\pmod{$1}", args
[0], args
[1]);
61 xtended
* gFmodPrim
= new FmodPrim();