PIPS
Pvecteur.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "linear.h"
#include "genC.h"
#include "ri.h"
#include "misc.h"
+ Include dependency graph for Pvecteur.c:

Go to the source code of this file.

Macros

#define TCST_OLD_NAME   "TERME_CONSTANT" /**compatibility to read old bases */
 
#define TCST_NAME   "."
 

Functions

static void print_token (FILE *fd, string s)
 print token More...
 
static string read_token (int(*f)())
 stop at ' ' or ')'. More...
 
void vect_gen_write (FILE *fd, Pvecteur v)
 output is "([val var ]* )" More...
 
Pvecteur vect_gen_read (FILE *fd __attribute__((unused)), int(*f)())
 
void vect_gen_free (Pvecteur v)
 
Pvecteur vect_gen_copy_tree (Pvecteur v)
 
int vect_gen_allocated_memory (Pvecteur v)
 
int contrainte_gen_allocated_memory (Pcontrainte pc)
 

Macro Definition Documentation

◆ TCST_NAME

#define TCST_NAME   "."

Definition at line 50 of file Pvecteur.c.

◆ TCST_OLD_NAME

#define TCST_OLD_NAME   "TERME_CONSTANT" /**compatibility to read old bases */

Definition at line 49 of file Pvecteur.c.

Function Documentation

◆ contrainte_gen_allocated_memory()

int contrainte_gen_allocated_memory ( Pcontrainte  pc)
Parameters
pcc

Definition at line 176 of file Pvecteur.c.

177 {
178  int result = 0;
179  for(; pc; pc=pc->succ)
180  result += sizeof(Scontrainte) +
182  return result;
183 }
int vect_gen_allocated_memory(Pvecteur v)
Definition: Pvecteur.c:168
Pvecteur vecteur
struct Scontrainte * succ

References Scontrainte::succ, vect_gen_allocated_memory(), and Scontrainte::vecteur.

Referenced by sc_gen_allocated_memory().

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

◆ print_token()

static void print_token ( FILE *  fd,
string  s 
)
static

print token

backslashify '\ )'

Definition at line 53 of file Pvecteur.c.

54 {
55  for (; *s; s++)
56  {
57  /* backslashify '\ )' */
58  if (*s=='\\' || *s==' ' || *s==')')
59  {
60  putc('\\', fd);
61  }
62  putc(*s, fd);
63  }
64 }

Referenced by vect_gen_write().

+ Here is the caller graph for this function:

◆ read_token()

static string read_token ( int(*)()  f)
static

stop at ' ' or ')'.

handles '\' as a protection. returns a pointer to a static buffer.

static internal buffer

should be ok for most codes.

for current char and ending 0

Definition at line 70 of file Pvecteur.c.

71 {
72  /* static internal buffer */
73  static string buf = NULL;
74  static int bufsize = 0;
75  int index = 0, c;
76 
77  if (!buf)
78  {
79  bufsize = 64; /* should be ok for most codes. */
80  buf = (char*) malloc(bufsize * sizeof(char));
81  pips_assert("malloc ok", buf);
82  }
83 
84  while ((c = f()) != -1 && c!=' ' && c!=')')
85  {
86  if (index+1>=bufsize) /* for current char and ending 0 */
87  {
88  bufsize *= 2;
89  buf = (char*) realloc(buf, bufsize * sizeof(char));
90  pips_assert("realloc ok", buf);
91  }
92 
93  if (c == '\\')
94  {
95  c = f();
96  pips_assert("there is a char after a backslash", c!=-1);
97  }
98 
99  buf[index++] = (char) c;
100  }
101  buf[index++] = '\0';
102 
103  return buf;
104 }
void * malloc(YYSIZE_T)
#define pips_assert(what, predicate)
common macros, two flavors depending on NDEBUG
Definition: misc-local.h:172
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
Definition: offsets.c:15
static char buf[BSZ]
Definition: split_file.c:157

References buf, f(), malloc(), and pips_assert.

Referenced by vect_gen_read().

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

◆ vect_gen_allocated_memory()

int vect_gen_allocated_memory ( Pvecteur  v)

Definition at line 168 of file Pvecteur.c.

169 {
170  int result = 0;
171  for (; v; v=v->succ)
172  result += sizeof(Svecteur);
173  return result;
174 }
le type des coefficients dans les vecteurs: Value est defini dans le package arithmetique
Definition: vecteur-local.h:89
struct Svecteur * succ
Definition: vecteur-local.h:92

References Svecteur::succ.

Referenced by contrainte_gen_allocated_memory(), initialize_newgen(), monome_gen_allocated_memory(), pips_init(), and sc_gen_allocated_memory().

+ Here is the caller graph for this function:

◆ vect_gen_copy_tree()

Pvecteur vect_gen_copy_tree ( Pvecteur  v)

Definition at line 163 of file Pvecteur.c.

164 {
165  return vect_copy(v);
166 }
Pbase vect_copy(Pvecteur b)
direct duplication.
Definition: alloc.c:240

References vect_copy().

Referenced by initialize_newgen(), main(), and pips_init().

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

◆ vect_gen_free()

void vect_gen_free ( Pvecteur  v)

Definition at line 158 of file Pvecteur.c.

159 {
160  vect_rm(v);
161 }
void vect_rm(Pvecteur v)
void vect_rm(Pvecteur v): desallocation des couples de v;
Definition: alloc.c:78

References vect_rm().

Referenced by initialize_newgen(), main(), and pips_init().

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

◆ vect_gen_read()

Pvecteur vect_gen_read ( FILE *fd   __attribute__(unused),
int(*)()  f 
)

Definition at line 124 of file Pvecteur.c.

126 {
127  Pvecteur p = NULL;
128  string svar, sval;
129  Variable var;
130  Value val;
131  int openpar;
132 
133  openpar = f();
134  pips_assert("vect starts with '('", openpar=='(');
135 
136  while ((sval = read_token(f)) && *sval)
137  {
138  sscan_Value(sval, &val);
139  svar = read_token(f);
140 
141  if (same_string_p(svar, TCST_NAME) ||
143  {
144  var = (Variable) 0;
145  }
146  else
147  {
149  pips_assert("valid variable entity", !entity_undefined_p((entity)var));
150  }
151  vect_add_elem(&p, var, val);
152  }
153 
154  p = vect_reversal(p);
155  return p;
156 }
#define TCST_OLD_NAME
Definition: Pvecteur.c:49
static string read_token(int(*f)())
stop at ' ' or ')'.
Definition: Pvecteur.c:70
#define TCST_NAME
Definition: Pvecteur.c:50
int Value
int sscan_Value(char *, Value *)
Definition: io.c:68
#define same_string_p(s1, s2)
void * gen_find_tabulated(const char *, int)
Definition: tabulated.c:218
Pvecteur vect_reversal(Pvecteur vect_in)
Pvecteur vect_reversal(Pvecteur vect_in); produces the reversal vector of the vect_in.
Definition: private.c:237
#define entity_undefined_p(x)
Definition: ri.h:2762
#define entity_domain
newgen_syntax_domain_defined
Definition: ri.h:410
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
void vect_add_elem(Pvecteur *pvect, Variable var, Value val)
void vect_add_elem(Pvecteur * pvect, Variable var, Value val): addition d'un vecteur colineaire au ve...
Definition: unaires.c:72

References entity_domain, entity_undefined_p, f(), gen_find_tabulated(), pips_assert, read_token(), same_string_p, sscan_Value(), TCST_NAME, TCST_OLD_NAME, vect_add_elem(), and vect_reversal().

+ Here is the call graph for this function:

◆ vect_gen_write()

void vect_gen_write ( FILE *  fd,
Pvecteur  v 
)

output is "([val var ]* )"

Pvecteur.c.

Parameters
fdd

Definition at line 108 of file Pvecteur.c.

109 {
110  Pvecteur p;
111 
112  putc('(', fd);
113  for (p = v; p != NULL; p = p->succ)
114  {
115  fprint_Value(fd, val_of(p));
116  putc(' ', fd);
117  print_token(fd, (p->var == (Variable) 0) ? TCST_NAME :
118  entity_name((entity) p->var));
119  putc(' ', fd);
120  }
121  putc(')', fd);
122 }
static void print_token(FILE *fd, string s)
print token
Definition: Pvecteur.c:53
void fprint_Value(FILE *, Value)
Definition: io.c:42
#define entity_name(x)
Definition: ri.h:2790
Variable var
Definition: vecteur-local.h:90
#define val_of(varval)

References entity_name, fprint_Value(), print_token(), Svecteur::succ, TCST_NAME, val_of, and Svecteur::var.

Referenced by initialize_newgen(), main(), monome_gen_write(), pips_init(), and sc_gen_write().

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