model_server/lde/src/lde_smt_flowchart.cxx
//
// build chart node for if, else, or else_if condition,
// and a chart node box for the statements,
// connect condition node to ldr_prev; 
// if index = 0, condition is if_test and the box is a true branch;
// build connector nodes and attach them as children to the exit
build chart node for if, else, or else_if condition,
and a chart node box for the statements,
connect condition node to ldr_prev;
if index = 0, condition is if_test and the box is a true branch;
build connector nodes and attach them as children to the exit
build chart node for if else or else_if condition and a chart node box for the statements connect condition node to ldr_prev ; if index = 0 condition is if_test and the box is a true branch ; build connector nodes and attach them as children to the exit
void build_if_clause (ldrNodePtr &ldr_prev, ldrChartNodePtr &ldr_prev_cond,
      ldrSymbolNodePtr if_exit, smtTreePtr smt_clause, int level)
{
  ldrChartNodePtr ldr_branch;            
  ldrChartNodePtr ldr_body;              
  ldrChartNodePtr ldr_cond;              
  ldrNodePtr      branch_box;
  smtTreePtr      smt_cond;
  smtTreePtr      smt_branch;
  int             this_level;
  ldrRole         ldr_role;
  ldrConnectorType     end_conn_type;
  ldrConnectionNodePtr if_then_connect,
                       if_else_connect,
                       end_if_connect;
  ldrChartNodePtr ldr_yes;               
  ldrSymbolType   sym_type = ldrIF_FLOW;
  Initialize(build_if_clause);
  smt_cond = smt_clause->get_first();
  if (ldr_prev_cond == NULL){                  
      this_level = level;
      ldr_role = ldrFLOW_IF_TEST;
      end_conn_type = ldrcENDIF;
  }
  else{
      this_level = level + 1;
      if ( smt_clause->type == SMT_else_clause ){
              ldr_role = ldrLAST_ELSE;
              sym_type = ldrFLOW_EMPTY;
      }
      else
          ldr_role = ldrFLOW_ELSE;
      end_conn_type = ldrcENDELSE;
  }
  ldr_cond = build_simple_node(smt_cond, this_level, 
                               sym_type, ldr_role); 
  if (ldr_prev_cond == NULL)
      ldr_prev->put_first(ldr_cond);
  else
      ldr_prev->put_after(ldr_cond);
  smt_branch = get_next_smt(smt_cond);
  ldr_body   = lde_build_smt_flowchart(smt_branch, this_level + 1);
  if (!ldr_body) {
     msg("STATUS: Missing conditional information - flowchart may be incomplete") << eom;
     return;
  }
  branch_box = checked_cast(ldrNode, ldr_body->get_first());
  if ( ! branch_box->ldrIsA(ldrContainerNodeType) )
      ldr_branch = build_block_ldr(smt_branch, this_level + 1,
                                   ldr_body);
  else
      ldr_branch = ldr_body;
  ldr_cond->put_after(ldr_branch);
  if (ldr_role != ldrLAST_ELSE){
      ldr_yes = build_simple_node(NULL, this_level + 1,
                                  ldrFLOW_YES, ldrIF_YES);
      ldr_cond->put_after(ldr_yes);
  }
  if_then_connect = connect1_1(ldr_cond, ldr_branch,
                        ldrcTRUE_BRANCH, this_level+1);
  if_exit->put_first(if_then_connect);
  end_if_connect = connect1_1(ldr_branch, if_exit, 
                              end_conn_type, this_level+1);
  if_exit->put_first(end_if_connect);
  if (ldr_prev_cond != NULL){         
      if_else_connect = connect1_1(ldr_prev_cond, ldr_cond,
                                   ldrcIF_ELSE, this_level+1);
      if_exit->put_first(if_else_connect);
  }
  ldr_prev      = ldr_branch;
  ldr_prev_cond = ldr_cond;
  return;
}
void build_if_clause ( ldrNodePtr & ldr_prev , ldrChartNodePtr & ldr_prev_cond , ldrSymbolNodePtr if_exit , smtTreePtr smt_clause , int level ) { ldrChartNodePtr ldr_branch ; ldrChartNodePtr ldr_body ; ldrChartNodePtr ldr_cond ; ldrNodePtr branch_box ; smtTreePtr smt_cond ; smtTreePtr smt_branch ; int this_level ; ldrRole ldr_role ; ldrConnectorType end_conn_type ; ldrConnectionNodePtr if_then_connect , if_else_connect , end_if_connect ; ldrChartNodePtr ldr_yes ; ldrSymbolType sym_type = ldrIF_FLOW ; Initialize ( build_if_clause ) ; smt_cond = smt_clause -> get_first ( ) ; if ( ldr_prev_cond == NULL ) { this_level = level ; ldr_role = ldrFLOW_IF_TEST ; end_conn_type = ldrcENDIF ; } else { this_level = level + 1 ; if ( smt_clause -> type == SMT_else_clause ) { ldr_role = ldrLAST_ELSE ; sym_type = ldrFLOW_EMPTY ; } else ldr_role = ldrFLOW_ELSE ; end_conn_type = ldrcENDELSE ; } ldr_cond = build_simple_node ( smt_cond , this_level , sym_type , ldr_role ) ; if ( ldr_prev_cond == NULL ) ldr_prev -> put_first ( ldr_cond ) ; else ldr_prev -> put_after ( ldr_cond ) ; smt_branch = get_next_smt ( smt_cond ) ; ldr_body = lde_build_smt_flowchart ( smt_branch , this_level + 1 ) ; if ( ! ldr_body ) { msg ( " " ) << eom ; return ; } branch_box = checked_cast ( ldrNode , ldr_body -> get_first ( ) ) ; if ( ! branch_box -> ldrIsA ( ldrContainerNodeType ) ) ldr_branch = build_block_ldr ( smt_branch , this_level + 1 , ldr_body ) ; else ldr_branch = ldr_body ; ldr_cond -> put_after ( ldr_branch ) ; if ( ldr_role != ldrLAST_ELSE ) { ldr_yes = build_simple_node ( NULL , this_level + 1 , ldrFLOW_YES , ldrIF_YES ) ; ldr_cond -> put_after ( ldr_yes ) ; } if_then_connect = connect1_1 ( ldr_cond , ldr_branch , ldrcTRUE_BRANCH , this_level + 1 ) ; if_exit -> put_first ( if_then_connect ) ; end_if_connect = connect1_1 ( ldr_branch , if_exit , end_conn_type , this_level + 1 ) ; if_exit -> put_first ( end_if_connect ) ; if ( ldr_prev_cond != NULL ) { if_else_connect = connect1_1 ( ldr_prev_cond , ldr_cond , ldrcIF_ELSE , this_level + 1 ) ; if_exit -> put_first ( if_else_connect ) ; } ldr_prev = ldr_branch ; ldr_prev_cond = ldr_cond ; return ; }
build chart node for if, else, or else_if condition,
and a chart node box for the statements,
connect condition node to ldr_prev;
if index = 0, condition is if_test and the box is a true branch;
build connector nodes and attach them as children to the exit
build chart node for if else or else_if condition and a chart node box for the statements connect condition node to ldr_prev ; if index = 0 condition is if_test and the box is a true branch ; build connector nodes and attach them as children to the exit
// true branch node // and a box around it // condition node (if/else) // to place "YES" text //------  Executable code ---------------------- // if test clause // process clause first child - if/else condition // - same symbol ldrIF_FLOW for if and else // process clause's next child - branch statements (can be  // either a block or one executable stmt, but with possible comments) // if branch is a box all done // put "YES" text creating fake nodes //-------------------- build connectors  and put after total exit // if-else or else_if - else