Lines Matching refs:e
16 static struct expr *expr_eliminate_yn(struct expr *e);
20 struct expr *e = xcalloc(1, sizeof(*e)); in expr_alloc_symbol() local
21 e->type = E_SYMBOL; in expr_alloc_symbol()
22 e->left.sym = sym; in expr_alloc_symbol()
23 return e; in expr_alloc_symbol()
28 struct expr *e = xcalloc(1, sizeof(*e)); in expr_alloc_one() local
29 e->type = type; in expr_alloc_one()
30 e->left.expr = ce; in expr_alloc_one()
31 return e; in expr_alloc_one()
36 struct expr *e = xcalloc(1, sizeof(*e)); in expr_alloc_two() local
37 e->type = type; in expr_alloc_two()
38 e->left.expr = e1; in expr_alloc_two()
39 e->right.expr = e2; in expr_alloc_two()
40 return e; in expr_alloc_two()
45 struct expr *e = xcalloc(1, sizeof(*e)); in expr_alloc_comp() local
46 e->type = type; in expr_alloc_comp()
47 e->left.sym = s1; in expr_alloc_comp()
48 e->right.sym = s2; in expr_alloc_comp()
49 return e; in expr_alloc_comp()
68 struct expr *e; in expr_copy() local
73 e = xmalloc(sizeof(*org)); in expr_copy()
74 memcpy(e, org, sizeof(*org)); in expr_copy()
77 e->left = org->left; in expr_copy()
80 e->left.expr = expr_copy(org->left.expr); in expr_copy()
88 e->left.sym = org->left.sym; in expr_copy()
89 e->right.sym = org->right.sym; 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()
98 fprintf(stderr, "can't copy type %d\n", e->type); in expr_copy()
99 free(e); in expr_copy()
100 e = NULL; in expr_copy()
104 return e; in expr_copy()
107 void expr_free(struct expr *e) in expr_free() argument
109 if (!e) in expr_free()
112 switch (e->type) { 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()
131 fprintf(stderr, "how to free type %d?\n", e->type); in expr_free()
134 free(e); in expr_free()
316 static struct expr *expr_eliminate_yn(struct expr *e) in expr_eliminate_yn() argument
320 if (e) switch (e->type) { 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()
328 e->type = E_SYMBOL; in expr_eliminate_yn()
329 e->left.sym = &symbol_no; in expr_eliminate_yn()
330 e->right.expr = NULL; in expr_eliminate_yn()
331 return e; 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()
337 return e; 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()
344 e->type = E_SYMBOL; in expr_eliminate_yn()
345 e->left.sym = &symbol_no; in expr_eliminate_yn()
346 e->right.expr = NULL; in expr_eliminate_yn()
347 return e; 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()
353 return e; 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()
366 return e; 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()
370 e->type = E_SYMBOL; in expr_eliminate_yn()
371 e->left.sym = &symbol_yes; in expr_eliminate_yn()
372 e->right.expr = NULL; in expr_eliminate_yn()
373 return e; 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()
382 return e; 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()
386 e->type = E_SYMBOL; in expr_eliminate_yn()
387 e->left.sym = &symbol_yes; in expr_eliminate_yn()
388 e->right.expr = NULL; in expr_eliminate_yn()
389 return e; in expr_eliminate_yn()
396 return e; in expr_eliminate_yn()
402 struct expr *expr_trans_bool(struct expr *e) in expr_trans_bool() argument
404 if (!e) in expr_trans_bool()
406 switch (e->type) { 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()
415 if (e->left.sym->type == S_TRISTATE) { in expr_trans_bool()
416 if (e->right.sym == &symbol_no) { in expr_trans_bool()
417 e->type = E_SYMBOL; in expr_trans_bool()
418 e->right.sym = NULL; in expr_trans_bool()
425 return e; in expr_trans_bool()
664 struct expr *expr_eliminate_dups(struct expr *e) in expr_eliminate_dups() argument
667 if (!e) in expr_eliminate_dups()
668 return e; in expr_eliminate_dups()
673 switch (e->type) { in expr_eliminate_dups()
675 expr_eliminate_dups1(e->type, &e, &e); in expr_eliminate_dups()
682 e = expr_eliminate_yn(e); in expr_eliminate_dups()
685 return e; in expr_eliminate_dups()
694 struct expr *expr_transform(struct expr *e) in expr_transform() argument
698 if (!e) in expr_transform()
700 switch (e->type) { 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()
715 switch (e->type) { in expr_transform()
717 if (e->left.sym->type != S_BOOLEAN) in expr_transform()
719 if (e->right.sym == &symbol_no) { in expr_transform()
720 e->type = E_NOT; in expr_transform()
721 e->left.expr = expr_alloc_symbol(e->left.sym); in expr_transform()
722 e->right.sym = NULL; in expr_transform()
725 if (e->right.sym == &symbol_mod) { in expr_transform()
726 printf("boolean symbol %s tested for 'm'? test forced to 'n'\n", e->left.sym->name); in expr_transform()
727 e->type = E_SYMBOL; in expr_transform()
728 e->left.sym = &symbol_no; in expr_transform()
729 e->right.sym = NULL; in expr_transform()
732 if (e->right.sym == &symbol_yes) { in expr_transform()
733 e->type = E_SYMBOL; in expr_transform()
734 e->right.sym = NULL; in expr_transform()
739 if (e->left.sym->type != S_BOOLEAN) in expr_transform()
741 if (e->right.sym == &symbol_no) { in expr_transform()
742 e->type = E_SYMBOL; in expr_transform()
743 e->right.sym = NULL; in expr_transform()
746 if (e->right.sym == &symbol_mod) { in expr_transform()
747 printf("boolean symbol %s tested for 'm'? test forced to 'y'\n", e->left.sym->name); in expr_transform()
748 e->type = E_SYMBOL; in expr_transform()
749 e->left.sym = &symbol_yes; in expr_transform()
750 e->right.sym = NULL; in expr_transform()
753 if (e->right.sym == &symbol_yes) { in expr_transform()
754 e->type = E_NOT; in expr_transform()
755 e->left.expr = expr_alloc_symbol(e->left.sym); in expr_transform()
756 e->right.sym = NULL; 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()
766 free(e); in expr_transform()
767 e = tmp; in expr_transform()
768 e = expr_transform(e); in expr_transform()
773 tmp = e->left.expr; in expr_transform()
774 free(e); in expr_transform()
775 e = tmp; in expr_transform()
776 e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL; in expr_transform()
781 tmp = e->left.expr; in expr_transform()
782 free(e); in expr_transform()
783 e = tmp; in expr_transform()
784 e->type = e->type == E_LEQ ? E_GTH : E_LTH; in expr_transform()
789 tmp = e->left.expr; in expr_transform()
790 free(e); in expr_transform()
791 e = tmp; in expr_transform()
792 e->type = e->type == E_LTH ? E_GEQ : E_LEQ; in expr_transform()
796 tmp = e->left.expr; in expr_transform()
797 e->type = E_AND; in expr_transform()
798 e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); in expr_transform()
801 e = expr_transform(e); in expr_transform()
805 tmp = e->left.expr; in expr_transform()
806 e->type = E_OR; in expr_transform()
807 e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); in expr_transform()
810 e = expr_transform(e); in expr_transform()
813 if (e->left.expr->left.sym == &symbol_yes) { in expr_transform()
815 tmp = e->left.expr; in expr_transform()
816 free(e); in expr_transform()
817 e = tmp; in expr_transform()
818 e->type = E_SYMBOL; in expr_transform()
819 e->left.sym = &symbol_no; in expr_transform()
822 if (e->left.expr->left.sym == &symbol_mod) { in expr_transform()
824 tmp = e->left.expr; in expr_transform()
825 free(e); in expr_transform()
826 e = tmp; in expr_transform()
827 e->type = E_SYMBOL; in expr_transform()
828 e->left.sym = &symbol_mod; in expr_transform()
831 if (e->left.expr->left.sym == &symbol_no) { in expr_transform()
833 tmp = e->left.expr; in expr_transform()
834 free(e); in expr_transform()
835 e = tmp; in expr_transform()
836 e->type = E_SYMBOL; in expr_transform()
837 e->left.sym = &symbol_yes; in expr_transform()
848 return e; in expr_transform()
922 struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym) in expr_trans_compare() argument
926 if (!e) { in expr_trans_compare()
927 e = expr_alloc_symbol(sym); in expr_trans_compare()
929 e = expr_alloc_one(E_NOT, e); in expr_trans_compare()
930 return e; in expr_trans_compare()
932 switch (e->type) { 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()
937 e = expr_alloc_two(E_AND, e1, e2); in expr_trans_compare()
939 e = expr_alloc_two(E_OR, e1, e2); in expr_trans_compare()
941 e = expr_alloc_one(E_NOT, e); in expr_trans_compare()
942 return e; 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()
947 e = expr_alloc_two(E_OR, e1, e2); in expr_trans_compare()
949 e = expr_alloc_two(E_AND, e1, e2); in expr_trans_compare()
951 e = expr_alloc_one(E_NOT, e); in expr_trans_compare()
952 return e; in expr_trans_compare()
954 return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym); in expr_trans_compare()
963 return expr_copy(e); in expr_trans_compare()
967 return expr_alloc_one(E_NOT, expr_copy(e)); in expr_trans_compare()
970 return expr_alloc_one(E_NOT, expr_copy(e)); in expr_trans_compare()
974 return expr_copy(e); in expr_trans_compare()
978 return expr_alloc_comp(type, e->left.sym, sym); in expr_trans_compare()
1030 tristate expr_calc_value(struct expr *e) in expr_calc_value() argument
1038 if (!e) in expr_calc_value()
1041 switch (e->type) { in expr_calc_value()
1043 sym_calc_value(e->left.sym); in expr_calc_value()
1044 return e->left.sym->curr.tri; 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()
1064 printf("expr_calc_value: %d?\n", e->type); in expr_calc_value()
1068 sym_calc_value(e->left.sym); in expr_calc_value()
1069 sym_calc_value(e->right.sym); in expr_calc_value()
1070 str1 = sym_get_string_value(e->left.sym); in expr_calc_value()
1071 str2 = sym_get_string_value(e->right.sym); in expr_calc_value()
1073 if (e->left.sym->type != S_STRING || e->right.sym->type != S_STRING) { in expr_calc_value()
1074 k1 = expr_parse_string(str1, e->left.sym->type, &lval); in expr_calc_value()
1075 k2 = expr_parse_string(str2, e->right.sym->type, &rval); in expr_calc_value()
1085 switch(e->type) { in expr_calc_value()
1099 printf("expr_calc_value: relation %d?\n", e->type); in expr_calc_value()
1138 void expr_print(struct expr *e, in expr_print() argument
1142 if (!e) { in expr_print()
1147 if (expr_compare_type(prevtoken, e->type) > 0) in expr_print()
1149 switch (e->type) { in expr_print()
1151 if (e->left.sym->name) in expr_print()
1152 fn(data, e->left.sym, e->left.sym->name); in expr_print()
1158 expr_print(e->left.expr, fn, data, E_NOT); in expr_print()
1161 if (e->left.sym->name) in expr_print()
1162 fn(data, e->left.sym, e->left.sym->name); in expr_print()
1166 fn(data, e->right.sym, e->right.sym->name); in expr_print()
1170 if (e->left.sym->name) in expr_print()
1171 fn(data, e->left.sym, e->left.sym->name); in expr_print()
1174 fn(data, NULL, e->type == E_LEQ ? "<=" : "<"); in expr_print()
1175 fn(data, e->right.sym, e->right.sym->name); in expr_print()
1179 if (e->left.sym->name) in expr_print()
1180 fn(data, e->left.sym, e->left.sym->name); in expr_print()
1183 fn(data, NULL, e->type == E_GEQ ? ">=" : ">"); in expr_print()
1184 fn(data, e->right.sym, e->right.sym->name); in expr_print()
1187 if (e->left.sym->name) in expr_print()
1188 fn(data, e->left.sym, e->left.sym->name); in expr_print()
1192 fn(data, e->right.sym, e->right.sym->name); 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()
1205 fn(data, e->right.sym, e->right.sym->name); in expr_print()
1206 if (e->left.expr) { in expr_print()
1208 expr_print(e->left.expr, fn, data, E_LIST); in expr_print()
1213 fn(data, e->left.sym, e->left.sym->name); in expr_print()
1215 fn(data, e->right.sym, e->right.sym->name); in expr_print()
1221 sprintf(buf, "<unknown type %d>", e->type); in expr_print()
1226 if (expr_compare_type(prevtoken, e->type) > 0) in expr_print()
1235 void expr_fprint(struct expr *e, FILE *out) in expr_fprint() argument
1237 expr_print(e, expr_print_file_helper, out, E_NONE); in expr_fprint()
1270 void expr_gstr_print(struct expr *e, struct gstr *gs) in expr_gstr_print() argument
1272 expr_print(e, expr_print_gstr_helper, gs, E_NONE); in expr_gstr_print()
1280 static void expr_print_revdep(struct expr *e, in expr_print_revdep() argument
1284 if (e->type == E_OR) { 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()
1287 } else if (expr_calc_value(e) == pr_type) { in expr_print_revdep()
1294 expr_print(e, fn, data, E_NONE); in expr_print_revdep()
1299 void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, in expr_gstr_print_revdep() argument
1302 expr_print_revdep(e, expr_print_gstr_helper, gs, pr_type, &title); in expr_gstr_print_revdep()