Lines Matching refs:stack
154 struct stack { struct
163 static void stack_check(struct stack *stack) in stack_check() argument
168 if (!stack) in stack_check()
171 SLJIT_ASSERT(stack->index >= 0 && stack->index < STACK_FRAGMENT_SIZE); in stack_check()
173 if (stack->first == NULL) { in stack_check()
174 SLJIT_ASSERT(stack->first == NULL && stack->last == NULL); in stack_check()
175 SLJIT_ASSERT(stack->index == STACK_FRAGMENT_SIZE - 1 && stack->count == 0); in stack_check()
180 if (stack->last == NULL) { in stack_check()
181 SLJIT_ASSERT(stack->index == STACK_FRAGMENT_SIZE - 1 && stack->count == 0); in stack_check()
185 SLJIT_ASSERT(stack->index >= 0 && stack->count >= 0); in stack_check()
187 SLJIT_ASSERT(stack->first->data.prev == NULL); in stack_check()
188 curr = stack->first; in stack_check()
190 if (curr == stack->last) in stack_check()
201 static void stack_init(struct stack *stack) in stack_init() argument
203 stack->first = NULL; in stack_init()
204 stack->last = NULL; in stack_init()
205 stack->index = STACK_FRAGMENT_SIZE - 1; in stack_init()
206 stack->count = 0; in stack_init()
209 static void stack_destroy(struct stack *stack) in stack_destroy() argument
211 struct stack_fragment *curr = stack->first; in stack_destroy()
215 stack_check(stack); in stack_destroy()
225 static SLJIT_INLINE struct stack_item* stack_top(struct stack *stack) in stack_top() argument
227 SLJIT_ASSERT(stack->last); in stack_top()
228 return stack->last->items + stack->index; in stack_top()
231 static int stack_push(struct stack *stack, int type, int value) in stack_push() argument
233 if (stack->last) { in stack_push()
234 stack->index++; in stack_push()
235 if (stack->index >= STACK_FRAGMENT_SIZE) { in stack_push()
236 stack->index = 0; in stack_push()
237 if (!stack->last->data.next) { in stack_push()
238 …stack->last->data.next = (struct stack_fragment*)SLJIT_MALLOC(sizeof(struct stack_fragment), NULL); in stack_push()
239 if (!stack->last->data.next) in stack_push()
241 stack->last->data.next->data.next = NULL; in stack_push()
242 stack->last->data.next->data.prev = stack->last; in stack_push()
244 stack->last = stack->last->data.next; in stack_push()
247 else if (!stack->first) { in stack_push()
248 stack->last = (struct stack_fragment*)SLJIT_MALLOC(sizeof(struct stack_fragment), NULL); in stack_push()
249 if (!stack->last) in stack_push()
251 stack->last->data.prev = NULL; in stack_push()
252 stack->last->data.next = NULL; in stack_push()
253 stack->first = stack->last; in stack_push()
254 stack->index = 0; in stack_push()
257 stack->last = stack->first; in stack_push()
258 stack->index = 0; in stack_push()
260 stack->last->items[stack->index].type = type; in stack_push()
261 stack->last->items[stack->index].value = value; in stack_push()
262 stack->count++; in stack_push()
264 stack_check(stack); in stack_push()
269 static struct stack_item* stack_pop(struct stack *stack) in stack_pop() argument
271 struct stack_item *ret = stack_top(stack); in stack_pop()
273 if (stack->index > 0) in stack_pop()
274 stack->index--; in stack_pop()
276 stack->last = stack->last->data.prev; in stack_pop()
277 stack->index = STACK_FRAGMENT_SIZE - 1; in stack_pop()
280 stack->count--; in stack_pop()
282 stack_check(stack); in stack_pop()
287 static SLJIT_INLINE void stack_clone(struct stack *src, struct stack *dst) in stack_clone()
292 static int stack_push_copy(struct stack *stack, int items, int length) in stack_push_copy() argument
300 SLJIT_ASSERT(stack->count >= length && items <= length && items > 0); in stack_push_copy()
304 frag1 = stack->last; in stack_push_copy()
305 ind1 = stack->index; in stack_push_copy()
307 if (stack->index + counter >= STACK_FRAGMENT_SIZE) { in stack_push_copy()
308 counter -= STACK_FRAGMENT_SIZE - stack->index - 1 + 1; in stack_push_copy()
309 stack->index = 0; in stack_push_copy()
310 if (!stack->last->data.next) { in stack_push_copy()
311 …stack->last->data.next = (struct stack_fragment*)SLJIT_MALLOC(sizeof(struct stack_fragment), NULL); in stack_push_copy()
312 if (!stack->last->data.next) in stack_push_copy()
314 stack->last->data.next->data.next = NULL; in stack_push_copy()
315 stack->last->data.next->data.prev = stack->last; in stack_push_copy()
317 stack->last = stack->last->data.next; in stack_push_copy()
320 stack->index += counter; in stack_push_copy()
325 frag2 = stack->last; in stack_push_copy()
326 ind2 = stack->index; in stack_push_copy()
341 stack_check(stack); in stack_push_copy()
343 stack->count += items; in stack_push_copy()
379 struct stack stack; member
380 struct stack depth;
425 static int iterate(struct stack *stack, int min, int max) in iterate() argument
427 struct stack it; in iterate()
433 stack_clone(stack, &it); in iterate()
480 stack_clone(&it, stack); in iterate()
482 if (stack_push(stack, type_open_br, 0)) in iterate()
484 if (stack_push(stack, type_close_br, 0)) in iterate()
489 count = stack->count - count; in iterate()
492 if (stack_push_copy(stack, 1, count)) in iterate()
511 if (stack_push_copy(stack, count, count)) in iterate()
516 if (stack_push_copy(stack, count, count)) in iterate()
518 if (stack_push(stack, type_qestion_mark, 0)) in iterate()
528 if (stack_push(stack, type_qestion_mark, 0)) in iterate()
533 if (stack_push_copy(stack, count, count)) in iterate()
544 if (stack_push_copy(stack, count, count)) in iterate()
549 if (stack_push(stack, type_plus_sign, 0)) in iterate()
554 if (stack_push(stack, type_close_br, 0)) in iterate()
560 static int parse_iterator(const regex_char_t *regex_string, int length, struct stack *stack, sljit_… in parse_iterator() argument
595 if (stack_push(stack, type_id, val1)) in parse_iterator()
632 val1 = iterate(stack, val1, val2); in parse_iterator()
638 if (stack_push(stack, type_asterisk, 0)) in parse_iterator()
643 if (stack_push(stack, type_plus_sign, 0)) in parse_iterator()
648 if (stack_push(stack, type_qestion_mark, 0)) in parse_iterator()
653 val1 = iterate(stack, 0, 0); in parse_iterator()
668 struct stack* stack = &compiler_common->stack; in parse_char_range() local
679 if (stack_push(stack, type_rng_start, 0)) in parse_char_range()
689 if (stack_push(stack, type_rng_start, 1)) in parse_char_range()
699 if (stack_push(stack, type_rng_char, ']')) in parse_char_range()
747 if (stack_push(stack, type_rng_left, left_char)) in parse_char_range()
749 if (stack_push(stack, type_rng_right, right_char)) in parse_char_range()
754 if (stack_push(stack, type_rng_char, left_char)) in parse_char_range()
760 if (stack_push(stack, type_rng_end, 0)) in parse_char_range()
772 struct stack* stack = &compiler_common->stack; in parse() local
777 stack_init(stack); in parse()
778 if (stack_push(stack, type_begin, 0)) in parse()
792 if (stack_push(stack, type_newline, 0)) in parse()
805 if (stack_push(stack, type_char, *regex_string)) in parse()
812 if (stack_push(stack, type_rng_start, 1)) in parse()
815 if (stack_push(stack, type_rng_char, '\n')) in parse()
817 if (stack_push(stack, type_rng_char, '\r')) in parse()
821 if (stack_push(stack, type_rng_end, 1)) in parse()
829 if (stack_push(stack, type_open_br, 0)) in parse()
838 if (stack_push(stack, type_close_br, 0)) in parse()
844 if (stack_push(stack, type_select, 0)) in parse()
853 if (stack_push(stack, type_asterisk, 0)) in parse()
862 if (stack_push(stack, (*regex_string == '+') ? type_plus_sign : type_qestion_mark, 0)) in parse()
868 tmp = parse_iterator(regex_string, length, stack, &compiler_common->dfa_size, begin); in parse()
879 if (stack_push(stack, type_char, '{')) in parse()
905 if (stack_push(stack, type_char, *regex_string)) in parse()
923 if (stack_push(stack, type_newline, 1)) in parse()
929 if (stack_push(stack, type_end, 0)) in parse()
946 …iteratives(struct stack_item *transitions_ptr, struct stack_item *transitions, struct stack *depth) in handle_iteratives()
978 struct stack *stack = &compiler_common->stack; in generate_transitions() local
979 struct stack *depth = &compiler_common->depth; in generate_transitions()
990 while (stack->count > 0) { in generate_transitions()
991 item = stack_pop(stack); in generate_transitions()
1000 if (stack->count == 0) in generate_transitions()
1234 struct stack *stack = &compiler_common->stack; in trace_transitions() local
1235 struct stack *depth = &compiler_common->depth; in trace_transitions()
1252 if (stack_push(stack, 0, from)) in trace_transitions()
1316 struct stack *stack = &compiler_common->stack; in compile_uncond_tran() local
1330 while (stack->count > 0) { in compile_uncond_tran()
1331 value = stack_pop(stack)->value; in compile_uncond_tran()
1374 struct stack *stack = &compiler_common->stack; in compile_cond_tran() local
1395 while (stack->count > 0) { in compile_cond_tran()
1396 value = stack_pop(stack)->value; in compile_cond_tran()
1635 struct stack *stack = &compiler_common->stack; in compile_leave_fast_forward() local
1642 while (stack->count > 0) { in compile_leave_fast_forward()
1643 ind = stack_pop(stack)->value; in compile_leave_fast_forward()
1868 stack_destroy(&compiler_common.stack); in regex_compile()
1876 stack_destroy(&compiler_common.stack); in regex_compile()
1901 stack_init(&compiler_common.stack); in regex_compile()
1937 while (compiler_common.stack.count > 0) { in regex_compile()
1938 ind = stack_pop(&compiler_common.stack)->value; in regex_compile()
1955 while (compiler_common.stack.count > 0) { in regex_compile()
1956 ind = stack_pop(&compiler_common.stack)->value; in regex_compile()
2044 while (compiler_common.stack.count > 0) { in regex_compile()
2045 ind = stack_pop(&compiler_common.stack)->value; in regex_compile()
2090 while (compiler_common.stack.count > 0) { in regex_compile()
2091 ind = stack_pop(&compiler_common.stack)->value; in regex_compile()
2282 stack_destroy(&compiler_common.stack); in regex_compile()