~ubuntu-branches/ubuntu/quantal/mesa/quantal

« back to all changes in this revision

Viewing changes to src/mesa/shader/slang/MachineIndependent/QualifierAlive.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Sebastien Bacher
  • Date: 2007-02-21 12:44:07 UTC
  • mfrom: (1.2.1 upstream)
  • mto: This revision was merged to the branch mainline in revision 22.
  • Revision ID: james.westby@ubuntu.com-20070221124407-rgcacs32mycrtadl
ImportĀ upstreamĀ versionĀ 6.5.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
//
2
 
//Copyright (C) 2002-2005  3Dlabs Inc. Ltd.
3
 
//All rights reserved.
4
 
//
5
 
//Redistribution and use in source and binary forms, with or without
6
 
//modification, are permitted provided that the following conditions
7
 
//are met:
8
 
//
9
 
//    Redistributions of source code must retain the above copyright
10
 
//    notice, this list of conditions and the following disclaimer.
11
 
//
12
 
//    Redistributions in binary form must reproduce the above
13
 
//    copyright notice, this list of conditions and the following
14
 
//    disclaimer in the documentation and/or other materials provided
15
 
//    with the distribution.
16
 
//
17
 
//    Neither the name of 3Dlabs Inc. Ltd. nor the names of its
18
 
//    contributors may be used to endorse or promote products derived
19
 
//    from this software without specific prior written permission.
20
 
//
21
 
//THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22
 
//"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23
 
//LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
24
 
//FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
25
 
//COPYRIGHT HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
26
 
//INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
27
 
//BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
28
 
//LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29
 
//CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
30
 
//LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
31
 
//ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
32
 
//POSSIBILITY OF SUCH DAMAGE.
33
 
//
34
 
 
35
 
#include "../Include/intermediate.h"
36
 
 
37
 
class TAliveTraverser : public TIntermTraverser {
38
 
public:
39
 
    TAliveTraverser(TQualifier q) : TIntermTraverser(), found(false), qualifier(q)
40
 
    {
41
 
        visitSymbol    = AliveSymbol;
42
 
        visitSelection = AliveSelection;
43
 
        rightToLeft    = true;
44
 
    }
45
 
    bool wasFound() { return found; }
46
 
protected:
47
 
    bool found;
48
 
    TQualifier qualifier;
49
 
 
50
 
    friend void AliveSymbol(TIntermSymbol*, TIntermTraverser*);
51
 
    friend bool AliveSelection(bool, TIntermSelection*, TIntermTraverser*);
52
 
};
53
 
 
54
 
//
55
 
// Report whether or not a variable of the given qualifier type
56
 
// is guaranteed written.  Not always possible to determine if
57
 
// it is written conditionally.
58
 
//
59
 
// ?? It does not do this well yet, this is just a place holder
60
 
// that simply determines if it was reference at all, anywhere.
61
 
//
62
 
bool QualifierWritten(TIntermNode* node, TQualifier qualifier)
63
 
{
64
 
    TAliveTraverser it(qualifier);
65
 
 
66
 
    if (node)
67
 
        node->traverse(&it);
68
 
 
69
 
    return it.wasFound();
70
 
}
71
 
 
72
 
void AliveSymbol(TIntermSymbol* node, TIntermTraverser* it)
73
 
{
74
 
    TAliveTraverser* lit = static_cast<TAliveTraverser*>(it);
75
 
 
76
 
    //
77
 
    // If it's what we're looking for, record it.
78
 
    //
79
 
    if (node->getQualifier() == lit->qualifier)
80
 
        lit->found = true;
81
 
}
82
 
 
83
 
bool AliveSelection(bool preVisit, TIntermSelection* node, TIntermTraverser* it)
84
 
{
85
 
    TAliveTraverser* lit = static_cast<TAliveTraverser*>(it);
86
 
 
87
 
    if (lit->wasFound())
88
 
        return false;
89
 
 
90
 
    return true;
91
 
}