FAUST compiler  0.9.9.6b8
loopDetector.cpp
Go to the documentation of this file.
1 #include "loopDetector.hh"
2 #include "ppbox.hh"
3 
5 {
6  fPhase++;
7  int w = fPhase%fBuffersize;
8  fBuffer[w] = t;
9  if ((fPhase%fCheckperiod) == 0) {
10  // time to check for a cycle
11  for (int i=1; i<fBuffersize; i++) {
12  int r = w-i; if (r < 0) { r += fBuffersize; }
13  assert(r>=0);
14  assert(r<fBuffersize);
15  assert(r != w);
16  if (fBuffer[r] == t) {
17  cerr << "ERROR : after "
18  << fPhase
19  << " evaluation steps, the compiler has detected an endless evaluation cycle of "
20  << i
21  << " steps"
22  << endl;
23  exit(1);
24  }
25  }
26  }
27  return false;
28 }
A CTree = (Node x [CTree]) is a Node associated with a list of subtrees called branches.
Definition: tree.hh:109
Detect evaluation loops.
const int fCheckperiod
Definition: loopDetector.hh:44
const int fBuffersize
Definition: loopDetector.hh:43
vector< Tree > fBuffer
Definition: loopDetector.hh:45
bool detect(Tree t)
Definition: loopDetector.cpp:4