111 bool gen_eq(
const void * obj1,
const void * obj2)
130 for (cl = ml; !
ENDP(cl);
POP(cl), i++) {
132 fprintf(stderr,
"warning: cycle found");
133 fprintf(stderr,
"next elem %d:'%p' already in list\n", i, cl);
154 for (i = 0;
cp !=
NIL ;
cp =
cp->cdr, i++) {;}
194 list iter0=l0,iter1=l1;
248 for ( ; c!=
NIL ; c=c->
cdr)
286 CDR(p) = nl, head = l;
291 while (
CDR(p)) p =
CDR(p);
298 #define NEXT(cp) (((cp) == NIL) ? NIL : (cp)->cdr)
306 cons *next, *next_next ;
312 next_next =
NEXT( next );
314 for( ; next !=
NIL ; )
319 next_next =
NEXT( next_next ) ;
330 for( p = l ; p !=
NIL ; p = nextp ) {
353 for( ; !
ENDP(
CDR( cp1 )) ; cp1 =
CDR( cp1 ));
373 for (; pc!=
NIL; pc=pc->
cdr)
374 if ((*
test)((*extract)(
CAR(pc))))
375 return (*extract)(
CAR(pc));
387 for (; pc!=
NIL; pc=pc->
cdr)
388 if ((*
test)((*extract)(
CAR(pc))))
389 e = (*extract)(
CAR(pc));
402 for (pc = seq; pc !=
NIL; pc = pc->
cdr )
403 if ((*
test)(item, (*extract)(
CAR(pc))))
404 return (*extract)(
CAR(pc));
414 for (pc = seq; pc !=
NIL; pc = pc->
cdr ) {
415 if ((*
test)(item, (*extract)(
CAR(pc))))
416 e = (*extract)(
CAR(pc));
425 for (pc = (
list) seq; pc !=
NIL; pc = pc->
cdr )
426 if (item ==
CAR(pc).p)
446 else if (l2 !=
NIL) {
580 if (
ENDP(l))
return l;
704 for (; !
ENDP(l) && n>0; l=
CDR(l), n--);
726 for(c=l; c!=
NIL; c=
CDR(c))
739 if (
CHUNK(
CAR(l))==item)
return true;
777 int n = size/
sizeof(
void*);
779 for (i=0; i<n; i++) {
806 for (c=l, point=table; !
ENDP(c); c=
CDR(c), point++)
811 qsort(table, n,
sizeof(
gen_chunk*), compare);
815 for (c=l, point=table; !
ENDP(c); c=
CDR(c), point++)
840 list (*iterate)(), initial;
846 MAPL(cc, l_next = iterate(
CHUNK(
CAR(cc)), l_next), l_close);
891 ncons->
car.
e = (
void *) item;
916 return gen_cons((
const void *) i, l);
921 return gen_cons((
const void *) s, l);
926 return gen_cons((
const void *) i, l);
931 return gen_cons((
const void *) c, l);
936 return gen_cons((
const void *) e, l);
1000 for(; !
ENDP(c_item);
POP(c_item)) {
1017 if (n<=0)
return NIL;
1019 list head = *lp, last = *lp;
1038 c1 =
CDR(c1), c2 =
CDR(c2))
1067 state->
phead = phead;
1068 state->
ptail = ptail;
1095 fprintf(stderr,
"unexpected sweep direction: %d\n", dir);
1139 CDR(state->
tail) = previous_tail;
1153 fprintf(stderr,
"unexpected sweep direction: %d\n", state->
dir);
1171 state->
phead = NULL;
1172 state->
ptail = NULL;
char * alloc(int size)
ALLOC is an "iron-clad" version of malloc(3).
#define NEWGEN_CHECK_TYPE(dom, item)
this macro does about the same as gen_check, but inlined and safer.
#define gen_chunk_undefined
void *() gen_extract_func_t(const gen_chunk)
gen_chunk * gen_copy_tree(gen_chunk *obj)
#define ENDP(l)
Test if a list is empty.
list gen_make_list(int domain,...)
void gen_fprint(FILE *out, string name, const list l, gen_string_func_t item_name)
list gen_insert_list(list nl, const void *item, list l, bool before)
insert nl before or after item in list l, both initial lists are consumed
list gen_list_head(list *lp, int n)
list gen_nreverse(list cp)
reverse a list in place
void gen_exchange_in_list(list l, const void *i1, const void *i2)
exchange items i1 & i2 in the list
void gen_remove(list *cpp, const void *o)
remove all occurences of item o from list *cpp, which is thus modified.
void gen_list_and(list *a, const list b)
Compute A = A inter B: complexity in O(n2)
int gen_position(const void *item, const list l)
Element ranks are strictly positive as for first, second, and so on.
#define POP(l)
Modify a list pointer to point on the next element of the list.
void gen_remove_once(list *pl, const void *o)
Remove the first occurence of o in list pl:
#define NIL
The empty list (nil in Lisp)
list gen_concatenate(const list l1x, const list l2x)
concatenate two lists.
void gen_map(gen_iter_func_t fp, const list l)
list gen_once(const void *vo, list l)
Prepend an item to a list only if it is not already in the list.
struct cons cons
The structure used to build lists in NewGen.
list gen_VOID_STAR_cons(const void *e, const list l)
list gen_copy_seq(list l)
Copy a list structure.
size_t gen_length(const list l)
list gen_cons(const void *item, const list next)
list gen_common_prefix(const list l1, const list l2)
return the common list prefix of lists l1 and l2.
void gen_list_and_not(list *a, const list b)
Compute A = A inter non B:
bool gen_once_p(list l)
FC: ARGH...O(n^2)!
void gen_free_string_list(list ls)
void gen_copy(void *a, void *b)
#define CONS(type,x,l) gen_cons((void*) (x), (l))
list gen_some(gen_filter_func_t fp, const list l)
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
list gen_nconc(list cp1, list cp2)
physically concatenates CP1 and CP2 but do not duplicates the elements
#define CAR(pcons)
Get the value of the first element of a list.
list gen_list_cons(const list i, const list l)
void gen_free_list(list l)
free the spine of the list
list gen_last(list l)
Return the last element of a list.
list gen_CHUNK_cons(const gen_chunk *c, const list l)
bool gen_in_list_p(const void *vo, const list lx)
tell whether vo belongs to lx
size_t list_own_allocated_memory(const list l)
void * gen_find_if_from_end(gen_filter_func_t test, const list l, gen_extract_func_t extract)
the last match is returned
#define CDR(pcons)
Get the list less its first element.
void * gen_find_if(gen_filter_func_t test, const list l, gen_extract_func_t extract)
void * gen_find_eq(const void *item, const list seq)
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...
#define MAPL(_map_list_cp, _code, _l)
Apply some code on the addresses of all the elements of a list.
void * gen_find(const void *item, const list seq, gen_filter2_func_t test, gen_extract_func_t extract)
list gen_append(list l1, const list l2)
bool gen_list_cyclic_p(const list ml)
static void gen_remove_from_list(list *pl, const void *o, bool once)
remove item o from list *pl which is modified as a side effect.
list gen_copy_string_list(list ls)
of string
void gen_mapl(gen_iter_func_t fp, const list l)
MAP.
int gen_occurences(const void *vo, const list l)
count occurences of vo in l
void * gen_reduce(void *r, void *(*fp)(void *, const list), const list l)
gen_chunk gen_nth(int n, const list l)
to be used as ENTITY(gen_nth(3, l))...
void gen_list_patch(list l, const void *x, const void *y)
Replace all the reference to x in list l by a reference to y:
list gen_string_cons(string s, const list l)
void gen_free_area(void **p, int size)
free an area.
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
Apply/map an instruction block on all the elements of a list (old fashioned)
void * gen_find_from_end(const void *item, const list seq, gen_filter2_func_t test, gen_extract_func_t extract)
static bool cons_of_gen_chunk(const list cp)
void gen_closure(list(*iterate)(), list(*initial)())
void gen_closure(iterate, initial) list [of X] (*iterate)([ X, list of X ]), initial;
list gen_full_copy_list(list l)
Copy a list structure with element copy.
void gen_sort_list(list l, gen_cmp_func_t compare)
Sorts a list of gen_chunks in place, to avoid allocations...
static gen_chunk * gen_chunk_of_cons_of_gen_chunk
SPECIAL INSERTION.
void gen_substitute_chunk_by_list(list *pl, const void *o, list sl)
substitute item o by list sl in list *pl, which is modified as a side effect.
list gen_bool_cons(bool b, const list l)
typed cons for "basic" types
void gen_insert_after(const void *no, const void *o, list l)
bool gen_replace_in_list(list l, const void *s, const void *t)
substitute all item s by t in list l
list gen_insert_before(const void *no, const void *o, list l)
list gen_int_cons(_int i, const list l)
bool gen_equals(const list l0, const list l1, gen_eq_func_t equals)
compares two lists using the functor given in parameters returns true if for all n,...
bool gen_eq(const void *obj1, const void *obj2)
list gen_typed_cons(_int type, const void *item, const list next)
CONS a list with minimal type checking this cannot be done within the CONS macro because possible fun...
void gen_sweep_done(gen_sweep_state state)
gen_sweep_state gen_sweep_init(list l, gen_sweep_direction dir, list *phead, list *ptail)
initialize list l sweep in direction dir, with pointers for head & tail
bool gen_sweep_update(gen_sweep_state state)
#define message_assert(msg, ex)
gen_sweep_direction
sweep a list...
bool set_belong_p(const set, const void *)
set set_make(set_type)
Create an empty set of any type but hash_private.
set set_add_element(set, const set, const void *)
bool(* gen_filter2_func_t)(const void *, const void *)
string(* gen_string_func_t)(const void *)
void(* gen_iter_func_t)(void *)
bool(* gen_filter_func_t)(const void *)
bool(* gen_eq_func_t)(const void *, const void *)
int(* gen_cmp_func_t)(const void *, const void *)
static hash_table pl
properties are stored in this hash table (string -> property) for fast accesses.
static const char * prefix
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.
A DOMAIN union describes the structure of a user type.
A gen_chunk is used to store every object.
void * e
For externals (foreign objects)