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

Go to the source code of this file.

Data Structures

struct  cons
 The structure used to build lists in NewGen. More...
 

Macros

#define NIL   ((list)NULL)
 The empty list (nil in Lisp) More...
 
#define POP(l)   ((l)=(l)->cdr)
 Modify a list pointer to point on the next element of the list. More...
 
#define ENDP(l)   ((l)==NIL)
 Test if a list is empty. More...
 
#define list_undefined   ((cons *)-3)
 Undefined list definition :-) More...
 
#define list_undefined_p(c)   ((c)==list_undefined)
 Return if a list is undefined. More...
 
#define CAR(pcons)   ((pcons)->car)
 Get the value of the first element of a list. More...
 
#define CDR(pcons)   ((pcons)->cdr)
 Get the list less its first element. More...
 
#define REFCAR(pc)   (&(CAR(pc).p))
 Get the adress of the first element of a list. More...
 
#define CONS(_t_, _i_, _l_)   gen_##_t_##_cons((_i_),(_l_))
 List element cell constructor (insert an element at the beginning of a list) More...
 
#define FOREACH(_fe_CASTER, _fe_item, _fe_list)
 Apply/map an instruction block on all the elements of a list. More...
 
#define VOLATILE_FOREACH(_fe_CASTER, _fe_item, _fe_list)
 
#define MAPL(_map_list_cp, _code, _l)
 Apply some code on the addresses of all the elements of a list. More...
 
#define MAP(_map_CASTER, _map_item, _map_code, _map_list)
 Apply/map an instruction block on all the elements of a list (old fashioned) More...
 
#define gen_BOOL_cons   gen_bool_cons
 Another name to the funtion to insert a bool element at the start of a list. More...
 
#define gen_INT_cons   gen_int_cons
 Another name to the funtion to insert an integer element at the start of a list. More...
 
#define gen_LIST_cons   gen_list_cons
 Another name to the funtion to insert a list element at the start of a list. More...
 
#define gen_CONSP_cons   gen_list_cons
 Another name to the funtion to insert a list element at the start of a list. More...
 
#define gen_STRING_cons   gen_string_cons
 Another name to the funtion to insert a string element at the start of a list. More...
 
#define gen_sweep_forward_init(l, p1, p2)   gen_sweep_init(l, gen_sweep_forward, p1, p2)
 
#define gen_sweep_backward_init(l, p1, p2)   gen_sweep_init(l, gen_sweep_backward, p1, p2)
 

Typedefs

typedef struct cons cons
 The structure used to build lists in NewGen. More...
 
typedef list(* gen_closure_func_t) (gen_chunk *, list)
 
typedef struct __gen_sweep_stategen_sweep_state
 

Enumerations

enum  gen_sweep_direction { gen_sweep_forward , gen_sweep_backward }
 sweep a list... More...
 

Functions

void gen_copy (void *, void *)
 #define CONS(type,x,l) gen_cons((void*) (x), (l)) More...
 
bool gen_eq (const void *, const void *)
 
void * gen_identity (const void *)
 Just return the argument. More...
 
void * gen_chunk_identity (gen_chunk)
 
void * gen_find_tabulated (const char *, int)
 
list gen_filter_tabulated (bool(*)(gen_chunk *), int)
 returns the list of entities with this caracteristics. More...
 
void gen_free_area (void **, int)
 free an area. More...
 
void gen_mapc_tabulated (void(*)(gen_chunk *), int)
 apply fp to domain... More...
 
list gen_append (list, const list)
 
list gen_concatenate (const list, const list)
 concatenate two lists. More...
 
list gen_copy_seq (const list)
 Copy a list structure. More...
 
list gen_nconc (list, list)
 physically concatenates CP1 and CP2 but do not duplicates the elements More...
 
list gen_full_copy_list (const list)
 Copy a list structure with element copy. More...
 
list gen_make_list (int,...)
 
list gen_nreverse (list)
 reverse a list in place More...
 
void * gen_find (const void *, const list, gen_filter2_func_t, gen_extract_func_t)
 
void * gen_find_from_end (const void *, const list, gen_filter2_func_t, gen_extract_func_t)
 
void * gen_find_eq (const void *, const list)
 
void * gen_find_if (gen_filter_func_t, const list, gen_extract_func_t)
 
void * gen_find_if_from_end (gen_filter_func_t, list, gen_extract_func_t)
 the last match is returned More...
 
void gen_free_list (list)
 free the spine of the list More...
 
void gen_full_free_list (list)
 
list gen_last (const list)
 Return the last element of a list. More...
 
void * gen_car (const list)
 
size_t gen_length (const list)
 
size_t list_own_allocated_memory (const list)
 
gen_chunk gen_nth (int, const list)
 to be used as ENTITY(gen_nth(3, l))... More...
 
list gen_nthcdr (int, const list)
 caution: the first item is 0! was: return( (n<=0) ? l : gen_nthcdr( n-1, CDR( l ))) ; if n>gen_length(l), NIL is returned. More...
 
void gen_map (gen_iter_func_t, const list)
 
void gen_mapl (gen_iter_func_t, const list)
 MAP. More...
 
void * gen_reduce (void *, void *(*)(void *, const list), const list)
 
void gen_remove (list *, const void *)
 remove all occurences of item o from list *cpp, which is thus modified. More...
 
void gen_remove_once (list *, const void *)
 Remove the first occurence of o in list pl: More...
 
list gen_some (gen_filter_func_t, const list)
 
bool gen_replace_in_list (list, const void *, const void *)
 substitute all item s by t in list l More...
 
void gen_exchange_in_list (list, const void *, const void *)
 exchange items i1 & i2 in the list More...
 
list gen_insert_list (list, const void *, list, bool)
 insert nl before or after item in list l, both initial lists are consumed More...
 
void gen_insert_after (const void *, const void *, list)
 
list gen_insert_before (const void *, const void *, list)
 
list gen_once (const void *, list)
 Prepend an item to a list only if it is not already in the list. More...
 
bool gen_in_list_p (const void *, const list)
 tell whether vo belongs to lx More...
 
int gen_occurences (const void *, const list)
 count occurences of vo in l More...
 
bool gen_once_p (const list)
 FC: ARGH...O(n^2)! More...
 
bool gen_equals (const list, const list, gen_eq_func_t)
 compares two lists using the functor given in parameters returns true if for all n, the n'th element of first list is equals to the n'th element of the second list More...
 
void gen_sort_list (list, gen_cmp_func_t)
 Sorts a list of gen_chunks in place, to avoid allocations... More...
 
void gen_list_patch (list, const void *, const void *)
 Replace all the reference to x in list l by a reference to y: More...
 
void gen_closure (gen_closure_func_t, const list)
 
list gen_copy_string_list (const list)
 of string More...
 
void gen_free_string_list (list)
 
void gen_fprint (FILE *, const string, const list, gen_string_func_t)
 
list gen_cons (const void *, const list)
 
list gen_bool_cons (bool, const list)
 typed cons for "basic" types More...
 
list gen_int_cons (_int, const list)
 
list gen_string_cons (string, const list)
 
list gen_list_cons (const list, const list)
 
list gen_typed_cons (_int, const void *, const list)
 CONS a list with minimal type checking this cannot be done within the CONS macro because possible functions calls must not be replicated. More...
 
list gen_CHUNK_cons (const gen_chunk *, const list)
 
list gen_VOID_STAR_cons (const void *, const list)
 
void gen_list_and (list *, const list)
 Compute A = A inter B: complexity in O(n2) More...
 
void gen_list_and_not (list *, const list)
 Compute A = A inter non B: More...
 
int gen_position (const void *, const list)
 Element ranks are strictly positive as for first, second, and so on. More...
 
bool gen_list_cyclic_p (const list)
 
list gen_list_head (list *, int)
 
list gen_common_prefix (const list, const list)
 return the common list prefix of lists l1 and l2. More...
 
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. More...
 
gen_sweep_state gen_sweep_init (list, gen_sweep_direction, list *, list *)
 initialize list l sweep in direction dir, with pointers for head & tail More...
 
bool gen_sweep_update (gen_sweep_state)
 
void gen_sweep_done (gen_sweep_state)
 

Macro Definition Documentation

◆ gen_sweep_backward_init

#define gen_sweep_backward_init (   l,
  p1,
  p2 
)    gen_sweep_init(l, gen_sweep_backward, p1, p2)

Definition at line 372 of file newgen_list.h.

◆ gen_sweep_forward_init

#define gen_sweep_forward_init (   l,
  p1,
  p2 
)    gen_sweep_init(l, gen_sweep_forward, p1, p2)

Definition at line 371 of file newgen_list.h.

Typedef Documentation

◆ gen_closure_func_t

typedef list(* gen_closure_func_t) (gen_chunk *, list)

Definition at line 335 of file newgen_list.h.

◆ gen_sweep_state

Definition at line 366 of file newgen_list.h.

Enumeration Type Documentation

◆ gen_sweep_direction

sweep a list...

Enumerator
gen_sweep_forward 
gen_sweep_backward 

Definition at line 365 of file newgen_list.h.

gen_sweep_direction
sweep a list...
Definition: newgen_list.h:365
@ gen_sweep_backward
Definition: newgen_list.h:365
@ gen_sweep_forward
Definition: newgen_list.h:365

Function Documentation

◆ gen_closure()

void gen_closure ( gen_closure_func_t  ,
const  list 
)

◆ gen_filter_tabulated()

list gen_filter_tabulated ( bool(*)(gen_chunk *)  filter,
int  domain 
)

returns the list of entities with this caracteristics.

Definition at line 144 of file tabulated.c.

145 {
147  register int i, size = gtp->size;
148  list l;
149 
150  for (l=NIL, i=0; i<size; i++) {
151  gen_chunk * o = gtp->table[i].p;
152  if (o && o != gen_chunk_undefined) {
153  if (filter(o)) l = CONS(CHUNK, o, l);
154  }
155  }
156 
157  return l;
158 }
#define CHUNK(x)
Definition: genC.h:90
#define gen_chunk_undefined
Definition: genC.h:74
#define NIL
The empty list (nil in Lisp)
Definition: newgen_list.h:47
#define CONS(_t_, _i_, _l_)
List element cell constructor (insert an element at the beginning of a list)
Definition: newgen_list.h:150
Definition: tabulated.c:51
gen_chunk * table
how many are used
Definition: tabulated.c:55
int size
domain number
Definition: tabulated.c:53
The structure used to build lists in NewGen.
Definition: newgen_list.h:41
static gen_tabulated_p get_tabulated_from_domain(int domain)
Definition: tabulated.c:59
A DOMAIN union describes the structure of a user type.
A gen_chunk is used to store every object.
Definition: genC.h:58
union gen_chunk * p
Definition: genC.h:69

References CHUNK, CONS, gen_chunk_undefined, get_tabulated_from_domain(), NIL, gen_chunk::p, _gtp::size, and _gtp::table.

Referenced by db_get_module_list_initial_order(), generate_starpu_pragma(), GenericCleanLocalEntities(), html_print_symbol_table(), RemoveLocalEntities(), and spire_distributed_unstructured_to_structured().

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

◆ gen_find_tabulated()

void* gen_find_tabulated ( const char *  key,
int  domain 
)

Definition at line 218 of file tabulated.c.

219 {
221 
222  if (number == (_int) HASH_UNDEFINED_VALUE)
223  {
224  return gen_chunk_undefined;
225  }
226  else
227  {
229  message_assert("valid tabulated number", number>=0 && number<gtp->size);
230  return gtp->table[number].p;
231  }
232 }
#define message_assert(msg, ex)
Definition: newgen_assert.h:47
#define HASH_UNDEFINED_VALUE
value returned by hash_get() when the key is not found; could also be called HASH_KEY_NOT_FOUND,...
Definition: newgen_hash.h:56
intptr_t _int
_INT
Definition: newgen_types.h:53
static _int gen_get_tabulated_name_basic(int domain, const char *id)
Definition: tabulated.c:212

References gen_chunk_undefined, gen_get_tabulated_name_basic(), get_tabulated_from_domain(), HASH_UNDEFINED_VALUE, message_assert, gen_chunk::p, and _gtp::table.

Referenced by add_address_of_value(), add_non_declared_reference_to_declaration(), add_old_value(), add_sizeof_value(), add_symbolic_constant_to_declaration(), add_test(), alias_check(), binary_arithmetic_operator_to_post_pv(), build_new_ref(), clone_variable_with_new_name(), cmf_layout_align(), compile_mpi(), complex_bound_generation(), craft_layout_align(), create_local_index(), create_local_index2(), create_named_entity(), create_parameter_for_new_module(), create_parameter_variable_for_new_module(), create_private_integer_variable_for_new_module(), create_private_variable_for_new_module(), create_state_variable(), create_tile_basis(), creer_nom_var(), db_module_exists_p(), ecrit_une_var_neg(), entity_all_locations(), entity_empty_label(), entity_field_to_entity(), entity_from_user_name(), entity_intrinsic(), entity_nowhere_locations(), eov_add_entity_to_eliminate(), external_entity_to_old_value(), fetch_complexity_parameters(), find_entity(), find_label_entity(), find_operator(), find_or_create_coeff(), find_or_create_db_symbol(), find_or_create_emulated_shared_variable(), find_or_create_scalar_entity(), find_or_create_typed_entity(), FindEntity(), FindEntityFromLocalNameAndPrefix(), FindEntityFromLocalNameAndPrefixAndScope(), FindEntityFromUserName(), FindOrCreateEntityLikeModel(), gen_enter_tabulated(), gen_find_db_symbol(), gen_find_entity(), gen_find_opcodeClass(), generate_pseudo_formal_variable_for_formal_label(), generic_make_entity_copy_with_new_name(), get_time_ent(), get_variables_to_filter(), gfc2pips_check_entity_block_data_exists(), gfc2pips_check_entity_doesnt_exists(), gfc2pips_check_entity_exists(), gfc2pips_check_entity_module_exists(), gfc2pips_check_entity_program_exists(), gfc2pips_namespace(), global_name_to_entity(), global_new_value_to_global_old_value(), init_loop_ctrl(), init_new_df_ref(), init_new_do_loop(), local_name_to_top_level_entity(), local_name_to_variable(), loop_normalize_of_loop(), make_array_bounds(), make_array_entity(), make_bound(), make_constraint_expression(), make_derived_entity(), make_empty_module(), make_emulated_shared_variable(), make_func_op(), make_host_and_node_modules(), make_id_expression(), make_integer_constant_entity(), make_local_value_entity(), make_movements_loop_body_wp65(), make_op_exp(), make_rational_exp(), make_ref(), make_scalar_entity(), make_statement_copy_i(), make_tile_index_entity_n(), MakeAssignedOrComputedGotoInst(), MakeCurrentFunction(), MakeDiVar(), MakeDsiVar(), MakeLiVar(), MakeLoopCounter(), module_entity_to_compilation_unit_entity(), mpi_init_ctx(), my_build_new_ref(), name_to_variable(), NameToFunctionalEntity(), new_eng_loop(), new_param(), predicate_to_expression(), psystem_to_expression(), rational_op_exp(), recursive_rename_types(), replicate_declaration(), SafeFindOrCreateEntity(), sc_add_new_variable_name(), signed_integer_constant_expression_p(), simplify_minmax_contrainte(), step_function(), transformer_filter_subsumed_variables(), translate_global_value(), type_to_named_type(), undefined_pointer_value_entity(), unique_entity_name_p(), update_called_modules(), value_to_variable(), vect_gen_read(), and xml_TaskParameter().

+ Here is the call graph for this function:

◆ gen_full_free_list()

void gen_full_free_list ( list  l)

Definition at line 1023 of file genClib.c.

1024 {
1025  list p, nextp ;
1026  bool first_in_stack = (free_already_seen==(hash_table)NULL);
1027 
1028  if (first_in_stack)
1030 
1031  for (p = l; p ; p=nextp)
1032  {
1033  nextp = p->cdr;
1034  gen_free(CAR(p).p);
1035  newgen_free(p);
1036  }
1037 
1038  if (first_in_stack)
1039  {
1041  free_already_seen = NULL;
1042  }
1043 }
void gen_free(gen_chunk *obj)
version without shared_pointers.
Definition: genClib.c:992
static __thread hash_table free_already_seen
These functions are used to implement the freeing of objects.
Definition: genClib.c:848
#define CAR(pcons)
Get the value of the first element of a list.
Definition: newgen_list.h:92
hash_table hash_table_make(hash_key_type key_type, size_t size)
Definition: hash.c:294
void hash_table_free(hash_table htp)
this function deletes a hash table that is no longer useful.
Definition: hash.c:327
@ hash_pointer
Definition: newgen_hash.h:32
struct __hash_table * hash_table
Define hash_table structure which is hidden.
Definition: newgen_hash.h:43
#define newgen_free(p)
struct cons * cdr
The pointer to the next element.
Definition: newgen_list.h:43

References CAR, cons::cdr, free_already_seen, gen_free(), hash_pointer, hash_table_free(), hash_table_make(), and newgen_free.

Referenced by __attribute__(), add_prettyprint_control_list_to_declaration_statement(), add_values_for_simple_effects_of_statement(), any_basic_update_operation_to_transformer(), apply_a_rule(), binary_arithmetic_operator_to_post_pv(), binary_intrinsic_call_to_points_to_sinks(), block_to_transformer_list(), c_convex_effects_on_actual_parameter_forward_translation(), c_convex_effects_on_formal_parameter_backward_translation(), c_text_entity(), call_flt(), cells_to_read_or_write_effects(), check_physical_resource_up_to_date(), check_proper_reductions(), clean_up_sequences_rewrite(), clean_up_transformer_list(), compute_recv_regions(), compute_send_regions(), condition_to_transformer(), conditional_operator_to_post_pv(), constant_reference_to_normalized_constant_reference(), convex_cell_reference_preceding_p(), dimensions_to_dma(), do_array_expansion(), do_atomize_call(), do_brace_expression_to_statements(), do_grouping_replace_reference_by_expression_walker(), do_linearize_array_init(), do_linearize_array_reference(), do_linearize_type(), do_loop_nest_unswitching(), do_outliner_smart_replacment(), do_resource_usage_check(), effects_to_dma(), eval_cell_with_points_to(), expr_level_of(), expression_effects_to_transformer(), expression_to_points_to(), expression_to_post_pv(), external_call_to_post_pv(), forloop_to_post_pv(), free_pv_results_paths(), free_to_post_pv(), freed_pointer_to_points_to(), generic_c_words_simplified_entity(), generic_effect_find_aliases_with_simple_pointer_values(), heap_intrinsic_to_post_pv(), hwac_replace_statement(), intrinsic_call_to_type(), invalidate_expressions_in_statement(), kill_pointer_values(), list_of_compatible_reductions(), live_in_paths_of_loop(), live_out_paths_from_loop_to_body(), logical_operator_to_post_pv(), loop_annotate(), loop_to_post_pv(), make_required(), module_initial_parameter_pv(), multiple_pointer_assignment_to_post_pv(), new_array_elements_backward_substitution_in_transformer(), opencl_generate_special_kernel_ops(), other_cool_enough_for_a_last_substitution(), outliner_smart_references_computation(), pointer_values_remove_var(), points_to_cell_to_upper_bound_points_to_cells(), print_qualifiers(), prune_singleton(), reductions_rewrite(), region_to_minimal_dimensions(), remove_interval_predecessors(), replace_field_by_reference_walker(), rmake(), safe_any_expression_to_transformer(), safe_expression_to_transformer(), safe_intrinsic_to_post_pv(), seq_flt(), simd_check_argType(), single_pointer_assignment_to_post_pv(), statement_clean_declarations_helper(), statement_insertion_fix_access(), statement_insertion_fix_access_in_callers(), statement_remove_extensions(), struct_variable_to_pointer_locations(), subscript_to_points_to_sinks(), subscripted_type_to_type(), successor_only_has_rr_conflict_p(), symbolic_tiling(), transformer_list_closure_to_precondition_depth_two(), transformer_list_closure_to_precondition_max_depth(), transformer_list_multiple_closure_to_precondition(), try_reorder_expressions(), two_addresses_code_generator(), undo_rename_reference(), unstructured_to_post_pv(), update_operator_to_post_pv(), update_preserved_resources(), whileloop_to_post_pv(), whileloop_to_postcondition(), and words_points_to_list().

+ Here is the call graph for this function:

◆ gen_mapc_tabulated()

void gen_mapc_tabulated ( void(*)(gen_chunk *)  fp,
int  domain 
)

apply fp to domain...

Definition at line 127 of file tabulated.c.

128 {
130  register int i, size = gtp->size;
131 
132  for (i=0; i<size; i++)
133  {
134  gen_chunk e = gtp->table[i];
135  if (e.p && e.p != gen_chunk_undefined)
136  {
137  message_assert("tabulated ok", e.p->i==domain);
138  fp(e.p);
139  }
140  }
141 }
_int i
Definition: genC.h:62

References gen_chunk_undefined, get_tabulated_from_domain(), gen_chunk::i, message_assert, gen_chunk::p, _gtp::size, and _gtp::table.

Referenced by gen_free_tabulated(), gen_read_and_check_tabulated(), gen_tabulated_consistent_p(), and gen_write_tabulated().

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

◆ gen_reduce()

void* gen_reduce ( void *  ,
void *  *)(void *, const list,
const  list 
)

◆ gen_sweep_done()

void gen_sweep_done ( gen_sweep_state  state)

Definition at line 1166 of file list.c.

1167 {
1168  message_assert("some state", state != NULL);
1169 
1170  // complete sweep to relink the initial list
1171  state->phead = NULL;
1172  state->ptail = NULL;
1173  while (gen_sweep_update(state));
1174 
1175  // cleanup
1176  free(state);
1177 }
void free(void *)
bool gen_sweep_update(gen_sweep_state state)
Definition: list.c:1108
list * phead
Definition: list.c:1053
list * ptail
Definition: list.c:1053

References free(), gen_sweep_update(), message_assert, __gen_sweep_state::phead, and __gen_sweep_state::ptail.

+ Here is the call graph for this function:

◆ gen_sweep_init()

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

Definition at line 1060 of file list.c.

1061 {
1062  gen_sweep_state state = malloc(sizeof(struct __gen_sweep_state));
1063  message_assert("malloc ok", state != NULL);
1064 
1065  state->dir = dir;
1066  state->initial = l;
1067  state->phead = phead;
1068  state->ptail = ptail;
1069  state->done = (l == NIL);
1070 
1071  switch (dir)
1072  {
1073  case gen_sweep_forward:
1074  state->head = NIL;
1075  state->tail = l;
1076  state->last = NIL;
1077  state->reversed = NIL; // unused
1078  break;
1079 
1080  case gen_sweep_backward:
1081  state->head = l;
1082  state->tail = NIL;
1083  state->last = NIL; // unused
1084  {
1085  list nl = NIL, c = l;
1086  while (c != NIL) {
1087  nl = CONS(LIST, c, nl);
1088  c = CDR(c);
1089  }
1090  state->reversed = nl;
1091  }
1092  break;
1093 
1094  default:
1095  fprintf(stderr, "unexpected sweep direction: %d\n", dir);
1096  abort();
1097  }
1098 
1099  // update external pointers
1100  if (state->phead)
1101  *(state->phead) = state->head;
1102  if (state->ptail)
1103  *(state->ptail) = state->tail;
1104 
1105  return state;
1106 }
#define LIST(x)
Definition: genC.h:93
if(!(yy_init))
Definition: genread_lex.c:1029
void * malloc(YYSIZE_T)
#define CDR(pcons)
Get the list less its first element.
Definition: newgen_list.h:111
#define abort()
Definition: misc-local.h:53
int fprintf()
test sc_min : ce test s'appelle par : programme fichier1.data fichier2.data ...
sweep status
Definition: list.c:1050
gen_sweep_direction dir
Definition: list.c:1052

References abort, CDR, CONS, __gen_sweep_state::dir, __gen_sweep_state::done, fprintf(), gen_sweep_backward, gen_sweep_forward, __gen_sweep_state::head, if(), __gen_sweep_state::initial, __gen_sweep_state::last, LIST, malloc(), message_assert, NIL, __gen_sweep_state::phead, __gen_sweep_state::ptail, __gen_sweep_state::reversed, and __gen_sweep_state::tail.

+ Here is the call graph for this function:

◆ gen_sweep_update()

bool gen_sweep_update ( gen_sweep_state  state)

Definition at line 1108 of file list.c.

1109 {
1110  if (state->done)
1111  return false;
1112 
1113  switch (state->dir)
1114  {
1115  case gen_sweep_forward:
1116  // first update
1117  if (state->head == NIL)
1118  state->head = state->last = state->tail;
1119  else
1120  // relink last cons
1121  CDR(state->last) = state->tail;
1122  // set new last cons
1123  state->last = state->tail;
1124  // move forward tail
1125  state->tail = CDR(state->tail);
1126  // check for end
1127  state->done = state->tail == NIL;
1128  // cut last const
1129  if (!state->done)
1130  CDR(state->last) = NIL;
1131  break;
1132 
1133  case gen_sweep_backward:
1134  {
1135  list previous_tail = state->tail, tmp = state->reversed;
1136  // tails move backwards
1137  state->tail = LIST(CAR(state->reversed));
1138  // relink tail
1139  CDR(state->tail) = previous_tail;
1140  // move backwards
1141  state->reversed = CDR(state->reversed);
1142  // cleanup
1143  free(tmp);
1144  // last one
1145  if (state->reversed == NIL)
1146  state->head = NIL;
1147  // check for end
1148  state->done = state->head == NIL;
1149  }
1150  break;
1151 
1152  default:
1153  fprintf(stderr, "unexpected sweep direction: %d\n", state->dir);
1154  abort();
1155  }
1156 
1157  // update external pointers
1158  if (state->phead)
1159  *(state->phead) = state->head;
1160  if (state->ptail)
1161  *(state->ptail) = state->tail;
1162 
1163  return true;
1164 }

References abort, CAR, CDR, __gen_sweep_state::dir, __gen_sweep_state::done, fprintf(), free(), gen_sweep_backward, gen_sweep_forward, __gen_sweep_state::head, if(), __gen_sweep_state::last, LIST, NIL, __gen_sweep_state::phead, __gen_sweep_state::ptail, __gen_sweep_state::reversed, and __gen_sweep_state::tail.

Referenced by gen_sweep_done().

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