PIPS
|
Go to the source code of this file.
Data Structures | |
struct | __stack_bucket |
STACK STRUCTURES. More... | |
struct | __stack_head |
the stack head More... | |
struct | __stack_iterator |
STACK ITERATOR. More... | |
Macros | |
#define | STACK_PTR_NULL ((_stack_ptr) NULL) |
and also *stack (in headers) More... | |
#define | STACK_PTR_NULL_P(x) ((x)==STACK_PTR_NULL) |
#define | STACK_DEFAULT_SIZE 50 |
#define | STACK_ITERATOR_END_P(i) STACK_PTR_NULL_P(i->bucket) |
#define | DEFINE_ITERATOR(i, blk, idx, dwn, lst) |
#define | UPDATE_ITERATOR_DOWNWARD(i) |
#define | UPDATE_ITERATOR_UPWARD(i) |
#define | NEXT_ITERATION(i) |
#define | STACK_OBSERVER(name, what) int stack_##name(const stack s) { STACK_CHECK(s); return(what); } |
STACK MISCELLANEOUS. More... | |
Typedefs | |
typedef struct __stack_bucket | _stack_bucket |
STACK STRUCTURES. More... | |
typedef struct __stack_bucket * | _stack_ptr |
typedef struct __stack_head | _stack_head |
the stack head More... | |
typedef struct __stack_iterator | _stack_iterator |
STACK ITERATOR. More... | |
Functions | |
static void | update_iterator_upward (stack_iterator i) |
and also *stack_iterator (in headers) More... | |
static void | stack_iterator_internal_init (const stack s, int down, stack_iterator i) |
stack_iterator | stack_iterator_init (const stack s, bool down) |
stack iterator More... | |
bool | stack_iterator_next_and_go (stack_iterator i, void **pitem) |
X-ward. More... | |
bool | stack_iterator_end_p (stack_iterator i) |
void | stack_iterator_end (stack_iterator *pi) |
static _stack_ptr | allocate_bucket (int size) |
allocates a bucket of size size More... | |
static _stack_ptr | find_or_allocate (stack s) |
search for a new bucket, first in the available list, if none are available, a new bucket is allocated More... | |
stack | stack_make (int type, int bucket_size, int policy) |
ALLOCATEs a new stack of type . More... | |
stack | stack_copy (const stack s) |
duplicate a stack with its contents. More... | |
static void | free_bucket (_stack_ptr x) |
FREEs the stack. More... | |
static void | free_buckets (_stack_ptr x) |
void | stack_free (stack *ps) |
type, bucket_size, policy More... | |
STACK_OBSERVER (consistent_p, 1) | |
Here we define stack_size(), stack_bsize(), stack_policy() and stack_max_extent(): More... | |
void | stack_map (const stack s, gen_iter_func_t f) |
APPLY f to all items of stack s;. More... | |
static int | number_of_buckets (_stack_ptr x) |
void | stack_info (FILE *f, const stack s) |
void | stack_push (void *item, stack s) |
STACK USE. More... | |
void * | stack_pop (stack s) |
POPs one item from stack s. More... | |
void * | stack_head (const stack s) |
returns the item on top of stack s More... | |
void * | stack_nth (const stack s, int nskip) |
returns the nth item starting from the head and counting from 1, when possible, or NULL, elsewhere. More... | |
void * | stack_replace (void *item, stack s) |
REPLACEs the item on top of stack s, and returns the old item. More... | |
#define DEFINE_ITERATOR | ( | i, | |
blk, | |||
idx, | |||
dwn, | |||
lst | |||
) |
#define NEXT_ITERATION | ( | i | ) |
#define STACK_ITERATOR_END_P | ( | i | ) | STACK_PTR_NULL_P(i->bucket) |
#define STACK_OBSERVER | ( | name, | |
what | |||
) | int stack_##name(const stack s) { STACK_CHECK(s); return(what); } |
#define STACK_PTR_NULL ((_stack_ptr) NULL) |
#define STACK_PTR_NULL_P | ( | x | ) | ((x)==STACK_PTR_NULL) |
#define UPDATE_ITERATOR_DOWNWARD | ( | i | ) |
#define UPDATE_ITERATOR_UPWARD | ( | i | ) |
typedef struct __stack_bucket _stack_bucket |
STACK STRUCTURES.
the stack buckets, i.e. arrays containing the elements
typedef struct __stack_head _stack_head |
the stack head
typedef struct __stack_iterator _stack_iterator |
STACK ITERATOR.
typedef struct __stack_bucket * _stack_ptr |
|
static |
allocates a bucket of size size
Definition at line 201 of file stack.c.
References malloc(), message_assert, STACK_PTR_NULL, and x.
Referenced by find_or_allocate(), and stack_make().
|
static |
search for a new bucket, first in the available list, if none are available, a new bucket is allocated
clean the bucket to be returned
may depend from the policy?
Definition at line 218 of file stack.c.
References allocate_bucket(), __stack_head::avail, __stack_head::bucket_size, __stack_head::n_buckets, STACK_PTR_NULL, STACK_PTR_NULL_P, and x.
Referenced by stack_push().
|
static |
FREEs the stack.
Definition at line 276 of file stack.c.
References gen_free_area(), and x.
Referenced by free_buckets().
|
static |
Definition at line 282 of file stack.c.
References free_bucket(), STACK_PTR_NULL, STACK_PTR_NULL_P, __stack_bucket::succ, and x.
Referenced by stack_free().
|
static |
Definition at line 335 of file stack.c.
References STACK_PTR_NULL_P, and x.
Referenced by stack_info().
duplicate a stack with its contents.
Definition at line 267 of file stack.c.
References __stack_head::bucket_size, __stack_head::policy, stack_make(), STACK_MAP_X, stack_push(), and __stack_head::type.
Referenced by RenameFunctionEntity(), store_call_context(), and SubstituteDummyParameters().
void stack_free | ( | stack * | ps | ) |
type, bucket_size, policy
Definition at line 292 of file stack.c.
References free_buckets(), gen_free_area(), stack_head(), STACK_NULL, and STACK_PTR_NULL.
Referenced by actual_c_parser(), bottom_up_abc_statement(), c_parser_error(), force_reset_c_parser_scope_stack(), force_reset_preprocessor_scope_stack(), ForceResetTypedefStack(), free_statement_global_stack(), gen_internal_context_multi_recurse(), initial_code_abc_statement(), interprocedural_abc_statement(), loop_statistics(), pips_code_abc_statement(), remove_entity_type_stack(), reset_c_parser_scope_stack(), reset_entity_type_stack_table(), reset_preprocessor_scope_stack(), reset_statement_points_to_context(), ResetCurrentModule(), ResetTypedefStack(), string_buffer_free(), top_down_abc_statement(), typing_of_expressions(), xml_Boxes(), xml_Task(), and xml_tasks().
void* stack_head | ( | const stack | s | ) |
returns the item on top of stack s
HEAD
Definition at line 420 of file stack.c.
References assert, __stack_head::stack, STACK_PTR_NULL_P, and x.
Referenced by abc_instrumentation_insert_before_statement(), add_arc_to_statement_points_to_context(), arguments_are_something(), bottom_up_abc_insert_before_statement(), call_rwt(), check_format(), check_io_list(), check_spec(), check_this_loop(), check_this_test(), check_this_whileloop(), EnterScope(), eov_stack_task_pop_task(), ExitScope(), FindOrCreateCurrentEntity(), gen_get_recurse_current_ancestor(), get_c_parser_current_scope(), get_current_statement_from_statement_global_stack(), get_preprocessor_current_scope(), GetContext(), GetContextCopy(), GetFunction(), GetScope(), interprocedural_abc_insert_before_statement(), is_integer_specifier(), is_label_integer_string_specifier(), is_label_specifier(), is_string_specifier(), is_unit_specifier(), is_varibale_array_element_specifier(), loop_flt(), loop_rwt(), MakeBreakStatement(), MakeCaseStatement(), MakeContinueStatement(), MakeDefaultStatement(), MakeForloop(), MakeParameterList(), MakeSwitchStatement(), MakeWhileLoop(), points_to_context_statement_in(), PopContext(), push_if(), push_loop(), pv_context_statement_head(), quick_multi_already_seen_p(), seq_rwt(), stack_free(), StackPop(), StackPush(), statement_with_at_most_one_expression_integer(), statement_with_at_most_one_integer_or_character(), statement_without_argument(), stmt_rwt(), store_call_context(), test_rwt(), top_down_abc_insert_before_statement(), type_this_entity_if_needed(), type_this_expression(), type_this_instruction(), typing_arguments_of_user_function(), typing_assign_substring(), typing_buffer_inout(), typing_function_argument_type_to_return_type(), typing_implied_do(), typing_of_assign(), typing_substring(), uns_rwt(), update_statement_points_to_context_with_arc(), UpdateAbstractEntity(), UpdateDerivedEntity(), UpdateEntity(), and wl_rwt().
void stack_info | ( | FILE * | f, |
const stack | s | ||
) |
else
else
Definition at line 342 of file stack.c.
References __stack_head::avail, f(), fprintf(), __stack_head::max_extent, number_of_buckets(), __stack_head::size, __stack_head::stack, STACK_NULL_P, stack_undefined_p, and __stack_head::type.
void stack_iterator_end | ( | stack_iterator * | pi | ) |
Definition at line 184 of file stack.c.
References free(), and NEWGEN_FREED.
bool stack_iterator_end_p | ( | stack_iterator | i | ) |
stack_iterator stack_iterator_init | ( | const | stack, |
bool | down | ||
) |
stack iterator
This way the stack type is fully encapsulated, but it is not very efficient, due to the many function calls. Consider "stack_map" first which has a very small overhead.
Definition at line 157 of file stack.c.
References malloc(), and stack_iterator_internal_init().
|
static |
NOT the define!
Definition at line 135 of file stack.c.
References DEFINE_ITERATOR, __stack_bucket::n_item, __stack_head::size, __stack_head::stack, STACK_CHECK, STACK_PTR_NULL, UPDATE_ITERATOR_DOWNWARD, and update_iterator_upward().
Referenced by stack_iterator_init(), and stack_nth().
bool stack_iterator_next_and_go | ( | stack_iterator | i, |
void ** | pitem | ||
) |
X-ward.
Definition at line 164 of file stack.c.
References __stack_iterator::bucket, __stack_iterator::index, __stack_bucket::items, NEXT_ITERATION, and STACK_ITERATOR_END_P.
Referenced by stack_nth().
ALLOCATEs a new stack of type
.
allocation
type | record newgen domain of stack contents. should be used to check the type of appended elements. |
bucket_size | is the number of elements in the elemental stack container. If you now you will have big stacks, try big numbers here to save memory. |
policy | not used, 0 is fine. |
not too small
not used
Definition at line 246 of file stack.c.
References allocate_bucket(), __stack_head::avail, __stack_head::bucket_size, malloc(), __stack_head::max_extent, message_assert, __stack_head::n_buckets, __stack_head::policy, __stack_head::size, __stack_head::stack, STACK_DEFAULT_SIZE, STACK_PTR_NULL, and __stack_head::type.
Referenced by actual_c_parser(), bottom_up_abc_statement(), eov_make_ctx(), gen_internal_context_multi_recurse(), guard_elimination(), init_c_parser_scope_stack(), init_preprocessor_scope_stack(), init_statement_points_to_context(), initial_code_abc_statement(), InitializeBlock(), interprocedural_abc_statement(), loop_statistics(), make_simple_pv_context(), make_statement_global_stack(), MakeCurrentModule(), MakeTypedefStack(), pips_code_abc_statement(), push_pips_context(), stack_copy(), string_buffer_make(), tiling_sequence(), top_down_abc_statement(), typing_of_expressions(), xml_Boxes(), xml_Task(), and xml_tasks().
void stack_map | ( | const stack | s, |
gen_iter_func_t | f | ||
) |
APPLY f to all items of stack s;.
Definition at line 323 of file stack.c.
References __stack_head::stack, STACK_CHECK, and x.
returns the nth item starting from the head and counting from 1, when possible, or NULL, elsewhere.
stack_nth(stack,1)==stack_head(stack) if stack_size(stack)>=1.
Definition at line 436 of file stack.c.
References message_assert, stack_iterator_internal_init(), and stack_iterator_next_and_go().
Referenced by get_c_parser_nth_scope(), get_preprocessor_nth_scope(), and GetParentScope().
STACK_OBSERVER | ( | consistent_p | , |
1 | |||
) |
Here we define stack_size(), stack_bsize(), stack_policy() and stack_max_extent():
well, it is not implemented
Definition at line 311 of file stack.c.
References STACK_CHECK.
void* stack_pop | ( | stack | s | ) |
POPs one item from stack s.
the empty buckets are not freed here. stack_free does the job.
POP!
Definition at line 399 of file stack.c.
References assert, __stack_head::avail, __stack_head::size, __stack_head::stack, STACK_PTR_NULL_P, and x.
Referenced by eov_stack_task_pop_task(), ExitScope(), gen_internal_context_multi_recurse(), MakeForloop(), NStackPop(), pop_c_parser_scope_stack(), pop_current_statement(), pop_if(), pop_loop(), pop_pips_context(), pop_preprocessor_scope(), pop_statement_global_stack(), pop_statement_points_to_context(), pop_uns(), PopContext(), PopFunction(), PopTypedef(), pv_context_statement_pop(), quick_multi_recurse_obj_out(), stmt_rwt(), string_buffer_reset(), UpdateAbstractEntity(), UpdateDerivedEntity(), and UpdateEntity().
void stack_push | ( | void * | item, |
stack | s | ||
) |
STACK USE.
stack use
PUSHes the item on stack s
a new bucket is allocated if necessary. the size it the same than the initial bucket size. Other policies may be considered.
PUSH!
Definition at line 373 of file stack.c.
References assert, find_or_allocate(), __stack_head::max_extent, __stack_head::size, __stack_head::stack, STACK_PTR_NULL_P, and x.
Referenced by EnterScope(), eov_stack_task_push_task(), gen_internal_context_multi_recurse(), push_current_statement(), push_if(), push_loop(), push_new_c_parser_scope(), push_new_preprocessor_scope(), push_pips_context(), push_statement_on_statement_global_stack(), push_statement_points_to_context(), push_uns(), PushContext(), PushFunction(), PushTypedef(), pv_context_statement_push(), quick_multi_recurse_obj_in(), stack_copy(), StackPush(), stmt_flt(), and string_buffer_append_internal().
void* stack_replace | ( | void * | item, |
stack | s | ||
) |
REPLACEs the item on top of stack s, and returns the old item.
REPLACE
Definition at line 450 of file stack.c.
References assert, __stack_head::stack, STACK_PTR_NULL_P, and x.
|
static |
and also *stack_iterator (in headers)
Definition at line 91 of file stack.c.
References __stack_iterator::bucket, __stack_iterator::index, __stack_iterator::list, __stack_bucket::n_item, STACK_PTR_NULL, STACK_PTR_NULL_P, and x.
Referenced by stack_iterator_internal_init().