blob: 9c4162ecbc4e2a881e817759fc1e2fae1edcdb60 [file] [log] [blame]
daniel@transgaming.com4f39fd92010-03-08 20:26:45 +00001//
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
13class RemoveTree : public TIntermTraverser
14{
15public:
16 RemoveTree() : TIntermTraverser(false, false, true)
17 {
18 }
19
20protected:
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
29void RemoveTree::visitSymbol(TIntermSymbol* node)
30{
31 delete node;
32}
33
34bool RemoveTree::visitBinary(Visit visit, TIntermBinary* node)
35{
36 delete node;
37
38 return true;
39}
40
41bool RemoveTree::visitUnary(Visit visit, TIntermUnary* node)
42{
43 delete node;
44
45 return true;
46}
47
48bool RemoveTree::visitAggregate(Visit visit, TIntermAggregate* node)
49{
50 delete node;
51
52 return true;
53}
54
55bool RemoveTree::visitSelection(Visit visit, TIntermSelection* node)
56{
57 delete node;
58
59 return true;
60}
61
62void RemoveTree::visitConstantUnion(TIntermConstantUnion* node)
63{
64 delete node;
65}
66
67//
68// Entry point.
69//
70void RemoveAllTreeNodes(TIntermNode* root)
71{
72 RemoveTree it;
73
74 root->traverse(&it);
75}
76