PIPS
gfc2pips-comments.c
Go to the documentation of this file.
1 /*
2 
3  $Id: gfc2pips-comments.c 23065 2016-03-02 09:05:50Z coelho $
4 
5  Copyright 1989-2016 MINES ParisTech
6  Copyright 2009-2010 HPC-Project
7 
8  This file is part of PIPS.
9 
10  PIPS is free software: you can redistribute it and/or modify it
11  under the terms of the GNU General Public License as published by
12  the Free Software Foundation, either version 3 of the License, or
13  any later version.
14 
15  PIPS is distributed in the hope that it will be useful, but WITHOUT ANY
16  WARRANTY; without even the implied warranty of MERCHANTABILITY or
17  FITNESS FOR A PARTICULAR PURPOSE.
18 
19  See the GNU General Public License for more details.
20 
21  You should have received a copy of the GNU General Public License
22  along with PIPS. If not, see <http://www.gnu.org/licenses/>.
23 
24  */
25 
26 
27 #ifdef HAVE_CONFIG_H
28 #include "pips_config.h"
29 #endif
30 
31 #include "gfc2pips-private.h"
32 
33 #include <stdio.h>
34 
35 
36 //we need to copy the content of the locus
37 void gfc2pips_push_comment(locus l, unsigned long num, char s) {
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 }
67 
70  while(retour) {
71  if(retour->l.nextc == l.nextc)
72  return true;
73  retour = retour->prev;
74  }
75  return false;
76 }
77 
78 
79 unsigned long gfc2pips_get_num_of_gfc_code(gfc_code *c) {
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 }
93 string gfc2pips_get_comment_of_code(gfc_code *c) {
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 }
127 
134  } else {
136  }
137  return retour;
138  } else {
139  return NULL;
140  }
141 }
142 
143 //changer en juste un numéro, sans que ce soit "done"
144 //puis faire une étape similaire qui assigne un statement à la premiÚre plage non "done" et la met à "done"
145 void gfc2pips_set_last_comments_done(unsigned long nb) {
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 }
156 void gfc2pips_assign_num_to_last_comments(unsigned long nb) {
158  while(retour) {
159  if(retour->done || retour->num)
160  return;
161  retour->num = nb;
162  retour = retour->prev;
163  }
164 }
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 }
181 
182 void gfc2pips_replace_comments_num(unsigned long old, unsigned long new) {
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 }
195 
196 void gfc2pips_assign_gfc_code_to_num_comments(gfc_code *c, unsigned long num) {
198  while(retour) {
199  if(retour->num == num)
200  retour->gfc = c;
201  retour = retour->next;
202  }
203 }
204 bool gfc2pips_comment_num_exists(unsigned long num) {
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 }
214 
218  }
219 }
220 
221 /**
222  * \brief We assign a gfc_code depending to a list of comments if any
223  * depending on the number of the statement
224  */
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 }
241 
242 void gfc2pips_push_last_code(gfc_code *c) {
245  //gfc2pips_list_of_declared_code =
247 }
248 
249 
static int num
Definition: bourdoncle.c:137
void * malloc(YYSIZE_T)
void free(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.
string gfc2pips_get_comment_of_code(gfc_code *c)
unsigned long gfc2pips_get_num_of_gfc_code(gfc_code *c)
bool gfc2pips_check_already_done(locus l)
bool gfc2pips_comment_num_exists(unsigned long num)
void gfc2pips_replace_comments_num(unsigned long old, unsigned long new)
void gfc2pips_set_last_comments_done(unsigned long nb)
void gfc2pips_assign_gfc_code_to_last_comments(gfc_code *c)
void gfc2pips_assign_gfc_code_to_num_comments(gfc_code *c, unsigned long num)
void gfc2pips_assign_num_to_last_comments(unsigned long nb)
void gfc2pips_pop_not_done_comments(void)
void gfc2pips_push_last_code(gfc_code *c)
gfc2pips_comments gfc2pips_pop_comment(void)
void gfc2pips_push_comment(locus l, unsigned long num, char s)
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
list gfc2pips_list_of_declared_code
Definition: gfc2pips-util.c:41
gfc2pips_comments gfc2pips_comments_stack_
gfc2pips_comments gfc2pips_comments_stack
list gen_nreverse(list cp)
reverse a list in place
Definition: list.c:304
list gen_cons(const void *item, const list next)
Definition: list.c:888
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
#define empty_comments
Empty comments (i.e.
int printf()
struct _gfc2pips_comments_ * next
Definition: gfc2pips.h:80
unsigned char done
Definition: gfc2pips.h:74
unsigned long num
Definition: gfc2pips.h:78
struct _gfc2pips_comments_ * prev
Definition: gfc2pips.h:79
gfc_code * gfc
Definition: gfc2pips.h:76
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