FAUST compiler  0.9.9.6b8
Public Member Functions | Private Member Functions | Private Attributes | List of all members
OccMarkup Class Reference

Occurences Markup of a root tree. More...

#include <occurences.hh>

Collaboration diagram for OccMarkup:
Collaboration graph
[legend]

Public Member Functions

void mark (Tree root)
 start markup of root tree with new unique key More...
 
Occurencesretrieve (Tree t)
 occurences of subtree t within root tree More...
 

Private Member Functions

void incOcc (Tree env, int v, int r, int d, Tree t)
 inc the occurence of t in context v,r More...
 
OccurencesgetOcc (Tree t)
 get Occurences property of t or null More...
 
void setOcc (Tree t, Occurences *occ)
 set Occurences property of t More...
 

Private Attributes

Tree fRootTree
 occurences computed within this tree More...
 
Tree fPropKey
 key used to store occurences property More...
 

Detailed Description

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.

Member Function Documentation

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().

145 {
146  Tree p = t->getProperty(fPropKey);
147  if (p) {
148  return (Occurences*) tree2ptr(p);
149  } else {
150  return 0;
151  }
152 }
Tree fPropKey
key used to store occurences property
Definition: occurences.hh:35
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
void * tree2ptr(Tree t)
if t has a node of type ptr, return it otherwise error
Definition: tree.cpp:288
Tree getProperty(Tree key)
Definition: tree.hh:173

Here is the call graph for this function:

Here is the caller graph for this function:

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().

96 {
97  // Check if we have already visited this tree
98  Occurences* occ = getOcc(t);
99 
100  if (occ==0) {
101  // 1) We build initial occurence information
102  Type ty = getCertifiedSigType(t);
103  int v0 = ty->variability();
104  int r0 = getRecursivness(t);
105 
106  occ = new Occurences(v0,r0);
107  setOcc(t, occ);
108 
109  // We mark the subtrees of t
110  Tree c, x, y, z;
111  if (isSigFixDelay(t,x,y)) {
112  Type g2 = getCertifiedSigType(y);
113  int d2 = checkDelayInterval(g2);
114  assert(d2>=0);
115  incOcc(env, v0, r0, d2, x);
116  incOcc(env, v0, r0, 0, y);
117  } else if (isSigPrefix(t,y,x)) {
118  incOcc(env, v0, r0, 1, x);
119  incOcc(env, v0, r0, 0, y);
120  } else if (isSigSelect3(t,c,y,x,z)) {
121  // make a special case for select3 implemented with real if
122  // because the c expression will be used twice in the C++
123  // translation
124  incOcc(env, v0, r0, 0, c);
125  incOcc(env, v0, r0, 0, c);
126  incOcc(env, v0, r0, 0, x);
127  incOcc(env, v0, r0, 0, y);
128  incOcc(env, v0, r0, 0, z);
129  } else {
130  vector<Tree> br;
131  int n = getSubSignals(t, br);
132  if (n>0 && ! isSigGen(t)) {
133  for (int i=0; i<n; i++) incOcc(env, v0, r0, 0, br[i]);
134  }
135  }
136  }
137 
138  occ->incOccurences(v,r,d);
139 
140 }
void incOcc(Tree env, int v, int r, int d, Tree t)
inc the occurence of t in context v,r
Definition: occurences.cpp:95
int getRecursivness(Tree sig)
Return the recursivness of a previously annotated signal.
bool isSigPrefix(Tree t, Tree &t0, Tree &t1)
Definition: signals.cpp:66
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
bool isSigFixDelay(Tree t, Tree &t0, Tree &t1)
Definition: signals.cpp:62
bool isSigSelect3(Tree t, Tree &selector, Tree &s1, Tree &s2, Tree &s3)
Definition: signals.cpp:119
bool isSigGen(Tree t, Tree &x)
Definition: signals.cpp:91
void setOcc(Tree t, Occurences *occ)
set Occurences property of t
Definition: occurences.cpp:155
int checkDelayInterval(Type t)
Check is a type is appropriate for a delay.
Definition: sigtype.cpp:327
Type getCertifiedSigType(Tree sig)
Retrieve the type of sig and check it exists.
Occurences * incOccurences(int v, int r, int d)
inc occurences in context v,r,d
Definition: occurences.cpp:34
Occurences * getOcc(Tree t)
get Occurences property of t or null
Definition: occurences.cpp:144
int getSubSignals(Tree sig, vector< Tree > &vsigs, bool visitgen=true)
Extract the sub signals of a signal expression, that is not necesseraly all the subtrees.
Definition: subsignals.cpp:12

Here is the call graph for this function:

Here is the caller graph for this function:

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().

64 {
65  fRootTree = root;
66  fPropKey = tree(unique("OCCURENCES"));
67 
68  if (isList(root)) {
69  while (isList(root)) {
70  //incOcc(kSamp, 1, hd(root));
71  incOcc(nil, kSamp, 0, 0, hd(root));
72  root = tl(root);
73  }
74  //cerr << "END OF LIST IS " << *root << endl;
75  } else {
76  //incOcc(kSamp, 1, root);
77  incOcc(nil, kSamp, 0, 0, root);
78  }
79 }
void incOcc(Tree env, int v, int r, int d, Tree t)
inc the occurence of t in context v,r
Definition: occurences.cpp:95
Symbol * unique(const char *str)
Returns a new unique symbol of name strxxx.
Definition: symbol.hh:97
Tree fRootTree
occurences computed within this tree
Definition: occurences.hh:34
Tree fPropKey
key used to store occurences property
Definition: occurences.hh:35
Tree hd(Tree l)
Definition: list.hh:133
bool isList(Tree l)
Definition: list.hh:138
Definition: sigtype.hh:56
Tree tree(const Node &n)
Definition: tree.hh:186
Tree nil
Definition: list.cpp:116
Tree tl(Tree l)
Definition: list.hh:134

Here is the call graph for this function:

Here is the caller graph for this function:

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().

82 {
83  Occurences* p = getOcc(t);
84  if (p == 0) {
85  //cerr << "No Occurences info attached to : " << *t << endl;
86  //exit(1);
87  }
88  return p;
89 }
Occurences * getOcc(Tree t)
get Occurences property of t or null
Definition: occurences.cpp:144

Here is the call graph for this function:

Here is the caller graph for this function:

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().

156 {
157  t->setProperty(fPropKey, tree(occ));
158 }
Tree fPropKey
key used to store occurences property
Definition: occurences.hh:35
void setProperty(Tree key, Tree value)
Definition: tree.hh:167
Tree tree(const Node &n)
Definition: tree.hh:186

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

Tree OccMarkup::fPropKey
private

key used to store occurences property

Definition at line 35 of file occurences.hh.

Referenced by getOcc(), mark(), and setOcc().

Tree OccMarkup::fRootTree
private

occurences computed within this tree

Definition at line 34 of file occurences.hh.

Referenced by mark().


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