2
//Copyright (C) 2002-2005 3Dlabs Inc. Ltd.
5
//Redistribution and use in source and binary forms, with or without
6
//modification, are permitted provided that the following conditions
9
// Redistributions of source code must retain the above copyright
10
// notice, this list of conditions and the following disclaimer.
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.
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.
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.
35
#include "../Include/intermediate.h"
37
class TAliveTraverser : public TIntermTraverser {
39
TAliveTraverser(TQualifier q) : TIntermTraverser(), found(false), qualifier(q)
41
visitSymbol = AliveSymbol;
42
visitSelection = AliveSelection;
45
bool wasFound() { return found; }
50
friend void AliveSymbol(TIntermSymbol*, TIntermTraverser*);
51
friend bool AliveSelection(bool, TIntermSelection*, TIntermTraverser*);
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.
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.
62
bool QualifierWritten(TIntermNode* node, TQualifier qualifier)
64
TAliveTraverser it(qualifier);
72
void AliveSymbol(TIntermSymbol* node, TIntermTraverser* it)
74
TAliveTraverser* lit = static_cast<TAliveTraverser*>(it);
77
// If it's what we're looking for, record it.
79
if (node->getQualifier() == lit->qualifier)
83
bool AliveSelection(bool preVisit, TIntermSelection* node, TIntermTraverser* it)
85
TAliveTraverser* lit = static_cast<TAliveTraverser*>(it);