|
FAUST compiler
0.9.9.6b8
|
#include <loopDetector.hh>
Public Member Functions | |
| loopDetector (int buffersize, int checkperiod) | |
| bool | detect (Tree t) |
Private Attributes | |
| const int | fBuffersize |
| const int | fCheckperiod |
| vector< Tree > | fBuffer |
| int | fPhase |
Definition at line 41 of file loopDetector.hh.
| loopDetector::loopDetector | ( | int | buffersize, |
| int | checkperiod | ||
| ) | [inline] |
Definition at line 49 of file loopDetector.hh.
: fBuffersize(buffersize), fCheckperiod(checkperiod), fBuffer(buffersize), fPhase(0) {}
| bool loopDetector::detect | ( | Tree | t | ) |
Definition at line 4 of file loopDetector.cpp.
References fBuffer, fBuffersize, fCheckperiod, and fPhase.
Referenced by eval().
{
fPhase++;
int w = fPhase%fBuffersize;
fBuffer[w] = t;
if ((fPhase%fCheckperiod) == 0) {
// time to check for a cycle
for (int i=1; i<fBuffersize; i++) {
int r = w-i; if (r < 0) { r += fBuffersize; }
assert(r>=0);
assert(r<fBuffersize);
assert(r != w);
if (fBuffer[r] == t) {
cerr << "ERROR : after "
<< fPhase
<< " evaluation steps, the compiler has detected an endless evaluation cycle of "
<< i
<< " steps"
<< endl;
exit(1);
}
}
}
return false;
}

vector<Tree> loopDetector::fBuffer [private] |
Definition at line 45 of file loopDetector.hh.
Referenced by detect().
const int loopDetector::fBuffersize [private] |
Definition at line 43 of file loopDetector.hh.
Referenced by detect().
const int loopDetector::fCheckperiod [private] |
Definition at line 44 of file loopDetector.hh.
Referenced by detect().
int loopDetector::fPhase [private] |
Definition at line 46 of file loopDetector.hh.
Referenced by detect().
1.8.0