Home | History | Annotate | Download | only in compiler
      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 	RemoveTree() : TIntermTraverser(false, false, true)
     18 	{
     19 	}
     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 void RemoveTree::visitSymbol(TIntermSymbol* node)
     31 {
     32 	delete node;
     33 }
     34 
     35 bool RemoveTree::visitBinary(Visit visit, TIntermBinary* node)
     36 {
     37 	delete node;
     38 
     39 	return true;
     40 }
     41 
     42 bool RemoveTree::visitUnary(Visit visit, TIntermUnary* node)
     43 {
     44     delete node;
     45 
     46 	return true;
     47 }
     48 
     49 bool RemoveTree::visitAggregate(Visit visit, TIntermAggregate* node)
     50 {
     51 	delete node;
     52 
     53 	return true;
     54 }
     55 
     56 bool RemoveTree::visitSelection(Visit visit, TIntermSelection* node)
     57 {
     58 	delete node;
     59 
     60 	return true;
     61 }
     62 
     63 void RemoveTree::visitConstantUnion(TIntermConstantUnion* node)
     64 {
     65 	delete node;
     66 }
     67 
     68 //
     69 // Entry point.
     70 //
     71 void RemoveAllTreeNodes(TIntermNode* root)
     72 {
     73     RemoveTree it;
     74 
     75     root->traverse(&it);
     76 }
     77 
     78