File: circular.cc

package info (click to toggle)
icmake 13.05.01-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,132 kB
  • sloc: cpp: 11,595; fortran: 883; makefile: 853; sh: 546; pascal: 342
file content (51 lines) | stat: -rw-r--r-- 1,584 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#define XERR "dependencies"
#include "dependencies.ih"

    // called from modules/modules.f

// d_circular contains the d_imports sets from the d_modVect modules
// d_idx[idx] initially contains indices 0..N. 
//
// It is reordered so that its elements 0..x contain the indices of the
// modules having 0 dependencies, then the indices of modules having <=
// 1 dependencies, then <= 2 dependencies etc.
// After each reordering 
// partitioned so that 0-importing indices are from 0..first

bool Dependencies::circular()
{
    setCircular();                              // cp modVect's imports, 
                                                // set d_idx
    IdxVectIter from = d_idx.begin();

    while (true)
    {
        IdxVectIter next =          // the 0-dependent module indices on top
                    partition(from, d_idx.end(), 
                        [&](size_t idx)
                        {
                            return d_circular[idx].size() == 0;
                        }
                    );

        if (next == d_idx.end())            // all circular checks were passed
            return false;                   // no circular deps

        if (from == next)                   // circ.deps: deps still exist
        {
            emsg << "can't compile module " << d_modVect[*from].modName() << 
                    ": circular or undefined module(s)\n" << endl;
            return true;
        }

        from = rmIndices(from, next);   // remove indices from to next from
                                        // d_circular
    }
}