FAUST compiler  0.9.9.6b8
Public Member Functions | List of all members
PowPrim Class Reference
Inheritance diagram for PowPrim:
Inheritance graph
[legend]
Collaboration diagram for PowPrim:
Collaboration graph
[legend]

Public Member Functions

 PowPrim ()
 
virtual unsigned int arity ()
 
virtual bool needCache ()
 
virtual Type infereSigType (const vector< Type > &args)
 
virtual void sigVisit (Tree sig, sigvisitor *visitor)
 
virtual int infereSigOrder (const vector< int > &args)
 
virtual Tree computeSigOutput (const vector< Tree > &args)
 
virtual string generateCode (Klass *klass, const vector< string > &args, const vector< Type > &types)
 
virtual string generateLateq (Lateq *lateq, const vector< string > &args, const vector< Type > &types)
 
virtual bool isSpecialInfix ()
 generaly false, but true for binary op # such that #(x) == _::x More...
 
- Public Member Functions inherited from xtended
 xtended (const char *name)
 
virtual ~xtended ()
 
Sym symbol ()
 
const char * name ()
 
Tree box ()
 

Detailed Description

Definition at line 7 of file powprim.cpp.

Constructor & Destructor Documentation

PowPrim::PowPrim ( )
inline

Definition at line 12 of file powprim.cpp.

12 : xtended("pow") {}
xtended(const char *name)
Definition: xtended.hh:18

Member Function Documentation

virtual unsigned int PowPrim::arity ( )
inlinevirtual

Implements xtended.

Definition at line 14 of file powprim.cpp.

Referenced by computeSigOutput(), generateCode(), generateLateq(), infereSigOrder(), and infereSigType().

14 { return 2; }

Here is the caller graph for this function:

virtual Tree PowPrim::computeSigOutput ( const vector< Tree > &  args)
inlinevirtual

Implements xtended.

Definition at line 38 of file powprim.cpp.

References arity(), isNum(), pow(), xtended::symbol(), and tree().

38  {
39  num n,m;
40  assert (args.size() == arity());
41  if (isNum(args[0],n) & isNum(args[1],m)) {
42  return tree(pow(double(n), double(m)));
43  } else {
44  return tree(symbol(), args[0], args[1]);
45  }
46  }
Definition: num.hh:58
interval pow(const interval &x, const interval &y)
Definition: interval.hh:213
bool isNum(Tree a)
Definition: signals.hh:187
Sym symbol()
Definition: xtended.hh:24
Tree tree(const Node &n)
Definition: tree.hh:186
virtual unsigned int arity()
Definition: powprim.cpp:14

Here is the call graph for this function:

virtual string PowPrim::generateCode ( Klass klass,
const vector< string > &  args,
const vector< Type > &  types 
)
inlinevirtual

Implements xtended.

Definition at line 48 of file powprim.cpp.

References arity(), isuffix(), kComp, kInt, kKonst, Klass::rememberNeedPowerDef(), and subst().

49  {
50  assert (args.size() == arity());
51  assert (types.size() == arity());
52 
53  if ((types[1]->nature() == kInt) && (types[1]->variability() == kKonst) && (types[1]->computability() == kComp)) {
54  klass->rememberNeedPowerDef();
55  return subst("faustpower<$1>($0)", args[0], args[1]);
56  } else {
57  return subst("pow$2($0,$1)", args[0], args[1], isuffix());
58  }
59  }
Definition: sigtype.hh:54
Definition: sigtype.hh:57
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
void rememberNeedPowerDef()
Definition: klass.hh:141
virtual unsigned int arity()
Definition: powprim.cpp:14
const char * isuffix()
suffix for math functions
Definition: floats.cpp:43

Here is the call graph for this function:

virtual string PowPrim::generateLateq ( Lateq lateq,
const vector< string > &  args,
const vector< Type > &  types 
)
inlinevirtual

Implements xtended.

Definition at line 61 of file powprim.cpp.

References arity(), and subst().

62  {
63  assert (args.size() == arity());
64  assert (types.size() == arity());
65 
66  return subst("{$0}^{$1}", args[0], args[1]);
67  }
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
virtual unsigned int arity()
Definition: powprim.cpp:14

Here is the call graph for this function:

virtual int PowPrim::infereSigOrder ( const vector< int > &  args)
inlinevirtual

Implements xtended.

Definition at line 32 of file powprim.cpp.

References arity(), and max().

32  {
33  assert (args.size() == arity());
34  return max(args[0], args[1]);
35  }
double max(double x, double y)
Definition: interval.hh:60
virtual unsigned int arity()
Definition: powprim.cpp:14

Here is the call graph for this function:

virtual Type PowPrim::infereSigType ( const vector< Type > &  args)
inlinevirtual

Implements xtended.

Definition at line 18 of file powprim.cpp.

References arity(), castInterval(), and pow().

19  {
20  assert (args.size() == arity());
21  //return castInterval(floatCast(args[0]|args[1]), interval()); // temporary !!!
22  //return castInterval(args[0]|args[1], interval()); // temporary !!!
23 
24  interval i = args[0]->getInterval();
25  interval j = args[1]->getInterval();
26  return castInterval(args[0]|args[1], pow(i,j));
27 
28  }
interval pow(const interval &x, const interval &y)
Definition: interval.hh:213
virtual unsigned int arity()
Definition: powprim.cpp:14
Type castInterval(Type t, const interval &i)
Definition: sigtype.hh:278

Here is the call graph for this function:

virtual bool PowPrim::isSpecialInfix ( )
inlinevirtual

generaly false, but true for binary op # such that #(x) == _::x

Reimplemented from xtended.

Definition at line 71 of file powprim.cpp.

71 { return true; }
virtual bool PowPrim::needCache ( )
inlinevirtual

Implements xtended.

Definition at line 16 of file powprim.cpp.

16 { return true; }
virtual void PowPrim::sigVisit ( Tree  sig,
sigvisitor visitor 
)
inlinevirtual

Definition at line 30 of file powprim.cpp.

30 {}

The documentation for this class was generated from the following file: