summaryrefslogtreecommitdiffstats
path: root/gfx/angle/src/compiler/translator/depgraph/DependencyGraphTraverse.cpp
blob: 197fde97e260d0b502e14d980c5e6fcd1880761c (plain)
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
67
68
69
//
// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//

#include "compiler/translator/depgraph/DependencyGraph.h"

// These methods do a breadth-first traversal through the graph and mark visited nodes.

void TGraphNode::traverse(TDependencyGraphTraverser* graphTraverser)
{
    graphTraverser->markVisited(this);
}

void TGraphParentNode::traverse(TDependencyGraphTraverser* graphTraverser)
{
    TGraphNode::traverse(graphTraverser);

    graphTraverser->incrementDepth();

    // Visit the parent node's children.
    for (TGraphNodeSet::const_iterator iter = mDependentNodes.begin();
         iter != mDependentNodes.end();
         ++iter)
    {
        TGraphNode* node = *iter;
        if (!graphTraverser->isVisited(node))
            node->traverse(graphTraverser);
    }

    graphTraverser->decrementDepth();
}

void TGraphArgument::traverse(TDependencyGraphTraverser* graphTraverser)
{
    graphTraverser->visitArgument(this);
    TGraphParentNode::traverse(graphTraverser);
}

void TGraphFunctionCall::traverse(TDependencyGraphTraverser* graphTraverser)
{
    graphTraverser->visitFunctionCall(this);
    TGraphParentNode::traverse(graphTraverser);
}

void TGraphSymbol::traverse(TDependencyGraphTraverser* graphTraverser)
{
    graphTraverser->visitSymbol(this);
    TGraphParentNode::traverse(graphTraverser);
}

void TGraphSelection::traverse(TDependencyGraphTraverser* graphTraverser)
{
    graphTraverser->visitSelection(this);
    TGraphNode::traverse(graphTraverser);
}

void TGraphLoop::traverse(TDependencyGraphTraverser* graphTraverser)
{
    graphTraverser->visitLoop(this);
    TGraphNode::traverse(graphTraverser);
}

void TGraphLogicalOp::traverse(TDependencyGraphTraverser* graphTraverser)
{
    graphTraverser->visitLogicalOp(this);
    TGraphNode::traverse(graphTraverser);
}