Lines Matching refs:expr
14 static int expr_eq(struct expr *e1, struct expr *e2);
15 static struct expr *expr_eliminate_yn(struct expr *e);
17 struct expr *expr_alloc_symbol(struct symbol *sym) in expr_alloc_symbol()
19 struct expr *e = xcalloc(1, sizeof(*e)); in expr_alloc_symbol()
25 struct expr *expr_alloc_one(enum expr_type type, struct expr *ce) in expr_alloc_one()
27 struct expr *e = xcalloc(1, 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 = xcalloc(1, sizeof(*e)); in expr_alloc_two()
37 e->left.expr = e1; in expr_alloc_two()
38 e->right.expr = e2; in expr_alloc_two()
42 struct expr *expr_alloc_comp(enum expr_type type, struct symbol *s1, struct symbol *s2) in expr_alloc_comp()
44 struct expr *e = xcalloc(1, sizeof(*e)); in expr_alloc_comp()
51 struct expr *expr_alloc_and(struct expr *e1, struct expr *e2) in expr_alloc_and()
58 struct expr *expr_alloc_or(struct expr *e1, struct expr *e2) in expr_alloc_or()
65 struct expr *expr_copy(const struct expr *org) in expr_copy()
67 struct expr *e; in expr_copy()
79 e->left.expr = expr_copy(org->left.expr); in expr_copy()
93 e->left.expr = expr_copy(org->left.expr); in expr_copy()
94 e->right.expr = expr_copy(org->right.expr); in expr_copy()
106 void expr_free(struct expr *e) in expr_free()
115 expr_free(e->left.expr); in expr_free()
126 expr_free(e->left.expr); in expr_free()
127 expr_free(e->right.expr); in expr_free()
149 static void __expr_eliminate_eq(enum expr_type type, struct expr **ep1, struct expr **ep2) in __expr_eliminate_eq()
154 __expr_eliminate_eq(type, &e1->left.expr, &e2); in __expr_eliminate_eq()
155 __expr_eliminate_eq(type, &e1->right.expr, &e2); in __expr_eliminate_eq()
159 __expr_eliminate_eq(type, &e1, &e2->left.expr); in __expr_eliminate_eq()
160 __expr_eliminate_eq(type, &e1, &e2->right.expr); in __expr_eliminate_eq()
220 void expr_eliminate_eq(struct expr **ep1, struct expr **ep2) in expr_eliminate_eq()
251 static int expr_eq(struct expr *e1, struct expr *e2) in expr_eq()
268 return expr_eq(e1->left.expr, e2->left.expr); in expr_eq()
308 static struct expr *expr_eliminate_yn(struct expr *e) in expr_eliminate_yn()
310 struct expr *tmp; in expr_eliminate_yn()
314 e->left.expr = expr_eliminate_yn(e->left.expr); in expr_eliminate_yn()
315 e->right.expr = expr_eliminate_yn(e->right.expr); in expr_eliminate_yn()
316 if (e->left.expr->type == E_SYMBOL) { in expr_eliminate_yn()
317 if (e->left.expr->left.sym == &symbol_no) { in expr_eliminate_yn()
318 expr_free(e->left.expr); in expr_eliminate_yn()
319 expr_free(e->right.expr); in expr_eliminate_yn()
322 e->right.expr = NULL; in expr_eliminate_yn()
324 } else if (e->left.expr->left.sym == &symbol_yes) { in expr_eliminate_yn()
325 free(e->left.expr); in expr_eliminate_yn()
326 tmp = e->right.expr; in expr_eliminate_yn()
327 *e = *(e->right.expr); in expr_eliminate_yn()
332 if (e->right.expr->type == E_SYMBOL) { in expr_eliminate_yn()
333 if (e->right.expr->left.sym == &symbol_no) { in expr_eliminate_yn()
334 expr_free(e->left.expr); in expr_eliminate_yn()
335 expr_free(e->right.expr); in expr_eliminate_yn()
338 e->right.expr = NULL; in expr_eliminate_yn()
340 } else if (e->right.expr->left.sym == &symbol_yes) { in expr_eliminate_yn()
341 free(e->right.expr); in expr_eliminate_yn()
342 tmp = e->left.expr; in expr_eliminate_yn()
343 *e = *(e->left.expr); in expr_eliminate_yn()
350 e->left.expr = expr_eliminate_yn(e->left.expr); in expr_eliminate_yn()
351 e->right.expr = expr_eliminate_yn(e->right.expr); in expr_eliminate_yn()
352 if (e->left.expr->type == E_SYMBOL) { in expr_eliminate_yn()
353 if (e->left.expr->left.sym == &symbol_no) { in expr_eliminate_yn()
354 free(e->left.expr); in expr_eliminate_yn()
355 tmp = e->right.expr; in expr_eliminate_yn()
356 *e = *(e->right.expr); in expr_eliminate_yn()
359 } else if (e->left.expr->left.sym == &symbol_yes) { in expr_eliminate_yn()
360 expr_free(e->left.expr); in expr_eliminate_yn()
361 expr_free(e->right.expr); in expr_eliminate_yn()
364 e->right.expr = NULL; in expr_eliminate_yn()
368 if (e->right.expr->type == E_SYMBOL) { in expr_eliminate_yn()
369 if (e->right.expr->left.sym == &symbol_no) { in expr_eliminate_yn()
370 free(e->right.expr); in expr_eliminate_yn()
371 tmp = e->left.expr; in expr_eliminate_yn()
372 *e = *(e->left.expr); in expr_eliminate_yn()
375 } else if (e->right.expr->left.sym == &symbol_yes) { in expr_eliminate_yn()
376 expr_free(e->left.expr); in expr_eliminate_yn()
377 expr_free(e->right.expr); in expr_eliminate_yn()
380 e->right.expr = NULL; in expr_eliminate_yn()
394 struct expr *expr_trans_bool(struct expr *e) in expr_trans_bool()
402 e->left.expr = expr_trans_bool(e->left.expr); in expr_trans_bool()
403 e->right.expr = expr_trans_bool(e->right.expr); in expr_trans_bool()
423 static struct expr *expr_join_or(struct expr *e1, struct expr *e2) in expr_join_or()
425 struct expr *tmp; in expr_join_or()
435 tmp = e1->left.expr; in expr_join_or()
442 if (e2->left.expr->type != E_SYMBOL) in expr_join_or()
444 sym2 = e2->left.expr->left.sym; in expr_join_or()
472 if ((e1->type == E_NOT && e1->left.expr->type == E_SYMBOL && e2->type == E_SYMBOL) || in expr_join_or()
473 (e2->type == E_NOT && e2->left.expr->type == E_SYMBOL && e1->type == E_SYMBOL)) in expr_join_or()
487 static struct expr *expr_join_and(struct expr *e1, struct expr *e2) in expr_join_and()
489 struct expr *tmp; in expr_join_and()
499 tmp = e1->left.expr; in expr_join_and()
506 if (e2->left.expr->type != E_SYMBOL) in expr_join_and()
508 sym2 = e2->left.expr->left.sym; in expr_join_and()
588 static void expr_eliminate_dups1(enum expr_type type, struct expr **ep1, struct expr **ep2) in expr_eliminate_dups1()
592 struct expr *tmp; in expr_eliminate_dups1()
597 expr_eliminate_dups1(type, &e1->left.expr, &e2); in expr_eliminate_dups1()
598 expr_eliminate_dups1(type, &e1->right.expr, &e2); in expr_eliminate_dups1()
602 expr_eliminate_dups1(type, &e1, &e2->left.expr); in expr_eliminate_dups1()
603 expr_eliminate_dups1(type, &e1, &e2->right.expr); in expr_eliminate_dups1()
656 struct expr *expr_eliminate_dups(struct expr *e) in expr_eliminate_dups()
686 struct expr *expr_transform(struct expr *e) in expr_transform()
688 struct expr *tmp; in expr_transform()
703 e->left.expr = expr_transform(e->left.expr); in expr_transform()
704 e->right.expr = expr_transform(e->right.expr); in expr_transform()
713 e->left.expr = expr_alloc_symbol(e->left.sym); in expr_transform()
747 e->left.expr = expr_alloc_symbol(e->left.sym); in expr_transform()
753 switch (e->left.expr->type) { in expr_transform()
756 tmp = e->left.expr->left.expr; in expr_transform()
757 free(e->left.expr); in expr_transform()
765 tmp = e->left.expr; in expr_transform()
773 tmp = e->left.expr; in expr_transform()
781 tmp = e->left.expr; in expr_transform()
788 tmp = e->left.expr; in expr_transform()
790 e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); in expr_transform()
792 tmp->right.expr = NULL; in expr_transform()
797 tmp = e->left.expr; in expr_transform()
799 e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); in expr_transform()
801 tmp->right.expr = NULL; in expr_transform()
805 if (e->left.expr->left.sym == &symbol_yes) { in expr_transform()
807 tmp = e->left.expr; in expr_transform()
814 if (e->left.expr->left.sym == &symbol_mod) { in expr_transform()
816 tmp = e->left.expr; in expr_transform()
823 if (e->left.expr->left.sym == &symbol_no) { in expr_transform()
825 tmp = e->left.expr; in expr_transform()
843 int expr_contains_symbol(struct expr *dep, struct symbol *sym) in expr_contains_symbol()
851 return expr_contains_symbol(dep->left.expr, sym) || in expr_contains_symbol()
852 expr_contains_symbol(dep->right.expr, sym); in expr_contains_symbol()
864 return expr_contains_symbol(dep->left.expr, sym); in expr_contains_symbol()
871 bool expr_depends_symbol(struct expr *dep, struct symbol *sym) in expr_depends_symbol()
878 return expr_depends_symbol(dep->left.expr, sym) || in expr_depends_symbol()
879 expr_depends_symbol(dep->right.expr, sym); in expr_depends_symbol()
914 struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym) in expr_trans_compare()
916 struct expr *e1, *e2; in expr_trans_compare()
926 e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); in expr_trans_compare()
927 e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); in expr_trans_compare()
936 e1 = expr_trans_compare(e->left.expr, E_EQUAL, sym); in expr_trans_compare()
937 e2 = expr_trans_compare(e->right.expr, E_EQUAL, sym); in expr_trans_compare()
946 return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym); in expr_trans_compare()
1026 tristate expr_calc_value(struct expr *e) in expr_calc_value()
1042 val1 = expr_calc_value(e->left.expr); in expr_calc_value()
1043 val2 = expr_calc_value(e->right.expr); 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()
1140 void expr_print(struct expr *e, in expr_print()
1160 expr_print(e->left.expr, fn, data, E_NOT); in expr_print()
1197 expr_print(e->left.expr, fn, data, E_OR); in expr_print()
1199 expr_print(e->right.expr, fn, data, E_OR); in expr_print()
1202 expr_print(e->left.expr, fn, data, E_AND); in expr_print()
1204 expr_print(e->right.expr, fn, data, E_AND); in expr_print()
1208 if (e->left.expr) { in expr_print()
1210 expr_print(e->left.expr, fn, data, E_LIST); in expr_print()
1237 void expr_fprint(struct expr *e, FILE *out) in expr_fprint()
1272 void expr_gstr_print(struct expr *e, struct gstr *gs) in expr_gstr_print()
1282 static void expr_print_revdep(struct expr *e, in expr_print_revdep()
1287 expr_print_revdep(e->left.expr, fn, data, pr_type, title); in expr_print_revdep()
1288 expr_print_revdep(e->right.expr, fn, data, pr_type, title); in expr_print_revdep()
1301 void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, in expr_gstr_print_revdep()