michael@0: // michael@0: // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. michael@0: // Use of this source code is governed by a BSD-style license that can be michael@0: // found in the LICENSE file. michael@0: // michael@0: michael@0: #include "compiler/intermediate.h" michael@0: #include "compiler/RemoveTree.h" michael@0: michael@0: // michael@0: // Code to recursively delete the intermediate tree. michael@0: // michael@0: michael@0: class RemoveTree : public TIntermTraverser michael@0: { michael@0: public: michael@0: RemoveTree() : TIntermTraverser(false, false, true) michael@0: { michael@0: } michael@0: michael@0: protected: michael@0: void visitSymbol(TIntermSymbol*); michael@0: void visitConstantUnion(TIntermConstantUnion*); michael@0: bool visitBinary(Visit visit, TIntermBinary*); michael@0: bool visitUnary(Visit visit, TIntermUnary*); michael@0: bool visitSelection(Visit visit, TIntermSelection*); michael@0: bool visitAggregate(Visit visit, TIntermAggregate*); michael@0: }; michael@0: michael@0: void RemoveTree::visitSymbol(TIntermSymbol* node) michael@0: { michael@0: delete node; michael@0: } michael@0: michael@0: bool RemoveTree::visitBinary(Visit visit, TIntermBinary* node) michael@0: { michael@0: delete node; michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool RemoveTree::visitUnary(Visit visit, TIntermUnary* node) michael@0: { michael@0: delete node; michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool RemoveTree::visitAggregate(Visit visit, TIntermAggregate* node) michael@0: { michael@0: delete node; michael@0: michael@0: return true; michael@0: } michael@0: michael@0: bool RemoveTree::visitSelection(Visit visit, TIntermSelection* node) michael@0: { michael@0: delete node; michael@0: michael@0: return true; michael@0: } michael@0: michael@0: void RemoveTree::visitConstantUnion(TIntermConstantUnion* node) michael@0: { michael@0: delete node; michael@0: } michael@0: michael@0: // michael@0: // Entry point. michael@0: // michael@0: void RemoveAllTreeNodes(TIntermNode* root) michael@0: { michael@0: RemoveTree it; michael@0: michael@0: root->traverse(&it); michael@0: } michael@0: