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 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 divNode (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 64 of file node.hh.


Function Documentation

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

Definition at line 235 of file node.hh.

References isDouble().

Referenced by addNums().

00236     { return (isDouble(x)||isDouble(y)) ? Node(double(x)+double(y)) : Node(int(x)+int(y)); }

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 275 of file node.hh.

00276     { return Node(int(x)&int(y)); }

const Node divExtendedNode ( const Node x,
const Node y 
) [inline]

Definition at line 247 of file node.hh.

References isDouble().

Referenced by divExtendedNums().

00248     { return  (isDouble(x)||isDouble(y)) ? Node(double(x)/double(y))
00249             : (double(int(x)/int(y))==double(x)/double(y)) ? Node(int(x)/int(y))
00250             : Node(double(x)/double(y)); }

Here is the call graph for this function:

Here is the caller graph for this function:

const Node divNode ( const Node x,
const Node y 
) [inline]

Definition at line 244 of file node.hh.

References isDouble().

Referenced by divNums(), and inverseNode().

00245     { return (isDouble(x)||isDouble(y)) ? Node(double(x)/double(y)) : Node(int(x)/int(y)); }

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 299 of file node.hh.

References isDouble().

00300     { return (isDouble(x)||isDouble(y)) ? Node(double(x)==double(y)) : Node(int(x)==int(y)); }

Here is the call graph for this function:

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

Definition at line 293 of file node.hh.

References isDouble().

00294     { return (isDouble(x)||isDouble(y)) ? Node(double(x)>=double(y)) : Node(int(x)>=int(y)); }

Here is the call graph for this function:

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

Definition at line 287 of file node.hh.

References isDouble().

00288     { return (isDouble(x)||isDouble(y)) ? Node(double(x)>double(y)) : Node(int(x)>int(y)); }

Here is the call graph for this function:

const Node inverseNode ( const Node x  )  [inline]

Definition at line 260 of file node.hh.

References divNode().

Referenced by inverseNum().

00261     { return divNode(1.0f, x); }

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 142 of file node.hh.

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

00143 {
00144     if (n.type() == kDoubleNode) {
00145         *x = n.getDouble();
00146         return true;
00147     } else {
00148         return false;
00149     }
00150 }

Here is the call graph for this function:

bool isDouble ( const Node n  )  [inline]

Definition at line 137 of file node.hh.

References kDoubleNode, and Node::type().

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

00138 {
00139     return (n.type() == kDoubleNode);
00140 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool isGEZero ( const Node n  )  [inline]

Definition at line 160 of file node.hh.

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

00161 {
00162     return (n.type() == kDoubleNode) && (n.getDouble() >= 0.0)
00163         || (n.type() == kIntNode) && (n.getInt() >= 0);
00164 }

Here is the call graph for this function:

bool isGTZero ( const Node n  )  [inline]

Definition at line 166 of file node.hh.

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

00167 {
00168     return (n.type() == kDoubleNode) && (n.getDouble() > 0.0)
00169         || (n.type() == kIntNode) && (n.getInt() > 0);
00170 }

Here is the call graph for this function:

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

Definition at line 125 of file node.hh.

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

00126 {
00127     if (n.type() == kIntNode) {
00128         *x = n.getInt();
00129         return true;
00130     } else {
00131         return false;
00132     }
00133 }

Here is the call graph for this function:

bool isInt ( const Node n  )  [inline]

Definition at line 120 of file node.hh.

References kIntNode, and Node::type().

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

00121 {
00122     return (n.type() == kIntNode);
00123 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool isMinusOne ( const Node n  )  [inline]

Definition at line 178 of file node.hh.

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

00179 {
00180     return (n.type() == kDoubleNode) && (n.getDouble() == -1.0)
00181         || (n.type() == kIntNode) && (n.getInt() == -1);
00182 }

Here is the call graph for this function:

bool isNum ( const Node n  )  [inline]

Definition at line 186 of file node.hh.

References isDouble(), and isInt().

00187 {
00188     return isInt(n)||isDouble(n);
00189 }

Here is the call graph for this function:

bool isOne ( const Node n  )  [inline]

Definition at line 172 of file node.hh.

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

00173 {
00174     return (n.type() == kDoubleNode) && (n.getDouble() == 1.0)
00175         || (n.type() == kIntNode) && (n.getInt() == 1);
00176 }

Here is the call graph for this function:

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

Definition at line 215 of file node.hh.

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

00216 {
00217     if (n.type() == kPointerNode) {
00218         *x = n.getPointer();
00219         return true;
00220     } else {
00221         return false;
00222     }
00223 }

Here is the call graph for this function:

bool isPointer ( const Node n  )  [inline]

Definition at line 210 of file node.hh.

References kPointerNode, and Node::type().

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

00211 {
00212     return (n.type() == kPointerNode);
00213 }

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 198 of file node.hh.

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

00199 {
00200     if (n.type() == kSymNode) {
00201         *x = n.getSym();
00202         return true;
00203     } else {
00204         return false;
00205     }
00206 }

Here is the call graph for this function:

bool isSym ( const Node n  )  [inline]

Definition at line 193 of file node.hh.

References kSymNode, and Node::type().

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

00194 {
00195     return (n.type() == kSymNode);
00196 }

Here is the call graph for this function:

Here is the caller graph for this function:

bool isZero ( const Node n  )  [inline]

Definition at line 154 of file node.hh.

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

00155 {
00156     return (n.type() == kDoubleNode) && (n.getDouble() == 0.0)
00157         || (n.type() == kIntNode) && (n.getInt() == 0);
00158 }

Here is the call graph for this function:

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

Definition at line 296 of file node.hh.

References isDouble().

00297     { return (isDouble(x)||isDouble(y)) ? Node(double(x)<=double(y)) : Node(int(x)<=int(y)); }

Here is the call graph for this function:

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

Definition at line 266 of file node.hh.

00267     { return Node(int(x)<<int(y)); }

const Node ltNode ( const Node x,
const Node y 
) [inline]

Definition at line 290 of file node.hh.

References isDouble().

00291     { return (isDouble(x)||isDouble(y)) ? Node(double(x)<double(y)) : Node(int(x)<int(y)); }

Here is the call graph for this function:

const Node minusNode ( const Node x  )  [inline]

Definition at line 257 of file node.hh.

References subNode().

Referenced by minusNum().

00258     { return subNode(0, x); }

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 241 of file node.hh.

References isDouble().

Referenced by mulNums().

00242     { return (isDouble(x)||isDouble(y)) ? Node(double(x)*double(y)) : Node(int(x)*int(y)); }

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 302 of file node.hh.

References isDouble().

00303     { return (isDouble(x)||isDouble(y)) ? Node(double(x)!=double(y)) : Node(int(x)!=int(y)); }

Here is the call graph for this function:

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

Definition at line 111 of file node.hh.

References Node::print().

00111 { return n.print(s); }

Here is the call graph for this function:

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

Definition at line 278 of file node.hh.

00279     { return Node(int(x)|int(y)); }

const Node remNode ( const Node x,
const Node y 
) [inline]

Definition at line 252 of file node.hh.

00253     { return Node(int(x)%int(y)); }

const Node rshNode ( const Node x,
const Node y 
) [inline]

Definition at line 269 of file node.hh.

00270     { return Node(int(x)>>int(y)); }

const Node subNode ( const Node x,
const Node y 
) [inline]

Definition at line 238 of file node.hh.

References isDouble().

Referenced by minusNode(), and subNums().

00239     { return (isDouble(x)||isDouble(y)) ? Node(double(x)-double(y)) : Node(int(x)-int(y)); }

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 281 of file node.hh.

00282     { return Node(int(x)^int(y)); }

Generated on Thu Apr 29 00:00:09 2010 for FAUST compiler by  doxygen 1.6.3