|
FAUST compiler
0.9.9.6b8
|
Occurences Markup of a root tree. More...
#include <occurences.hh>

Public Member Functions | |
| void | mark (Tree root) |
| start markup of root tree with new unique key | |
| Occurences * | retrieve (Tree t) |
| occurences of subtree t within root tree | |
Private Member Functions | |
| void | incOcc (Tree env, int v, int r, int d, Tree t) |
| inc the occurence of t in context v,r | |
| Occurences * | getOcc (Tree t) |
| get Occurences property of t or null | |
| void | setOcc (Tree t, Occurences *occ) |
| set Occurences property of t | |
Private Attributes | |
| Tree | fRootTree |
| occurences computed within this tree | |
| Tree | fPropKey |
| key used to store occurences property | |
Occurences Markup of a root tree.
First create an OccMarkup om, second om.mark(root) then om.retrieve(subtree)
Definition at line 32 of file occurences.hh.
| Occurences * OccMarkup::getOcc | ( | Tree | t | ) | [private] |
get Occurences property of t or null
Definition at line 144 of file occurences.cpp.
References fPropKey, CTree::getProperty(), and tree2ptr().
Referenced by incOcc(), and retrieve().
{
Tree p = t->getProperty(fPropKey);
if (p) {
return (Occurences*) tree2ptr(p);
} else {
return 0;
}
}


| void OccMarkup::incOcc | ( | Tree | env, |
| int | v, | ||
| int | r, | ||
| int | d, | ||
| Tree | t | ||
| ) | [private] |
inc the occurence of t in context v,r
Definition at line 95 of file occurences.cpp.
References checkDelayInterval(), getCertifiedSigType(), getOcc(), getRecursivness(), getSubSignals(), Occurences::incOccurences(), isSigFixDelay(), isSigGen(), isSigPrefix(), isSigSelect3(), and setOcc().
Referenced by mark().
{
// Check if we have already visited this tree
Occurences* occ = getOcc(t);
if (occ==0) {
// 1) We build initial occurence information
Type ty = getCertifiedSigType(t);
int v0 = ty->variability();
int r0 = getRecursivness(t);
occ = new Occurences(v0,r0);
setOcc(t, occ);
// We mark the subtrees of t
Tree c, x, y, z;
if (isSigFixDelay(t,x,y)) {
Type g2 = getCertifiedSigType(y);
int d2 = checkDelayInterval(g2);
assert(d2>=0);
incOcc(env, v0, r0, d2, x);
incOcc(env, v0, r0, 0, y);
} else if (isSigPrefix(t,y,x)) {
incOcc(env, v0, r0, 1, x);
incOcc(env, v0, r0, 0, y);
} else if (isSigSelect3(t,c,y,x,z)) {
// make a special case for select3 implemented with real if
// because the c expression will be used twice in the C++
// translation
incOcc(env, v0, r0, 0, c);
incOcc(env, v0, r0, 0, c);
incOcc(env, v0, r0, 0, x);
incOcc(env, v0, r0, 0, y);
incOcc(env, v0, r0, 0, z);
} else {
vector<Tree> br;
int n = getSubSignals(t, br);
if (n>0 && ! isSigGen(t)) {
for (int i=0; i<n; i++) incOcc(env, v0, r0, 0, br[i]);
}
}
}
occ->incOccurences(v,r,d);
}


| void OccMarkup::mark | ( | Tree | root | ) |
start markup of root tree with new unique key
Definition at line 63 of file occurences.cpp.
References fPropKey, fRootTree, hd(), incOcc(), isList(), kSamp, nil, tl(), tree(), and unique().
Referenced by DocCompiler::annotate().
{
fRootTree = root;
fPropKey = tree(unique("OCCURENCES"));
if (isList(root)) {
while (isList(root)) {
//incOcc(kSamp, 1, hd(root));
incOcc(nil, kSamp, 0, 0, hd(root));
root = tl(root);
}
//cerr << "END OF LIST IS " << *root << endl;
} else {
//incOcc(kSamp, 1, root);
incOcc(nil, kSamp, 0, 0, root);
}
}


| Occurences * OccMarkup::retrieve | ( | Tree | t | ) |
occurences of subtree t within root tree
Definition at line 81 of file occurences.cpp.
References getOcc().
Referenced by VectorCompiler::generateCacheCode(), DocCompiler::generateCacheCode(), DocCompiler::generateFConst(), VectorCompiler::generateFixDelay(), DocCompiler::generateFVar(), DocCompiler::generateNumber(), DocCompiler::generateRec(), and VectorCompiler::needSeparateLoop().
{
Occurences* p = getOcc(t);
if (p == 0) {
//cerr << "No Occurences info attached to : " << *t << endl;
//exit(1);
}
return p;
}


| void OccMarkup::setOcc | ( | Tree | t, |
| Occurences * | occ | ||
| ) | [private] |
set Occurences property of t
Definition at line 155 of file occurences.cpp.
References fPropKey, CTree::setProperty(), and tree().
Referenced by incOcc().
{
t->setProperty(fPropKey, tree(occ));
}


Tree OccMarkup::fPropKey [private] |
key used to store occurences property
Definition at line 35 of file occurences.hh.
Tree OccMarkup::fRootTree [private] |
occurences computed within this tree
Definition at line 34 of file occurences.hh.
Referenced by mark().
1.8.0