7 class ExpPrim
: public xtended
12 ExpPrim() : xtended("exp") {}
14 virtual unsigned int arity () { return 1; }
16 virtual bool needCache () { return true; }
18 virtual Type
infereSigType (const vector
<Type
>& args
)
20 assert (args
.size() == arity());
21 return floatCast(args
[0]);
24 virtual void sigVisit (Tree sig
, sigvisitor
* visitor
) {}
26 virtual int infereSigOrder (const vector
<int>& args
) {
27 assert (args
.size() == arity());
32 virtual Tree
computeSigOutput (const vector
<Tree
>& args
) {
34 assert (args
.size() == arity());
35 if (isNum(args
[0],n
)) {
36 return tree(exp(double(n
)));
38 return tree(symbol(), args
[0]);
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("exp$1($0)", args
[0], 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("e^{$0}", args
[0]);
61 xtended
* gExpPrim
= new ExpPrim();