Wed, 31 Dec 2014 07:16:47 +0100
Revert simplistic fix pending revisit of Mozilla integration attempt.
michael@0 | 1 | // |
michael@0 | 2 | // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
michael@0 | 3 | // Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | // found in the LICENSE file. |
michael@0 | 5 | // |
michael@0 | 6 | |
michael@0 | 7 | #include "compiler/intermediate.h" |
michael@0 | 8 | |
michael@0 | 9 | class TAliveTraverser : public TIntermTraverser { |
michael@0 | 10 | public: |
michael@0 | 11 | TAliveTraverser(TQualifier q) : TIntermTraverser(true, false, false, true), found(false), qualifier(q) |
michael@0 | 12 | { |
michael@0 | 13 | } |
michael@0 | 14 | |
michael@0 | 15 | bool wasFound() { return found; } |
michael@0 | 16 | |
michael@0 | 17 | protected: |
michael@0 | 18 | bool found; |
michael@0 | 19 | TQualifier qualifier; |
michael@0 | 20 | |
michael@0 | 21 | void visitSymbol(TIntermSymbol*); |
michael@0 | 22 | bool visitSelection(Visit, TIntermSelection*); |
michael@0 | 23 | }; |
michael@0 | 24 | |
michael@0 | 25 | // |
michael@0 | 26 | // Report whether or not a variable of the given qualifier type |
michael@0 | 27 | // is guaranteed written. Not always possible to determine if |
michael@0 | 28 | // it is written conditionally. |
michael@0 | 29 | // |
michael@0 | 30 | // ?? It does not do this well yet, this is just a place holder |
michael@0 | 31 | // that simply determines if it was reference at all, anywhere. |
michael@0 | 32 | // |
michael@0 | 33 | bool QualifierWritten(TIntermNode* node, TQualifier qualifier) |
michael@0 | 34 | { |
michael@0 | 35 | TAliveTraverser it(qualifier); |
michael@0 | 36 | |
michael@0 | 37 | if (node) |
michael@0 | 38 | node->traverse(&it); |
michael@0 | 39 | |
michael@0 | 40 | return it.wasFound(); |
michael@0 | 41 | } |
michael@0 | 42 | |
michael@0 | 43 | void TAliveTraverser::visitSymbol(TIntermSymbol* node) |
michael@0 | 44 | { |
michael@0 | 45 | // |
michael@0 | 46 | // If it's what we're looking for, record it. |
michael@0 | 47 | // |
michael@0 | 48 | if (node->getQualifier() == qualifier) |
michael@0 | 49 | found = true; |
michael@0 | 50 | } |
michael@0 | 51 | |
michael@0 | 52 | bool TAliveTraverser::visitSelection(Visit preVisit, TIntermSelection* node) |
michael@0 | 53 | { |
michael@0 | 54 | if (wasFound()) |
michael@0 | 55 | return false; |
michael@0 | 56 | |
michael@0 | 57 | return true; |
michael@0 | 58 | } |