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 30 of file occurences.hh.
Occurences * OccMarkup::getOcc | ( | Tree | t | ) | [private] |
get Occurences property of t or null
Definition at line 137 of file occurences.cpp.
References fPropKey, CTree::getProperty(), and tree2ptr().
Referenced by incOcc(), and retrieve().
00138 { 00139 Tree p = t->getProperty(fPropKey); 00140 if (p) { 00141 return (Occurences*) tree2ptr(p); 00142 } else { 00143 return 0; 00144 } 00145 }
inc the occurence of t in context v,r
Definition at line 95 of file occurences.cpp.
References checkDelayInterval(), getOcc(), getRecursivness(), getSigType(), getSubSignals(), Occurences::incOccurences(), isSigFixDelay(), isSigGen(), isSigPrefix(), and setOcc().
Referenced by mark().
00096 { 00097 //cerr << "enter incOcc(" << v << "," << r << "," << d << "," << *t << ")" << endl; 00098 00099 // Check if we have already visited this tree 00100 Occurences* occ = getOcc(t); 00101 00102 if (occ==0) { 00103 // 1) We build initial occurence information 00104 Type ty = getSigType(t); 00105 int v0 = ty->variability(); 00106 int r0 = getRecursivness(t); 00107 00108 occ = new Occurences(v0,r0); 00109 setOcc(t, occ); 00110 00111 // We mark the subtrees of t 00112 Tree x, y; 00113 if (isSigFixDelay(t,x,y)) { 00114 Type g2 = getSigType(y); 00115 int d2 = checkDelayInterval(g2); 00116 assert(d2>=0); 00117 incOcc(env, v0, r0, d2, x); 00118 incOcc(env, v0, r0, 0, y); 00119 } else if (isSigPrefix(t,y,x)) { 00120 incOcc(env, v0, r0, 1, x); 00121 incOcc(env, v0, r0, 0, y); 00122 } else { 00123 vector<Tree> br; 00124 int n = getSubSignals(t, br); 00125 if (n>0 && ! isSigGen(t)) { 00126 for (int i=0; i<n; i++) incOcc(env, v0, r0, 0, br[i]); 00127 } 00128 } 00129 } 00130 00131 occ->incOccurences(v,r,d); 00132 00133 }
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(), ScalarCompiler::prepare(), and ScalarCompiler::prepare2().
00064 { 00065 fRootTree = root; 00066 fPropKey = tree(unique("OCCURENCES")); 00067 00068 if (isList(root)) { 00069 while (isList(root)) { 00070 //incOcc(kSamp, 1, hd(root)); 00071 incOcc(nil, kSamp, 0, 0, hd(root)); 00072 root = tl(root); 00073 } 00074 //cerr << "END OF LIST IS " << *root << endl; 00075 } else { 00076 //incOcc(kSamp, 1, root); 00077 incOcc(nil, kSamp, 0, 0, root); 00078 } 00079 }
Occurences * OccMarkup::retrieve | ( | Tree | t | ) |
occurences of subtree t within root tree
Definition at line 81 of file occurences.cpp.
References getOcc().
Referenced by DocCompiler::generateCacheCode(), VectorCompiler::generateCacheCode(), ScalarCompiler::generateCacheCode(), DocCompiler::generateFConst(), ScalarCompiler::generateFConst(), VectorCompiler::generateFixDelay(), ScalarCompiler::generateFixDelay(), DocCompiler::generateFVar(), ScalarCompiler::generateFVar(), DocCompiler::generateNumber(), ScalarCompiler::generateNumber(), DocCompiler::generateRec(), ScalarCompiler::generateRec(), and VectorCompiler::needSeparateLoop().
00082 { 00083 Occurences* p = getOcc(t); 00084 if (p == 0) { 00085 //cerr << "No Occurences info attached to : " << *t << endl; 00086 //exit(1); 00087 } 00088 return p; 00089 }
void OccMarkup::setOcc | ( | Tree | t, | |
Occurences * | occ | |||
) | [private] |
set Occurences property of t
Definition at line 148 of file occurences.cpp.
References fPropKey, CTree::setProperty(), and tree().
Referenced by incOcc().
00149 { 00150 t->setProperty(fPropKey, tree(occ)); 00151 }
Tree OccMarkup::fPropKey [private] |
key used to store occurences property
Definition at line 33 of file occurences.hh.
Tree OccMarkup::fRootTree [private] |
occurences computed within this tree
Definition at line 32 of file occurences.hh.
Referenced by mark().