PIPS
icfg.h File Reference
#include "dg.h"
#include "graph.h"
+ Include dependency graph for icfg.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define ICFG_NOT_FOUND   NULL
 Warning! Do not modify this file that is automatically generated! More...
 
#define ICFG_OPTIONS   "tcdDIFl"
 
#define ICFG_CALLEES_TOPO_SORT   "ICFG_CALLEES_TOPO_SORT"
 
#define ICFG_DRAW   "ICFG_DRAW"
 
#define ICFG_DEBUG   "ICFG_DEBUG"
 
#define ICFG_DEBUG_LEVEL   "ICFG_DEBUG_LEVEL"
 
#define ICFG_DOs   "ICFG_DOs"
 
#define ICFG_IFs   "ICFG_IFs"
 
#define ICFG_DV   "ICFG_DV"
 
#define ICFG_FLOATs   "ICFG_FLOATs"
 
#define ICFG_SHORT_NAMES   "ICFG_SHORT_NAMES"
 
#define CALL_MARK   "CALL_MARK@@@@"
 
#define ADD_ELEMENT_TO_LIST(_list, _type, _element)    (_list = gen_nconc( _list, CONS( _type, _element, NIL)))
 

Typedefs

typedef dg_arc_label arc_label
 
typedef dg_vertex_label vertex_label
 

Functions

list module_name_to_callees (const char *)
 cproto-generated files More...
 
list module_to_callees (entity)
 
void topological_number_assign_to_module (hash_table, entity, size_t)
 
list module_list_sort (hash_table, list, entity, size_t)
 
list topologically_sorted_module_list (entity)
 
void print_module_name_to_toposorts (const char *)
 
void icfg_set_indentation (int)
 icfg_scan.c More...
 
void icfg_reset_indentation (void)
 
void icfg_error_handler (void)
 
bool generic_print_icfg (const string, bool, bool, bool, text(*)(const string))
 
bool generic_print_icfg_precise (const string, bool, bool, bool, text(*)(entity, entity, statement, call))
 
bool generic_print_icfg_filtered (const string, bool, bool, bool, text(*)(entity, statement, call), text(*)(entity, statement))
 
bool print_icfg (const string)
 print.c More...
 
bool print_icfg_with_loops (const string)
 
bool print_icfg_with_control (const string)
 
void safe_free_vertex (vertex, list)
 util.c More...
 
list safe_add_vertex_to_list (vertex, list)
 
list list_of_connected_nodes (vertex, list)
 
vertex get_vertex_by_string (const char *, list)
 
list safe_make_successor (vertex, vertex, list)
 
void print_graph_of_text_to_daVinci (FILE *, list)
 
void print_graph_daVinci_from_starting_node (FILE *, vertex)
 
void print_marged_text_from_starting_node (FILE *, int, vertex, list)
 
bool make_resource_from_starting_node (const char *, string, string, vertex, list, bool)
 

Macro Definition Documentation

◆ ADD_ELEMENT_TO_LIST

#define ADD_ELEMENT_TO_LIST (   _list,
  _type,
  _element 
)     (_list = gen_nconc( _list, CONS( _type, _element, NIL)))

Definition at line 58 of file icfg.h.

◆ CALL_MARK

#define CALL_MARK   "CALL_MARK@@@@"

Definition at line 57 of file icfg.h.

◆ ICFG_CALLEES_TOPO_SORT

#define ICFG_CALLEES_TOPO_SORT   "ICFG_CALLEES_TOPO_SORT"

Definition at line 40 of file icfg.h.

◆ ICFG_DEBUG

#define ICFG_DEBUG   "ICFG_DEBUG"

Definition at line 42 of file icfg.h.

◆ ICFG_DEBUG_LEVEL

#define ICFG_DEBUG_LEVEL   "ICFG_DEBUG_LEVEL"

Definition at line 43 of file icfg.h.

◆ ICFG_DOs

#define ICFG_DOs   "ICFG_DOs"

Definition at line 44 of file icfg.h.

◆ ICFG_DRAW

#define ICFG_DRAW   "ICFG_DRAW"

Definition at line 41 of file icfg.h.

◆ ICFG_DV

#define ICFG_DV   "ICFG_DV"

Definition at line 46 of file icfg.h.

◆ ICFG_FLOATs

#define ICFG_FLOATs   "ICFG_FLOATs"

Definition at line 47 of file icfg.h.

◆ ICFG_IFs

#define ICFG_IFs   "ICFG_IFs"

Definition at line 45 of file icfg.h.

◆ ICFG_NOT_FOUND

#define ICFG_NOT_FOUND   NULL

Warning! Do not modify this file that is automatically generated!

Modify src/Libs/icfg/icfg-local.h instead, to add your own modifications. header file built by cproto icfg-local.h

Definition at line 37 of file icfg.h.

◆ ICFG_OPTIONS

#define ICFG_OPTIONS   "tcdDIFl"

Definition at line 38 of file icfg.h.

◆ ICFG_SHORT_NAMES

#define ICFG_SHORT_NAMES   "ICFG_SHORT_NAMES"

Definition at line 48 of file icfg.h.

Typedef Documentation

◆ arc_label

Definition at line 52 of file icfg.h.

◆ vertex_label

Definition at line 53 of file icfg.h.

Function Documentation

◆ generic_print_icfg()

bool generic_print_icfg ( const  string,
bool  with_ifs,
bool  with_loops,
bool  do_graph,
text(*)(const string decoration 
)
Parameters
stringodule_name
with_ifsith_ifs
with_loopsith_loops
do_grapho_graph

Definition at line 713 of file icfg_scan.c.

719 {
720  return internal_print_icfg(module_name, with_ifs, with_loops, do_graph,
721  true, decoration, NULL, NULL, NULL);
722 }
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
static bool internal_print_icfg(const string module_name, bool with_ifs, bool with_loops, bool do_graph, bool do_reset, text(*deco1)(const string), text(*deco2)(entity, entity, statement, call), text(*deco3)(entity, statement, call), text(*deco4)(entity, statement))
Definition: icfg_scan.c:668

References internal_print_icfg(), and module_name().

Referenced by print_icfg(), print_icfg_with_control(), and print_icfg_with_loops().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ generic_print_icfg_filtered()

bool generic_print_icfg_filtered ( const  string,
bool  with_ifs,
bool  with_loops,
bool  do_graph,
text(*)(entity, statement, call decoration_call,
text(*)(entity, statement decoration_stmt 
)
Parameters
stringodule_name
with_ifsith_ifs
with_loopsith_loops
do_grapho_graph

Definition at line 735 of file icfg_scan.c.

742 {
743  return internal_print_icfg(module_name, with_ifs, with_loops, do_graph,
744  false, NULL, NULL, decoration_call, decoration_stmt);
745 }

References internal_print_icfg(), and module_name().

+ Here is the call graph for this function:

◆ generic_print_icfg_precise()

bool generic_print_icfg_precise ( const  string,
bool  with_ifs,
bool  with_loops,
bool  do_graph,
text(*)(entity, entity, statement, call decoration 
)
Parameters
stringodule_name
with_ifsith_ifs
with_loopsith_loops
do_grapho_graph

Definition at line 724 of file icfg_scan.c.

730 {
731  return internal_print_icfg(module_name, with_ifs, with_loops, do_graph,
732  true, NULL, decoration, NULL, NULL);
733 }

References internal_print_icfg(), and module_name().

+ Here is the call graph for this function:

◆ get_vertex_by_string()

vertex get_vertex_by_string ( const char *  str_name,
list  l_of_vers 
)
Parameters
str_nametr_name
l_of_vers_of_vers

Definition at line 92 of file util.c.

93 {
94  MAP(VERTEX, ver, {
95  text ver_label = (text)vertex_vertex_label(ver);
96  list sens = text_sentences(ver_label);
97  sentence ver_first_sen = SENTENCE(CAR(sens));
98  string ver_name = first_word_of_sentence(ver_first_sen);
99  string ver_real_name = remove_newline_of_string(ver_name);
100  if (same_string_p(ver_real_name, str_name) || same_string_p(ver_name, str_name)) {
101  free(ver_real_name);
102  return ver;
103  } else
104  free(ver_real_name);
105  }, l_of_vers);
106  return vertex_undefined;
107 }
void free(void *)
#define vertex_undefined
Definition: graph.h:128
#define vertex_vertex_label(x)
Definition: graph.h:152
#define VERTEX(x)
VERTEX.
Definition: graph.h:122
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
Definition: newgen_list.h:226
string remove_newline_of_string(string)
Definition: string.c:309
#define same_string_p(s1, s2)
int sens
facteur multiplicatif suivant qu'on analyse un terme
Definition: sc_gram.c:100
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
string first_word_of_sentence(sentence s)
Return the first word of a sentence:
Definition: util.c:76
struct _newgen_struct_text_ * text
Definition: text.h:23
#define SENTENCE(x)
newgen_unformatted_domain_defined
Definition: text.h:36
#define text_sentences(x)
Definition: text.h:113

References CAR, first_word_of_sentence(), free(), MAP, remove_newline_of_string(), same_string_p, sens, SENTENCE, text_sentences, VERTEX, vertex_undefined, and vertex_vertex_label.

Referenced by call_flt(), and print_marged_text_from_starting_node().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ icfg_error_handler()

void icfg_error_handler ( void  )

Definition at line 122 of file icfg_scan.c.

123 {
124  // ???
125 }

Referenced by print_module_icfg().

+ Here is the caller graph for this function:

◆ icfg_reset_indentation()

void icfg_reset_indentation ( void  )

Definition at line 117 of file icfg_scan.c.

118 {
120 }
#define ICFG_DEFAULT_INDENTATION
Definition: icfg_scan.c:82
static int icfg_indent
Definition: icfg_scan.c:83

References ICFG_DEFAULT_INDENTATION, and icfg_indent.

Referenced by internal_print_icfg().

+ Here is the caller graph for this function:

◆ icfg_set_indentation()

void icfg_set_indentation ( int  indent)

icfg_scan.c

icfg_scan.c

Parameters
indentndent

Definition at line 112 of file icfg_scan.c.

113 {
114  icfg_indent = indent;
115 }

References icfg_indent.

Referenced by internal_print_icfg().

+ Here is the caller graph for this function:

◆ list_of_connected_nodes()

list list_of_connected_nodes ( vertex  ver,
list  l_of_vers 
)
Parameters
verer
l_of_vers_of_vers

Definition at line 57 of file util.c.

58 {
59  MAP(SUCCESSOR, succ, {
60  vertex ver_child = successor_vertex(succ);
61  l_of_vers = safe_add_vertex_to_list(ver_child, l_of_vers);
62  l_of_vers = list_of_connected_nodes(ver_child, l_of_vers);
63  }, vertex_successors(ver));
64  return l_of_vers;
65 }
#define successor_vertex(x)
Definition: graph.h:118
#define vertex_successors(x)
Definition: graph.h:154
#define SUCCESSOR(x)
SUCCESSOR.
Definition: graph.h:86
list list_of_connected_nodes(vertex ver, list l_of_vers)
Definition: util.c:57
list safe_add_vertex_to_list(vertex ver, list l_of_vers)
Definition: util.c:50

References list_of_connected_nodes(), MAP, safe_add_vertex_to_list(), SUCCESSOR, successor_vertex, and vertex_successors.

Referenced by list_of_connected_nodes(), and print_graph_daVinci_from_starting_node().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ make_resource_from_starting_node()

bool make_resource_from_starting_node ( const char *  mod_name,
string  res_name,
string  file_ext,
vertex  start_ver,
list  l_of_vers,
bool  res_text_type 
)

ree(dir);

this line may cause a problem of bus errone

this line must be after DB_PUT_FILE_RESOURCE for the reason of memory liberation

Parameters
mod_nameod_name
res_namees_name
file_extile_ext
start_vertart_ver
l_of_vers_of_vers
res_text_typees_text_type

Definition at line 220 of file util.c.

222 {
223  string filename, localfilename, dir;
224  FILE *fd;
225 
226  localfilename = db_build_file_resource_name(res_name, mod_name, file_ext);
228  filename = strdup(concatenate(dir, "/", localfilename, NULL));
229  /*free(dir);*/ /* this line may cause a problem of bus errone*/
230 
231  fd = safe_fopen(filename, "w");
232  if (!vertex_undefined_p(start_ver)) {
233  if (res_text_type) {
234  print_marged_text_from_starting_node(fd, 0, start_ver, l_of_vers);
235  safe_fclose(fd, filename);
236  write_an_attachment_file(filename);
237  } else {
239  safe_fclose(fd, filename);
240  }
241  }
242  DB_PUT_FILE_RESOURCE(res_name, mod_name, localfilename);
243  free(filename); /* this line must be after DB_PUT_FILE_RESOURCE for the reason of memory liberation */
244 
245  return true;
246 }
void write_an_attachment_file(string file_name)
Add the attachment in Emacs mode by creating a twin file that is decorated with Emacs properties:
FILE * safe_fopen(const char *filename, const char *what)
Definition: file.c:67
int safe_fclose(FILE *stream, const char *filename)
Definition: file.c:77
#define vertex_undefined_p(x)
Definition: graph.h:129
#define DB_PUT_FILE_RESOURCE
Put a file resource into the current workspace database.
Definition: pipsdbm-local.h:85
void print_graph_daVinci_from_starting_node(FILE *f_out, vertex start_ver)
Definition: util.c:190
void print_marged_text_from_starting_node(FILE *fd, int margin, vertex start_ver, list l_of_vers)
Definition: util.c:200
string db_build_file_resource_name(const char *rname, const char *oname, const char *suffix)
returns an allocated file name for a file resource.
Definition: lowlevel.c:169
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
string db_get_current_workspace_directory(void)
Definition: workspace.c:96
char * strdup()

References concatenate(), db_build_file_resource_name(), db_get_current_workspace_directory(), DB_PUT_FILE_RESOURCE, free(), print_graph_daVinci_from_starting_node(), print_marged_text_from_starting_node(), safe_fclose(), safe_fopen(), strdup(), vertex_undefined_p, and write_an_attachment_file().

Referenced by print_module_icfg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_list_sort()

list module_list_sort ( hash_table  hash_module_to_depth,
list  current_list,
entity  mod,
size_t  n 
)

create the callees list whose caller has the depth n

free the same_depth_list for later use

create same_depth_list whose depth is n+1

concatenate former current_list with same_depth_list

use module_list_sort recursively

Parameters
hash_module_to_depthash_module_to_depth
current_listurrent_list
modod

Definition at line 123 of file toposort.c.

128 {
129  list callees_list = NIL;
130  static list same_depth_list = NIL;
131  size_t depth;
132 
133  /* create the callees list whose caller has the depth n */
134  if ( same_depth_list == NIL )
135  callees_list = module_to_callees(mod);
136  else {
137  MAPL(pm,{ entity e = ENTITY(CAR(pm));
138  callees_list = gen_nconc(callees_list,
140  },
141  same_depth_list);
142  }
143 
144  /* free the same_depth_list for later use */
145 
146  same_depth_list = NIL;
147 
148  /* create same_depth_list whose depth is n+1 */
149  if ( callees_list != NIL ) {
150  MAPL(pm,{ entity e = ENTITY(CAR(pm));
151  depth = (size_t) hash_get(hash_module_to_depth, (char *) e);
152  if ( depth == n+1 ) {
153  same_depth_list = gen_nconc(same_depth_list,
154  CONS(ENTITY, e, NIL));
155  hash_put(hash_module_to_depth,
156  (char *) e, (char *) -1);
157  }
158  },
159  callees_list);
160 
161  /* concatenate former current_list with same_depth_list */
162  current_list = gen_nconc(current_list, same_depth_list);
163 
164  /* use module_list_sort recursively */
165  current_list = module_list_sort(hash_module_to_depth,
166  current_list,
167  ENTITY(CAR(same_depth_list)),
168  n+1);
169  }
170  return (current_list);
171 }
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
list gen_copy_seq(list l)
Copy a list structure.
Definition: list.c:501
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
Definition: list.c:344
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
Definition: newgen_list.h:203
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
Definition: hash.c:449
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
Definition: hash.c:364
size_t size_t
Definition: properties.c:413
#define ENTITY(x)
ENTITY.
Definition: ri.h:2755
static int depth
la sequence de nids
list module_list_sort(hash_table hash_module_to_depth, list current_list, entity mod, size_t n)
Definition: toposort.c:123
list module_to_callees(entity mod)
Definition: toposort.c:85

References CAR, CONS, depth, ENTITY, gen_copy_seq(), gen_nconc(), hash_get(), hash_put(), MAPL, module_list_sort(), module_to_callees(), and NIL.

Referenced by module_list_sort(), and topologically_sorted_module_list().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ module_name_to_callees()

list module_name_to_callees ( const char *  )

cproto-generated files

toposort.c

◆ module_to_callees()

list module_to_callees ( entity  mod)
Parameters
modod

Definition at line 85 of file toposort.c.

87 {
88  list return_list = NIL;
89  list callees_list = code_declarations(entity_code(mod));
90 
91  MAPL(ce,{
92  entity e = ENTITY(CAR(ce));
94  return_list = CONS(ENTITY,
96  return_list);
97  },callees_list);
98 
99  return(return_list);
100 }
const char * entity_local_name(entity e)
entity_local_name modified so that it does not core when used in vect_fprint, since someone thought t...
Definition: entity.c:453
entity local_name_to_top_level_entity(const char *n)
This function try to find a top-level entity from a local name.
Definition: entity.c:1450
code entity_code(entity e)
Definition: entity.c:1098
#define type_functional_p(x)
Definition: ri.h:2950
#define code_declarations(x)
Definition: ri.h:784
#define entity_type(x)
Definition: ri.h:2792

References CAR, code_declarations, CONS, ENTITY, entity_code(), entity_local_name(), entity_type, local_name_to_top_level_entity(), MAPL, NIL, and type_functional_p.

Referenced by module_list_sort(), and topological_number_assign_to_module().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_graph_daVinci_from_starting_node()

void print_graph_daVinci_from_starting_node ( FILE *  f_out,
vertex  start_ver 
)
Parameters
f_out_out
start_vertart_ver

Definition at line 190 of file util.c.

191 {
192  list l = NIL;
193  ADD_ELEMENT_TO_LIST(l, VERTEX, start_ver);
194  l = list_of_connected_nodes(start_ver, l);
196  gen_free_list(l);
197  return;
198 }
void gen_free_list(list l)
free the spine of the list
Definition: list.c:327
#define ADD_ELEMENT_TO_LIST(_list, _type, _element)
Definition: icfg-local.h:50
void print_graph_of_text_to_daVinci(FILE *f_out, list l_of_vers)
Definition: util.c:134

References ADD_ELEMENT_TO_LIST, gen_free_list(), list_of_connected_nodes(), NIL, print_graph_of_text_to_daVinci(), and VERTEX.

Referenced by make_resource_from_starting_node().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_graph_of_text_to_daVinci()

void print_graph_of_text_to_daVinci ( FILE *  f_out,
list  l_of_vers 
)

printf(f_out, convert_string_for_daVinci_graph(s + strlen(CALL_MARK)));

Parameters
f_out_out
l_of_vers_of_vers

Definition at line 134 of file util.c.

135 {
136  bool first_node_parent = true;
137  fprintf(f_out, "[\n");
138 
139  FOREACH (VERTEX, ver_parent, l_of_vers) {
140  bool first_node_child = true;
141  text node_parent_text = (text)vertex_vertex_label(ver_parent);
142  bool first_sentence = true;
143 
144  if (first_node_parent)
145  first_node_parent = false;
146  else
147  fprintf(f_out, ",\n");
148 
149  FOREACH (SENTENCE, sen, text_sentences(node_parent_text)){
150  string s = sentence_to_string(sen);
151  if (first_sentence) {
152  string tmp = remove_newline_of_string (s);
153  fprintf(f_out, "l(\"%s\",n(\"\",[a(\"OBJECT\",\"", tmp);
154  first_sentence = false;
155  free (tmp);
156  }
157  if (strstr(s, CALL_MARK)) {
158  /*fprintf(f_out, convert_string_for_daVinci_graph(s + strlen(CALL_MARK)));*/
159  } else {
160  string r = convert_string_for_daVinci_graph(s);
161  fputs(r, f_out);
162  free(r);
163  }
164  }
165 
166  fprintf(f_out, "\")],[\n");
167 
168  FOREACH (SUCCESSOR, succ, vertex_successors(ver_parent)){
169  vertex ver_child = successor_vertex(succ);
170  text node_child_text = (text)vertex_vertex_label(ver_child);
171  sentence node_child_sen = SENTENCE(CAR(text_sentences(node_child_text)));
172  string node_name_child = remove_newline_of_string(first_word_of_sentence(node_child_sen));
173 
174  if (first_node_child)
175  first_node_child = false;
176  else
177  fprintf(f_out, ",\n");
178  fprintf(f_out, " l(\"\",e(\"\",[],r(\"%s\")))", node_name_child);
179  free(node_name_child);
180  }
181 
182  fprintf(f_out, "]))");
183  }
184 
185  fprintf(f_out, "\n]");
186 
187  return;
188 }
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
Apply/map an instruction block on all the elements of a list.
Definition: newgen_list.h:179
#define CALL_MARK
Definition: icfg-local.h:49
static string convert_string_for_daVinci_graph(string s)
Definition: util.c:67
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
string sentence_to_string(sentence sen)
SG: moved here from icfdg.
Definition: print.c:230

References CALL_MARK, CAR, convert_string_for_daVinci_graph(), first_word_of_sentence(), FOREACH, fprintf(), free(), remove_newline_of_string(), SENTENCE, sentence_to_string(), SUCCESSOR, successor_vertex, text_sentences, VERTEX, vertex_successors, and vertex_vertex_label.

Referenced by print_graph_daVinci_from_starting_node().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_icfg()

bool print_icfg ( const string  module_name)

print.c

print.c

They should be called by pipsmake

Lei Zhou, February 91

Parameters
module_nameodule_name

Definition at line 45 of file print.c.

46 {
47  return generic_print_icfg(module_name, false, false, false, NULL);
48 }
bool generic_print_icfg(const string, bool, bool, bool, text(*)(const string))
Definition: icfg_scan.c:713

References generic_print_icfg(), and module_name().

+ Here is the call graph for this function:

◆ print_icfg_with_control()

bool print_icfg_with_control ( const  string)
Parameters
stringodule_name

Definition at line 55 of file print.c.

56 {
57  return generic_print_icfg(module_name, true, true, false, NULL);
58 }

References generic_print_icfg(), and module_name().

+ Here is the call graph for this function:

◆ print_icfg_with_loops()

bool print_icfg_with_loops ( const  string)
Parameters
stringodule_name

Definition at line 50 of file print.c.

51 {
52  return generic_print_icfg(module_name, false, true, false, NULL);
53 }

References generic_print_icfg(), and module_name().

+ Here is the call graph for this function:

◆ print_marged_text_from_starting_node()

void print_marged_text_from_starting_node ( FILE *  fd,
int  margin,
vertex  start_ver,
list  l_of_vers 
)

if s in not empty, ok write out

Parameters
fdd
marginargin
start_vertart_ver
l_of_vers_of_vers

Definition at line 200 of file util.c.

201 {
202  if (!vertex_undefined_p(start_ver)) {
203  text txt = (text)vertex_vertex_label(start_ver);
204  MAP(SENTENCE, sen, {
205  string s = sentence_to_string(sen);
206  string call_mark = strstr(s, CALL_MARK);
207  if(call_mark) {
208  vertex ver_child = get_vertex_by_string(call_mark + strlen(CALL_MARK), l_of_vers);
209  print_marged_text_from_starting_node(fd, margin + (call_mark - s), ver_child, l_of_vers);
210  } else if (strlen(s)) { /* if s in not empty, ok write out */
211  string tmp = remove_newline_of_string(s);
212  fprintf(fd, "%*s%s\n", margin, "", tmp);
213  free (tmp);
214  }
215  }, text_sentences(txt));
216  }
217  return;
218 }
vertex get_vertex_by_string(const char *str_name, list l_of_vers)
Definition: util.c:92

References CALL_MARK, fprintf(), free(), get_vertex_by_string(), MAP, print_marged_text_from_starting_node(), remove_newline_of_string(), SENTENCE, sentence_to_string(), text_sentences, vertex_undefined_p, and vertex_vertex_label.

Referenced by make_resource_from_starting_node(), and print_marged_text_from_starting_node().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ print_module_name_to_toposorts()

void print_module_name_to_toposorts ( const char *  )

◆ safe_add_vertex_to_list()

list safe_add_vertex_to_list ( vertex  ver,
list  l_of_vers 
)
Parameters
verer
l_of_vers_of_vers

Definition at line 50 of file util.c.

51 {
52  if (!gen_in_list_p(ver, l_of_vers))
53  ADD_ELEMENT_TO_LIST(l_of_vers, VERTEX, ver);
54  return l_of_vers;
55 }
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
Definition: list.c:734

References ADD_ELEMENT_TO_LIST, gen_in_list_p(), and VERTEX.

Referenced by list_of_connected_nodes(), print_module_icfg(), and safe_make_successor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ safe_free_vertex()

void safe_free_vertex ( vertex  ver,
list  l_of_vers 
)

util.c

Parameters
verer
l_of_vers_of_vers

Definition at line 43 of file util.c.

44 {
45  if (!gen_in_list_p(ver, l_of_vers))
46  free_vertex(ver);
47  return;
48 }
void free_vertex(vertex p)
Definition: graph.c:107

References free_vertex(), and gen_in_list_p().

Referenced by print_module_icfg().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ safe_make_successor()

list safe_make_successor ( vertex  ver_parent,
vertex  ver_child,
list  l_of_vers 
)

search if it was made yet, do not make

if it was not made, do it

add vertex parent to the list of vertex

Parameters
ver_parenter_parent
ver_childer_child
l_of_vers_of_vers

Definition at line 110 of file util.c.

111 {
112  successor succ;
113  sentence ver_child_first_sen = SENTENCE(CAR(text_sentences((text)vertex_vertex_label(ver_child))));
114  string ver_child_name = first_word_of_sentence(ver_child_first_sen);
115 
116  /* search if it was made yet, do not make */
117  MAP(SUCCESSOR, succ, {
118  vertex ver = successor_vertex(succ);
119  sentence ver_first_sen = SENTENCE(CAR(text_sentences((text)vertex_vertex_label(ver))));
120  string ver_name = first_word_of_sentence(ver_first_sen);
121  if (same_string_p(ver_name, ver_child_name)) return l_of_vers;
122  }, vertex_successors(ver_parent));
123 
124  /* if it was not made, do it */
125  succ = make_successor(NULL, ver_child);
126  ADD_ELEMENT_TO_LIST(vertex_successors(ver_parent), SUCCESSOR, succ);
127  /* add vertex parent to the list of vertex */
128  l_of_vers = safe_add_vertex_to_list(ver_parent, l_of_vers);
129 
130  return l_of_vers;
131 }
successor make_successor(arc_label a1, vertex a2)
Definition: graph.c:98

References ADD_ELEMENT_TO_LIST, CAR, first_word_of_sentence(), make_successor(), MAP, safe_add_vertex_to_list(), same_string_p, SENTENCE, SUCCESSOR, successor_vertex, text_sentences, vertex_successors, and vertex_vertex_label.

Referenced by call_flt().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ topological_number_assign_to_module()

void topological_number_assign_to_module ( hash_table  hash_module_to_depth,
entity  mod,
size_t  n 
)

assigns depth n+1 to callees of current module

Parameters
hash_module_to_depthash_module_to_depth
modod

Definition at line 102 of file toposort.c.

106 {
107  size_t depth = (size_t) hash_get(hash_module_to_depth, (char *) mod);
108  list callees_list = module_to_callees(mod);
109 
110  if ((depth == (size_t) ICFG_NOT_FOUND) || (depth < n))
111  hash_put(hash_module_to_depth, (char *) mod, (char *) n);
112 
113  if ( callees_list != NIL ) {
114  /* assigns depth n+1 to callees of current module */
115  MAPL(pm,
116  { entity e = ENTITY(CAR(pm));
117  topological_number_assign_to_module(hash_module_to_depth, e, n+1);
118  },
119  callees_list);
120  }
121 }
#define ICFG_NOT_FOUND
Definition: icfg-local.h:29
void topological_number_assign_to_module(hash_table hash_module_to_depth, entity mod, size_t n)
Definition: toposort.c:102

References CAR, depth, ENTITY, hash_get(), hash_put(), ICFG_NOT_FOUND, MAPL, module_to_callees(), NIL, and topological_number_assign_to_module().

Referenced by topological_number_assign_to_module(), and topologically_sorted_module_list().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ topologically_sorted_module_list()

list topologically_sorted_module_list ( entity  mod)

"depth" of subroutine or function for topological sort

Parameters
modod

Definition at line 173 of file toposort.c.

175 {
176  /* "depth" of subroutine or function for topological sort */
177  hash_table hash_module_to_depth = (hash_table) NULL;
178  list sorted_list;
179 
180  hash_module_to_depth = hash_table_make(hash_pointer, 0);
182 
183  topological_number_assign_to_module(hash_module_to_depth, mod, 0);
184 
185  sorted_list = module_list_sort(hash_module_to_depth, NIL, mod, 0);
186 
187  pips_assert("free_hash_table",
188  hash_module_to_depth != (hash_table) NULL);
189  hash_table_free(hash_module_to_depth);
190  hash_module_to_depth = (hash_table) NULL;
191 
192  return (sorted_list);
193 }
void hash_dont_warn_on_redefinition(void)
Definition: hash.c:188
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
@ hash_pointer
Definition: newgen_hash.h:32
struct __hash_table * hash_table
Define hash_table structure which is hidden.
Definition: newgen_hash.h:43

References hash_dont_warn_on_redefinition(), hash_pointer, hash_table_free(), hash_table_make(), module_list_sort(), NIL, pips_assert, and topological_number_assign_to_module().

Referenced by print_module_name_to_toposorts().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: