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

Go to the source code of this file.

Data Structures

struct  gen_binding
 
union  domain
 A DOMAIN union describes the structure of a user type. More...
 

Macros

#define UNIT_TYPE_NAME   "unit"
 The UNIT_TYPE_NAME is the used to type expressions which only perform side-effects. More...
 
#define DEFLIST(type, cartype, carname)
 A list type constructor. More...
 
#define MAX_DOMAIN   300
 MAX_DOMAIN is the maximum number of entries in the DOMAINS table. More...
 
#define IS_INLINABLE(bp)   ((bp)->inlined != NULL)
 Different kinds of BINDING structure pointers. More...
 
#define IS_EXTERNAL(bp)   ((bp)->domain->ba.type == EXTERNAL_DT)
 
#define IS_TABULATED(bp)   ((bp)->tabulated!=NULL)
 
#define IS_IMPORT(bp)   ((bp)->domain->ba.type == IMPORT_DT)
 
#define IS_NORMAL(bp)    (!IS_INLINABLE(bp)&&!IS_EXTERNAL(bp)&&!IS_TABULATED(bp))
 
#define NEW_BINDING   1
 Action parameter to the LOOKUP() function in the symbol table. More...
 
#define OLD_BINDING   2
 
#define HASH_OFFSET   2
 For tabulated objects, the offset HASH_OFFSET of the hashed subdomain. More...
 
#define same_string_p(s1, s2)   (strcmp((s1), (s2)) == 0)
 
#define IS_UNIT_TYPE(n)   ((n)==unit_domain)
 
#define IS_BOOL_TYPE(n)   ((n)==bool_domain)
 
#define IS_CHAR_TYPE(n)   ((n)==char_domain)
 
#define IS_INT_TYPE(n)   ((n)==int_domain)
 
#define IS_FLOAT_TYPE(n)   ((n)==float_domain)
 
#define IS_STRING_TYPE(n)   ((n)==string_domain)
 
#define check_domain(dom)
 
#define check_read_spec_performed()
 
#define NEWGEN_FREED   ((void*)NULL)
 
#define newgen_free(p)   (*((char*)(p))='\0',free(p)) /**just to hide bugs */
 
#define quick_domain_index(obj)
 inlined version of domain_index. More...
 

Typedefs

typedef struct _gtpgen_tabulated_p
 actually defined in tabulated.c More...
 

Enumerations

enum  type_of_domain {
  UNDEF_DT = 0 , EXTERNAL_DT = 1 , BASIS_DT = 2 , LIST_DT = 3 ,
  ARRAY_DT = 4 , CONSTRUCTED_DT = 5 , IMPORT_DT = 6 , SET_DT = 7
}
 Types of domain. More...
 
enum  domain_operator { UNDEF_OP = 0 , AND_OP = 1 , OR_OP = 2 , ARROW_OP = 3 }
 Operators for CONSTRUCTED domains. More...
 

Functions

 DEFLIST (namelist, char *, name)
 
 DEFLIST (intlist, int, val)
 
 DEFLIST (domainlist, union domain *, domain)
 
struct gen_bindinglookup ()
 
struct gen_bindingnew_binding ()
 
void user (char *,...)
 External routines. More...
 
void gencode (string)
 generate the code necessary to manipulate every internal non-inlinable type in the Domains table. More...
 
void fatal (char *,...)
 
char * i2a (int)
 I2A (Integer TO Ascii) yields a string for a given Integer. More...
 
void print_domains (FILE *)
 PRINT_DOMAINS prints on the OUT stream the Domains table. More...
 
void init (void)
 INIT initializes global data structures. More...
 
void compile (void)
 COMPILE reconnects the Domains table (for not compiled types – note that an inlined type is already compiled). More...
 
int gen_size (int)
 GEN_SIZE returns the size (in gen_chunks) of an object of type defined by the BP type. More...
 
void print_domain (FILE *, union domain *)
 PRINT_DOMAIN prints on the OUT stream a domain denoted by the DP pointer. More...
 
string concatenate (const char *,...)
 Return the concatenation of the given strings. More...
 
int genspec_parse (void)
 
int genspec_lex (void)
 
int genread_parse (void)
 
int genread_lex (void)
 
gen_tabulated_p gen_init_tabulated (int)
 
gen_chunkgen_enter_tabulated (int, char *, gen_chunk *, bool)
 ENTER_TABULATED_DEF enters a new definition (previous refs are allowed if ALLOW_REF) in the INDEX tabulation table of the DOMAIN, with the unique ID and value CHUNKP. More...
 
gen_chunkgen_do_enter_tabulated (int, char *, gen_chunk *, bool)
 
gen_chunkgen_tabulated_fake_object_hack (int)
 WARNING: it is not reentrant... More...
 
int newgen_domain_index (gen_chunk *)
 DOMAIN_INDEX returns the index in the Domain table for object OBJ. More...
 

Variables

struct gen_binding Domains []
 The implementation of tabulated domains. More...
 
struct gen_bindingTabulated_bp
 hack to walk thru tabulateds... More...
 
gen_chunkRead_chunk
 The root of the gen_chunk read with READ_CHUNK. More...
 
int Current_op
 Used to check, while parsing specs, that a constructed domain use only one operator type. More...
 
int Number_imports
 To manage imported domains: More...
 
int Current_start
 
int Read_spec_mode
 extern int Current_first ; More...
 

Macro Definition Documentation

◆ check_domain

#define check_domain (   dom)
Value:
message_assert("Consistant domain number",\
(dom)>=0 && (dom)<MAX_DOMAIN)
#define message_assert(msg, ex)
Definition: newgen_assert.h:47
#define MAX_DOMAIN
MAX_DOMAIN is the maximum number of entries in the DOMAINS table.

Definition at line 212 of file newgen_include.h.

◆ check_read_spec_performed

#define check_read_spec_performed ( )
Value:
message_assert("gen_read_spec performed prior to use", \
static bool Read_spec_performed
Definition: genClib.c:61

Definition at line 216 of file newgen_include.h.

◆ DEFLIST

#define DEFLIST (   type,
  cartype,
  carname 
)
Value:
struct type {\
cartype carname ;\
struct type *cdr ;\
}

A list type constructor.

Definition at line 55 of file newgen_include.h.

◆ HASH_OFFSET

#define HASH_OFFSET   2

For tabulated objects, the offset HASH_OFFSET of the hashed subdomain.

Definition at line 196 of file newgen_include.h.

◆ IS_BOOL_TYPE

#define IS_BOOL_TYPE (   n)    ((n)==bool_domain)

Definition at line 201 of file newgen_include.h.

◆ IS_CHAR_TYPE

#define IS_CHAR_TYPE (   n)    ((n)==char_domain)

Definition at line 202 of file newgen_include.h.

◆ IS_EXTERNAL

#define IS_EXTERNAL (   bp)    ((bp)->domain->ba.type == EXTERNAL_DT)

Definition at line 155 of file newgen_include.h.

◆ IS_FLOAT_TYPE

#define IS_FLOAT_TYPE (   n)    ((n)==float_domain)

Definition at line 204 of file newgen_include.h.

◆ IS_IMPORT

#define IS_IMPORT (   bp)    ((bp)->domain->ba.type == IMPORT_DT)

Definition at line 157 of file newgen_include.h.

◆ IS_INLINABLE

#define IS_INLINABLE (   bp)    ((bp)->inlined != NULL)

Different kinds of BINDING structure pointers.

Definition at line 154 of file newgen_include.h.

◆ IS_INT_TYPE

#define IS_INT_TYPE (   n)    ((n)==int_domain)

Definition at line 203 of file newgen_include.h.

◆ IS_NORMAL

#define IS_NORMAL (   bp)     (!IS_INLINABLE(bp)&&!IS_EXTERNAL(bp)&&!IS_TABULATED(bp))

Definition at line 158 of file newgen_include.h.

◆ IS_STRING_TYPE

#define IS_STRING_TYPE (   n)    ((n)==string_domain)

Definition at line 205 of file newgen_include.h.

◆ IS_TABULATED

#define IS_TABULATED (   bp)    ((bp)->tabulated!=NULL)

Definition at line 156 of file newgen_include.h.

◆ IS_UNIT_TYPE

#define IS_UNIT_TYPE (   n)    ((n)==unit_domain)

Definition at line 200 of file newgen_include.h.

◆ MAX_DOMAIN

#define MAX_DOMAIN   300

MAX_DOMAIN is the maximum number of entries in the DOMAINS table.

Definition at line 147 of file newgen_include.h.

◆ NEW_BINDING

#define NEW_BINDING   1

Action parameter to the LOOKUP() function in the symbol table.

Are looking for a new symbol or an old one ?

Definition at line 170 of file newgen_include.h.

◆ newgen_free

#define newgen_free (   p)    (*((char*)(p))='\0',free(p)) /**just to hide bugs */

Definition at line 222 of file newgen_include.h.

◆ NEWGEN_FREED

#define NEWGEN_FREED   ((void*)NULL)

Definition at line 220 of file newgen_include.h.

◆ OLD_BINDING

#define OLD_BINDING   2

Definition at line 171 of file newgen_include.h.

◆ quick_domain_index

#define quick_domain_index (   obj)
Value:
(((! (obj)) || ((obj)==gen_chunk_undefined) || \
((obj)->i<0) || ((obj)->i>MAX_DOMAIN)) ? \
newgen_domain_index(obj) : (obj)->i) \
/**prints the error message or returns */
#define gen_chunk_undefined
Definition: genC.h:74
int newgen_domain_index(gen_chunk *)
DOMAIN_INDEX returns the index in the Domain table for object OBJ.
Definition: genClib.c:105

inlined version of domain_index.

what is done by optimizing compilers?

Definition at line 226 of file newgen_include.h.

◆ same_string_p

#define same_string_p (   s1,
  s2 
)    (strcmp((s1), (s2)) == 0)

Definition at line 198 of file newgen_include.h.

◆ UNIT_TYPE_NAME

#define UNIT_TYPE_NAME   "unit"

The UNIT_TYPE_NAME is the used to type expressions which only perform side-effects.

It is mainly used to build sets.

Definition at line 51 of file newgen_include.h.

Typedef Documentation

◆ gen_tabulated_p

typedef struct _gtp* gen_tabulated_p

actually defined in tabulated.c

Definition at line 66 of file newgen_include.h.

Enumeration Type Documentation

◆ domain_operator

Operators for CONSTRUCTED domains.

Enumerator
UNDEF_OP 
AND_OP 
OR_OP 
ARROW_OP 

Definition at line 41 of file newgen_include.h.

41  {
42  UNDEF_OP = 0,
43  AND_OP = 1,
44  OR_OP = 2,
45  ARROW_OP = 3
46 };
@ ARROW_OP
@ OR_OP
@ AND_OP
@ UNDEF_OP

◆ type_of_domain

Types of domain.

Enumerator
UNDEF_DT 
EXTERNAL_DT 
BASIS_DT 
LIST_DT 
ARRAY_DT 
CONSTRUCTED_DT 
IMPORT_DT 
SET_DT 

Definition at line 28 of file newgen_include.h.

28  {
29  UNDEF_DT = 0,
30  EXTERNAL_DT = 1,
31  BASIS_DT = 2,
32  LIST_DT = 3,
33  ARRAY_DT = 4,
34  CONSTRUCTED_DT = 5,
35  IMPORT_DT = 6,
36  SET_DT = 7
37 };
@ EXTERNAL_DT
@ SET_DT
@ ARRAY_DT
@ LIST_DT
@ UNDEF_DT
@ BASIS_DT
@ IMPORT_DT
@ CONSTRUCTED_DT

Function Documentation

◆ compile()

void compile ( void  )

COMPILE reconnects the Domains table (for not compiled types – note that an inlined type is already compiled).

set size of domain.

Definition at line 422 of file build.c.

423 {
424  int i;
425  current_first = 0;
426 
427  for(i=0; i<MAX_DOMAIN; i++)
428  {
429  struct gen_binding * bp = &Domains[i];
430 
431  if( bp->name == NULL || bp->compiled || bp == Tabulated_bp )
432  continue ;
433 
434  reconnect( -1, bp->domain ) ;
435  bp->compiled = (bp->domain->ba.type != EXTERNAL_DT ) ;
436 
437  if( IS_TABULATED( bp )) {
438  union domain *dp = NULL;
439 
440  if( !(bp->domain->ba.type == CONSTRUCTED_DT &&
441  (dp=bp->domain->co.components->domain)->ba.type == BASIS_DT &&
442  strcmp( dp->ba.constructand->name, "string" ) == 0)) {
443  user( "compile: tabulated first %s domain isn't string\n",
444  dp->ba.constructand->name ) ;
445  }
446  }
447 
448  /* set size of domain. */
449  if (bp->domain->ba.type == BASIS_DT ||
450  bp->domain->ba.type == ARRAY_DT ||
451  bp->domain->ba.type == SET_DT ||
452  bp->domain->ba.type == LIST_DT ||
453  bp->domain->ba.type == CONSTRUCTED_DT)
454  bp->size = gen_size(i);
455  }
456 
457 #ifdef DBG_COMPILE
458  print_domains( stderr ) ;
459 #endif
460 }
void reconnect(int op, union domain *dp)
Definition: build.c:384
static int current_first
RECONNECT replaces the (STRUCT BINDING *) members of the DP domain which are, on entry,...
Definition: build.c:382
void print_domains(FILE *out)
PRINT_DOMAINS prints on the OUT stream the Domains table.
Definition: build.c:352
int gen_size(int domain)
GEN_SIZE returns the size (in gen_chunks) of an object of type defined by the BP type.
Definition: genC.c:71
struct gen_binding * Tabulated_bp
pointer to tabulated domain hack
Definition: genClib.c:58
struct gen_binding Domains[MAX_DOMAIN]
in build.c
Definition: genspec_yacc.c:114
void user(char *,...)
External routines.
#define IS_TABULATED(bp)
union domain * domain
A DOMAIN union describes the structure of a user type.
struct domainlist * components
struct domain::@7 co
int type
EXTERNAL.
struct domain::@3 ba
struct gen_binding * constructand

References ARRAY_DT, domain::ba, BASIS_DT, domain::co, gen_binding::compiled, domain::components, domain::constructand, CONSTRUCTED_DT, current_first, gen_binding::domain, Domains, EXTERNAL_DT, gen_size(), IS_TABULATED, LIST_DT, MAX_DOMAIN, gen_binding::name, print_domains(), reconnect(), SET_DT, gen_binding::size, Tabulated_bp, domain::type, and user().

Referenced by build(), gen_read_spec(), and opencl_compile_mergeable_dag().

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

◆ concatenate()

string concatenate ( const char *  next,
  ... 
)

Return the concatenation of the given strings.

CAUTION! concatenation is based on a static dynamically allocated buffer which is shared from one call to another.

Note that if a string is string_undefined, it is just skiped.

FC.

else first argument is the buffer itself...

now gets the strings and concatenates them

skipping first argument if is buffer

should stop after some count?

returns the static '\0' terminated buffer.

Parameters
nextext

Definition at line 183 of file string.c.

184 {
185  int count = 0;
186  va_list args;
187  char * initial_buffer = buffer;
188 
189  if (next && next!=initial_buffer)
190  init_the_buffer();
191  /* else first argument is the buffer itself... */
192 
193  /* now gets the strings and concatenates them
194  */
195  va_start(args, next);
196  while (next)
197  {
198  count++;
199  if (next!=initial_buffer) /* skipping first argument if is buffer */
200  (void) append_to_the_buffer(next);
201  next = va_arg(args, string);
202  message_assert("reuse concatenate result only as the first argument",
203  !next || next!=initial_buffer);
204  /* should stop after some count? */
205  }
206  va_end(args);
207 
208  /* returns the static '\0' terminated buffer.
209  */
210  return buffer;
211 }
static int count
Definition: SDG.c:519
string append_to_the_buffer(const char *s)
If the string is undefined, just skip it.
Definition: string.c:145
static string buffer
Definition: string.c:113
void init_the_buffer(void)
Definition: string.c:127

Referenced by str_append(), and str_prepend().

+ Here is the caller graph for this function:

◆ DEFLIST() [1/3]

DEFLIST ( domainlist  ,
union domain ,
domain   
)

◆ DEFLIST() [2/3]

DEFLIST ( intlist  ,
int  ,
val   
)

◆ DEFLIST() [3/3]

DEFLIST ( namelist  ,
char *  ,
name   
)

◆ fatal()

◆ gen_do_enter_tabulated()

gen_chunk* gen_do_enter_tabulated ( int  domain,
char *  id,
gen_chunk cp,
bool  is_a_ref 
)

stores - if ref

Definition at line 265 of file tabulated.c.

266 {
267  int number = gen_put_tabulated(domain, cp);
268  (cp+1)->i = is_a_ref? -number: number; /* stores - if ref */
269  message_assert("name pointer ok", (cp+2)->s == id);
270  gen_put_tabulated_name(domain, id, number);
271  return cp;
272 }
Pvecteur cp
pointeur sur l'egalite ou l'inegalite courante
Definition: sc_read.c:87
static int gen_put_tabulated(int domain, gen_chunk *gc)
add tabulated in table.
Definition: tabulated.c:162
static void gen_put_tabulated_name(int domain, char *id, _int number)
Definition: tabulated.c:188

References cp, gen_put_tabulated(), gen_put_tabulated_name(), and message_assert.

Referenced by gen_enter_tabulated(), and make_ref().

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

◆ gen_enter_tabulated()

gen_chunk* gen_enter_tabulated ( int  domain,
char *  id,
gen_chunk cp,
bool  allow_ref 
)

ENTER_TABULATED_DEF enters a new definition (previous refs are allowed if ALLOW_REF) in the INDEX tabulation table of the DOMAIN, with the unique ID and value CHUNKP.

already in, redefine

Definition at line 279 of file tabulated.c.

280 {
281  gen_chunk * gp = gen_find_tabulated(id, domain);
282 
283  if (gp==gen_chunk_undefined)
284  {
285  cp = gen_do_enter_tabulated(domain, id, cp, false);
286  }
287  else /* already in, redefine */
288  {
289  register int i, size, number = (gp+1)->i;
290 
291  if (number>0)
292  fprintf(stderr, "warning: '%s' of %d redefined\n", id, domain);
293  else
294  number = -number;
295 
296  if (!allow_ref)
297  fprintf(stderr, "unexpected reference to '%s' of %d\n", id, domain);
298 
299  size = gen_size(domain);
300 
301  message_assert("same name", same_string_p((gp+2)->s, (cp+2)->s));
302  message_assert("same domain", gp->i == cp->i);
303 
304  for (i=3; i<size; i++)
305  gp[i] = cp[i];
306 
307  free((cp+2)->s), free(cp), cp = gp;
308  (cp+1)->i = number;
309  }
310 
311  return cp;
312 }
void free(void *)
#define same_string_p(s1, s2)
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
gen_chunk * gen_do_enter_tabulated(int domain, string id, gen_chunk *cp, bool is_a_ref)
Definition: tabulated.c:265
void * gen_find_tabulated(const char *key, int domain)
Definition: tabulated.c:218
A gen_chunk is used to store every object.
Definition: genC.h:58
_int i
Definition: genC.h:62

References cp, fprintf(), free(), gen_chunk_undefined, gen_do_enter_tabulated(), gen_find_tabulated(), gen_size(), gen_chunk::i, message_assert, and same_string_p.

Referenced by gen_alloc(), and make_def().

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

◆ gen_init_tabulated()

gen_tabulated_p gen_init_tabulated ( int  domain)

Definition at line 66 of file tabulated.c.

67 {
68  int i;
69  gen_chunk * t;
70  gen_tabulated_p gtp;
71 
72  gtp = (gen_tabulated_p) alloc(sizeof(struct _gtp));
73 
75  gtp->used = 0;
76  gtp->domain = domain;
78 
79  for (i=0; i<TABULATED_ELEMENTS_SIZE; i++)
80  t[i].p = gen_chunk_undefined;
81 
82  gtp->table = t;
84 
85  return gtp;
86 }
char * alloc(int size)
ALLOC is an "iron-clad" version of malloc(3).
Definition: build.c:501
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
@ hash_string
Definition: newgen_hash.h:32
struct _gtp * gen_tabulated_p
actually defined in tabulated.c
Definition: tabulated.c:51
int used
current allocated size
Definition: tabulated.c:54
gen_chunk * table
how many are used
Definition: tabulated.c:55
int domain
Definition: tabulated.c:52
hash_table names
actual table
Definition: tabulated.c:56
int size
domain number
Definition: tabulated.c:53
#define TABULATED_ELEMENTS_SIZE
table of tabulated elements.
Definition: tabulated.c:47

References alloc(), _gtp::domain, gen_chunk_undefined, hash_string, hash_table_make(), _gtp::names, _gtp::size, _gtp::table, TABULATED_ELEMENTS_SIZE, and _gtp::used.

+ Here is the call graph for this function:

◆ gen_size()

int gen_size ( int  domain)

GEN_SIZE returns the size (in gen_chunks) of an object of type defined by the BP type.

to avoid a gcc warning

OTREACHED

Definition at line 71 of file genC.c.

72 {
73  struct gen_binding * bp = Domains+domain;
74  int overhead = GEN_HEADER + IS_TABULATED(bp);
75 
76  switch (bp->domain->ba.type)
77  {
78  case BASIS_DT:
79  case ARRAY_DT:
80  case LIST_DT:
81  case SET_DT:
82  return overhead + 1;
83  case CONSTRUCTED_DT:
84  if (bp->domain->co.op == OR_OP)
85  return overhead + 2;
86  else if (bp->domain->co.op == AND_OP)
87  {
88  int size ;
89  struct domainlist * dlp = bp->domain->co.components ;
90  for( size=0 ; dlp != NULL ; dlp=dlp->cdr, size++ );
91  return overhead + size;
92  }
93  else if (bp->domain->co.op == ARROW_OP)
94  return overhead+1;
95  else
96  {
97  fatal("gen_size: unknown constructed domain operator %d\n",
98  bp->domain->co.op);
99  return -1;
100  }
101  default:
102  fatal( "gen_size: Unknown type %s\n", i2a( bp->domain->ba.type )) ;
103  return -1; /* to avoid a gcc warning */
104  /*NOTREACHED*/
105  }
106 }
#define GEN_HEADER
include <sys/stdtypes.h>
Definition: genC.h:45
char * i2a(int)
I2A (Integer TO Ascii) yields a string for a given Integer.
Definition: string.c:121
void fatal(char *,...)
enum domain_operator op

References AND_OP, ARRAY_DT, ARROW_OP, domain::ba, BASIS_DT, domain::co, domain::components, CONSTRUCTED_DT, gen_binding::domain, Domains, fatal(), GEN_HEADER, i2a(), IS_TABULATED, LIST_DT, domain::op, OR_OP, SET_DT, gen_binding::size, and domain::type.

Referenced by allocated_memory_obj_in(), compile(), copy_obj_in(), gen_enter_tabulated(), and generate_make().

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

◆ gen_tabulated_fake_object_hack()

gen_chunk* gen_tabulated_fake_object_hack ( int  domain)

WARNING: it is not reentrant...

max_tabulated_elements()

Definition at line 107 of file tabulated.c.

108 {
109  static gen_chunk c[2];
110  static struct intlist il;
111 
113 
114  c[0].i = Tabulated_bp-Domains;
115  c[1].p = gtp->table;
116 
117  il.val = gtp->size; /* max_tabulated_elements() */
118  il.cdr = (struct intlist *) NULL;
119 
122 
123  return c;
124 }
static gen_tabulated_p get_tabulated_from_domain(int domain)
Definition: tabulated.c:59
struct gen_binding * element
struct intlist * dimensions
struct domain::@6 ar
union gen_chunk * p
Definition: genC.h:69

References domain::ar, domain::dimensions, gen_binding::domain, Domains, domain::element, get_tabulated_from_domain(), gen_chunk::i, gen_chunk::p, and Tabulated_bp.

Referenced by gen_write_tabulated().

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

◆ gencode()

void gencode ( string  file)

generate the code necessary to manipulate every internal non-inlinable type in the Domains table.

header = fopen_suffix(file, ".h");

first generate protected forward declarations.

then generate actual declarations.

fclose(header);

Definition at line 928 of file genC.c.

929 {
930  // Just a hack to pretend we use these functions
931  void * no_warning = &sharp_ifopt - &sharp_else + &sharp_endif;
932  int i;
933  FILE * header, * code;
934 
935  if (file==NULL)
936  fatal("[gencode] no file name specified (%p)\n", no_warning);
937 
938  if (sizeof(void *)!=sizeof(gen_chunk))
939  fatal("[gencode] newgen fundamental layout hypothesis broken\n");
940 
941  /* header = fopen_suffix(file, ".h"); */
942  header = stdout;
943  code = fopen_suffix(file, ".c");
944 
945  fprintf(header, DONT_TOUCH);
947 
948  for (i=0; i<MAX_DOMAIN; i++) {
949  struct gen_binding * bp = &Domains[i];
950  if (bp->name && !IS_INLINABLE(bp) && !IS_TAB(bp))
951  if (IS_EXTERNAL(bp))
952  fprintf(code, "typedef void * %s;\n", bp->name);
953  }
954 
955  fprintf(code,
956  "\n"
957  "#include <stdio.h>\n"
958  "#include <stdlib.h>\n"
959  "#include <string.h>\n"
960  "#include \"genC.h\"\n"
961  "#include \"%s.h\"\n"
962  "\n",
963  file);
964 
965  /* first generate protected forward declarations.
966  */
967  for (i=0; i<MAX_DOMAIN; i++) {
968  struct gen_binding * bp = &Domains[i];
969  if (bp->name && !IS_INLINABLE(bp) && !IS_TAB(bp))
970  generate_safe_definition(header, bp, file);
971  }
972 
973  /* then generate actual declarations.
974  */
975  for (i=0; i<MAX_DOMAIN; i++) {
976  struct gen_binding * bp = &Domains[i];
977  if (bp->name && !IS_INLINABLE(bp) && !IS_IMPORT(bp) && !IS_TAB(bp))
978  generate_domain(header, code, bp);
979  }
980 
981  /* fclose(header); */
982  fclose(code);
983 }
static int sharp_ifopt(FILE *out)
Might be used to generate optimized versions (say macros instead of functions).
Definition: genC.c:59
#define DONT_TOUCH
Definition: genC.c:918
static int sharp_endif(FILE *out)
Definition: genC.c:65
static void generate_safe_definition(FILE *out, struct gen_binding *bp, string file)
generates a needed type declaration.
Definition: genC.c:661
static int sharp_else(FILE *out)
Definition: genC.c:62
#define IS_TAB(x)
Definition: genC.c:46
static void generate_domain(FILE *header, FILE *code, struct gen_binding *bp)
generate the needed stuff for bp.
Definition: genC.c:711
static FILE * fopen_suffix(string prefix, string suffix)
fopen prefix + suffix.
Definition: genC.c:905
#define IS_EXTERNAL(bp)
#define IS_INLINABLE(bp)
Different kinds of BINDING structure pointers.
#define IS_IMPORT(bp)
struct _newgen_struct_code_ * code
Definition: ri.h:79

References Domains, DONT_TOUCH, fatal(), fopen_suffix(), fprintf(), generate_domain(), generate_safe_definition(), IS_EXTERNAL, IS_IMPORT, IS_INLINABLE, IS_TAB, MAX_DOMAIN, gen_binding::name, sharp_else(), sharp_endif(), and sharp_ifopt().

Referenced by build().

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

◆ genread_lex()

int genread_lex ( void  )

◆ genread_parse()

int genread_parse ( void  )

◆ genspec_lex()

int genspec_lex ( void  )

◆ genspec_parse()

int genspec_parse ( void  )

◆ i2a()

char* i2a ( int  i)

I2A (Integer TO Ascii) yields a string for a given Integer.

Moved in this global place from build.c since it used in many place in PIPS.

Definition at line 121 of file string.c.

121  {
122  static char buf[ 20 ] ;
123  sprintf( &buf[0], "%d", i ) ;
124  return buf;
125 }
static char buf[BSZ]
Definition: split_file.c:157

◆ init()

void init ( void  )

INIT initializes global data structures.

FC: formats are directly inlined in genClib...

Tabulated_bp hack is statically allocated here.

Definition at line 130 of file build.c.

131 {
132  struct gen_binding *bp ;
133  struct inlinable *ip ;
134 
135  /* FC: formats are directly inlined in genClib...
136  */
137  struct inlinable Inline[] = {
138  {UNIT_TYPE_NAME, "U", "U", ":unit", "U"},
139  {"bool", "1", "B%d", "newgen:gen-true", "~S"},
140  {"char", "#\\a", "#\\%c", "#\\space", "~C"},
141  {"int", "0", "%d", "0", "~D"},
142  {"float", "0.0", "%f", "0.0", "~F"},
143  {"string", "\"\"", "\"%s\"", "\"\"", "~S"},
144  {NULL, "-- HELP --", "-- HELP --", "-- HELP --", "-- HELP --"},
145  } ;
146 
147  for( bp = Domains ; bp < &Domains[ MAX_DOMAIN ] ; bp++ ) {
148  bp->name = NULL ;
149  bp->compiled = 0 ;
150  bp->size = 0 ;
151  bp->tabulated = NULL;
152  bp->domain = NULL ;
153  bp->inlined = NULL ;
154  }
155 
156  for( ip = Inline, bp = Domains ; ip->name != NULL ; ip++, bp++ ) {
157  bp->name = ip->name ;
158  bp->compiled = 1 ;
159  bp->inlined = ip ;
160  }
161 
162  /* Tabulated_bp hack is statically allocated here. */
163  {
164  static union domain d ;
165  bp->name = "Name for tabulated domain" ;
166  bp->domain = &d ;
167  d.ba.type = ARRAY_DT ;
168  d.ar.constructor = "Constructor for tabulated domain" ;
169  d.ar.element = (struct gen_binding *) NULL ;
170  d.ar.dimensions = (struct intlist *) NULL;
171  Tabulated_bp = bp ;
172  }
173 
174  Current_op = UNDEF_OP ;
175  Current_start = -1 ;
176  error_seen = 0 ;
177 }
int error_seen
Have we seen a user error somewhere ?
Definition: build.c:76
int Current_op
Used to check, while parsing specs, that a constructed domain use only one operator type.
Definition: build.c:62
int Current_start
Definition: build.c:62
#define UNIT_TYPE_NAME
The UNIT_TYPE_NAME is the used to type expressions which only perform side-effects.
struct inlinable * inlined
gen_tabulated_p tabulated
number of chunks to hold this data.
INLINE[] gives, for each inlinable (i.e., unboxed) type, its NAME, its initial VALUE and its printing...
Definition: build.c:45
string name
Definition: build.c:46

References domain::ar, ARRAY_DT, domain::ba, gen_binding::compiled, domain::constructor, Current_op, Current_start, domain::dimensions, gen_binding::domain, Domains, domain::element, error_seen, gen_binding::inlined, MAX_DOMAIN, inlinable::name, gen_binding::name, gen_binding::size, gen_binding::tabulated, Tabulated_bp, domain::type, UNDEF_OP, and UNIT_TYPE_NAME.

Referenced by build().

+ Here is the caller graph for this function:

◆ lookup()

struct gen_binding* lookup ( )

◆ new_binding()

struct gen_binding* new_binding ( )

◆ newgen_domain_index()

int newgen_domain_index ( gen_chunk obj)

DOMAIN_INDEX returns the index in the Domain table for object OBJ.

Definition at line 105 of file genClib.c.

106 {
107  message_assert("No NULL object", obj!=NULL);
108  message_assert("No undefined object", obj!=gen_chunk_undefined);
109  if ((obj->i)<0 || (obj->i)>=MAX_DOMAIN)
110  fatal("Inconsistent domain number %d (%p) found\n",
111  obj->i, obj);
112  return obj->i;
113 }

References fatal(), gen_chunk_undefined, gen_chunk::i, MAX_DOMAIN, and message_assert.

+ Here is the call graph for this function:

◆ print_domain()

void print_domain ( FILE *  out,
union domain dp 
)

PRINT_DOMAIN prints on the OUT stream a domain denoted by the DP pointer.

This is done before the compilation so (STRUCT BINDING *) members are still strings.

Definition at line 294 of file build.c.

295 {
296  if (!dp) {
297  fprintf(out, " NULL union domain");
298  return;
299  }
300 
301  switch( dp->ba.type ) {
302  case EXTERNAL_DT:
303  break ;
304  case IMPORT_DT:
305  (void)fprintf( out, " from \"%s\"", dp->im.filename ) ;
306  break ;
307  case BASIS_DT:
308  (void)print_persistant( out, dp ) ;
309 #ifdef DBG_DOMAINS
310  (void)fprintf( out, "%s:%s (%d)",
311  dp->ba.constructor, dp->ba.constructand->name,
312  dp->ba.constructand-Domains ) ;
313 #else
314  (void)fprintf(out, "%s:%s",
315  dp->ba.constructor, dp->ba.constructand->name );
316 #endif
317  break ;
318  case LIST_DT:
319  print_persistant( out, dp ) ;
320  (void)fprintf(out, "%s:%s*",
321  dp->li.constructor, dp->li.element->name ) ;
322  break ;
323  case SET_DT:
324  print_persistant( out, dp ) ;
325  (void)fprintf(out, "%s:%s{}",
326  dp->se.constructor, dp->se.element->name ) ;
327  break ;
328  case ARRAY_DT: {
329  struct intlist *ilp ;
330 
331  print_persistant( out, dp ) ;
332  (void)fprintf(out, "%s:%s",
333  dp->ar.constructor, dp->ar.element->name ) ;
334 
335  for( ilp = dp->ar.dimensions ; ilp != NULL ; ilp = ilp->cdr )
336  (void)fprintf( out, "[%d]", ilp->val ) ;
337 
338  break ;
339  }
340  case CONSTRUCTED_DT:
341  print_domainlist( out, dp->co.components, dp->co.op ) ;
342  break ;
343  default:
344  fatal( "print_domain: switch on %s\n", i2a( dp->ba.type )) ;
345  }
346 }
static FILE * out
Definition: alias_check.c:128
void print_domainlist(out, l, op)
PRINT_DOMAINLIST prints, in the OUT stream, the List of domains, bound together by an OPerator.
Definition: build.c:265
void print_persistant(out, dp)
Definition: build.c:281
char * constructor
struct domain::@5 se
struct domain::@8 im
struct domain::@4 li
char * filename

References domain::ar, ARRAY_DT, domain::ba, BASIS_DT, domain::co, domain::components, domain::constructand, CONSTRUCTED_DT, domain::constructor, domain::dimensions, Domains, domain::element, EXTERNAL_DT, fatal(), domain::filename, fprintf(), i2a(), domain::im, IMPORT_DT, domain::li, LIST_DT, gen_binding::name, domain::op, out, print_domainlist(), print_persistant(), domain::se, SET_DT, and domain::type.

Referenced by defined_null(), gen_trav_obj(), gen_trav_simple(), print_domainlist(), and print_domains().

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

◆ print_domains()

void print_domains ( FILE *  out)

PRINT_DOMAINS prints on the OUT stream the Domains table.

Inlined domains aren't printed.

if( (dp=bp->domain)->ba.type==CONSTRUCTED_DT && dp->co.op==OR_OP) (void)fprintf( out, "--NEWGEN-FIRST %d\n", dp->co.first ) ;

Definition at line 352 of file build.c.

353 {
354  struct gen_binding *bp ;
355 
356  for( bp = Domains ; bp < &Domains[ MAX_DOMAIN ] ; bp++ ) {
357  if( bp->name == NULL || bp == Tabulated_bp ) continue ;
358 
359  if( !IS_INLINABLE( bp )) {
360 
361  /* if( (dp=bp->domain)->ba.type==CONSTRUCTED_DT && dp->co.op==OR_OP)
362  (void)fprintf( out, "--NEWGEN-FIRST %d\n", dp->co.first ) ; */
363 
364  (void)fprintf( out,
365  (IS_EXTERNAL( bp ) ? "external %s" :
366  IS_IMPORT( bp ) ? "import %s" :
367  IS_TABULATED( bp ) ? "tabulated %s = " :
368  "%s = "),
369  bp->name ) ;
370  print_domain( out, bp->domain ) ;
371  (void)fprintf( out, ";\n" ) ;
372  }
373  }
374 }
void print_domain(FILE *out, union domain *dp)
PRINT_DOMAIN prints on the OUT stream a domain denoted by the DP pointer.
Definition: build.c:294

References gen_binding::domain, Domains, fprintf(), IS_EXTERNAL, IS_IMPORT, IS_INLINABLE, IS_TABULATED, MAX_DOMAIN, gen_binding::name, out, print_domain(), and Tabulated_bp.

Referenced by compile(), and gen_write_spec().

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

◆ user()

Variable Documentation

◆ Current_op

int Current_op
extern

Used to check, while parsing specs, that a constructed domain use only one operator type.

Definition at line 62 of file build.c.

Referenced by init(), and update_op().

◆ Current_start

int Current_start
extern

Definition at line 62 of file build.c.

Referenced by init(), and lookup().

◆ Domains

struct gen_binding Domains[]
extern

The implementation of tabulated domains.

Domains is the symbol table for user defined types.

COMPILED refers to inlined data types. INDEX is used whenever the type is used with refs and defs (ALLOC is the next place to allocate tabulated values).

The implementation of tabulated domains.

Domains is the symbol table for user defined types.

COMPILED refers to inlined data types. INDEX is used whenever the type is used with refs and defs (ALLOC is the next place to allocate tabulated values).

Definition at line 150 of file newgen_include.h.

Referenced by allocated_memory_obj_in(), chunk_for_domain(), compile(), copy_obj_in(), free_obj_in(), gen_alloc(), gen_check(), gen_domain_name(), gen_init_external(), gen_read_spec(), gen_size(), gen_tabulated_fake_object_hack(), gen_trav_leaf(), gen_trav_obj(), gen_write_tabulated(), gencode(), generate_make(), get_domain_number(), get_tabulated_from_domain(), gtt_read(), gtt_write(), init(), init_gen_quick_recurse_tables(), initialize_DirectDomainsTable(), initialize_domain_DecisionTables(), initialize_domain_DirectDomainsTable(), lookup(), make_ref(), new_binding(), print_decision_table(), print_domain(), print_domains(), quick_multi_recurse_obj_in(), quick_multi_recurse_simple_in(), read_external(), sharing_obj_in(), write_leaf_in(), and write_obj_in().

◆ Number_imports

int Number_imports
extern

To manage imported domains:

  • NUMBER_IMPORTS is the number of imported domains (for which no access functions have to be generated - see TYPE in genC.c)
  • CURRENT_START is the beginning index (after TABULATED_BP) in Domains
  • CURRENT_FIRST WAS, for each OR_OP domain, the first tag number (used only in READ_SPEC_MODE). It is now 0.

Definition at line 115 of file genspec_yacc.c.

◆ Read_chunk

gen_chunk* Read_chunk
extern

The root of the gen_chunk read with READ_CHUNK.

The root of the gen_chunk read with READ_CHUNK.

Definition at line 134 of file genread_yacc.c.

Referenced by gen_read(), and gen_read_tabulated().

◆ Read_spec_mode

int Read_spec_mode
extern

extern int Current_first ;

Definition at line 60 of file genClib.c.

Referenced by gen_read_spec(), main(), new_binding(), and reconnect().

◆ Tabulated_bp

struct gen_binding* Tabulated_bp

hack to walk thru tabulateds...

Definition at line 80 of file newgen_include.h.