PIPS
gfc2pips-comments.c File Reference
#include "gfc2pips-private.h"
#include <stdio.h>
+ Include dependency graph for gfc2pips-comments.c:

Go to the source code of this file.

Functions

void gfc2pips_push_comment (locus l, unsigned long num, char s)
 
bool gfc2pips_check_already_done (locus l)
 
unsigned long gfc2pips_get_num_of_gfc_code (gfc_code *c)
 
string gfc2pips_get_comment_of_code (gfc_code *c)
 
gfc2pips_comments gfc2pips_pop_comment (void)
 
void gfc2pips_set_last_comments_done (unsigned long nb)
 
void gfc2pips_assign_num_to_last_comments (unsigned long nb)
 
void gfc2pips_assign_gfc_code_to_last_comments (gfc_code *c)
 
void gfc2pips_replace_comments_num (unsigned long old, unsigned long new)
 
void gfc2pips_assign_gfc_code_to_num_comments (gfc_code *c, unsigned long num)
 
bool gfc2pips_comment_num_exists (unsigned long num)
 
void gfc2pips_pop_not_done_comments (void)
 
void gfc2pips_shift_comments (void)
 We assign a gfc_code depending to a list of comments if any depending on the number of the statement. More...
 
void gfc2pips_push_last_code (gfc_code *c)
 

Function Documentation

◆ gfc2pips_assign_gfc_code_to_last_comments()

void gfc2pips_assign_gfc_code_to_last_comments ( gfc_code *  c)

Definition at line 165 of file gfc2pips-comments.c.

165  {
167  if(c) {
168  while(retour && retour->done) {
169  retour = retour->next;
170  }
171  if(retour) {
172  unsigned long num_plage = retour->num;
173  while(retour && retour->num == num_plage) {
174  retour->gfc = c;
175  retour->done = true;
176  retour = retour->next;
177  }
178  }
179  }
180 }
gfc2pips_comments gfc2pips_comments_stack_
struct _gfc2pips_comments_ * next
Definition: gfc2pips.h:80
unsigned char done
Definition: gfc2pips.h:74
unsigned long num
Definition: gfc2pips.h:78
gfc_code * gfc
Definition: gfc2pips.h:76

References _gfc2pips_comments_::done, _gfc2pips_comments_::gfc, gfc2pips_comments_stack_, _gfc2pips_comments_::next, and _gfc2pips_comments_::num.

◆ gfc2pips_assign_gfc_code_to_num_comments()

void gfc2pips_assign_gfc_code_to_num_comments ( gfc_code *  c,
unsigned long  num 
)

Definition at line 196 of file gfc2pips-comments.c.

196  {
198  while(retour) {
199  if(retour->num == num)
200  retour->gfc = c;
201  retour = retour->next;
202  }
203 }
static int num
Definition: bourdoncle.c:137

References _gfc2pips_comments_::gfc, gfc2pips_comments_stack_, _gfc2pips_comments_::next, num, and _gfc2pips_comments_::num.

Referenced by gfc2pips_code2instruction__TOP().

+ Here is the caller graph for this function:

◆ gfc2pips_assign_num_to_last_comments()

void gfc2pips_assign_num_to_last_comments ( unsigned long  nb)

Definition at line 156 of file gfc2pips-comments.c.

156  {
158  while(retour) {
159  if(retour->done || retour->num)
160  return;
161  retour->num = nb;
162  retour = retour->prev;
163  }
164 }
gfc2pips_comments gfc2pips_comments_stack
struct _gfc2pips_comments_ * prev
Definition: gfc2pips.h:79

References _gfc2pips_comments_::done, gfc2pips_comments_stack, _gfc2pips_comments_::num, and _gfc2pips_comments_::prev.

◆ gfc2pips_check_already_done()

bool gfc2pips_check_already_done ( locus  l)

Definition at line 68 of file gfc2pips-comments.c.

68  {
70  while(retour) {
71  if(retour->l.nextc == l.nextc)
72  return true;
73  retour = retour->prev;
74  }
75  return false;
76 }

References gfc2pips_comments_stack, _gfc2pips_comments_::l, and _gfc2pips_comments_::prev.

Referenced by gfc2pips_push_comment().

+ Here is the caller graph for this function:

◆ gfc2pips_comment_num_exists()

bool gfc2pips_comment_num_exists ( unsigned long  num)

Definition at line 204 of file gfc2pips-comments.c.

204  {
206  //fprintf(stderr,"gfc2pips_comment_num_exists: %d\n", num );
207  while(retour) {
208  if(retour->num == num)
209  return true;
210  retour = retour->prev;
211  }
212  return false;
213 }

References gfc2pips_comments_stack, num, _gfc2pips_comments_::num, and _gfc2pips_comments_::prev.

◆ gfc2pips_get_comment_of_code()

string gfc2pips_get_comment_of_code ( gfc_code *  c)

Definition at line 93 of file gfc2pips-comments.c.

93  {
95  char *a, *b;
96  while(retour) {
97  if(retour->gfc == c) {
98  a = retour->s;
99  retour = retour->next;
100  while(retour && retour->gfc == c) {
101  if(a && retour->s) {
102  b = (char*)malloc(sizeof(char) * (strlen(a) + strlen(retour->s) + 2));
103  strcpy(b, a);
104  strcpy(b + strlen(b), "\n");
105  strcpy(b + strlen(b), retour->s);
106  free(a);
107  a = b;
108  } else if(retour->s) {
109  a = retour->s;
110  }
111  retour = retour->next;
112  }
113  if(a) {
114  b = (char*)malloc(sizeof(char) * (strlen(a) + 2));
115  strcpy(b, a);
116  strcpy(b + strlen(b), "\n");
117  free(a);
118  return b;
119  } else {
120  return empty_comments;
121  }
122  }
123  retour = retour->next;
124  }
125  return empty_comments;
126 }
void * malloc(YYSIZE_T)
void free(void *)
#define empty_comments
Empty comments (i.e.

References empty_comments, free(), _gfc2pips_comments_::gfc, gfc2pips_comments_stack_, malloc(), _gfc2pips_comments_::next, and _gfc2pips_comments_::s.

Referenced by gfc2pips_code2instruction(), and gfc2pips_code2instruction__TOP().

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

◆ gfc2pips_get_num_of_gfc_code()

unsigned long gfc2pips_get_num_of_gfc_code ( gfc_code *  c)

Definition at line 79 of file gfc2pips-comments.c.

79  {
80  unsigned long retour = 0;
82  while(curr) {
83  if(curr->gfc == c) {
84  return retour + 1;
85  }
86  curr = curr->next;
87  retour++;
88  }
89  if(retour)
90  return retour + 1;
91  return retour;// 0
92 }

References _gfc2pips_comments_::gfc, gfc2pips_comments_stack_, and _gfc2pips_comments_::next.

Referenced by gfc2pips_code2instruction__TOP().

+ Here is the caller graph for this function:

◆ gfc2pips_pop_comment()

gfc2pips_comments gfc2pips_pop_comment ( void  )

Definition at line 128 of file gfc2pips-comments.c.

128  {
134  } else {
136  }
137  return retour;
138  } else {
139  return NULL;
140  }
141 }

References gfc2pips_comments_stack, gfc2pips_comments_stack_, _gfc2pips_comments_::next, and _gfc2pips_comments_::prev.

Referenced by gfc2pips_pop_not_done_comments().

+ Here is the caller graph for this function:

◆ gfc2pips_pop_not_done_comments()

void gfc2pips_pop_not_done_comments ( void  )

Definition at line 215 of file gfc2pips-comments.c.

215  {
218  }
219 }
gfc2pips_comments gfc2pips_pop_comment(void)

References _gfc2pips_comments_::done, gfc2pips_comments_stack, and gfc2pips_pop_comment().

+ Here is the call graph for this function:

◆ gfc2pips_push_comment()

void gfc2pips_push_comment ( locus  l,
unsigned long  num,
char  s 
)

Definition at line 37 of file gfc2pips-comments.c.

37  {
38  printf("gfc2pips_push_comment \n");
41  return;
42  }
46 
48  } else {
53  }
54  //fprintf(stderr,"push comments %d\n",l.lb->location);
55 
60 
62  gfc2pips_comments_stack->s[strlen(gfc2pips_comments_stack->s) - 2] = '\0';
65  printf("gfc2pips_push_comment : '%s'\n", gfc2pips_comments_stack->s);
66 }
bool gfc2pips_check_already_done(locus l)
char * strrcpy(char *dest, __const char *src)
same as strcpy, but begin by the end of the string allowing you to give twice the same string
char * gfc2pips_gfc_char_t2string2(gfc_char_t *c)
translate the <nb> first elements of from a wide integer representation to a char representation
Definition: gfc2pips.c:1875
int printf()

References _gfc2pips_comments_::done, _gfc2pips_comments_::gfc, gfc2pips_check_already_done(), gfc2pips_comments_stack, gfc2pips_comments_stack_, gfc2pips_gfc_char_t2string2(), _gfc2pips_comments_::l, malloc(), _gfc2pips_comments_::next, num, _gfc2pips_comments_::num, _gfc2pips_comments_::prev, printf(), _gfc2pips_comments_::s, and strrcpy().

+ Here is the call graph for this function:

◆ gfc2pips_push_last_code()

void gfc2pips_push_last_code ( gfc_code *  c)

Definition at line 242 of file gfc2pips-comments.c.

242  {
245  //gfc2pips_list_of_declared_code =
247 }
list gfc2pips_list_of_declared_code
Definition: gfc2pips-util.c:41
list gen_cons(const void *item, const list next)
Definition: list.c:888

References gen_cons(), and gfc2pips_list_of_declared_code.

+ Here is the call graph for this function:

◆ gfc2pips_replace_comments_num()

void gfc2pips_replace_comments_num ( unsigned long  old,
unsigned long  new 
)

Definition at line 182 of file gfc2pips-comments.c.

182  {
184  bool if_changed = false;
185  //fprintf(stderr,"gfc2pips_replace_comments_num: replace %d by %d\n", old, new );
186  while(retour) {
187  if(retour->num == old) {
188  if_changed = true;
189  retour->num = new;
190  }
191  retour = retour->prev;
192  }
193  //if(if_changed) gfc2pips_nb_of_statements--;
194 }

References gfc2pips_comments_stack, _gfc2pips_comments_::num, and _gfc2pips_comments_::prev.

Referenced by gfc2pips_code2instruction__TOP().

+ Here is the caller graph for this function:

◆ gfc2pips_set_last_comments_done()

void gfc2pips_set_last_comments_done ( unsigned long  nb)

Definition at line 145 of file gfc2pips-comments.c.

145  {
146  //printf("gfc2pips_set_last_comments_done\n");
148  while(retour) {
149  if(retour->done)
150  return;
151  retour->num = nb;
152  retour->done = true;
153  retour = retour->prev;
154  }
155 }

References _gfc2pips_comments_::done, gfc2pips_comments_stack, _gfc2pips_comments_::num, and _gfc2pips_comments_::prev.

◆ gfc2pips_shift_comments()

void gfc2pips_shift_comments ( void  )

We assign a gfc_code depending to a list of comments if any depending on the number of the statement.

Definition at line 225 of file gfc2pips-comments.c.

225  {
226  /*
227  *
228  */
231  while(retour) {
232 
233  list curr = gen_nthcdr(retour->num, l);
234  if(curr) {
235  retour->gfc = (gfc_code*)curr->car.e;
236  }
237  retour = retour->prev;
238  }
239  return;
240 }
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
list gen_nthcdr(int n, const list lx)
caution: the first item is 0! was: return( (n<=0) ? l : gen_nthcdr( n-1, CDR( l ))) ; if n>gen_length...
Definition: list.c:700
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
gen_chunk car
The data payload of a list element.
Definition: newgen_list.h:42
void * e
For externals (foreign objects)
Definition: genC.h:65

References cons::car, gen_chunk::e, gen_nreverse(), gen_nthcdr(), _gfc2pips_comments_::gfc, gfc2pips_comments_stack, gfc2pips_list_of_declared_code, _gfc2pips_comments_::num, and _gfc2pips_comments_::prev.

Referenced by gfc2pips_namespace().

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