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

Public Member Functions

 AbsPrim ()
 
virtual unsigned int arity ()
 
virtual bool needCache ()
 
virtual Type infereSigType (const vector< Type > &types)
 
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)
 
- Public Member Functions inherited from xtended
 xtended (const char *name)
 
virtual ~xtended ()
 
Sym symbol ()
 
const char * name ()
 
Tree box ()
 
virtual bool isSpecialInfix ()
 generaly false, but true for binary op # such that #(x) == _::x More...
 

Detailed Description

Definition at line 8 of file absprim.cpp.

Constructor & Destructor Documentation

AbsPrim::AbsPrim ( )
inline

Definition at line 13 of file absprim.cpp.

13 : xtended("abs") {}
xtended(const char *name)
Definition: xtended.hh:18

Member Function Documentation

virtual unsigned int AbsPrim::arity ( )
inlinevirtual

Implements xtended.

Definition at line 15 of file absprim.cpp.

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

15 { return 1; }

Here is the caller graph for this function:

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

Implements xtended.

Definition at line 36 of file absprim.cpp.

References abs(), arity(), isDouble(), isInt(), xtended::symbol(), and tree().

37  {
38  double f; int i;
39 
40  assert (args.size() == arity());
41 
42  if (isDouble(args[0]->node(),&f)) {
43  return tree(fabs(f));
44 
45  } else if (isInt(args[0]->node(),&i)) {
46  return tree(abs(i));
47 
48  } else {
49  return tree(symbol(), args[0]);
50  }
51  }
interval abs(const interval &x)
Definition: interval.hh:226
virtual unsigned int arity()
Definition: absprim.cpp:15
bool isDouble(const Node &n)
Definition: node.hh:143
Sym symbol()
Definition: xtended.hh:24
Tree tree(const Node &n)
Definition: tree.hh:186
bool isInt(const Node &n)
Definition: node.hh:126

Here is the call graph for this function:

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

Implements xtended.

Definition at line 53 of file absprim.cpp.

References arity(), infereSigType(), isuffix(), kReal, and subst().

54  {
55  assert (args.size() == arity());
56  assert (types.size() == arity());
57 
58  Type t = infereSigType(types);
59  if (t->nature() == kReal) {
60  return subst("fabs$1($0)", args[0], isuffix());
61  } else {
62  return subst("abs($0)", args[0]);
63  }
64  }
virtual unsigned int arity()
Definition: absprim.cpp:15
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
Definition: sigtype.hh:54
const char * isuffix()
suffix for math functions
Definition: floats.cpp:43
virtual Type infereSigType(const vector< Type > &types)
Definition: absprim.cpp:19

Here is the call graph for this function:

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

Implements xtended.

Definition at line 66 of file absprim.cpp.

References arity(), infereSigType(), and subst().

67  {
68  assert (args.size() == arity());
69  assert (types.size() == arity());
70 
71  Type t = infereSigType(types);
72  return subst("\\left\\lvert{$0}\\right\\rvert", args[0]);
73  }
virtual unsigned int arity()
Definition: absprim.cpp:15
string subst(const string &model, const vector< string > &args)
Text substitution.
Definition: Text.cpp:47
virtual Type infereSigType(const vector< Type > &types)
Definition: absprim.cpp:19

Here is the call graph for this function:

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

Implements xtended.

Definition at line 29 of file absprim.cpp.

References arity().

30  {
31  assert (args.size() == arity());
32  return args[0];
33  }
virtual unsigned int arity()
Definition: absprim.cpp:15

Here is the call graph for this function:

virtual Type AbsPrim::infereSigType ( const vector< Type > &  types)
inlinevirtual

Implements xtended.

Definition at line 19 of file absprim.cpp.

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

Referenced by generateCode(), and generateLateq().

20  {
21  assert (types.size() == arity());
22  Type t = types[0];
23  return castInterval(t, abs(t->getInterval()));
24  return t;
25  }
interval abs(const interval &x)
Definition: interval.hh:226
virtual unsigned int arity()
Definition: absprim.cpp:15
Type castInterval(Type t, const interval &i)
Definition: sigtype.hh:278

Here is the call graph for this function:

Here is the caller graph for this function:

virtual bool AbsPrim::needCache ( )
inlinevirtual

Implements xtended.

Definition at line 17 of file absprim.cpp.

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

Definition at line 27 of file absprim.cpp.

27 {}

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