39 #undef gen_context_recurse
110 fatal(
"Inconsistent domain number %d (%p) found\n",
122 number = number<0 ? 0 : number;
123 number = number<40 ? number : 40;
124 for(; number ; number-- )
133 write_gen_chunk( file, obj, l )
140 (void)
fprintf( file,
"Chunk %x on %d:", obj, l ) ;
142 for( i=0 ; i<l ; i++ )
143 (
void)
fprintf( file,
"%d ", *(obj+i)) ;
156 struct intlist *dim ;
160 for( ; dim != NULL ; dim = dim->cdr )
175 for( ; sizarray ; sizarray-- )
198 #define gen_alloc_component(dp, cp, ap, gen_check_p) \
200 message_assert("gen_check_p parameter value ok", \
201 gen_check_p==0 || gen_check_p==1); \
203 switch( dp->ba.type ) { \
205 if( ((cp)->p = va_arg( ap, gen_chunk * )) == NULL ) \
206 (cp)->p = init_array( dp ) ; \
209 (cp)->l = va_arg( ap, cons * ) ; \
212 (cp)->t = va_arg( ap, set ) ; \
215 if( IS_INLINABLE( dp->ba.constructand )) { \
216 switch( *dp->ba.constructand->name ) { \
217 case 'u': (cp)->u = va_arg( ap, unit ) ; break ; \
218 case 'b': (cp)->b = va_arg( ap, int )
; break ; \
219 case 'c': (cp)->c = va_arg( ap, int ) ; break ; \
220 case 'i': (cp)->i = va_arg( ap, int ) ; break ; \
221 case 'f': (cp)->f = va_arg( ap, double ) ; break ; \
222 case 's': (cp)->s = va_arg( ap, string ) ; break ; \
224 fatal( "gen_alloc: unknown inlinable %s\n", \
225 dp->ba.constructand->name ) ; \
228 else if( IS_EXTERNAL( dp->ba.constructand )) { \
229 (cp)->s = va_arg( ap, char * ) ; \
232 (cp)->p = va_arg( ap, gen_chunk * ) ; \
234 if( gen_debug & GEN_DBG_CHECK || gen_check_p ) { \
235 (void) gen_check( (cp)->p, dp->ba.constructand-Domains ) ; \
240 fatal("gen_alloc_component: unknown type %s\n", \
241 i2a(dp->ba.type)) ; \
256 struct domainlist * dlp;
259 gen_check_p==0 || gen_check_p==1);
261 switch( dp->
co.
op ) {
267 dlp=dlp->cdr, cpp++ ) {
275 (
cp+
data)->i = va_arg( ap,
int ) ;
278 for( dlp=dp->
co.
components; dlp!=NULL && which ;dlp=dlp->cdr ){
282 user(
"gen_alloc: unknown tag for type %s\n", bp->
name ) ;
292 fatal(
"gen_alloc: Unknown op %s\n",
i2a( dp->
co.
op )) ;
307 gen_check_p==0 || gen_check_p==1);
318 char * p = (
char *)
cp;
320 for (i=0; i<
size; i++)
329 switch( (dp = bp->
domain)->ba.type ) {
380 #define CHECK_NULL(obj,bp,dr) \
381 if((obj)==gen_chunk_undefined) {(*(dr)->null)(bp) ; return ;}
399 (void)
fprintf( stderr,
"trav_leaf dealing with " ) ;
402 (
void)
fprintf( stderr,
"inlined %s\n", bp->
name ) ;
404 (void)
fprintf( stderr,
"external %s\n", bp->
name ) ;
406 (
void)
fprintf( stderr,
"tabulated %s\n", bp->
name ) ;
407 else (
void)
fprintf( stderr,
"constructed %s\n", bp->
name ) ;
443 (void)
fprintf( stderr,
"trav_simple dealing with " ) ;
445 (void)
fprintf( stderr,
"\n" ) ;
458 for (p = obj->
l ; p != NULL ; p = p->
cdr)
472 for (i=0 ; i<size; i++)
517 struct domainlist *dlp;
526 for(
cp = obj+
data ; dlp != NULL ;
cp++, dlp = dlp->cdr)
536 for(; dlp!=NULL && which; which--,dlp=dlp->cdr)
539 fatal(
"gen_trav_obj: Unknown tag %s\n",
i2a( (obj+
data)->i )) ;
547 *dvalp=dlp->cdr->domain;
562 fatal(
"gen_trav_obj: Unknown op %s\n",
i2a(dp->
co.
op)) ;
577 fatal(
"unexpected NULL value encountered\n");
582 if ((*dr->
obj_in)(obj, dr))
593 (void)
fprintf( stderr,
"trav_obj (%p) ", obj) ;
595 (void)
fprintf( stderr,
"\n" ) ;
632 #define MAX_SHARED_OBJECTS 10000
637 #define FIRST_SEEN(s) ((s)>=first_seen && (s)<first_seen+MAX_SHARED_OBJECTS)
706 for( p=obj->
l ; p!=
NIL ; p=p->
cdr )
722 fatal(
"shared_simple_in: unknown type %s\n",
i2a( dp->
ba.
type )) ;
797 #define MAX_GEN_TRAV_ENV 100
889 user(
"gen_free: uninitialized external type %s\n",
966 fatal(
"persistant_simple_in: unknown type %s\n",
i2a( dp->
ba.
type )) ;
1031 for (p = l; p ; p=nextp)
1064 fatal(
"[copy_hsearch] bad key: %p\n", key );
1103 (void) memcpy((
char *) new_obj, (
char *) obj,
size);
1130 return(!persistence);
1164 user(
"gen_copy_tree: uninitialized external type %s\n",
1183 list old_p, new_p =
NIL, new_l, pc;
1196 for (old_p = old_l ; old_p !=
NIL ; old_p = old_p->
cdr)
1234 (void) memcpy((
char *) new_a, (
char *) old_a, size*
sizeof(
gen_chunk));
1237 for (i = 0; i < size; i++) {
1299 #define COPYABLE_DOMAIN(d) \
1300 ( d->ba.type != BASIS_DT || \
1301 (!(IS_INLINABLE(d->ba.constructand) && (*d->ba.constructand->name!='s')) && \
1302 !IS_TABULATED( d->ba.constructand )))
1317 switch( dp->
co.
op ) {
1321 for(
cp = obj+
data ; dlp != NULL ;
cp++, dlp = dlp->cdr ) {
1331 for( ; dlp!=NULL && which ; which--,dlp=dlp->cdr ) {
1335 fatal(
"[copy_obj_out] Unknown tag %s\n",
i2a( (obj+
data)->i )) ;
1352 }, (obj+
data)->h ) ;
1356 fatal(
"[copy_obj_out] Unknown op %s\n",
i2a( dp->
co.
op )) ;
1541 fatal(
"write_obj_in: Don't know how to write an EXTERNAL: %s\n",
1591 user(
"null string not allowed");
1601 for(; *s !=
'\0' ; s++)
1603 if (*s==
'"' || *s==
'\\') putc(
'\\',
user_file);
1619 user(
"gen_write: writing undefined tabulated object\n", NULL);
1648 fatal(
"write_leaf_in: Don't know how to print %s\n", bp->
name ) ;
1653 user(
"gen_write: uninitialized external type %s (%d)\n",
1819 number = (obj->
p+1)->i;
1822 fatal(
"write_tabulated_leaf_in: Zero index in domain %s\n", bp->
name);
1841 (obj->
p+1)->i = - (obj->
p+1)->i;
1860 if ((o+1)->i < 0) (o+1)->i = -((o+1)->i);
1912 static char *
strdup(
const char * s)
1914 char *
new = (
char*)
malloc(strlen(s)+1);
1945 int i=0, size = 20, c;
1946 char *
buf = (
char*)
malloc(
sizeof(
char)*size), * res;
1948 while((c=getc(file)) && c!=EOF && c!=upto)
1953 buf = (
char*) realloc((
char*)
buf,
sizeof(char)*size);
1957 buf[i++] = (char) c;
1959 if (c==EOF && i==0) { res = NULL;
free(
buf); }
2011 if (t[i] == -1)
return i;
2034 items[i].name = NULL;
2035 items[i].number = -1;
2036 items[i].definition = NULL;
2042 file = fopen(filename,
"r");
2045 fatal(
"cannot open type translation file \"%s\"\n", file);
2051 fscanf(file,
"%d", &items[i].number) &&
2056 fatal(
"file translation too long, extend MAX_DOMAIN");
2061 for (i=0, same=
true; i<
MAX_DOMAIN && same; i++)
2063 if (items[i].number!=-1 && items[i].name)
2065 (items[i].number==i);
2078 fprintf(stderr,
"warning: newgen compatibility mode\n");
2086 if (items[i].name && items[i].number!=-1)
2096 fprintf(stderr,
"warning, domain \"%s\" (%d) not found\n",
2097 items[i].name, items[i].number);
2111 fatal(
"too many types to allow translations, extend MAX_DOMAIN...");
2135 FILE * file = fopen(filename,
"w");
2153 if (nn==-1)
fatal(
"old type number %d not available", n);
2166 if (on==-1)
fatal(
"new type number %d not available", n);
2212 #define genspec_lex_destroy()
2222 extern int unlink();
2232 va_start(ap, spec) ;
2243 spec = va_arg( ap,
char *);
2253 user(
"Cannot run with imported domains: %s\n", bp->
name ) ;
2277 void *(*read)(FILE*,
int(*)(
void)),
2278 void (*write)(FILE*,
void*),
2279 void (*
free)(
void*),
2280 void *(*copy)(
void*),
2281 int (*allocated_memory)(
void*))
2287 user(
"gen_init_external: %s isn't external\n", bp->
name ) ;
2290 if( dp->
ex.
read != NULL ) {
2291 user(
"gen_init_external: redefinition of %s skipped\n",
2314 for( i=0 ; i<
num ; i++ )
2364 (void)
user(
"gen_check: NULL pointer, expecting type %s\n",
2372 user(
"gen_check: Type clash (expecting %s, getting %s)\n",
2374 (obj->
i >= 0 && obj->
i<=max_index )?
Domains[ obj->
i ].
name :
"???") ;
2390 if ((
black_hole=fopen(
"/dev/null",
"r")) == NULL)
2391 fatal(
"Cannot open /dev/null !") ;
2432 user(
"", (
char *)NULL ) ;
2433 (void)
fprintf( stderr,
"gen_defined_p: Undefined object of type < " );
2435 (void)
fprintf( stderr,
"> found\n" ) ;
2478 user(
"Sharing of %s detected on %p",
type, p ) ;
2508 for( p=obj->
l ; p!=
NIL ; p=p->
cdr ) {
2546 if( (found=setjmp(
env )) == 0 )
2600 user(
"[gen_allocated_memory] warning: "
2601 "external with no allocated memory function\n");
2683 fatal(
"allocated_memory_simple_in: unknown type %s\n",
i2a(dp->
ba.
type));
2694 int result, saved_size;
2853 #define decision_table_undefined ((char)25)
2867 fprintf(stderr,
"[print_decision_table] %p\n", t);
2887 "[initialize_domain_DecisionTables] domain %s (%d)\n",
2913 not_used[i] =
false;
2925 " - shortening with already computed %s (%d)\n",
2936 " - including %s (%d)\n",
2945 fprintf(stderr,
" - computed table is\n"),
2956 if (dp==NULL)
return;
2968 " - setting %s (%d) contains %s (%zd)\n",
2977 for (; l!=NULL; l=l->cdr)
2985 fprintf(stderr,
"newgen: unexpected domain type (%d)\n", dp->
ba.
type),
3003 "[initialized_DirectDomainsTable] analysing %s\n",
3018 fprintf(stderr,
"[initialized_DirectDomainsTable] %s (%d)\n",
3051 "[init_gen_quick_recurse_tables] %d domains\n",
3157 int dom = obj->
i, go = !
GO;
3236 (
fatal(
"persistant_simple_in: unknown type %s\n",
3283 message_assert(
"tabulated domain recursion is not implemented", !gointabs);
3294 new_domain_table[i] =
false;
3295 new_decision_table[i] =
false;
3296 new_filter_table[i] = NULL;
3297 new_rewrite_table[i] = NULL;
3301 while((
domain=va_arg(pvar,
int)) != 0)
3305 new_domain_table[
domain] =
true;
3310 new_decision_table[i] |= (*p_table)[i];
3316 new_mrc.
domains = &new_domain_table,
3317 new_mrc.
decisions = &new_decision_table,
3318 new_mrc.
filters = &new_filter_table,
3319 new_mrc.
rewrites = &new_rewrite_table,
3455 bool (*filter)(
void * encountered),
3456 void (*rewrite)(
void * encountered_object))
3487 bool (*filter)(
void * encountered_object,
void *
context),
3488 void (*rewrite)(
void * encountered_object,
void *
context))
3569 else if (prev->
i ==
type)
float a2sf[2] __attribute__((aligned(16)))
USER generates a user error (i.e., non fatal) by printing the given MSG according to the FMT.
static hash_table seen
static function to store whether a module has been seen during the recursive generation of the daVinc...
void const char const char const int
char * alloc(int size)
ALLOC is an "iron-clad" version of malloc(3).
void print_domain(FILE *out, union domain *dp)
PRINT_DOMAIN prints on the OUT stream a domain denoted by the DP pointer.
void compile(void)
COMPILE reconnects the Domains table (for not compiled types – note that an inlined type is already c...
int gen_size(int domain)
GEN_SIZE returns the size (in gen_chunks) of an object of type defined by the BP type.
#define GEN_DBG_TRAV_OBJECT
#define gen_chunk_undefined_p(c)
union gen_chunk gen_chunk
A gen_chunk is used to store every object.
#define GEN_DBG_TRAV_LEAF
#define GEN_DBG_TRAV_SIMPLE
#define gen_chunk_undefined
static int shared_obj_in(gen_chunk *obj, struct driver *dr)
SHARED_OBJ_IN introduces an object OBJ in the OBJ_TABLE.
static void write_define_shared_node(int n)
WRITE_DEFINE_SHARED_NODE defines the node whose number is N.
#define gen_alloc_component(dp, cp, ap, gen_check_p)
gen_alloc_component updates the gen_chunk CP from the arg list AP according to the domain DP.
void gen_free(gen_chunk *obj)
version without shared_pointers.
static int free_leaf_in(gen_chunk *obj, struct gen_binding *bp)
A tabulated domain BP prohibits its OBJ to be recursively freed.
static int allocated_memory_simple_in(gen_chunk *obj, union domain *dp)
manages newgen simples (list, set, array)
static bool gen_trav_stop_recursion
static int quick_multi_recurse_obj_in(gen_chunk *obj, __attribute__((unused)) struct driver *dr)
static gen_chunk * gen_copy_array(gen_chunk *old_a, dp)
GEN_COPY_ARRAY duplicates an array.
gen_chunk * gen_alloc(int size, int gen_check_p, int dom,...)
allocates something in newgen.
static void gen_array_leaf(struct gen_binding *bp, int i, gen_chunk *obj, struct driver *dr)
GEN_ARRAY_LEAF is the default recursive call to gen_trav_leaf.
static int disallow_undefined_tabulated
Default option in GEN_WRITE.
static int copy_obj_in(gen_chunk *obj, __attribute__((unused)) struct driver *dr)
COPY_OBJ_IN duplicates an object if it has not already been seen (this migth happen with shared objec...
static void write_obj_out(gen_chunk *obj, struct gen_binding *bp, struct driver *dr)
WRITE_OBJ_OUT is done when the OBJect (of type BP) has been printed.
int gen_write_tabulated(FILE *fd, int domain)
GEN_WRITE_TABULATED writes the tabulated object TABLE on FD.
string gen_domain_name(int t)
GEN_DOMAIN_NAME returns the domain name, and may be used for debug purposes.
static FILE * user_file
These functions implements the writing of objects.
static gen_chunk * gen_local_copy_tree(gen_chunk *obj, bool keep)
GEN_COPY_TREE makes a copy of the object OBJ.
static int write_obj_in(gen_chunk *obj, struct driver *dr)
WRITE_OBJ_IN writes the OBJect of type BP.
static FILE * black_hole
used for consistence checking...
int gen_type_translation_old_to_actual(int n)
forwards conversion
void gen_full_free_list(list l)
void gen_type_translation_reset(void)
static gen_chunk * init_array(union domain *dp)
INIT_ARRAY returns a freshly allocated array initialized according to the information in its domain D...
void genspec_set_string_to_parse(char *)
static int write_tabulated_leaf_in(gen_chunk *obj, struct gen_binding *bp)
WRITE_TABULATED_LEAF_IN prints the OBJect of type BP.
int gen_read_tabulated(FILE *file, int create_p)
GEN_READ_TABULATED reads FILE to update the Gen_tabulated_ table.
void gen_type_translation_write(string filename)
int current_shared_obj_table_size(void)
returns the number of byte allocated for obj_table.
static void copy_obj_out_constructed(gen_chunk *obj, struct gen_binding *bp, dp, data, new_obj, dr)
FILE * genspec_in
lex files
static struct multi_recurse * current_mrc
the current multi recurse driver.
static int allocated_memory_obj_in(gen_chunk *obj, struct driver *dr)
manages newgen objects and strings...
static void free_simple_out(gen_chunk *obj, union domain *dp)
FREE_SIMPLE_OUT frees the spine of the list OBJ or the whole array (according to the type DP).
void gen_write_without_sharing(fd, obj)
GEN_WRITE_WITHOUT_SHARING writes the OBJect on the stream FD.
static void write_this_tabulated(gen_chunk *o)
static gtt_p gtt_current_table
global translation table.
static void init_gen_quick_recurse_tables(void)
GEN_READ_SPEC reads the specifications.
int error_seen
Have we seen a user error somewhere ?
int gen_consistent_p(gen_chunk *obj)
GEN_CONSISTENT_P dynamically checks the type correctness of OBJ.
bool gen_sharing_p(gen_chunk *obj1, gen_chunk *obj2)
static int gen_debug_indent
static void free_obj_out(gen_chunk *obj, struct gen_binding *bp, struct driver *dr)
FREE_OBJ_OUT just frees the object OBJ.
static int free_obj_in(gen_chunk *obj, struct driver *dr)
static int tabulated_leaf_in(gen_chunk *obj, struct gen_binding *bp)
#define decision_table_undefined
GLOBAL VARIABLES: to deal with decision tables.
static int array_own_allocated_memory(union domain *dp)
static void print_decision_table(GenDecisionTableType t)
static void gen_trav_leaf(struct gen_binding *bp, gen_chunk *obj, struct driver *dr)
set to true to stop...
static hash_table obj_table
The OBJ_TABLE maps objects to addresses within the arrays FIRST_SEEN and SEEN_ONCE.
static void copy_obj_out(obj, bp, dr)
static int write_simple_in(obj, dp)
WRITE_SIMPLE_IN is done before printing a simple OBJect of type DP.
static struct driver * wtt_dr
int newgen_domain_index(gen_chunk *obj)
DOMAIN_INDEX returns the index in the Domain table for object OBJ.
static hash_table copy_table
These functions are used to implement the copying of objects.
GenDecisionTableType gen_tables[MAX_DOMAIN]
static int quick_multi_recurse_simple_in(gen_chunk *obj, union domain *dp)
#define MAX_SHARED_OBJECTS
These functions computes an hash table of object pointers (to be used to manage sharing when dealing ...
#define COPYABLE_DOMAIN(d)
COPY_OBJ_OUT achieves to update the new object (copy of the old one) once all sub-domains have been r...
int gen_debug
The debug flag can be changed by the user to check genClib code.
static int get_domain_number(string name, int i)
== simplified lookup? returns the index of domain name if found, looking up from i.
string gen_read_string(FILE *file, char upto)
returns the allocated line read, whatever its length.
static void write_null(struct gen_binding *bp)
static int first_available(int t[MAX_DOMAIN])
static void write_shared_node(int n)
WRITE_SHARED_NODE references a shared node N.
static int persistant_simple_in(obj, dp)
GEN_LOCAL_FREE frees the object OBJ with or without KEEPing the sharing.
int gen_defined_p(gen_chunk *obj)
static void gtt_write(string filename, gtt_p table)
writes what the previous reads...
static list gen_copy_list(list old_l, union domain *dp)
GEN_COPY_LIST duplicates cons cells.
void newgen_start_lexer(FILE *)
starting the scanner.
gen_chunk * gen_copy_tree_with_sharing(gen_chunk *obj)
for re-entry only in gen_copy_tree...
static int write_leaf_in(gen_chunk *obj, struct gen_binding *bp)
WRITE_LEAF_IN prints the OBJect of type BP.
static void gtt_table_init(gtt_p table)
static bool allocated_memory_already_seen_p(gen_chunk *obj)
true if obj was already seen in this recursion, and put it at true
gen_chunk * gen_check(gen_chunk *obj, int t)
GEN_CHECK checks that the gen_chunk received OBJ is of the appropriate TYPE.
int gen_free_tabulated(int domain)
free tabulated elements of this domain.
static void void_gen_consistent_p(gen_chunk *obj)
for side effects only
static gen_tables DecisionTables
static void push_gen_trav_env()
gen_chunk * gen_make_array(num)
GEN_MAKE_ARRAY allocates an initialized array of NUM gen_chunks.
#define CHECK_NULL(obj, bp, dr)
To be called on any object pointer.
static GenDecisionTableType * get_decision_table(int domain)
returns a decision table for the given domain.
static void write_simple_out(gen_chunk *obj, union domain *dp)
WRITE_LEAF_OUT prints the closing parenthesis of (non-basis) simple OBJect of type DP.
GenFilterType GenFilterTableType[MAX_DOMAIN]
struct gen_binding * Tabulated_bp
pointer to tabulated domain hack
static void write_string(string init, string s, string end, string ifnull, string ifundefined)
static bool Read_spec_performed
void gen_init_external(int which, void *(*read)(FILE *, int(*)(void)), void(*write)(FILE *, void *), void(*free)(void *), void *(*copy)(void *), int(*allocated_memory)(void *))
GEN_INIT_EXTERNAL defines entry points for free, read and write functions of external types.
void genspec_reset_string_to_parse(void)
static __thread hash_table free_already_seen
These functions are used to implement the freeing of objects.
int gen_type(gen_chunk *obj)
GEN_TYPE returns the domain number for the object in argument.
static struct gen_binding * wtt_bp
static void write_array_leaf(struct gen_binding *bp, int i, gen_chunk *obj, struct driver *dr)
WRITE_ARRAY_LEAF only writes non-null elements, in a sparse way.
gen_chunk * gen_read(FILE *file)
GEN_READ reads any object from the FILE stream.
static void fputi(int i, FILE *f)
static gen_tables DirectDomainsTable
int gen_type_translation_actual_to_old(int n)
backwards conversion
static void shared_pointers(obj, keep)
SHARED_POINTERS creates (in OBJ_TABLE) the association between objects and their numbers (!...
static gtt_p gtt_make(void)
returns an allocated and initialized translation table...
static set gen_copy_set(set old_s, dp)
GEN_COPY_SET duplicates a set.
static hash_table pointers
GEN_SHARING_P checks whether OBJ1 uses objects (except tabulated) or CONS cells that appear in OBJ2.
static void fputci(char c, int i, FILE *f)
static void change_sign(gen_chunk *o)
static int copy_simple_in(gen_chunk *obj, union domain *dp)
Just check for defined simple domains.
static int number_of_domains
static int shared_obj(obj, void(*first)(), void(*others)())
SHARED_OBJ manages the OBJect modulo sharing (the OBJ_TABLE has to be set first, see above).
static void open_black_hole()
static bool quick_multi_already_seen_p(gen_chunk *obj)
true if obj was already seen in this recursion.
static void copy_hput(hash_table t, char *k, char *v)
static int allocated_memory_leaf_in(obj, bp)
manages EXTERNALS and INLINABLES
static void gen_alloc_constructed(va_list ap, struct gen_binding *bp, union domain *dp, gen_chunk *cp, int data, int gen_check_p)
GEN_ALLOC allocates SIZE bytes to implement an object whose TYPE is the index in the Domains table.
static void free_leaf_out(obj, bp)
FREE_LEAF_OUT manages external types.
char GenDecisionTableType[MAX_DOMAIN]
static void initialize_DirectDomainsTable(void)
static int shared_number
The running counter of shared objects number.
static void gen_trav_obj()
static int array_size(dim)
ARRAY_SIZE returns the number of elements in the array whose dimension list is DIM.
static hash_table already_seen_objects
void gen_read_spec(char *spec,...)
static void fprintf_spaces(fd, number)
FPRINTF_SPACES prints NUMBER spaces on the FD file descriptor.
static void initialize_domain_DecisionTables(int domain)
demand driven computation of the decision table to scan domain.
static void copy_leaf_out(obj, bp)
COPY_LEAF_OUT manages external sub-domains.
static void quick_multi_recurse_obj_out(gen_chunk *obj, __attribute__((unused)) struct gen_binding *bp, __attribute__((unused)) struct driver *dr)
gen_chunk * gen_copy_tree(gen_chunk *obj)
static bool cumulated_error_seen
int gen_allocated_memory(gen_chunk *obj)
re-entry is automatic for this function.
int gen_tabulated_consistent_p(int domain)
static void gen_trav_simple(union domain *dp, gen_chunk *obj, struct driver *dr)
GEN_TRAV_SIMPLE traverses a simple OBJ (which is a (CONS *) for a list or points to the first element...
static void copy_simple_out(obj, dp)
COPY_SIMPLE_OUT copies the spine of the list OBJ or the whole array (according to the type DP).
static int shared_simple_in(obj, dp)
void gen_type_translation_default(void)
static gtt_p gtt_read(string filename)
read and setup a table from a file
static bool free_already_seen_p(gen_chunk *obj)
static void initialize_domain_DirectDomainsTable(int target, union domain *dp)
walks thru the domain to tag all types for target.
static bool check_sharing(char *p, char *type)
GenRewriteType GenRewriteTableType[MAX_DOMAIN]
static void gen_trav_obj_constructed(gen_chunk *obj, __attribute__((unused)) struct gen_binding *bp, union domain *dp, int data, struct driver *dr)
GEN_TRAV_OBJ (the root function) traverses the object OBJ according to the driver DR.
void genspec_lex_destroy()
static gen_chunk * copy_hsearch(gen_chunk *key)
maps an object on its copy
#define MAX_GEN_TRAV_ENV
GEN_TRAV_ENVS are stacked to allow recursive calls to GEN_TRAV_OBJ (cf.
static int sharing_obj_in(gen_chunk *obj, struct driver *dr)
void gen_write(FILE *fd, gen_chunk *obj)
GEN_WRITE writes the OBJect on the stream FD.
void gen_type_translation_read(string filename)
set current type translation table according to file
static void defined_null(struct gen_binding *bp)
GEN_DEFINED_P checks that the OBJect is fully defined.
int Read_spec_mode
extern int Current_first ;
static void gtt_table_identity(gtt_p table)
struct gen_trav_env gen_trav_envs[MAX_GEN_TRAV_ENV]
static void pop_gen_trav_env()
static int sharing_simple_in(gen_chunk *obj, union domain *dp)
static int gen_trav_env_top
static int current_size
returns the number of bytes allocated for a given structure may need additional fonctions for externa...
static void initialize_DecisionTables()
int newgen_allow_forward_ref
The GEN_TABULATED_NAMES hash table maps ids to index in the table of the tabulated domains.
gen_chunk * Read_chunk
Where the root will be.
struct gen_binding Domains[MAX_DOMAIN]
in build.c
void gen_context_recurse(void *obj, void *context, int domain, bool(*filter)(void *encountered_object, void *context), void(*rewrite)(void *encountered_object, void *context))
Visit all the objects from a given types found in an object with a context.
void gen_recurse_stop(void *obj)
Tells the recursion not to go in this object.
void gen_recurse(void *obj, int domain, bool(*filter)(void *encountered), void(*rewrite)(void *encountered_object))
Visit all the objects from a given types found in an object.
void gen_full_recurse(void *o, void *context,...)
Full multi-recursion with context function visitor.
void gen_multi_recurse(void *o,...)
Multi recursion visitor function.
static void gen_internal_context_multi_recurse(void *o, void *context, bool gointabs, va_list pvar)
Multi recursion generic visitor function.
void gen_context_multi_recurse(void *o, void *context,...)
Multi-recursion with context function visitor.
gen_chunk * gen_get_recurse_previous_visited_object(void)
Get the previously visited object.
gen_chunk * gen_get_current_ancestor(int type)
Return current object of that type...
gen_chunk * gen_get_current_object(void)
return the current visited object, or NULL if not in a recursion.
gen_chunk * gen_get_ancestor(int type, const void *obj)
return the first ancestor object found of the given type.
gen_chunk * gen_get_recurse_ancestor(const void *object)
Get the first ancestor object encountered during the recursion for the given object.
gen_chunk * gen_get_recurse_current_ancestor(void)
Get the ancestor of the current object.
void * gen_NULL(__attribute__((unused)) void *unused)
idem with a void* return
void gen_null2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
void * gen_chunk_identity(gen_chunk x)
void * gen_core_NULL(__attribute__((unused)) void *p)
bool gen_false(__attribute__((unused)) gen_chunk *unused)
Return false and ignore the argument.
void gen_core(__attribute__((unused)) void *p)
Abort when called.
void * gen_NULL2(__attribute__((unused)) void *u1, __attribute__((unused)) void *u2)
idem with 2 args, to please overpeaky compiler checks
bool gen_true2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
void gen_null(__attribute__((unused)) void *unused)
Ignore the argument.
bool gen_false2(__attribute__((unused)) gen_chunk *u1, __attribute__((unused)) void *u2)
bool gen_true(__attribute__((unused)) gen_chunk *unused)
Return true and ignore the argument.
void * gen_identity(const void *x)
Just return the argument.
#define list_undefined_p(c)
Return if a list is undefined.
#define NIL
The empty list (nil in Lisp)
list gen_copy_seq(list l)
Copy a list structure.
#define CAR(pcons)
Get the value of the first element of a list.
void gen_free_list(list l)
free the spine of the list
size_t list_own_allocated_memory(const list l)
#define list_undefined
Undefined list definition :-)
hash_table hash_table_make(hash_key_type key_type, size_t size)
int hash_table_own_allocated_memory(hash_table htp)
void * hash_get(const hash_table htp, const void *key)
this function retrieves in the hash table pointed to by htp the couple whose key is equal to key.
void hash_put(hash_table htp, const void *key, const void *val)
This functions stores a couple (key,val) in the hash table pointed to by htp.
void hash_update(hash_table htp, const void *key, const void *val)
update key->val in htp, that MUST be pre-existent.
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
bool hash_defined_p(const hash_table htp, const void *key)
true if key has e value in htp.
hash_key_type hash_table_type(hash_table htp)
returns the type of the hash_table.
void hash_table_clear(hash_table htp)
Clears all entries of a hash table HTP.
#define message_assert(msg, ex)
char * i2a(int)
I2A (Integer TO Ascii) yields a string for a given Integer.
#define HASH_MAP(k, v, code, ht)
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
#define hash_table_undefined
Value of an undefined hash_table.
struct __hash_table * hash_table
Define hash_table structure which is hidden.
#define check_read_spec_performed()
#define quick_domain_index(obj)
inlined version of domain_index.
gen_chunk * gen_tabulated_fake_object_hack(int)
WARNING: it is not reentrant...
#define IS_INLINABLE(bp)
Different kinds of BINDING structure pointers.
#define check_domain(dom)
#define HASH_OFFSET
For tabulated objects, the offset HASH_OFFSET of the hashed subdomain.
#define MAX_DOMAIN
MAX_DOMAIN is the maximum number of entries in the DOMAINS table.
#define IS_STRING_TYPE(n)
void user(char *,...)
External routines.
gen_chunk * gen_enter_tabulated(int, char *, gen_chunk *, bool)
ENTER_TABULATED_DEF enters a new definition (previous refs are allowed if ALLOW_REF) in the INDEX tab...
#define same_string_p(s1, s2)
void gen_mapc_tabulated(void(*)(gen_chunk *), int)
apply fp to domain...
#define SET_MAP(element, code, the_set)
set set_assign(set, const set)
Assign a set with the content of another set.
int set_own_allocated_memory(const set)
#define set_undefined_p(s)
set set_make(set_type)
Create an empty set of any type but hash_private.
set set_add_element(set, const set, const void *)
void * stack_head(const stack)
returns the item on top of stack s
int stack_size(const stack)
observers
void stack_push(void *, stack)
stack use
void stack_free(stack *)
type, bucket_size, policy
stack stack_make(int, int, int)
allocation
void * stack_pop(stack)
POPs one item from stack s.
int bool
we cannot use an enum or stdbool because we need to be compatible with newgen, thus boolean need to h...
#define array_undefined_p(a)
#define string_undefined_p(s)
#define array_undefined
ARRAY.
int f(int off1, int off2, int n, float r[n], float a[n], float b[n])
struct _newgen_struct_data_ * data
static int init
Maximal value set for Fortran 77.
Pvecteur cp
pointeur sur l'egalite ou l'inegalite courante
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
FI: I do not understand why the type is duplicated at the set level.
The structure used to build lists in NewGen.
struct cons * cdr
The pointer to the next element.
gen_chunk car
The data payload of a list element.
The DRIVER structure is used to monitor the general function which traverses objects.
gen_tabulated_p tabulated
number of chunks to hold this data.
translation tables type...
int actual_to_old[MAX_DOMAIN]
forwards translation
int old_to_actual[MAX_DOMAIN]
whether the translation is nope...
INLINE[] gives, for each inlinable (i.e., unboxed) type, its NAME, its initial VALUE and its printing...
the current data needed for a multi recursion are stored in a multi recurse struct.
GenFilterTableType * filters
GenDecisionTableType * decisions
GenDecisionTableType * domains
GenRewriteTableType * rewrites
void gen_clear_tabulated_element(gen_chunk *obj)
GEN_CLEAR_TABULATED_ELEMENT only clears the entry for object OBJ in the gen_tabulated_ and gen_tabula...
@ keep
bj > b1 -> h1/hj = h1
A DOMAIN union describes the structure of a user type.
int(* allocated_memory)(void *)
struct gen_binding * element
struct domainlist * components
void *(* read)(FILE *, int(*)(void))
struct intlist * dimensions
struct gen_binding * constructand
void(* write)(FILE *, void *)
A gen_chunk is used to store every object.
struct cons * l
A pointer to a list element.