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 "compiler/intermediate.h"
8 : #include "compiler/RemoveTree.h"
9 :
10 : //
11 : // Code to recursively delete the intermediate tree.
12 : //
13 :
14 : class RemoveTree : public TIntermTraverser
15 : {
16 : public:
17 0 : RemoveTree() : TIntermTraverser(false, false, true)
18 : {
19 0 : }
20 :
21 : protected:
22 : void visitSymbol(TIntermSymbol*);
23 : void visitConstantUnion(TIntermConstantUnion*);
24 : bool visitBinary(Visit visit, TIntermBinary*);
25 : bool visitUnary(Visit visit, TIntermUnary*);
26 : bool visitSelection(Visit visit, TIntermSelection*);
27 : bool visitAggregate(Visit visit, TIntermAggregate*);
28 : };
29 :
30 0 : void RemoveTree::visitSymbol(TIntermSymbol* node)
31 : {
32 0 : delete node;
33 0 : }
34 :
35 0 : bool RemoveTree::visitBinary(Visit visit, TIntermBinary* node)
36 : {
37 0 : delete node;
38 :
39 0 : return true;
40 : }
41 :
42 0 : bool RemoveTree::visitUnary(Visit visit, TIntermUnary* node)
43 : {
44 0 : delete node;
45 :
46 0 : return true;
47 : }
48 :
49 0 : bool RemoveTree::visitAggregate(Visit visit, TIntermAggregate* node)
50 : {
51 0 : delete node;
52 :
53 0 : return true;
54 : }
55 :
56 0 : bool RemoveTree::visitSelection(Visit visit, TIntermSelection* node)
57 : {
58 0 : delete node;
59 :
60 0 : return true;
61 : }
62 :
63 0 : void RemoveTree::visitConstantUnion(TIntermConstantUnion* node)
64 : {
65 0 : delete node;
66 0 : }
67 :
68 : //
69 : // Entry point.
70 : //
71 0 : void RemoveAllTreeNodes(TIntermNode* root)
72 : {
73 0 : RemoveTree it;
74 :
75 0 : root->traverse(&it);
76 0 : }
77 :
|