Lines Matching refs:expr

15 struct expr *expr_alloc_symbol(struct symbol *sym)  in expr_alloc_symbol()
17 struct expr *e = malloc(sizeof(*e)); in expr_alloc_symbol()
24 struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) in expr_alloc_one()
26 struct expr *e = malloc(sizeof(*e)); in expr_alloc_one()
29 e->left.expr = ce; in expr_alloc_one()
33 struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2) in expr_alloc_two()
35 struct expr *e = malloc(sizeof(*e)); in expr_alloc_two()
38 e->left.expr = e1; in expr_alloc_two()
39 e->right.expr = e2; in expr_alloc_two()
43 struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2) in expr_alloc_comp()
45 struct expr *e = malloc(sizeof(*e)); in expr_alloc_comp()
53 struct expr *expr_alloc_and(struct expr *e1, struct expr *e2) in expr_alloc_and()
60 struct expr *expr_alloc_or(struct expr *e1, struct expr *e2) in expr_alloc_or()
67 struct expr *expr_copy(struct expr *org) in expr_copy()
69 struct expr *e; in expr_copy()
81 e->left.expr = expr_copy(org->left.expr); in expr_copy()
91 e->left.expr = expr_copy(org->left.expr); in expr_copy()
92 e->right.expr = expr_copy(org->right.expr); in expr_copy()
104 void expr_free(struct expr *e) in expr_free()
113 expr_free(e->left.expr); in expr_free()
120 expr_free(e->left.expr); in expr_free()
121 expr_free(e->right.expr); in expr_free()
135 static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2) in __expr_eliminate_eq()
138 __expr_eliminate_eq(type, &e1->left.expr, &e2); in __expr_eliminate_eq()
139 __expr_eliminate_eq(type, &e1->right.expr, &e2); in __expr_eliminate_eq()
143 __expr_eliminate_eq(type, &e1, &e2->left.expr); in __expr_eliminate_eq()
144 __expr_eliminate_eq(type, &e1, &e2->right.expr); in __expr_eliminate_eq()
169 void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) in expr_eliminate_eq()
194 int expr_eq(struct expr *e1, struct expr *e2) in expr_eq()
207 return expr_eq(e1->left.expr, e2->left.expr); in expr_eq()
236 struct expr *expr_eliminate_yn(struct expr *e) in expr_eliminate_yn()
238 struct expr *tmp; in expr_eliminate_yn()
242 e->left.expr = expr_eliminate_yn(e->left.expr); in expr_eliminate_yn()
243 e->right.expr = expr_eliminate_yn(e->right.expr); in expr_eliminate_yn()
244 if (e->left.expr->type == E_SYMBOL) { in expr_eliminate_yn()
245 if (e->left.expr->left.sym == &symbol_no) { in expr_eliminate_yn()
246 expr_free(e->left.expr); in expr_eliminate_yn()
247 expr_free(e->right.expr); in expr_eliminate_yn()
250 e->right.expr = NULL; in expr_eliminate_yn()
252 } else if (e->left.expr->left.sym == &symbol_yes) { in expr_eliminate_yn()
253 free(e->left.expr); in expr_eliminate_yn()
254 tmp = e->right.expr; in expr_eliminate_yn()
255 *e = *(e->right.expr); in expr_eliminate_yn()
260 if (e->right.expr->type == E_SYMBOL) { in expr_eliminate_yn()
261 if (e->right.expr->left.sym == &symbol_no) { in expr_eliminate_yn()
262 expr_free(e->left.expr); in expr_eliminate_yn()
263 expr_free(e->right.expr); in expr_eliminate_yn()
266 e->right.expr = NULL; in expr_eliminate_yn()
268 } else if (e->right.expr->left.sym == &symbol_yes) { in expr_eliminate_yn()
269 free(e->right.expr); in expr_eliminate_yn()
270 tmp = e->left.expr; in expr_eliminate_yn()
271 *e = *(e->left.expr); in expr_eliminate_yn()
278 e->left.expr = expr_eliminate_yn(e->left.expr); in expr_eliminate_yn()
279 e->right.expr = expr_eliminate_yn(e->right.expr); in expr_eliminate_yn()
280 if (e->left.expr->type == E_SYMBOL) { in expr_eliminate_yn()
281 if (e->left.expr->left.sym == &symbol_no) { in expr_eliminate_yn()
282 free(e->left.expr); in expr_eliminate_yn()
283 tmp = e->right.expr; in expr_eliminate_yn()
284 *e = *(e->right.expr); in expr_eliminate_yn()
287 } else if (e->left.expr->left.sym == &symbol_yes) { in expr_eliminate_yn()
288 expr_free(e->left.expr); in expr_eliminate_yn()
289 expr_free(e->right.expr); in expr_eliminate_yn()
292 e->right.expr = NULL; in expr_eliminate_yn()
296 if (e->right.expr->type == E_SYMBOL) { in expr_eliminate_yn()
297 if (e->right.expr->left.sym == &symbol_no) { in expr_eliminate_yn()
298 free(e->right.expr); in expr_eliminate_yn()
299 tmp = e->left.expr; in expr_eliminate_yn()
300 *e = *(e->left.expr); in expr_eliminate_yn()
303 } else if (e->right.expr->left.sym == &symbol_yes) { in expr_eliminate_yn()
304 expr_free(e->left.expr); in expr_eliminate_yn()
305 expr_free(e->right.expr); in expr_eliminate_yn()
308 e->right.expr = NULL; in expr_eliminate_yn()
322 struct expr *expr_trans_bool(struct expr *e) in expr_trans_bool()
330 e->left.expr = expr_trans_bool(e->left.expr); in expr_trans_bool()
331 e->right.expr = expr_trans_bool(e->right.expr); in expr_trans_bool()
351 struct expr *expr_join_or(struct expr *e1, struct expr *e2) in expr_join_or()
353 struct expr *tmp; in expr_join_or()
363 tmp = e1->left.expr; in expr_join_or()
370 if (e2->left.expr->type != E_SYMBOL) in expr_join_or()
372 sym2 = e2->left.expr->left.sym; in expr_join_or()
400 if ((e1->type == E_NOT && e1->left.expr->type == E_SYMBOL && e2->type == E_SYMBOL) || in expr_join_or()
401 (e2->type == E_NOT && e2->left.expr->type == E_SYMBOL && e1->type == E_SYMBOL)) in expr_join_or()
415 struct expr *expr_join_and(struct expr *e1, struct expr *e2) in expr_join_and()
417 struct expr *tmp; in expr_join_and()
427 tmp = e1->left.expr; in expr_join_and()
434 if (e2->left.expr->type != E_SYMBOL) in expr_join_and()
436 sym2 = e2->left.expr->left.sym; in expr_join_and()
509 static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2) in expr_eliminate_dups1()
513 struct expr *tmp; in expr_eliminate_dups1()
516 expr_eliminate_dups1(type, &e1->left.expr, &e2); in expr_eliminate_dups1()
517 expr_eliminate_dups1(type, &e1->right.expr, &e2); in expr_eliminate_dups1()
521 expr_eliminate_dups1(type, &e1, &e2->left.expr); in expr_eliminate_dups1()
522 expr_eliminate_dups1(type, &e1, &e2->right.expr); in expr_eliminate_dups1()
561 static void expr_eliminate_dups2(enum expr_type type, struct expr **ep1, struct expr **ep2) in expr_eliminate_dups2()
565 struct expr *tmp, *tmp1, *tmp2; in expr_eliminate_dups2()
568 expr_eliminate_dups2(type, &e1->left.expr, &e2); in expr_eliminate_dups2()
569 expr_eliminate_dups2(type, &e1->right.expr, &e2); in expr_eliminate_dups2()
573 expr_eliminate_dups2(type, &e1, &e2->left.expr); in expr_eliminate_dups2()
574 expr_eliminate_dups2(type, &e1, &e2->right.expr); in expr_eliminate_dups2()
617 struct expr *expr_eliminate_dups(struct expr *e) in expr_eliminate_dups()
641 struct expr *expr_transform(struct expr *e) in expr_transform()
643 struct expr *tmp; in expr_transform()
654 e->left.expr = expr_transform(e->left.expr); in expr_transform()
655 e->right.expr = expr_transform(e->right.expr); in expr_transform()
664 e->left.expr = expr_alloc_symbol(e->left.sym); in expr_transform()
698 e->left.expr = expr_alloc_symbol(e->left.sym); in expr_transform()
704 switch (e->left.expr->type) { in expr_transform()
707 tmp = e->left.expr->left.expr; in expr_transform()
708 free(e->left.expr); in expr_transform()
716 tmp = e->left.expr; in expr_transform()
723 tmp = e->left.expr; in expr_transform()
725 e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); in expr_transform()
727 tmp->right.expr = NULL; in expr_transform()
732 tmp = e->left.expr; in expr_transform()
734 e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); in expr_transform()
736 tmp->right.expr = NULL; in expr_transform()
740 if (e->left.expr->left.sym == &symbol_yes) { in expr_transform()
742 tmp = e->left.expr; in expr_transform()
749 if (e->left.expr->left.sym == &symbol_mod) { in expr_transform()
751 tmp = e->left.expr; in expr_transform()
758 if (e->left.expr->left.sym == &symbol_no) { in expr_transform()
760 tmp = e->left.expr; in expr_transform()
778 int expr_contains_symbol(struct expr *dep, struct symbol *sym) in expr_contains_symbol()
786 return expr_contains_symbol(dep->left.expr, sym) || in expr_contains_symbol()
787 expr_contains_symbol(dep->right.expr, sym); in expr_contains_symbol()
795 return expr_contains_symbol(dep->left.expr, sym); in expr_contains_symbol()
802 bool expr_depends_symbol(struct expr *dep, struct symbol *sym) in expr_depends_symbol()
809 return expr_depends_symbol(dep->left.expr, sym) || in expr_depends_symbol()
810 expr_depends_symbol(dep->right.expr, sym); in expr_depends_symbol()
831 struct expr *expr_extract_eq_and(struct expr **ep1, struct expr **ep2) in expr_extract_eq_and()
833 struct expr *tmp = NULL; in expr_extract_eq_and()
842 struct expr *expr_extract_eq_or(struct expr **ep1, struct expr **ep2) in expr_extract_eq_or()
844 struct expr *tmp = NULL; in expr_extract_eq_or()
853 void expr_extract_eq(enum expr_type type, struct expr **ep, struct expr **ep1, struct expr **ep2) in expr_extract_eq()
858 expr_extract_eq(type, ep, &e1->left.expr, &e2); in expr_extract_eq()
859 expr_extract_eq(type, ep, &e1->right.expr, &e2); in expr_extract_eq()
863 expr_extract_eq(type, ep, ep1, &e2->left.expr); in expr_extract_eq()
864 expr_extract_eq(type, ep, ep1, &e2->right.expr); in expr_extract_eq()
882 struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym) in expr_trans_compare()
884 struct expr *e1, *e2; in expr_trans_compare()
894 e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); in expr_trans_compare()
895 e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); in expr_trans_compare()
904 e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); in expr_trans_compare()
905 e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); in expr_trans_compare()
914 return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym); in expr_trans_compare()
943 tristate expr_calc_value(struct expr *e) in expr_calc_value()
956 val1 = expr_calc_value(e->left.expr); in expr_calc_value()
957 val2 = expr_calc_value(e->right.expr); in expr_calc_value()
960 val1 = expr_calc_value(e->left.expr); in expr_calc_value()
961 val2 = expr_calc_value(e->right.expr); in expr_calc_value()
964 val1 = expr_calc_value(e->left.expr); in expr_calc_value()
1016 void expr_print(struct expr *e, void (*fn)(void *, struct symbol *, const char *), void *data, int … in expr_print()
1034 expr_print(e->left.expr, fn, data, E_NOT); in expr_print()
1047 expr_print(e->left.expr, fn, data, E_OR); in expr_print()
1049 expr_print(e->right.expr, fn, data, E_OR); in expr_print()
1052 expr_print(e->left.expr, fn, data, E_AND); in expr_print()
1054 expr_print(e->right.expr, fn, data, E_AND); in expr_print()
1058 if (e->left.expr) { in expr_print()
1060 expr_print(e->left.expr, fn, data, E_CHOICE); in expr_print()
1087 void expr_fprint(struct expr *e, FILE *out) in expr_fprint()
1097 void expr_gstr_print(struct expr *e, struct gstr *gs) in expr_gstr_print()