Ignore:
Timestamp:
Dec 10, 2008, 7:31:39 PM (15 years ago)
Author:
rosiere
Message:

Almost complete design
with Test and test platform

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/IPs/systemC/processor/Morpheo/Behavioural/src/Stat_binary_tree_valid.cpp

    r81 r88  
    44namespace morpheo {
    55namespace behavioural {
     6
    67  bool Stat_binary_tree::valid (void)
    78  {
     9    if (_data_type == NONE)
     10      return false;
     11
    812    if ((_data_type == VARIABLE) or
    913        (_data_type == CONSTANT))
    1014      return ((_left  == NULL) and
    11               (_right == NULL) );
    12 
     15              (_right == NULL) );
     16   
    1317    if (_data_type == OPERATOR_UNARY)
    1418      return ((_right == NULL) and
    15               (_left  != NULL) and
    16               (_left->valid()));
     19              (_left  != NULL) and
     20              (_left->valid()));
    1721
    1822    if (_data_type == OPERATOR_BINARY)
    1923      return ((_left  != NULL ) and
    20               (_left ->valid()) and
    21               (_right != NULL ) and
    22               (_right->valid()));
     24              (_left ->valid()) and
     25              (_right != NULL ) and
     26              (_right->valid()));
    2327
    2428    return false;
    2529  }
     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
    2692};
    2793};
Note: See TracChangeset for help on using the changeset viewer.