FAUST compiler  0.9.9.6b8
Public Member Functions | Private Attributes
loopDetector Class Reference

#include <loopDetector.hh>

List of all members.

Public Member Functions

 loopDetector (int buffersize, int checkperiod)
bool detect (Tree t)

Private Attributes

const int fBuffersize
const int fCheckperiod
vector< TreefBuffer
int fPhase

Detailed Description

Definition at line 41 of file loopDetector.hh.


Constructor & Destructor Documentation

loopDetector::loopDetector ( int  buffersize,
int  checkperiod 
) [inline]

Definition at line 49 of file loopDetector.hh.

: fBuffersize(buffersize), fCheckperiod(checkperiod), fBuffer(buffersize), fPhase(0) {}

Member Function Documentation

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;
}

Here is the caller graph for this function:


Member Data Documentation

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


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