model_server/lde/src/lde_smt_flowchart.cxx
// ------------------  BLOCK ------------------------------
//
// builds a block around either chain of app_nodes for
//          tree of appTree nodes starting from smt_block;
//          in last case  input ldr_node = NULL;  if ldr role is
//          supplied, set it to root
BLOCK
builds a block around either chain of app_nodes for
tree of appTree nodes starting from smt_block;
in last case  input ldr_node = NULL;  if ldr role is
supplied, set it to root
BLOCK builds a block around either chain of app_nodes for tree of appTree nodes starting from smt_block ; in last case input ldr_node = NULL ; if ldr role is supplied set it to root
ldrChartNodePtr build_block_ldr(smtTreePtr smt_block, int level,
                ldrChartNodePtr ldr_node, ldrRole l_role)
{
   ldrSymbolNodePtr exit_symbol   = db_new(ldrSymbolNode, (ldrFLOW_EMPTY));
   ldrSymbolNodePtr entry_symbol  = db_new(ldrSymbolNode, (ldrENTRY_SYMBOL));
   ldrContainerNodePtr the_box  = db_new(ldrContainerNode,());
   ldrChartNodePtr     root     = db_new (ldrChartNode,
                                                (ldrFLOW_EMPTY));
   ldrSymbolNodePtr    prev_child = entry_symbol;
   ldrConnectionNodePtr connect_node;
   int                 skip_decl;     
   Initialize(build_block_ldr);
   the_box->set_graphlevel(level);
   the_box->set_role(ldrCONTAINMENT);
   entry_symbol->set_role(ldrENTRY);
   entry_symbol->set_graphlevel(level+1);
   exit_symbol->set_role(ldrEXIT);
   exit_symbol->set_graphlevel(level+1);
   root->set_entry_symbol(entry_symbol);
   root->set_exit_symbol(exit_symbol);
   root->set_graphlevel(level);
   root->put_first(the_box);
   root->set_role(l_role);
   the_box->put_after(entry_symbol);
   if ( smt_block->type == SMT_cbody )
       skip_decl = 0;
   else
       skip_decl = 1;
   if (ldr_node == NULL)
   {
      smtTreePtr smt_child = smt_block->get_first();
      while( smt_child != NULL )
      {
          ldrChartNodePtr curr_child = 
              lde_build_smt_flowchart(smt_child, level+1);
          if (curr_child != NULL){
              prev_child->put_after(curr_child);
              if (prev_child->get_role() != ldrENTRY &&
                  skip_decl != 0 ){
                  connect_node = connect1_1(prev_child,
                           curr_child, ldrcSEQUENCE, level + 1);
                  curr_child->put_after(connect_node);
              }
              prev_child = curr_child;
          }
          smt_child = get_next_smt(smt_child, skip_decl);
       }
       prev_child->put_after(exit_symbol);
   }
   else{          
       reset_level(ldr_node);      
       entry_symbol->put_after(ldr_node);
       ldrChartNodePtr ldr_last = build_chain(ldr_node, level+1);
       if (ldr_last == NULL)
           ldr_last = ldr_node;
       ldr_last->put_after(exit_symbol);
   }
   root->set_appTree(smt_block);
   return(root);
}
ldrChartNodePtr build_block_ldr ( smtTreePtr smt_block , int level , ldrChartNodePtr ldr_node , ldrRole l_role ) { ldrSymbolNodePtr exit_symbol = db_new ( ldrSymbolNode , ( ldrFLOW_EMPTY ) ) ; ldrSymbolNodePtr entry_symbol = db_new ( ldrSymbolNode , ( ldrENTRY_SYMBOL ) ) ; ldrContainerNodePtr the_box = db_new ( ldrContainerNode , ( ) ) ; ldrChartNodePtr root = db_new ( ldrChartNode , ( ldrFLOW_EMPTY ) ) ; ldrSymbolNodePtr prev_child = entry_symbol ; ldrConnectionNodePtr connect_node ; int skip_decl ; Initialize ( build_block_ldr ) ; the_box -> set_graphlevel ( level ) ; the_box -> set_role ( ldrCONTAINMENT ) ; entry_symbol -> set_role ( ldrENTRY ) ; entry_symbol -> set_graphlevel ( level + 1 ) ; exit_symbol -> set_role ( ldrEXIT ) ; exit_symbol -> set_graphlevel ( level + 1 ) ; root -> set_entry_symbol ( entry_symbol ) ; root -> set_exit_symbol ( exit_symbol ) ; root -> set_graphlevel ( level ) ; root -> put_first ( the_box ) ; root -> set_role ( l_role ) ; the_box -> put_after ( entry_symbol ) ; if ( smt_block -> type == SMT_cbody ) skip_decl = 0 ; else skip_decl = 1 ; if ( ldr_node == NULL ) { smtTreePtr smt_child = smt_block -> get_first ( ) ; while ( smt_child != NULL ) { ldrChartNodePtr curr_child = lde_build_smt_flowchart ( smt_child , level + 1 ) ; if ( curr_child != NULL ) { prev_child -> put_after ( curr_child ) ; if ( prev_child -> get_role ( ) != ldrENTRY && skip_decl != 0 ) { connect_node = connect1_1 ( prev_child , curr_child , ldrcSEQUENCE , level + 1 ) ; curr_child -> put_after ( connect_node ) ; } prev_child = curr_child ; } smt_child = get_next_smt ( smt_child , skip_decl ) ; } prev_child -> put_after ( exit_symbol ) ; } else { reset_level ( ldr_node ) ; entry_symbol -> put_after ( ldr_node ) ; ldrChartNodePtr ldr_last = build_chain ( ldr_node , level + 1 ) ; if ( ldr_last == NULL ) ldr_last = ldr_node ; ldr_last -> put_after ( exit_symbol ) ; } root -> set_appTree ( smt_block ) ; return ( root ) ; }
BLOCK
builds a block around either chain of app_nodes for
tree of appTree nodes starting from smt_block;
in last case  input ldr_node = NULL;  if ldr role is
supplied, set it to root
BLOCK builds a block around either chain of app_nodes for tree of appTree nodes starting from smt_block ; in last case input ldr_node = NULL ; if ldr role is supplied set it to root
// flag = 0, if not skipping //------  Executable code ---------------------- // if processing CLASS node don't skip declarations of smt //    dive inside smt block; no existing ldr node is given //            connect nodes // build block around chain of smt nodes starting from // existing ldr node // reset all levels (+1)