X-Git-Url: https://scm.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/1059e1cc0c2ecfa237406949aa26155b6a5b9154..66f23d4fabf89ad09adbd4dfc15ac6b5b2b7da83:/interpreter/preprocessor/faust-0.9.47mr3/compiler/extended/remainderprim.cpp diff --git a/interpreter/preprocessor/faust-0.9.47mr3/compiler/extended/remainderprim.cpp b/interpreter/preprocessor/faust-0.9.47mr3/compiler/extended/remainderprim.cpp new file mode 100644 index 0000000..4b5b20d --- /dev/null +++ b/interpreter/preprocessor/faust-0.9.47mr3/compiler/extended/remainderprim.cpp @@ -0,0 +1,64 @@ +#include "xtended.hh" +#include "compatibility.hh" +#include "Text.hh" +#include + +#include "floats.hh" + +class RemainderPrim : public xtended +{ + + public: + + RemainderPrim() : xtended("remainder") {} + + virtual unsigned int arity () { return 2; } + + virtual bool needCache () { return true; } + + virtual Type infereSigType (const vector& args) + { + assert (args.size() == arity()); + return castInterval(floatCast(args[0]|args[1]), interval()); // temporary rule !!! + } + + virtual void sigVisit (Tree sig, sigvisitor* visitor) {} + + virtual int infereSigOrder (const vector& args) { + assert (args.size() == arity()); + return max(args[0], args[1]); + } + + + virtual Tree computeSigOutput (const vector& args) { + num n,m; + assert (args.size() == arity()); + if (isNum(args[0],n) & isNum(args[1],m)) { + return tree(remainder(double(n), double(m))); + } else { + return tree(symbol(), args[0], args[1]); + } + } + + virtual string generateCode (Klass* klass, const vector& args, const vector& types) + { + assert (args.size() == arity()); + assert (types.size() == arity()); + + return subst("remainder$2($0,$1)", args[0], args[1], isuffix()); + } + + virtual string generateLateq (Lateq* lateq, const vector& args, const vector& types) + { + assert (args.size() == arity()); + assert (types.size() == arity()); + + return subst("$0\\pmod{$1}", args[0], args[1]); // Same as fmodprim.cpp. + } + +}; + + +xtended* gRemainderPrim = new RemainderPrim(); + +