PIPS
prettyprint.c File Reference
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "genC.h"
#include "text.h"
#include "text-util.h"
#include "top-level.h"
#include "linear.h"
#include "ri.h"
#include "effects.h"
#include "ri-util.h"
#include "workspace-util.h"
#include "effects-util.h"
#include "callgraph.h"
#include "database.h"
#include "pipsdbm.h"
#include "resources.h"
#include "misc.h"
#include "properties.h"
#include "prettyprint.h"
#include "transformer.h"
#include "effects-generic.h"
#include "semantics.h"
#include "pips-libs.h"
+ Include dependency graph for prettyprint.c:

Go to the source code of this file.

Macros

#define PREC_FORESYS_PREFIX   "C$PREC"
 
#define TRAN_FORESYS_PREFIX   "C$TRAN"
 
#define append(s)   add_to_current_line(crt_line, s, str_prefix, txt)
 
#define MAX_PRED_COMMENTARY_STRLEN   70
 to convert strings containing predicates to text of commentaries More...
 

Functions

void set_prettyprint_transformer (void)
 
static bool print_code_semantics ()
 
static text get_semantic_text (const char *, bool)
 
bool print_code_transformers (const char *module_name)
 
bool print_code_as_a_graph_transformers (const string mod_name)
 
bool print_code_preconditions (const char *module_name)
 
bool print_code_as_a_graph_preconditions (const string mod_name)
 
bool print_code_total_preconditions (const char *module_name)
 
bool print_code_as_a_graph_total_preconditions (const string mod_name)
 
bool print_source_transformers (const char *module_name)
 
bool print_source_preconditions (const char *module_name)
 
bool print_source_total_preconditions (const char *module_name)
 
text get_text_transformers (const string module_name)
 
text get_text_preconditions (const string module_name)
 
text get_text_total_preconditions (const string module_name)
 
static bool print_code_semantics (const char *module_name)
 
text semantic_to_text (entity module, int margin, statement stmt)
 this function name is VERY misleading - it should be changed, sometime FI More...
 
static int semantics_is_inferior_pvarval (Pvecteur *pvarval1, Pvecteur *pvarval2)
 The strange argument type is required by qsort(), deep down in the calls. More...
 
static bool __attribute__ ((unused))
 
text text_transformer (transformer tran)
 text text_transformer(transformer tran) input : a transformer representing a transformer or a precondition output : a text containing commentaries representing the transformer modifies : nothing. More...
 
text text_for_a_transformer (transformer tran, bool is_a_transformer)
 call this one from outside. More...
 
text string_predicate_to_commentary (string str_pred, string comment_prefix)
 text string_predicate_to_commentary(string str_pred, string comment_prefix) input : a string, part of which represents a predicate. More...
 
text words_predicate_to_commentary (list w_pred, string comment_prefix)
 text words_predicate_to_commentary(list w_pred, string comment_prefix) input : a list of strings, one of them representing a predicate. More...
 
sentence make_pred_commentary_sentence (string str_pred, string comment_prefix)
 sentence make_pred_commentary_sentence(string str_pred, string comment_prefix) input : a substring formatted to be a commentary output : a sentence, containing the commentary form of this string, beginning with the comment_prefix. More...
 
bool print_call_graph_with_transformers (const string module_name)
 
bool print_call_graph_with_preconditions (const string module_name)
 
bool print_call_graph_with_total_preconditions (const string module_name)
 

Variables

static bool is_transformer
 
static bool is_total_precondition
 
static bool is_user_view
 
static bool is_transformer_filtered
 
static hash_table nts = hash_table_undefined
 

Macro Definition Documentation

◆ append

#define append (   s)    add_to_current_line(crt_line, s, str_prefix, txt)

Definition at line 433 of file prettyprint.c.

◆ MAX_PRED_COMMENTARY_STRLEN

#define MAX_PRED_COMMENTARY_STRLEN   70

to convert strings containing predicates to text of commentaries


BA, april 1994


Definition at line 560 of file prettyprint.c.

◆ PREC_FORESYS_PREFIX

#define PREC_FORESYS_PREFIX   "C$PREC"

Definition at line 67 of file prettyprint.c.

◆ TRAN_FORESYS_PREFIX

#define TRAN_FORESYS_PREFIX   "C$TRAN"

Definition at line 68 of file prettyprint.c.

Function Documentation

◆ __attribute__()

static bool __attribute__ ( (unused)  )
static

Definition at line 435 of file prettyprint.c.

437 {
438  bool is_inferior = true;
439 
440  if (term_cst(*pvarval1))
441  is_inferior = false;
442  else if(term_cst(*pvarval2))
443  is_inferior = true;
444  else
445  is_inferior = (strcmp(external_value_name((entity) vecteur_var(*pvarval1)),
446  external_value_name((entity) vecteur_var(*pvarval2)))
447  > 0 );
448 
449  return is_inferior;
450 }
const char * external_value_name(entity)
Definition: value.c:753
#define vecteur_var(v)
#define term_cst(varval)

References external_value_name(), term_cst, and vecteur_var.

+ Here is the call graph for this function:

◆ get_semantic_text()

static text get_semantic_text ( const char *  module_name,
bool  give_code_p 
)
static

To set up the hash table to translate value into value names

The summary precondition may be in another module's frame

initial version; to be used again when prettyprint really prettyprints

print_text(fd, text_statement(mod, 0, mod_stat));

summary information first

Definition at line 254 of file prettyprint.c.

255 {
256  text r = make_text(NIL), txt_summary;
257  entity mod;
260  statement user_stat = statement_undefined;
261 
264 
266  ((statement)db_get_memory_resource(DBR_CODE, module_name, true) );
268 
269  /* To set up the hash table to translate value into value names */
272  (DBR_CUMULATED_EFFECTS, module_name, true));
275  (DBR_PROPER_EFFECTS, module_name, true));
276 
277  debug_on("SEMANTICS_PRINT_DEBUG_LEVEL");
278 
280 
281  if(is_user_view) {
282  user_stat = (statement)
283  db_get_memory_resource(DBR_PARSED_CODE, module_name, true);
284 
287 
289  }
290 
292  db_get_memory_resource(is_transformer? DBR_TRANSFORMERS:
294  DBR_TOTAL_PRECONDITIONS : DBR_PRECONDITIONS),
295  module_name, true));
296 
297  summary = (transformer)
298  db_get_memory_resource(is_transformer? DBR_SUMMARY_TRANSFORMER:
300  DBR_SUMMARY_TOTAL_PRECONDITION: DBR_SUMMARY_PRECONDITION),
301  module_name, true);
302  /* The summary precondition may be in another module's frame */
303  translate_global_values(mod, summary);
304 
306 
307  /* initial version; to be used again when prettyprint really prettyprints*/
308  /* print_text(fd, text_statement(mod, 0, mod_stat)); */
309 
310  /* summary information first */
311  txt_summary = text_transformer(summary);
312  ifdebug(7){
313  dump_text(txt_summary);
314  pips_debug(7, "summary text consistent? %s\n",
315  text_consistent_p(txt_summary)? "YES":"NO");
316  }
317  MERGE_TEXTS(r,txt_summary );
319  if (is_transformer) {
321  }
322  else if(is_total_precondition) {
324  }
325  else {
327  }
328 
329  if (give_code_p == true) {
330  MERGE_TEXTS(r, text_module(mod, is_user_view? user_stat:mod_stat));
331  }
332 
333  debug_off();
334 
335  if(is_user_view) {
338  }
339 
341 
347 
349 
350  return r;
351 }
bool text_consistent_p(text p)
Definition: text.c:80
text make_text(list a)
Definition: text.c:107
void attach_transformers_decoration_to_text(text t)
Attach a transformers decoration:
void attach_preconditions_decoration_to_text(text t)
Attach a preconditions decoration:
void attach_decoration_to_text(text t)
Attach a decoration:
void attach_total_preconditions_decoration_to_text(text __attribute__((unused)) t)
Attach a total preconditions decoration:
struct _newgen_struct_statement_ * statement
Definition: cloning.h:21
void reset_proper_rw_effects(void)
void set_proper_rw_effects(statement_effects)
void set_cumulated_rw_effects(statement_effects)
void reset_cumulated_rw_effects(void)
const char * module_name(const char *s)
Return the module part of an entity name.
Definition: entity_names.c:296
void reset_current_module_entity(void)
Reset the current module entity.
Definition: static.c:97
void reset_current_module_statement(void)
Reset the current module statement.
Definition: static.c:221
statement set_current_module_statement(statement)
Set the current module statement.
Definition: static.c:165
statement get_current_module_statement(void)
Get the current module statement.
Definition: static.c:208
entity set_current_module_entity(entity)
static.c
Definition: static.c:66
entity get_current_module_entity(void)
Get the entity of the current module.
Definition: static.c:85
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
string db_get_memory_resource(const char *rname, const char *oname, bool pure)
Return the pointer to the resource, whatever it is.
Definition: database.c:755
hash_table allocate_number_to_statement(void)
Definition: statement.c:1540
hash_table build_number_to_statement(hash_table, statement)
Definition: statement.c:1516
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
static statement mod_stat
We want to keep track of the current statement inside the recurse.
Definition: impact_check.c:41
#define debug_on(env)
Definition: misc-local.h:157
#define pips_debug
these macros use the GNU extensions that allow variadic macros, including with an empty list.
Definition: misc-local.h:145
#define debug_off()
Definition: misc-local.h:160
#define hash_table_undefined
Value of an undefined hash_table.
Definition: newgen_hash.h:49
#define true
Definition: newgen_types.h:81
void close_prettyprint()
because some prettyprint functions may be used for debug, so the last hook set by somebody may have s...
Definition: misc.c:242
void init_prettyprint(text(*hook)(entity, int, statement))
checks that the prettyprint hook was actually reset...
Definition: misc.c:231
text text_module(entity, statement)
void print_number_to_statement(hash_table)
Definition: statement.c:209
entity module_name_to_entity(const char *mn)
This is an alias for local_name_to_top_level_entity.
Definition: entity.c:1479
#define transformer_undefined
Definition: ri.h:2847
#define statement_undefined
Definition: ri.h:2419
void translate_global_values(entity m, transformer tf)
void module_to_value_mappings(entity m)
void module_to_value_mappings(entity m): build hash tables between variables and values (old,...
Definition: mappings.c:624
static bool is_total_precondition
Definition: prettyprint.c:73
static bool is_transformer
Definition: prettyprint.c:72
static bool is_user_view
Definition: prettyprint.c:74
text semantic_to_text(entity module, int margin, statement stmt)
this function name is VERY misleading - it should be changed, sometime FI
Definition: prettyprint.c:354
static hash_table nts
Definition: prettyprint.c:84
text text_transformer(transformer tran)
text text_transformer(transformer tran) input : a transformer representing a transformer or a precond...
Definition: prettyprint.c:464
void set_semantic_map(statement_mapping)
void reset_semantic_map(void)
#define ifdebug(n)
Definition: sg.c:47
#define MERGE_TEXTS(r, t)
void dump_text(text t)
FI: print_text() should be fprint_text() and dump_text(), print_text()
Definition: print.c:205
void free_value_mappings(void)
Normal call to free the mappings.
Definition: value.c:1212

References allocate_number_to_statement(), attach_decoration_to_text(), attach_preconditions_decoration_to_text(), attach_total_preconditions_decoration_to_text(), attach_transformers_decoration_to_text(), build_number_to_statement(), close_prettyprint(), db_get_memory_resource(), debug_off, debug_on, dump_text(), free_value_mappings(), get_current_module_entity(), get_current_module_statement(), hash_table_free(), hash_table_undefined, ifdebug, init_prettyprint(), is_total_precondition, is_transformer, is_user_view, make_text(), MERGE_TEXTS, mod_stat, module_name(), module_name_to_entity(), module_to_value_mappings(), NIL, nts, pips_debug, print_number_to_statement(), reset_cumulated_rw_effects(), reset_current_module_entity(), reset_current_module_statement(), reset_proper_rw_effects(), reset_semantic_map(), semantic_to_text(), set_cumulated_rw_effects(), set_current_module_entity(), set_current_module_statement(), set_proper_rw_effects(), set_semantic_map(), statement_undefined, text_consistent_p(), text_module(), text_transformer(), transformer_undefined, and translate_global_values().

Referenced by get_text_preconditions(), get_text_total_preconditions(), get_text_transformers(), and print_code_semantics().

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

◆ get_text_preconditions()

text get_text_preconditions ( const string  module_name)
Parameters
module_nameodule_name

Definition at line 193 of file prettyprint.c.

194 {
195  is_user_view = false;
196  is_transformer = false;
197  is_total_precondition = false;
199  get_bool_property("SEMANTICS_FILTERED_PRECONDITIONS");
200  return get_semantic_text(module_name,false);
201 }
bool get_bool_property(const string)
FC 2015-07-20: yuk, moved out to prevent an include cycle dependency include "properties....
static text get_semantic_text(const char *, bool)
Definition: prettyprint.c:254
static bool is_transformer_filtered
Definition: prettyprint.c:75

References get_bool_property(), get_semantic_text(), is_total_precondition, is_transformer, is_transformer_filtered, is_user_view, and module_name().

Referenced by print_call_graph_with_preconditions().

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

◆ get_text_total_preconditions()

text get_text_total_preconditions ( const string  module_name)
Parameters
module_nameodule_name

Definition at line 203 of file prettyprint.c.

204 {
205  is_user_view = false;
206  is_transformer = false;
207  is_total_precondition = true;
209  get_bool_property("SEMANTICS_FILTERED_PRECONDITIONS");
210  return get_semantic_text(module_name,false);
211 }

References get_bool_property(), get_semantic_text(), is_total_precondition, is_transformer, is_transformer_filtered, is_user_view, and module_name().

Referenced by print_call_graph_with_total_preconditions().

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

◆ get_text_transformers()

text get_text_transformers ( const string  module_name)
Parameters
module_nameodule_name

Definition at line 184 of file prettyprint.c.

185 {
186  is_user_view = false;
187  is_transformer = true;
188  is_total_precondition = false;
189  is_transformer_filtered = false;
190  return get_semantic_text(module_name,false);
191 }

References get_semantic_text(), is_total_precondition, is_transformer, is_transformer_filtered, is_user_view, and module_name().

Referenced by print_call_graph_with_transformers().

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

◆ make_pred_commentary_sentence()

sentence make_pred_commentary_sentence ( string  str_pred,
string  comment_prefix 
)

sentence make_pred_commentary_sentence(string str_pred, string comment_prefix) input : a substring formatted to be a commentary output : a sentence, containing the commentary form of this string, beginning with the comment_prefix.

modifies : nothing

Parameters
str_predtr_pred
comment_prefixomment_prefix

Definition at line 678 of file prettyprint.c.

681 {
682  /*
683  char str_tmp[MAX_PRED_COMMENTARY_STRLEN + 1];
684 
685  str_tmp[0] = '\0';
686  (void) strcat(str_tmp, comment_prefix);
687  (void) strcat(str_tmp, " ");
688  (void) strcat(str_tmp, str_pred);
689  (void) strcat(str_tmp, "\n");
690  */
691  char * str_tmp = NULL;
692  sentence sent_pred = sentence_undefined;
693 
694  str_tmp = strdup(concatenate(comment_prefix, " ", str_pred, "\n", NULL));
695  sent_pred = make_sentence_formatted(str_tmp);
696  return(sent_pred);
697 }
sentence make_sentence_formatted(string _field_)
Definition: text.c:62
string concatenate(const char *,...)
Return the concatenation of the given strings.
Definition: string.c:183
char * strdup()
#define sentence_undefined
Definition: text.h:42

References concatenate(), make_sentence_formatted(), sentence_undefined, and strdup().

Referenced by string_predicate_to_commentary(), and text_comp_region().

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

◆ print_call_graph_with_preconditions()

bool print_call_graph_with_preconditions ( const string  module_name)
Parameters
module_nameodule_name

Definition at line 712 of file prettyprint.c.

713 {
714  bool success = false;
716  return success;
717 }
bool print_decorated_call_graph(const string, text(*)(const string))
Definition: print.c:64
bool success
Definition: gpips-local.h:59
text get_text_preconditions(const string module_name)
Definition: prettyprint.c:193

References get_text_preconditions(), module_name(), and print_decorated_call_graph().

+ Here is the call graph for this function:

◆ print_call_graph_with_total_preconditions()

bool print_call_graph_with_total_preconditions ( const string  module_name)
Parameters
module_nameodule_name

Definition at line 722 of file prettyprint.c.

723 {
724  bool success = false;
727  return success;
728 }
text get_text_total_preconditions(const string module_name)
Definition: prettyprint.c:203

References get_text_total_preconditions(), module_name(), and print_decorated_call_graph().

+ Here is the call graph for this function:

◆ print_call_graph_with_transformers()

bool print_call_graph_with_transformers ( const string  module_name)
Parameters
module_nameodule_name

Definition at line 702 of file prettyprint.c.

703 {
704  bool success = false;
706  return success;
707 }
text get_text_transformers(const string module_name)
Definition: prettyprint.c:184

References get_text_transformers(), module_name(), and print_decorated_call_graph().

+ Here is the call graph for this function:

◆ print_code_as_a_graph_preconditions()

bool print_code_as_a_graph_preconditions ( const string  mod_name)
Parameters
mod_nameod_name

Definition at line 120 of file prettyprint.c.

121 {
122  bool success;
123 
124  set_bool_property("PRETTYPRINT_UNSTRUCTURED_AS_A_GRAPH", true);
125  success = print_code_preconditions(mod_name);
126  set_bool_property("PRETTYPRINT_UNSTRUCTURED_AS_A_GRAPH", false);
127 
128  return success;
129 }
void set_bool_property(const char *, bool)
bool print_code_preconditions(const char *module_name)
Definition: prettyprint.c:110

References print_code_preconditions(), and set_bool_property().

+ Here is the call graph for this function:

◆ print_code_as_a_graph_total_preconditions()

bool print_code_as_a_graph_total_preconditions ( const string  mod_name)
Parameters
mod_nameod_name

Definition at line 144 of file prettyprint.c.

145 {
146  bool success;
147 
148  set_bool_property("PRETTYPRINT_UNSTRUCTURED_AS_A_GRAPH", true);
150  set_bool_property("PRETTYPRINT_UNSTRUCTURED_AS_A_GRAPH", false);
151 
152  return success;
153 }
bool print_code_total_preconditions(const char *module_name)
Definition: prettyprint.c:131

References print_code_total_preconditions(), and set_bool_property().

+ Here is the call graph for this function:

◆ print_code_as_a_graph_transformers()

bool print_code_as_a_graph_transformers ( const string  mod_name)
Parameters
mod_nameod_name

Definition at line 99 of file prettyprint.c.

100 {
101  bool success;
102 
103  set_bool_property("PRETTYPRINT_UNSTRUCTURED_AS_A_GRAPH", true);
104  success = print_code_transformers(mod_name);
105  set_bool_property("PRETTYPRINT_UNSTRUCTURED_AS_A_GRAPH", false);
106 
107  return success;
108 }
bool print_code_transformers(const char *module_name)
Definition: prettyprint.c:90

References print_code_transformers(), and set_bool_property().

+ Here is the call graph for this function:

◆ print_code_preconditions()

bool print_code_preconditions ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 110 of file prettyprint.c.

111 {
112  is_user_view = false;
113  is_transformer = false;
114  is_total_precondition = false;
116  get_bool_property("SEMANTICS_FILTERED_PRECONDITIONS");
118 }
static bool print_code_semantics()

References get_bool_property(), is_total_precondition, is_transformer, is_transformer_filtered, is_user_view, module_name(), and print_code_semantics().

Referenced by print_code_as_a_graph_preconditions().

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

◆ print_code_semantics() [1/2]

◆ print_code_semantics() [2/2]

static bool print_code_semantics ( const char *  module_name)
static

To exploit the language sensitive prettyprint ability of the display

Definition at line 213 of file prettyprint.c.

214 {
215  bool success = true;
216  text t = text_undefined;
217 
218  char * file_ext =
222  :
228 
230  ("PRETTYPRINT_UNSTRUCTURED_AS_A_GRAPH") ?
231  GRAPH_FILE_EXT : "",
232 
233  /* To exploit the language sensitive prettyprint ability of the display */
235 
236  NULL));
237 
238  char * resource_name =
239  get_bool_property("PRETTYPRINT_UNSTRUCTURED_AS_A_GRAPH") ?
240  DBR_GRAPH_PRINTED_FILE :
241  (is_user_view? DBR_PARSED_PRINTED_FILE :
242  DBR_PRINTED_FILE);
243 
245  t = get_semantic_text(module_name,true);
248 
249  free_text(t);
250  free(file_ext);
251  return success;
252 }
void free_text(text p)
Definition: text.c:74
void begin_attachment_prettyprint(void)
The translation functions between unique names and objects:
void end_attachment_prettyprint(void)
Clean the things related with the attachment of properties:
#define resource_name(x)
Definition: database.h:108
void free(void *)
bool make_text_resource(const char *, const char *, const char *, text)
print.c
Definition: print.c:55
bool c_module_p(entity m)
Test if a module "m" is written in C.
Definition: entity.c:2777
#define SEQUENTIAL_PRECONDITION_SUFFIX
#define SEQUENTIAL_TOTAL_PRECONDITION_SUFFIX
#define USER_TOTAL_PRECONDITION_SUFFIX
#define USER_PRECONDITION_SUFFIX
#define SEQUENTIAL_TRANSFORMER_SUFFIX
#define USER_TRANSFORMER_SUFFIX
#define text_undefined
Definition: text.h:91

References begin_attachment_prettyprint(), c_module_p(), concatenate(), end_attachment_prettyprint(), free(), free_text(), get_bool_property(), get_semantic_text(), is_total_precondition, is_transformer, is_user_view, make_text_resource(), module_name(), module_name_to_entity(), resource_name, SEQUENTIAL_PRECONDITION_SUFFIX, SEQUENTIAL_TOTAL_PRECONDITION_SUFFIX, SEQUENTIAL_TRANSFORMER_SUFFIX, strdup(), text_undefined, USER_PRECONDITION_SUFFIX, USER_TOTAL_PRECONDITION_SUFFIX, and USER_TRANSFORMER_SUFFIX.

+ Here is the call graph for this function:

◆ print_code_total_preconditions()

bool print_code_total_preconditions ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 131 of file prettyprint.c.

132 {
133  bool success;
134 
135  is_user_view = false;
136  is_transformer = false;
137  is_total_precondition = true;
139  get_bool_property("SEMANTICS_FILTERED_PRECONDITIONS");
141  return success;
142 }

References get_bool_property(), is_total_precondition, is_transformer, is_transformer_filtered, is_user_view, module_name(), and print_code_semantics().

Referenced by print_code_as_a_graph_total_preconditions().

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

◆ print_code_transformers()

bool print_code_transformers ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 90 of file prettyprint.c.

91 {
92  is_user_view = false;
93  is_transformer = true;
94  is_total_precondition = false;
97 }

References is_total_precondition, is_transformer, is_transformer_filtered, is_user_view, module_name(), and print_code_semantics().

Referenced by print_code_as_a_graph_transformers().

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

◆ print_source_preconditions()

bool print_source_preconditions ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 164 of file prettyprint.c.

165 {
166  is_user_view = true;
167  is_transformer = false;
168  is_total_precondition = false;
170  get_bool_property("SEMANTICS_FILTERED_PRECONDITIONS");
172 }

References get_bool_property(), is_total_precondition, is_transformer, is_transformer_filtered, is_user_view, module_name(), and print_code_semantics().

+ Here is the call graph for this function:

◆ print_source_total_preconditions()

bool print_source_total_preconditions ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 174 of file prettyprint.c.

175 {
176  is_user_view = true;
177  is_transformer = false;
178  is_total_precondition = true;
180  get_bool_property("SEMANTICS_FILTERED_PRECONDITIONS");
182 }

References get_bool_property(), is_total_precondition, is_transformer, is_transformer_filtered, is_user_view, module_name(), and print_code_semantics().

+ Here is the call graph for this function:

◆ print_source_transformers()

bool print_source_transformers ( const char *  module_name)
Parameters
module_nameodule_name

Definition at line 155 of file prettyprint.c.

156 {
157  is_user_view = true;
158  is_transformer = true;
159  is_total_precondition = false;
160  is_transformer_filtered = false;
162 }

References is_total_precondition, is_transformer, is_transformer_filtered, is_user_view, module_name(), and print_code_semantics().

+ Here is the call graph for this function:

◆ semantic_to_text()

text semantic_to_text ( entity  module,
int  margin,
statement  stmt 
)

this function name is VERY misleading - it should be changed, sometime FI

Parameters
moduleodule
marginargin
stmttmt

Definition at line 354 of file prettyprint.c.

358 {
359  transformer t;
360  text txt;
361 
362  pips_assert("To please the compiler", module==module && margin==margin);
363 
364  if(is_user_view) {
366 
367  if(!statement_undefined_p(i)) {
369  }
370  else
372  }
373  else
375 
377  && t != (transformer) HASH_UNDEFINED_VALUE) {
379  t = filter_transformer(t, ef);
380  }
381 
382  txt = text_transformer(t);
383 
384  if (is_transformer)
386  else if (is_total_precondition)
388  else
390 
391  return txt;
392 }
list load_cumulated_rw_effects_list(statement)
statement apply_number_to_statement(hash_table, _int)
Definition: statement.c:1495
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
static char * module
Definition: pips.c:74
#define transformer_undefined_p(x)
Definition: ri.h:2848
struct _newgen_struct_transformer_ * transformer
Definition: ri.h:431
#define statement_undefined_p(x)
Definition: ri.h:2420
#define statement_number(x)
Definition: ri.h:2452
transformer filter_transformer(transformer t, list e)
Previous version of effects_to_transformer() transformer effects_to_transformer(list e) { list args =...
transformer load_statement_semantic(statement)
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
Definition: statement.c:54

References apply_number_to_statement(), attach_preconditions_decoration_to_text(), attach_total_preconditions_decoration_to_text(), attach_transformers_decoration_to_text(), filter_transformer(), HASH_UNDEFINED_VALUE, is_total_precondition, is_transformer, is_transformer_filtered, is_user_view, load_cumulated_rw_effects_list(), load_statement_semantic(), module, nts, pips_assert, statement_number, statement_undefined_p, text_transformer(), and transformer_undefined_p.

Referenced by get_semantic_text().

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

◆ semantics_is_inferior_pvarval()

static int semantics_is_inferior_pvarval ( Pvecteur pvarval1,
Pvecteur pvarval2 
)
static

The strange argument type is required by qsort(), deep down in the calls.

FI: what is it supposed to do? Is it allowed to return with equal==0, which leads to an assert failure later above vect_lexicographic_unsafe_compare_generic ().

The constant term is given the highest weight to push constant terms at the end of the constraints and to make those easy to compare. If not, constant 0 will be handled differently from other constants. However, it would be nice to give constant terms the lowest weight to print simple constraints first...

Either I define two comparison functions, or I cheat somewhere else. Let's cheat?

Definition at line 402 of file prettyprint.c.

403 {
404  /* The constant term is given the highest weight to push constant
405  terms at the end of the constraints and to make those easy
406  to compare. If not, constant 0 will be handled differently from
407  other constants. However, it would be nice to give constant terms
408  the lowest weight to print simple constraints first...
409 
410  Either I define two comparison functions, or I cheat somewhere else.
411  Let's cheat? */
412  int is_equal = 0;
413 
414  if (term_cst(*pvarval1) && !term_cst(*pvarval2))
415  is_equal = 1;
416  else if (term_cst(*pvarval1) && term_cst(*pvarval2))
417  is_equal = 0;
418  else if(term_cst(*pvarval2))
419  is_equal = -1;
420  else {
421  is_equal =
422  strcmp(pips_user_value_name((entity) vecteur_var(*pvarval1)),
423  pips_user_value_name((entity) vecteur_var(*pvarval2)));
424  if(is_equal==0 && !vect_equal(*pvarval1, *pvarval2))
425  is_equal =
426  strcmp(entity_name((entity) vecteur_var(*pvarval1)),
427  entity_name((entity) vecteur_var(*pvarval2)));
428  }
429 
430  return is_equal;
431 }
bool vect_equal(Pvecteur v1, Pvecteur v2)
bool vect_equal(Pvecteur v1, Pvecteur v2): test a egalite de deux vecteurs
Definition: reductions.c:278
#define entity_name(x)
Definition: ri.h:2790
const char * pips_user_value_name(entity)
This function is called many times when the constraints and the system of constraints are sorted usin...
Definition: value.c:815

References entity_name, pips_user_value_name(), term_cst, vect_equal(), and vecteur_var.

Referenced by text_transformer().

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

◆ set_prettyprint_transformer()

void set_prettyprint_transformer ( void  )

Definition at line 77 of file prettyprint.c.

78 {
79  is_transformer = true;
80  is_total_precondition = false;
82 }

References is_total_precondition, is_transformer, and is_transformer_filtered.

◆ string_predicate_to_commentary()

text string_predicate_to_commentary ( string  str_pred,
string  comment_prefix 
)

text string_predicate_to_commentary(string str_pred, string comment_prefix) input : a string, part of which represents a predicate.

output : a text consisting of several lines of commentaries, containing the string str_pred, and beginning with comment_prefix. modifies : str_pred;

if str_pred is too long, it must be splitted in several lines; the hyphenation must be done only between the constraints of the predicate, when there is a "," or a ")". A space is added at the beginning of extra lines, for indentation.

search the maximal substring which length is less than longueur_max

add it to the text

if the remaining string fits in one line

Parameters
str_predtr_pred
comment_prefixomment_prefix

Definition at line 570 of file prettyprint.c.

573 {
574  text t_pred = make_text(NIL);
575  string str_suiv = NULL;
576  string str_prefix = comment_prefix;
577  char str_tmp[MAX_PRED_COMMENTARY_STRLEN];
578  int len, new_str_pred_len, longueur_max;
579  bool premiere_ligne = true;
580  bool foresys = get_bool_property("PRETTYPRINT_FOR_FORESYS");
581  longueur_max = MAX_PRED_COMMENTARY_STRLEN - strlen(str_prefix) - 2;
582 
583  /* if str_pred is too long, it must be splitted in several lines;
584  * the hyphenation must be done only between the constraints of the
585  * predicate, when there is a "," or a ")". A space is added at the beginning
586  * of extra lines, for indentation. */
587  while((len = strlen(str_pred)) > 0) {
588  if (len > longueur_max) {
589 
590  /* search the maximal substring which length
591  * is less than longueur_max */
592  str_tmp[0] = '\0';
593  (void) strncat(str_tmp, str_pred, longueur_max);
594 
595  if (foresys)
596  str_suiv = strrchr(str_tmp, ')');
597  else
598  str_suiv = strrchr(str_tmp, ',');
599 
600  new_str_pred_len = (strlen(str_tmp) - strlen(str_suiv)) + 1;
601  str_suiv = strdup(&(str_pred[new_str_pred_len]));
602 
603  str_tmp[0] = '\0';
604  if (!premiere_ligne)
605  (void) strcat(str_tmp, " ");
606  (void) strncat(str_tmp, str_pred, new_str_pred_len);
607 
608  /* add it to the text */
609  ADD_SENTENCE_TO_TEXT(t_pred,
611  str_prefix));
612  str_pred = str_suiv;
613  }
614  else {
615  /* if the remaining string fits in one line */
616  str_tmp[0] = '\0';
617  if (!premiere_ligne)
618  (void) strcat(str_tmp, " ");
619  (void) strcat(str_tmp, str_pred);
620 
621  ADD_SENTENCE_TO_TEXT(t_pred,
623  str_prefix));
624  str_pred[0] = '\0';
625  }
626 
627  if (premiere_ligne) {
628  premiere_ligne = false;
629  longueur_max = longueur_max - 1;
630  if (foresys){
631  int i;
632  int nb_espaces = strlen(str_prefix) -
634 
635  str_prefix = strdup(str_prefix);
636  str_prefix[0] = '\0';
637  (void) strcat(str_prefix, FORESYS_CONTINUATION_PREFIX);
638  for (i=1; i <= nb_espaces; i++)
639  (void) strcat(str_prefix, " ");
640  }
641  }
642  }
643 
644  return(t_pred);
645 }
sentence make_pred_commentary_sentence(string str_pred, string comment_prefix)
sentence make_pred_commentary_sentence(string str_pred, string comment_prefix) input : a substring fo...
Definition: prettyprint.c:678
#define MAX_PRED_COMMENTARY_STRLEN
to convert strings containing predicates to text of commentaries
Definition: prettyprint.c:560
#define FORESYS_CONTINUATION_PREFIX
#define ADD_SENTENCE_TO_TEXT(t, p)

References ADD_SENTENCE_TO_TEXT, FORESYS_CONTINUATION_PREFIX, get_bool_property(), make_pred_commentary_sentence(), make_text(), MAX_PRED_COMMENTARY_STRLEN, NIL, and strdup().

Referenced by words_predicate_to_commentary().

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

◆ text_for_a_transformer()

text text_for_a_transformer ( transformer  tran,
bool  is_a_transformer 
)

call this one from outside.

Parameters
tranran
is_a_transformers_a_transformer

Definition at line 540 of file prettyprint.c.

541 {
542  bool save_is_transformer = is_transformer;
543  bool save_is_total_precondition = is_total_precondition;
544  text t = text_undefined;
545 
546  is_transformer = is_a_transformer;
547  is_total_precondition = false;
548  t = text_transformer(tran);
549  is_transformer = save_is_transformer;
550  is_total_precondition = save_is_total_precondition;
551  return t;
552 }

References is_total_precondition, is_transformer, text_transformer(), and text_undefined.

Referenced by call_site_to_module_precondition_text().

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

◆ text_transformer()

text text_transformer ( transformer  tran)

text text_transformer(transformer tran) input : a transformer representing a transformer or a precondition output : a text containing commentaries representing the transformer modifies : nothing.

Modification: AP, Nov 10th, 1995. Instead of building a (very long) string, I directly use the transformer to build the prettyprint in text format. This is to avoid the problem occuring when the buffer used in transformer[precondition]_to_string() is too small. I also use a static buffer to build each constraint; we are restricted to constraints of lengths smaller than the line length.

If in EMACS mode, does not add any separator line:

Parameters
tranran

Definition at line 464 of file prettyprint.c.

465 {
466  text txt = make_text(NIL);
467  bool foresys = get_bool_property("PRETTYPRINT_FOR_FORESYS");
468  string str_prefix;
469  char crt_line[MAX_LINE_LENGTH];
470 
471  /* If in EMACS mode, does not add any separator line: */
472  if (get_bool_property("PRETTYPRINT_ANALYSES_WITH_LF")
473  && !get_bool_property("PRETTYPRINT_ADD_EMACS_PROPERTIES"))
475  strdup("\n")));
476 
477  str_prefix = foresys? FORESYS_CONTINUATION_PREFIX: get_comment_continuation();
478  crt_line[0] = '\0';
479 
480  if (foresys)
482  else
484 
485  if(tran != (transformer) HASH_UNDEFINED_VALUE &&
486  tran != (transformer) list_undefined) {
487  if(tran==transformer_undefined) {
488  if (is_transformer)
489  append(" TRANSFORMER: TRANSFORMER_UNDEFINED");
490  else if(is_total_precondition)
491  append(" TOTAL PRECONDITION: TRANSFORMER_UNDEFINED");
492  else
493  append(" PRECONDITION: TRANSFORMER_UNDEFINED");
494  }
495  else {
496  Psysteme ps;
497  list args = transformer_arguments(tran);
498 
499  append(is_transformer? " T(": (is_total_precondition? " TP(" : " P("));
500 
501  entity_list_text_format(crt_line, str_prefix, txt,
502  args, entity_minimal_name);
503 
504  append(")");
505  if (foresys) append(",");
506  append(" ");
507 
510 
511  ifdebug(7) {
512  pips_debug(7, "sys %p\n", ps);
513  sc_syst_debug(ps);
514  }
515 
516  system_text_format(crt_line, str_prefix, txt, ps,
517  (char * (*)(Variable)) pips_user_value_name, foresys);
518 
519  sc_rm(ps);
520  }
521 
522  close_current_line(crt_line, txt, str_prefix);
523  }
524 
525  if (get_bool_property("PRETTYPRINT_ANALYSES_WITH_LF")
526  && !get_bool_property("PRETTYPRINT_ADD_EMACS_PROPERTIES"))
528  strdup("\n")));
529 
530  ifdebug(7){
531  pips_debug(7, "final txt: \n");
532  dump_text(txt);
533  }
534 
535  return txt;
536 }
sentence make_sentence(enum sentence_utype tag, void *val)
Definition: text.c:59
void entity_list_text_format(string line, string continuation, text t, list le, const char *(*var_name)(entity))
appends the list of entity...
void system_text_format(string line, string prefix, text txt, Psysteme ps, string(*variable_name)(Variable), bool a_la_fortran)
appends ps to line/txt with prefix continuations.
void sc_syst_debug(Psysteme s)
constraint_to_text.c
#define list_undefined
Undefined list definition :-)
Definition: newgen_list.h:69
const char * entity_minimal_name(entity e)
Do preserve scope informations.
Definition: naming.c:214
string get_comment_sentinel()
Start a single line comment.
Definition: misc.c:154
string get_comment_continuation()
Start a single line comment with continuation (blank spaces)
Definition: misc.c:167
#define transformer_relation(x)
Definition: ri.h:2873
#define transformer_arguments(x)
Definition: ri.h:2871
#define predicate_system(x)
Definition: ri.h:2069
void sc_rm(Psysteme ps)
void sc_rm(Psysteme ps): liberation de l'espace memoire occupe par le systeme de contraintes ps;
Definition: sc_alloc.c:277
Psysteme sc_copy(Psysteme ps)
Psysteme sc_copy(Psysteme ps): duplication d'un systeme (allocation et copie complete des champs sans...
Definition: sc_alloc.c:230
void sc_lexicographic_sort(Psysteme sc, int(*compare)(Pvecteur *, Pvecteur *))
Minimize first the lexico-graphic weight of each constraint according to the comparison function "com...
Definition: sc_unaires.c:206
static int semantics_is_inferior_pvarval(Pvecteur *pvarval1, Pvecteur *pvarval2)
The strange argument type is required by qsort(), deep down in the calls.
Definition: prettyprint.c:402
#define PREC_FORESYS_PREFIX
Definition: prettyprint.c:67
#define TRAN_FORESYS_PREFIX
Definition: prettyprint.c:68
#define append(s)
Definition: prettyprint.c:433
#define MAX_LINE_LENGTH
maximum length of a line when prettyprinting...
void close_current_line(string, text, string)
Definition: util.c:235
@ is_sentence_formatted
Definition: text.h:57
void * Variable
arithmetique is a requirement for vecteur, but I do not want to inforce it in all pips files....
Definition: vecteur-local.h:60

References ADD_SENTENCE_TO_TEXT, append, close_current_line(), dump_text(), entity_list_text_format(), entity_minimal_name(), FORESYS_CONTINUATION_PREFIX, get_bool_property(), get_comment_continuation(), get_comment_sentinel(), HASH_UNDEFINED_VALUE, ifdebug, is_sentence_formatted, is_total_precondition, is_transformer, list_undefined, make_sentence(), make_text(), MAX_LINE_LENGTH, NIL, pips_debug, pips_user_value_name(), PREC_FORESYS_PREFIX, predicate_system, sc_copy(), sc_lexicographic_sort(), sc_rm(), sc_syst_debug(), semantics_is_inferior_pvarval(), strdup(), system_text_format(), TRAN_FORESYS_PREFIX, transformer_arguments, transformer_relation, and transformer_undefined.

Referenced by get_semantic_text(), print_initial_precondition(), print_program_precondition(), semantic_to_text(), and text_for_a_transformer().

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

◆ words_predicate_to_commentary()

text words_predicate_to_commentary ( list  w_pred,
string  comment_prefix 
)

text words_predicate_to_commentary(list w_pred, string comment_prefix) input : a list of strings, one of them representing a predicate.

output : a text of several lines of commentaries containing this list of strings, and beginning with comment_prefix. modifies : nothing.

str_pred is the string corresponding to the concatenation of the strings in w_pred

Parameters
w_pred_pred
comment_prefixomment_prefix

Definition at line 653 of file prettyprint.c.

656 {
657  string str_pred;
658  text t_pred;
659 
660  /* str_pred is the string corresponding to the concatenation
661  * of the strings in w_pred */
662  str_pred = words_to_string(w_pred);
663 
664  t_pred = string_predicate_to_commentary(str_pred, comment_prefix);
665 
666  return(t_pred);
667 }
text string_predicate_to_commentary(string str_pred, string comment_prefix)
text string_predicate_to_commentary(string str_pred, string comment_prefix) input : a string,...
Definition: prettyprint.c:570
string words_to_string(cons *lw)
Definition: print.c:211

References string_predicate_to_commentary(), and words_to_string().

Referenced by print_any_reductions(), text_comp_region(), text_points_to(), and text_reductions().

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

Variable Documentation

◆ is_total_precondition

◆ is_transformer

◆ is_transformer_filtered

◆ is_user_view

◆ nts

Definition at line 84 of file prettyprint.c.

Referenced by get_semantic_text(), and semantic_to_text().