gfx/angle/src/compiler/QualifierAlive.cpp

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/gfx/angle/src/compiler/QualifierAlive.cpp	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,58 @@
     1.4 +//
     1.5 +// Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved.
     1.6 +// Use of this source code is governed by a BSD-style license that can be
     1.7 +// found in the LICENSE file.
     1.8 +//
     1.9 +
    1.10 +#include "compiler/intermediate.h"
    1.11 +
    1.12 +class TAliveTraverser : public TIntermTraverser {
    1.13 +public:
    1.14 +    TAliveTraverser(TQualifier q) : TIntermTraverser(true, false, false, true), found(false), qualifier(q)
    1.15 +    {
    1.16 +    }
    1.17 +
    1.18 +	bool wasFound() { return found; }
    1.19 +
    1.20 +protected:
    1.21 +    bool found;
    1.22 +    TQualifier qualifier;
    1.23 +
    1.24 +    void visitSymbol(TIntermSymbol*);
    1.25 +    bool visitSelection(Visit, TIntermSelection*);
    1.26 +};
    1.27 +
    1.28 +//
    1.29 +// Report whether or not a variable of the given qualifier type
    1.30 +// is guaranteed written.  Not always possible to determine if
    1.31 +// it is written conditionally.
    1.32 +//
    1.33 +// ?? It does not do this well yet, this is just a place holder
    1.34 +// that simply determines if it was reference at all, anywhere.
    1.35 +//
    1.36 +bool QualifierWritten(TIntermNode* node, TQualifier qualifier)
    1.37 +{
    1.38 +    TAliveTraverser it(qualifier);
    1.39 +
    1.40 +    if (node)
    1.41 +        node->traverse(&it);
    1.42 +
    1.43 +    return it.wasFound();
    1.44 +}
    1.45 +
    1.46 +void TAliveTraverser::visitSymbol(TIntermSymbol* node)
    1.47 +{
    1.48 +    //
    1.49 +    // If it's what we're looking for, record it.
    1.50 +    //
    1.51 +    if (node->getQualifier() == qualifier)
    1.52 +        found = true;
    1.53 +}
    1.54 +
    1.55 +bool TAliveTraverser::visitSelection(Visit preVisit, TIntermSelection* node)
    1.56 +{
    1.57 +    if (wasFound())
    1.58 +        return false;
    1.59 +
    1.60 +    return true;
    1.61 +}

mercurial