FAUST compiler  0.9.9.6b8
Classes | Enumerations | Functions
node.hh File Reference

A Node is a tagged unions of int, double, symbol and void* used in the implementation of CTrees. More...

#include <iostream>
#include "symbol.hh"
#include <sys/types.h>
Include dependency graph for node.hh:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  Node
 Class Node = (type x (int + double + Sym + void*)) More...
 

Enumerations

enum  { kIntNode, kDoubleNode, kSymNode, kPointerNode }
 Tags used to define the type of a Node. More...
 

Functions

ostream & operator<< (ostream &s, const Node &n)
 
bool isInt (const Node &n)
 
bool isInt (const Node &n, int *x)
 
bool isDouble (const Node &n)
 
bool isDouble (const Node &n, double *x)
 
bool isZero (const Node &n)
 
bool isGEZero (const Node &n)
 
bool isGTZero (const Node &n)
 
bool isOne (const Node &n)
 
bool isMinusOne (const Node &n)
 
bool isNum (const Node &n)
 
bool isSym (const Node &n)
 
bool isSym (const Node &n, Sym *x)
 
bool isPointer (const Node &n)
 
bool isPointer (const Node &n, void **x)
 
const Node addNode (const Node &x, const Node &y)
 
const Node subNode (const Node &x, const Node &y)
 
const Node mulNode (const Node &x, const Node &y)
 
const Node divExtendedNode (const Node &x, const Node &y)
 
const Node remNode (const Node &x, const Node &y)
 
const Node minusNode (const Node &x)
 
const Node inverseNode (const Node &x)
 
const Node lshNode (const Node &x, const Node &y)
 
const Node rshNode (const Node &x, const Node &y)
 
const Node andNode (const Node &x, const Node &y)
 
const Node orNode (const Node &x, const Node &y)
 
const Node xorNode (const Node &x, const Node &y)
 
const Node gtNode (const Node &x, const Node &y)
 
const Node ltNode (const Node &x, const Node &y)
 
const Node geNode (const Node &x, const Node &y)
 
const Node leNode (const Node &x, const Node &y)
 
const Node eqNode (const Node &x, const Node &y)
 
const Node neNode (const Node &x, const Node &y)
 

Detailed Description

A Node is a tagged unions of int, double, symbol and void* used in the implementation of CTrees.

Nodes are completly described by the node.h file, there is no node.cpp file.

API:

Node(symbol("abcd"));   : node with symbol content
Node(10);               : node with int content
Node(3.14159);          : node with double content

n->type();              : kIntNode or kDoubleNode or kSymNode

n->getInt();            : int content of n
n->getDouble();         : double content of n
n->getSym();            : symbol content of n

if (isInt(n, &i))   ... : int i = int content of n
if (isDouble(n, &f))    ... : double f = double content of n
if (isSym(n, &s))   ... : Sym s = Sym content of n

Definition in file node.hh.

Enumeration Type Documentation

anonymous enum

Tags used to define the type of a Node.

Enumerator
kIntNode 
kDoubleNode 
kSymNode 
kPointerNode 

Definition at line 69 of file node.hh.

Function Documentation

const Node addNode ( const Node x,
const Node y 
)
inline

Definition at line 241 of file node.hh.

References isDouble().

Referenced by addNums().

242  { return (isDouble(x)||isDouble(y)) ? Node(double(x)+double(y)) : Node(int(x)+int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
bool isDouble(const Node &n)
Definition: node.hh:143

Here is the call graph for this function:

Here is the caller graph for this function:

const Node andNode ( const Node x,
const Node y 
)
inline

Definition at line 278 of file node.hh.

279  { return Node(int(x)&int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
const Node divExtendedNode ( const Node x,
const Node y 
)
inline

Definition at line 250 of file node.hh.

References isDouble().

Referenced by divExtendedNums(), and inverseNode().

251  { return (isDouble(x)||isDouble(y)) ? Node(double(x)/double(y))
252  : (double(int(x)/int(y))==double(x)/double(y)) ? Node(int(x)/int(y))
253  : Node(double(x)/double(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
bool isDouble(const Node &n)
Definition: node.hh:143

Here is the call graph for this function:

Here is the caller graph for this function:

const Node eqNode ( const Node x,
const Node y 
)
inline

Definition at line 302 of file node.hh.

References isDouble().

303  { return (isDouble(x)||isDouble(y)) ? Node(double(x)==double(y)) : Node(int(x)==int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
bool isDouble(const Node &n)
Definition: node.hh:143

Here is the call graph for this function:

const Node geNode ( const Node x,
const Node y 
)
inline

Definition at line 296 of file node.hh.

References isDouble().

297  { return (isDouble(x)||isDouble(y)) ? Node(double(x)>=double(y)) : Node(int(x)>=int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
bool isDouble(const Node &n)
Definition: node.hh:143

Here is the call graph for this function:

const Node gtNode ( const Node x,
const Node y 
)
inline

Definition at line 290 of file node.hh.

References isDouble().

291  { return (isDouble(x)||isDouble(y)) ? Node(double(x)>double(y)) : Node(int(x)>int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
bool isDouble(const Node &n)
Definition: node.hh:143

Here is the call graph for this function:

const Node inverseNode ( const Node x)
inline

Definition at line 263 of file node.hh.

References divExtendedNode().

Referenced by inverseNum().

264  { return divExtendedNode(1.0f, x); }
const Node divExtendedNode(const Node &x, const Node &y)
Definition: node.hh:250

Here is the call graph for this function:

Here is the caller graph for this function:

bool isDouble ( const Node n)
inline

Definition at line 143 of file node.hh.

References kDoubleNode, and Node::type().

Referenced by addNode(), MaxPrim::computeSigOutput(), MinPrim::computeSigOutput(), AbsPrim::computeSigOutput(), divExtendedNode(), eqNode(), geNode(), gtNode(), isBoxReal(), isNum(), isSigReal(), leNode(), ltNode(), mulNode(), neNode(), print(), sigFloatCast(), sigIntCast(), simplification(), subNode(), tree2double(), tree2float(), and tree2int().

144 {
145  return (n.type() == kDoubleNode);
146 }
int type() const
Definition: node.hh:102

Here is the call graph for this function:

Here is the caller graph for this function:

bool isDouble ( const Node n,
double *  x 
)
inline

Definition at line 148 of file node.hh.

References Node::getDouble(), kDoubleNode, and Node::type().

149 {
150  if (n.type() == kDoubleNode) {
151  *x = n.getDouble();
152  return true;
153  } else {
154  return false;
155  }
156 }
int type() const
Definition: node.hh:102
double getDouble() const
Definition: node.hh:105

Here is the call graph for this function:

bool isGEZero ( const Node n)
inline

Definition at line 166 of file node.hh.

References Node::getDouble(), Node::getInt(), kDoubleNode, kIntNode, and Node::type().

167 {
168  return (n.type() == kDoubleNode) && (n.getDouble() >= 0.0)
169  || (n.type() == kIntNode) && (n.getInt() >= 0);
170 }
Definition: node.hh:69
int type() const
Definition: node.hh:102
double getDouble() const
Definition: node.hh:105
int getInt() const
Definition: node.hh:104

Here is the call graph for this function:

bool isGTZero ( const Node n)
inline

Definition at line 172 of file node.hh.

References Node::getDouble(), Node::getInt(), kDoubleNode, kIntNode, and Node::type().

173 {
174  return (n.type() == kDoubleNode) && (n.getDouble() > 0.0)
175  || (n.type() == kIntNode) && (n.getInt() > 0);
176 }
Definition: node.hh:69
int type() const
Definition: node.hh:102
double getDouble() const
Definition: node.hh:105
int getInt() const
Definition: node.hh:104

Here is the call graph for this function:

bool isInt ( const Node n)
inline

Definition at line 126 of file node.hh.

References kIntNode, and Node::type().

Referenced by CTree::calcTreeAperture(), AbsPrim::computeSigOutput(), MaxPrim::computeSigOutput(), MinPrim::computeSigOutput(), ensureFloat(), infereWaveformType(), isBoxInt(), isBoxSlot(), isNum(), isProj(), isRef(), isSigBinOp(), isSigInput(), isSigInt(), isSigOutput(), isSigTuple(), print(), sigFloatCast(), sigIntCast(), simplification(), tree2double(), tree2float(), and tree2int().

127 {
128  return (n.type() == kIntNode);
129 }
Definition: node.hh:69
int type() const
Definition: node.hh:102

Here is the call graph for this function:

Here is the caller graph for this function:

bool isInt ( const Node n,
int *  x 
)
inline

Definition at line 131 of file node.hh.

References Node::getInt(), kIntNode, and Node::type().

132 {
133  if (n.type() == kIntNode) {
134  *x = n.getInt();
135  return true;
136  } else {
137  return false;
138  }
139 }
Definition: node.hh:69
int type() const
Definition: node.hh:102
int getInt() const
Definition: node.hh:104

Here is the call graph for this function:

bool isMinusOne ( const Node n)
inline

Definition at line 184 of file node.hh.

References Node::getDouble(), Node::getInt(), kDoubleNode, kIntNode, and Node::type().

185 {
186  return (n.type() == kDoubleNode) && (n.getDouble() == -1.0)
187  || (n.type() == kIntNode) && (n.getInt() == -1);
188 }
Definition: node.hh:69
int type() const
Definition: node.hh:102
double getDouble() const
Definition: node.hh:105
int getInt() const
Definition: node.hh:104

Here is the call graph for this function:

bool isNum ( const Node n)
inline

Definition at line 192 of file node.hh.

References isDouble(), and isInt().

193 {
194  return isInt(n)||isDouble(n);
195 }
bool isDouble(const Node &n)
Definition: node.hh:143
bool isInt(const Node &n)
Definition: node.hh:126

Here is the call graph for this function:

bool isOne ( const Node n)
inline

Definition at line 178 of file node.hh.

References Node::getDouble(), Node::getInt(), kDoubleNode, kIntNode, and Node::type().

179 {
180  return (n.type() == kDoubleNode) && (n.getDouble() == 1.0)
181  || (n.type() == kIntNode) && (n.getInt() == 1);
182 }
Definition: node.hh:69
int type() const
Definition: node.hh:102
double getDouble() const
Definition: node.hh:105
int getInt() const
Definition: node.hh:104

Here is the call graph for this function:

bool isPointer ( const Node n)
inline

Definition at line 216 of file node.hh.

References kPointerNode, and Node::type().

Referenced by isBoxPrim0(), isBoxPrim1(), isBoxPrim2(), isBoxPrim3(), isBoxPrim4(), isBoxPrim5(), print(), and tree2ptr().

217 {
218  return (n.type() == kPointerNode);
219 }
int type() const
Definition: node.hh:102

Here is the call graph for this function:

Here is the caller graph for this function:

bool isPointer ( const Node n,
void **  x 
)
inline

Definition at line 221 of file node.hh.

References Node::getPointer(), kPointerNode, and Node::type().

222 {
223  if (n.type() == kPointerNode) {
224  *x = n.getPointer();
225  return true;
226  } else {
227  return false;
228  }
229 }
int type() const
Definition: node.hh:102
void * getPointer() const
Definition: node.hh:107

Here is the call graph for this function:

bool isSym ( const Node n)
inline

Definition at line 199 of file node.hh.

References kSymNode, and Node::type().

Referenced by getUserData(), isBefore(), isBoxIdent(), isDocTxt(), normalizeLabel(), print(), and tree2str().

200 {
201  return (n.type() == kSymNode);
202 }
int type() const
Definition: node.hh:102
Definition: node.hh:69

Here is the call graph for this function:

Here is the caller graph for this function:

bool isSym ( const Node n,
Sym x 
)
inline

Definition at line 204 of file node.hh.

References Node::getSym(), kSymNode, and Node::type().

205 {
206  if (n.type() == kSymNode) {
207  *x = n.getSym();
208  return true;
209  } else {
210  return false;
211  }
212 }
Sym getSym() const
Definition: node.hh:106
int type() const
Definition: node.hh:102
Definition: node.hh:69

Here is the call graph for this function:

bool isZero ( const Node n)
inline

Definition at line 160 of file node.hh.

References Node::getDouble(), Node::getInt(), kDoubleNode, kIntNode, and Node::type().

161 {
162  return (n.type() == kDoubleNode) && (n.getDouble() == 0.0)
163  || (n.type() == kIntNode) && (n.getInt() == 0);
164 }
Definition: node.hh:69
int type() const
Definition: node.hh:102
double getDouble() const
Definition: node.hh:105
int getInt() const
Definition: node.hh:104

Here is the call graph for this function:

const Node leNode ( const Node x,
const Node y 
)
inline

Definition at line 299 of file node.hh.

References isDouble().

300  { return (isDouble(x)||isDouble(y)) ? Node(double(x)<=double(y)) : Node(int(x)<=int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
bool isDouble(const Node &n)
Definition: node.hh:143

Here is the call graph for this function:

const Node lshNode ( const Node x,
const Node y 
)
inline

Definition at line 269 of file node.hh.

270  { return Node(int(x)<<int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
const Node ltNode ( const Node x,
const Node y 
)
inline

Definition at line 293 of file node.hh.

References isDouble().

294  { return (isDouble(x)||isDouble(y)) ? Node(double(x)<double(y)) : Node(int(x)<int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
bool isDouble(const Node &n)
Definition: node.hh:143

Here is the call graph for this function:

const Node minusNode ( const Node x)
inline

Definition at line 260 of file node.hh.

References subNode().

Referenced by minusNum().

261  { return subNode(0, x); }
const Node subNode(const Node &x, const Node &y)
Definition: node.hh:244

Here is the call graph for this function:

Here is the caller graph for this function:

const Node mulNode ( const Node x,
const Node y 
)
inline

Definition at line 247 of file node.hh.

References isDouble().

Referenced by mulNums().

248  { return (isDouble(x)||isDouble(y)) ? Node(double(x)*double(y)) : Node(int(x)*int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
bool isDouble(const Node &n)
Definition: node.hh:143

Here is the call graph for this function:

Here is the caller graph for this function:

const Node neNode ( const Node x,
const Node y 
)
inline

Definition at line 305 of file node.hh.

References isDouble().

306  { return (isDouble(x)||isDouble(y)) ? Node(double(x)!=double(y)) : Node(int(x)!=int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
bool isDouble(const Node &n)
Definition: node.hh:143

Here is the call graph for this function:

ostream& operator<< ( ostream &  s,
const Node n 
)
inline

Definition at line 117 of file node.hh.

References Node::print().

117 { return n.print(s); }
ostream & print(ostream &fout) const
print a node on a stream
Definition: node.cpp:3

Here is the call graph for this function:

const Node orNode ( const Node x,
const Node y 
)
inline

Definition at line 281 of file node.hh.

282  { return Node(int(x)|int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
const Node remNode ( const Node x,
const Node y 
)
inline

Definition at line 255 of file node.hh.

256  { return Node(int(x)%int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
const Node rshNode ( const Node x,
const Node y 
)
inline

Definition at line 272 of file node.hh.

273  { return Node(int(x)>>int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
const Node subNode ( const Node x,
const Node y 
)
inline

Definition at line 244 of file node.hh.

References isDouble().

Referenced by minusNode(), and subNums().

245  { return (isDouble(x)||isDouble(y)) ? Node(double(x)-double(y)) : Node(int(x)-int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75
bool isDouble(const Node &n)
Definition: node.hh:143

Here is the call graph for this function:

Here is the caller graph for this function:

const Node xorNode ( const Node x,
const Node y 
)
inline

Definition at line 284 of file node.hh.

285  { return Node(int(x)^int(y)); }
Class Node = (type x (int + double + Sym + void*))
Definition: node.hh:75