- Timestamp:
- Dec 10, 2008, 7:31:39 PM (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/IPs/systemC/processor/Morpheo/Behavioural/src/Stat_binary_tree_valid.cpp
r81 r88 4 4 namespace morpheo { 5 5 namespace behavioural { 6 6 7 bool Stat_binary_tree::valid (void) 7 8 { 9 if (_data_type == NONE) 10 return false; 11 8 12 if ((_data_type == VARIABLE) or 9 13 (_data_type == CONSTANT)) 10 14 return ((_left == NULL) and 11 12 15 (_right == NULL) ); 16 13 17 if (_data_type == OPERATOR_UNARY) 14 18 return ((_right == NULL) and 15 16 19 (_left != NULL) and 20 (_left->valid())); 17 21 18 22 if (_data_type == OPERATOR_BINARY) 19 23 return ((_left != NULL ) and 20 21 22 24 (_left ->valid()) and 25 (_right != NULL ) and 26 (_right->valid())); 23 27 24 28 return false; 25 29 } 30 31 void Stat_binary_tree::print (uint32_t depth) 32 { 33 std::string tab = std::string(depth,'\t'); 34 std::string sep = " "; 35 if (_data_type == NONE) 36 { 37 std::cout << tab << "<node> NONE (error)" << std::endl; 38 39 if (_left != NULL) 40 _left ->print(depth+1); 41 if (_right != NULL) 42 _right->print(depth+1); 43 } 44 45 if ((_data_type == VARIABLE) or 46 (_data_type == CONSTANT)) 47 { 48 std::cout << tab << "<leaf>" 49 << " " 50 << ((_left == NULL)?"left == NULL ":"left != NULL (error)") 51 << " " 52 << ((_right == NULL)?"right == NULL ":"right != NULL (error)") 53 << std::endl; 54 55 if (_left != NULL) 56 _left ->print(depth+1); 57 if (_right != NULL) 58 _right->print(depth+1); 59 } 60 61 if (_data_type == OPERATOR_UNARY) 62 { 63 std::cout << tab << "<unary>" 64 << " " 65 << ((_left == NULL)?"left == NULL (error)":"left != NULL ") 66 << " " 67 << ((_right == NULL)?"right == NULL ":"right != NULL (error)") 68 << std::endl; 69 70 if (_left != NULL) 71 _left ->print(depth+1); 72 if (_right != NULL) 73 _right->print(depth+1); 74 } 75 76 if (_data_type == OPERATOR_BINARY) 77 { 78 std::cout << tab << "<binary>" 79 << " " 80 << ((_left == NULL)?"left == NULL (error)":"left != NULL ") 81 << " " 82 << ((_right == NULL)?"right == NULL (error)":"right != NULL ") 83 << std::endl; 84 85 if (_left != NULL) 86 _left ->print(depth+1); 87 if (_right != NULL) 88 _right->print(depth+1); 89 } 90 } 91 26 92 }; 27 93 };
Note: See TracChangeset
for help on using the changeset viewer.