File: print.cc

package info (click to toggle)
oxref 2.02.00-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 692 kB
  • sloc: cpp: 1,282; makefile: 131; sh: 48
file content (66 lines) | stat: -rw-r--r-- 1,881 bytes parent folder | download | duplicates (3)
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "tree.ih"

void Tree::print(size_t symIdx, size_t level)
{
    string const &name = d_xrefVector[symIdx].symbol(); // the symbol name
    cout << name;

    for (size_t idx = 0; idx != level; ++idx)
    {
        if (d_info[idx].symIdx == symIdx)       // recursive call?
        {
            cout << " ==> " << idx << '\n';     // show the recursion level
            return;
        }
    }

    cout << '\n';    

    size_t callIdx = calls(symIdx, 0);          // idx of 1st called entity
    if (callIdx == d_xrefVector.size())         // nothing called from here
        return;

    d_info.resize(level + 1);                   // room for the next level
    d_info[level].symIdx = symIdx;              // store this symbol's idx

    size_t nextLevel = level + 1;

    while (true)
    {
        size_t nextIdx = calls(symIdx, callIdx + 1);    // anything else
                                                        // called? 

                                                // callIdx refers to the last
                                                // called entity ?
        d_info[level].last =  nextIdx == d_xrefVector.size();

//        cout << "   " << d_xrefVector[callIdx].symbol() << '\n';
        indent(level);
        print(callIdx, nextLevel);

        if (nextIdx == d_xrefVector.size())
            break;

        callIdx = nextIdx;
    }



///////////////////////////////////////////////////////////////////
//    auto iter
//    size_t size = d_idMap.callSize(name);
//                  d_xrefVector[symIdx].
//
//    d_info.resize(level + 1);
//
//    d_info[level] = Data{ size, 0, name };
//
//    size_t nextLevel = level + 1;   // next recursion
//
//    for (size_t elem = 0; elem != size; ++elem)
//    {
//        ++d_info[level].current;
//        indent(level);
//        print(d_idMap.element(elem, name), nextLevel);
//    }
}