daniel@transgaming.com | 4f39fd9 | 2010-03-08 20:26:45 +0000 | [diff] [blame^] | 1 | // |
| 2 | // Copyright (c) 2002-2010 The ANGLE Project Authors. All rights reserved. |
| 3 | // Use of this source code is governed by a BSD-style license that can be |
| 4 | // found in the LICENSE file. |
| 5 | // |
| 6 | |
| 7 | #include "intermediate.h" |
| 8 | #include "RemoveTree.h" |
| 9 | // |
| 10 | // Code to recursively delete the intermediate tree. |
| 11 | // |
| 12 | |
| 13 | class RemoveTree : public TIntermTraverser |
| 14 | { |
| 15 | public: |
| 16 | RemoveTree() : TIntermTraverser(false, false, true) |
| 17 | { |
| 18 | } |
| 19 | |
| 20 | protected: |
| 21 | void visitSymbol(TIntermSymbol*); |
| 22 | void visitConstantUnion(TIntermConstantUnion*); |
| 23 | bool visitBinary(Visit visit, TIntermBinary*); |
| 24 | bool visitUnary(Visit visit, TIntermUnary*); |
| 25 | bool visitSelection(Visit visit, TIntermSelection*); |
| 26 | bool visitAggregate(Visit visit, TIntermAggregate*); |
| 27 | }; |
| 28 | |
| 29 | void RemoveTree::visitSymbol(TIntermSymbol* node) |
| 30 | { |
| 31 | delete node; |
| 32 | } |
| 33 | |
| 34 | bool RemoveTree::visitBinary(Visit visit, TIntermBinary* node) |
| 35 | { |
| 36 | delete node; |
| 37 | |
| 38 | return true; |
| 39 | } |
| 40 | |
| 41 | bool RemoveTree::visitUnary(Visit visit, TIntermUnary* node) |
| 42 | { |
| 43 | delete node; |
| 44 | |
| 45 | return true; |
| 46 | } |
| 47 | |
| 48 | bool RemoveTree::visitAggregate(Visit visit, TIntermAggregate* node) |
| 49 | { |
| 50 | delete node; |
| 51 | |
| 52 | return true; |
| 53 | } |
| 54 | |
| 55 | bool RemoveTree::visitSelection(Visit visit, TIntermSelection* node) |
| 56 | { |
| 57 | delete node; |
| 58 | |
| 59 | return true; |
| 60 | } |
| 61 | |
| 62 | void RemoveTree::visitConstantUnion(TIntermConstantUnion* node) |
| 63 | { |
| 64 | delete node; |
| 65 | } |
| 66 | |
| 67 | // |
| 68 | // Entry point. |
| 69 | // |
| 70 | void RemoveAllTreeNodes(TIntermNode* root) |
| 71 | { |
| 72 | RemoveTree it; |
| 73 | |
| 74 | root->traverse(&it); |
| 75 | } |
| 76 | |