X-Git-Url: https://scm.cri.ensmp.fr/git/Faustine.git/blobdiff_plain/c7f552fd8888da2f0d8cfb228fe0f28d3df3a12c..b4b6f2ea75b9f0f3ca918f5b84016610bf7a4d4f:/interpretor/faust-0.9.47mr3/compiler/extended/absprim.cpp diff --git a/interpretor/faust-0.9.47mr3/compiler/extended/absprim.cpp b/interpretor/faust-0.9.47mr3/compiler/extended/absprim.cpp deleted file mode 100644 index 2b54eea..0000000 --- a/interpretor/faust-0.9.47mr3/compiler/extended/absprim.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "xtended.hh" -#include "Text.hh" -#include -#include "sigtyperules.hh" - -#include "floats.hh" - -class AbsPrim : public xtended -{ - - public: - - AbsPrim() : xtended("abs") {} - - virtual unsigned int arity () { return 1; } - - virtual bool needCache () { return true; } - - virtual Type infereSigType (const vector& types) - { - assert (types.size() == arity()); - Type t = types[0]; - return castInterval(t, abs(t->getInterval())); - return t; - } - - virtual void sigVisit (Tree sig, sigvisitor* visitor) {} - - virtual int infereSigOrder (const vector& args) - { - assert (args.size() == arity()); - return args[0]; - } - - - virtual Tree computeSigOutput (const vector& args) - { - double f; int i; - - assert (args.size() == arity()); - - if (isDouble(args[0]->node(),&f)) { - return tree(fabs(f)); - - } else if (isInt(args[0]->node(),&i)) { - return tree(abs(i)); - - } else { - return tree(symbol(), args[0]); - } - } - - virtual string generateCode (Klass* klass, const vector& args, const vector& types) - { - assert (args.size() == arity()); - assert (types.size() == arity()); - - Type t = infereSigType(types); - if (t->nature() == kReal) { - return subst("fabs$1($0)", args[0], isuffix()); - } else { - return subst("abs($0)", args[0]); - } - } - - virtual string generateLateq (Lateq* lateq, const vector& args, const vector& types) - { - assert (args.size() == arity()); - assert (types.size() == arity()); - - Type t = infereSigType(types); - return subst("\\left\\lvert{$0}\\right\\rvert", args[0]); - } -}; - - -xtended* gAbsPrim = new AbsPrim(); - -