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