Lines Matching refs:expr
16 static struct expr *expr_eliminate_yn(struct expr *e);
18 struct expr *expr_alloc_symbol(struct symbol *sym) in expr_alloc_symbol()
20 struct expr *e = xcalloc(1, sizeof(*e)); in expr_alloc_symbol()
26 struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) in expr_alloc_one()
28 struct expr *e = xcalloc(1, sizeof(*e)); in expr_alloc_one()
30 e->left.expr = ce; in expr_alloc_one()
34 struct expr *expr_alloc_two(enum expr_type type, struct expr *e1, struct expr *e2) in expr_alloc_two()
36 struct expr *e = xcalloc(1, 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 = xcalloc(1, sizeof(*e)); in expr_alloc_comp()
52 struct expr *expr_alloc_and(struct expr *e1, struct expr *e2) in expr_alloc_and()
59 struct expr *expr_alloc_or(struct expr *e1, struct expr *e2) in expr_alloc_or()
66 struct expr *expr_copy(const struct expr *org) in expr_copy()
68 struct expr *e; in expr_copy()
80 e->left.expr = expr_copy(org->left.expr); in expr_copy()
94 e->left.expr = expr_copy(org->left.expr); in expr_copy()
95 e->right.expr = expr_copy(org->right.expr); in expr_copy()
107 void expr_free(struct expr *e) in expr_free()
116 expr_free(e->left.expr); in expr_free()
127 expr_free(e->left.expr); in expr_free()
128 expr_free(e->right.expr); in expr_free()
150 static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2) in __expr_eliminate_eq()
155 __expr_eliminate_eq(type, &e1->left.expr, &e2); in __expr_eliminate_eq()
156 __expr_eliminate_eq(type, &e1->right.expr, &e2); in __expr_eliminate_eq()
160 __expr_eliminate_eq(type, &e1, &e2->left.expr); in __expr_eliminate_eq()
161 __expr_eliminate_eq(type, &e1, &e2->right.expr); in __expr_eliminate_eq()
221 void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) in expr_eliminate_eq()
252 int expr_eq(struct expr *e1, struct expr *e2) in expr_eq()
276 return expr_eq(e1->left.expr, e2->left.expr); in expr_eq()
316 static struct expr *expr_eliminate_yn(struct expr *e) in expr_eliminate_yn()
318 struct expr *tmp; in expr_eliminate_yn()
322 e->left.expr = expr_eliminate_yn(e->left.expr); in expr_eliminate_yn()
323 e->right.expr = expr_eliminate_yn(e->right.expr); in expr_eliminate_yn()
324 if (e->left.expr->type == E_SYMBOL) { in expr_eliminate_yn()
325 if (e->left.expr->left.sym == &symbol_no) { in expr_eliminate_yn()
326 expr_free(e->left.expr); in expr_eliminate_yn()
327 expr_free(e->right.expr); in expr_eliminate_yn()
330 e->right.expr = NULL; in expr_eliminate_yn()
332 } else if (e->left.expr->left.sym == &symbol_yes) { in expr_eliminate_yn()
333 free(e->left.expr); in expr_eliminate_yn()
334 tmp = e->right.expr; in expr_eliminate_yn()
335 *e = *(e->right.expr); in expr_eliminate_yn()
340 if (e->right.expr->type == E_SYMBOL) { in expr_eliminate_yn()
341 if (e->right.expr->left.sym == &symbol_no) { in expr_eliminate_yn()
342 expr_free(e->left.expr); in expr_eliminate_yn()
343 expr_free(e->right.expr); in expr_eliminate_yn()
346 e->right.expr = NULL; in expr_eliminate_yn()
348 } else if (e->right.expr->left.sym == &symbol_yes) { in expr_eliminate_yn()
349 free(e->right.expr); in expr_eliminate_yn()
350 tmp = e->left.expr; in expr_eliminate_yn()
351 *e = *(e->left.expr); in expr_eliminate_yn()
358 e->left.expr = expr_eliminate_yn(e->left.expr); in expr_eliminate_yn()
359 e->right.expr = expr_eliminate_yn(e->right.expr); in expr_eliminate_yn()
360 if (e->left.expr->type == E_SYMBOL) { in expr_eliminate_yn()
361 if (e->left.expr->left.sym == &symbol_no) { in expr_eliminate_yn()
362 free(e->left.expr); in expr_eliminate_yn()
363 tmp = e->right.expr; in expr_eliminate_yn()
364 *e = *(e->right.expr); in expr_eliminate_yn()
367 } else if (e->left.expr->left.sym == &symbol_yes) { in expr_eliminate_yn()
368 expr_free(e->left.expr); in expr_eliminate_yn()
369 expr_free(e->right.expr); in expr_eliminate_yn()
372 e->right.expr = NULL; in expr_eliminate_yn()
376 if (e->right.expr->type == E_SYMBOL) { in expr_eliminate_yn()
377 if (e->right.expr->left.sym == &symbol_no) { in expr_eliminate_yn()
378 free(e->right.expr); in expr_eliminate_yn()
379 tmp = e->left.expr; in expr_eliminate_yn()
380 *e = *(e->left.expr); in expr_eliminate_yn()
383 } else if (e->right.expr->left.sym == &symbol_yes) { in expr_eliminate_yn()
384 expr_free(e->left.expr); in expr_eliminate_yn()
385 expr_free(e->right.expr); in expr_eliminate_yn()
388 e->right.expr = NULL; in expr_eliminate_yn()
402 struct expr *expr_trans_bool(struct expr *e) in expr_trans_bool()
410 e->left.expr = expr_trans_bool(e->left.expr); in expr_trans_bool()
411 e->right.expr = expr_trans_bool(e->right.expr); in expr_trans_bool()
431 static struct expr *expr_join_or(struct expr *e1, struct expr *e2) in expr_join_or()
433 struct expr *tmp; in expr_join_or()
443 tmp = e1->left.expr; in expr_join_or()
450 if (e2->left.expr->type != E_SYMBOL) in expr_join_or()
452 sym2 = e2->left.expr->left.sym; in expr_join_or()
480 if ((e1->type == E_NOT && e1->left.expr->type == E_SYMBOL && e2->type == E_SYMBOL) || in expr_join_or()
481 (e2->type == E_NOT && e2->left.expr->type == E_SYMBOL && e1->type == E_SYMBOL)) in expr_join_or()
495 static struct expr *expr_join_and(struct expr *e1, struct expr *e2) in expr_join_and()
497 struct expr *tmp; in expr_join_and()
507 tmp = e1->left.expr; in expr_join_and()
514 if (e2->left.expr->type != E_SYMBOL) in expr_join_and()
516 sym2 = e2->left.expr->left.sym; in expr_join_and()
596 static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2) in expr_eliminate_dups1()
600 struct expr *tmp; in expr_eliminate_dups1()
605 expr_eliminate_dups1(type, &e1->left.expr, &e2); in expr_eliminate_dups1()
606 expr_eliminate_dups1(type, &e1->right.expr, &e2); in expr_eliminate_dups1()
610 expr_eliminate_dups1(type, &e1, &e2->left.expr); in expr_eliminate_dups1()
611 expr_eliminate_dups1(type, &e1, &e2->right.expr); in expr_eliminate_dups1()
664 struct expr *expr_eliminate_dups(struct expr *e) in expr_eliminate_dups()
694 struct expr *expr_transform(struct expr *e) in expr_transform()
696 struct expr *tmp; in expr_transform()
711 e->left.expr = expr_transform(e->left.expr); in expr_transform()
712 e->right.expr = expr_transform(e->right.expr); in expr_transform()
721 e->left.expr = expr_alloc_symbol(e->left.sym); in expr_transform()
755 e->left.expr = expr_alloc_symbol(e->left.sym); in expr_transform()
761 switch (e->left.expr->type) { in expr_transform()
764 tmp = e->left.expr->left.expr; in expr_transform()
765 free(e->left.expr); in expr_transform()
773 tmp = e->left.expr; in expr_transform()
781 tmp = e->left.expr; in expr_transform()
789 tmp = e->left.expr; in expr_transform()
796 tmp = e->left.expr; in expr_transform()
798 e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); in expr_transform()
800 tmp->right.expr = NULL; in expr_transform()
805 tmp = e->left.expr; in expr_transform()
807 e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); in expr_transform()
809 tmp->right.expr = NULL; in expr_transform()
813 if (e->left.expr->left.sym == &symbol_yes) { in expr_transform()
815 tmp = e->left.expr; in expr_transform()
822 if (e->left.expr->left.sym == &symbol_mod) { in expr_transform()
824 tmp = e->left.expr; in expr_transform()
831 if (e->left.expr->left.sym == &symbol_no) { in expr_transform()
833 tmp = e->left.expr; in expr_transform()
851 int expr_contains_symbol(struct expr *dep, struct symbol *sym) in expr_contains_symbol()
859 return expr_contains_symbol(dep->left.expr, sym) || in expr_contains_symbol()
860 expr_contains_symbol(dep->right.expr, sym); in expr_contains_symbol()
872 return expr_contains_symbol(dep->left.expr, sym); in expr_contains_symbol()
879 bool expr_depends_symbol(struct expr *dep, struct symbol *sym) in expr_depends_symbol()
886 return expr_depends_symbol(dep->left.expr, sym) || in expr_depends_symbol()
887 expr_depends_symbol(dep->right.expr, sym); in expr_depends_symbol()
922 struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym) in expr_trans_compare()
924 struct expr *e1, *e2; in expr_trans_compare()
934 e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); in expr_trans_compare()
935 e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); in expr_trans_compare()
944 e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); in expr_trans_compare()
945 e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); in expr_trans_compare()
954 return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym); in expr_trans_compare()
1030 tristate expr_calc_value(struct expr *e) in expr_calc_value()
1046 val1 = expr_calc_value(e->left.expr); in expr_calc_value()
1047 val2 = expr_calc_value(e->right.expr); in expr_calc_value()
1050 val1 = expr_calc_value(e->left.expr); in expr_calc_value()
1051 val2 = expr_calc_value(e->right.expr); in expr_calc_value()
1054 val1 = expr_calc_value(e->left.expr); in expr_calc_value()
1138 void expr_print(struct expr *e, in expr_print()
1158 expr_print(e->left.expr, fn, data, E_NOT); in expr_print()
1195 expr_print(e->left.expr, fn, data, E_OR); in expr_print()
1197 expr_print(e->right.expr, fn, data, E_OR); in expr_print()
1200 expr_print(e->left.expr, fn, data, E_AND); in expr_print()
1202 expr_print(e->right.expr, fn, data, E_AND); in expr_print()
1206 if (e->left.expr) { in expr_print()
1208 expr_print(e->left.expr, fn, data, E_LIST); in expr_print()
1235 void expr_fprint(struct expr *e, FILE *out) in expr_fprint()
1270 void expr_gstr_print(struct expr *e, struct gstr *gs) in expr_gstr_print()
1280 static void expr_print_revdep(struct expr *e, in expr_print_revdep()
1285 expr_print_revdep(e->left.expr, fn, data, pr_type, title); in expr_print_revdep()
1286 expr_print_revdep(e->right.expr, fn, data, pr_type, title); in expr_print_revdep()
1299 void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, in expr_gstr_print_revdep()