diff options
Diffstat (limited to 'mesalib/src/glsl/list.h')
-rw-r--r-- | mesalib/src/glsl/list.h | 40 |
1 files changed, 39 insertions, 1 deletions
diff --git a/mesalib/src/glsl/list.h b/mesalib/src/glsl/list.h index 9f08d45f7..500a85717 100644 --- a/mesalib/src/glsl/list.h +++ b/mesalib/src/glsl/list.h @@ -333,6 +333,8 @@ struct exec_list { const exec_node *get_tail() const; exec_node *get_tail(); + unsigned length() const; + void push_head(exec_node *n); void push_tail(exec_node *n); void push_degenerate_list_at_head(exec_node *n); @@ -353,9 +355,15 @@ struct exec_list { void move_nodes_to(exec_list *target); /** - * Append all nodes from the source list to the target list + * Append all nodes from the source list to the end of the target list */ void append_list(exec_list *source); + + /** + * Prepend all nodes from the source list to the beginning of the target + * list + */ + void prepend_list(exec_list *source); #endif }; @@ -407,6 +415,19 @@ exec_list_get_tail(struct exec_list *list) return !exec_list_is_empty(list) ? list->tail_pred : NULL; } +static inline unsigned +exec_list_length(const struct exec_list *list) +{ + unsigned size = 0; + struct exec_node *node; + + for (node = list->head; node->next != NULL; node = node->next) { + size++; + } + + return size; +} + static inline void exec_list_push_head(struct exec_list *list, struct exec_node *n) { @@ -487,6 +508,13 @@ exec_list_append(struct exec_list *list, struct exec_list *source) } static inline void +exec_list_prepend(struct exec_list *list, struct exec_list *source) +{ + exec_list_append(source, list); + exec_list_move_nodes_to(source, list); +} + +static inline void exec_node_insert_list_before(struct exec_node *n, struct exec_list *before) { if (exec_list_is_empty(before)) @@ -532,6 +560,11 @@ inline exec_node *exec_list::get_tail() return exec_list_get_tail(this); } +inline unsigned exec_list::length() const +{ + return exec_list_length(this); +} + inline void exec_list::push_head(exec_node *n) { exec_list_push_head(this, n); @@ -562,6 +595,11 @@ inline void exec_list::append_list(exec_list *source) exec_list_append(this, source); } +inline void exec_list::prepend_list(exec_list *source) +{ + exec_list_prepend(this, source); +} + inline void exec_node::insert_before(exec_list *before) { exec_node_insert_list_before(this, before); |