• Home
  • Raw
  • Download

Lines Matching refs:e

15 static struct expr *expr_eliminate_yn(struct expr *e);
19 struct expr *e = xcalloc(1, sizeof(*e)); in expr_alloc_symbol() local
20 e->type = E_SYMBOL; in expr_alloc_symbol()
21 e->left.sym = sym; in expr_alloc_symbol()
22 return e; in expr_alloc_symbol()
27 struct expr *e = xcalloc(1, sizeof(*e)); in expr_alloc_one() local
28 e->type = type; in expr_alloc_one()
29 e->left.expr = ce; in expr_alloc_one()
30 return e; in expr_alloc_one()
35 struct expr *e = xcalloc(1, sizeof(*e)); in expr_alloc_two() local
36 e->type = type; in expr_alloc_two()
37 e->left.expr = e1; in expr_alloc_two()
38 e->right.expr = e2; in expr_alloc_two()
39 return e; in expr_alloc_two()
44 struct expr *e = xcalloc(1, sizeof(*e)); in expr_alloc_comp() local
45 e->type = type; in expr_alloc_comp()
46 e->left.sym = s1; in expr_alloc_comp()
47 e->right.sym = s2; in expr_alloc_comp()
48 return e; in expr_alloc_comp()
67 struct expr *e; in expr_copy() local
72 e = xmalloc(sizeof(*org)); in expr_copy()
73 memcpy(e, org, sizeof(*org)); in expr_copy()
76 e->left = org->left; in expr_copy()
79 e->left.expr = expr_copy(org->left.expr); in expr_copy()
87 e->left.sym = org->left.sym; in expr_copy()
88 e->right.sym = org->right.sym; 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()
97 fprintf(stderr, "can't copy type %d\n", e->type); in expr_copy()
98 free(e); in expr_copy()
99 e = NULL; in expr_copy()
103 return e; in expr_copy()
106 void expr_free(struct expr *e) in expr_free() argument
108 if (!e) in expr_free()
111 switch (e->type) { 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()
130 fprintf(stderr, "how to free type %d?\n", e->type); in expr_free()
133 free(e); in expr_free()
308 static struct expr *expr_eliminate_yn(struct expr *e) in expr_eliminate_yn() argument
312 if (e) switch (e->type) { 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()
320 e->type = E_SYMBOL; in expr_eliminate_yn()
321 e->left.sym = &symbol_no; in expr_eliminate_yn()
322 e->right.expr = NULL; in expr_eliminate_yn()
323 return e; 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()
329 return e; 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()
336 e->type = E_SYMBOL; in expr_eliminate_yn()
337 e->left.sym = &symbol_no; in expr_eliminate_yn()
338 e->right.expr = NULL; in expr_eliminate_yn()
339 return e; 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()
345 return e; 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()
358 return e; 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()
362 e->type = E_SYMBOL; in expr_eliminate_yn()
363 e->left.sym = &symbol_yes; in expr_eliminate_yn()
364 e->right.expr = NULL; in expr_eliminate_yn()
365 return e; 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()
374 return e; 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()
378 e->type = E_SYMBOL; in expr_eliminate_yn()
379 e->left.sym = &symbol_yes; in expr_eliminate_yn()
380 e->right.expr = NULL; in expr_eliminate_yn()
381 return e; in expr_eliminate_yn()
388 return e; in expr_eliminate_yn()
394 struct expr *expr_trans_bool(struct expr *e) in expr_trans_bool() argument
396 if (!e) in expr_trans_bool()
398 switch (e->type) { 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()
407 if (e->left.sym->type == S_TRISTATE) { in expr_trans_bool()
408 if (e->right.sym == &symbol_no) { in expr_trans_bool()
409 e->type = E_SYMBOL; in expr_trans_bool()
410 e->right.sym = NULL; in expr_trans_bool()
417 return e; in expr_trans_bool()
656 struct expr *expr_eliminate_dups(struct expr *e) in expr_eliminate_dups() argument
659 if (!e) in expr_eliminate_dups()
660 return e; in expr_eliminate_dups()
665 switch (e->type) { in expr_eliminate_dups()
667 expr_eliminate_dups1(e->type, &e, &e); in expr_eliminate_dups()
674 e = expr_eliminate_yn(e); in expr_eliminate_dups()
677 return e; in expr_eliminate_dups()
686 struct expr *expr_transform(struct expr *e) in expr_transform() argument
690 if (!e) in expr_transform()
692 switch (e->type) { 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()
707 switch (e->type) { in expr_transform()
709 if (e->left.sym->type != S_BOOLEAN) in expr_transform()
711 if (e->right.sym == &symbol_no) { in expr_transform()
712 e->type = E_NOT; in expr_transform()
713 e->left.expr = expr_alloc_symbol(e->left.sym); in expr_transform()
714 e->right.sym = NULL; in expr_transform()
717 if (e->right.sym == &symbol_mod) { in expr_transform()
718 printf("boolean symbol %s tested for 'm'? test forced to 'n'\n", e->left.sym->name); in expr_transform()
719 e->type = E_SYMBOL; in expr_transform()
720 e->left.sym = &symbol_no; in expr_transform()
721 e->right.sym = NULL; in expr_transform()
724 if (e->right.sym == &symbol_yes) { in expr_transform()
725 e->type = E_SYMBOL; in expr_transform()
726 e->right.sym = NULL; in expr_transform()
731 if (e->left.sym->type != S_BOOLEAN) in expr_transform()
733 if (e->right.sym == &symbol_no) { in expr_transform()
734 e->type = E_SYMBOL; in expr_transform()
735 e->right.sym = NULL; in expr_transform()
738 if (e->right.sym == &symbol_mod) { in expr_transform()
739 printf("boolean symbol %s tested for 'm'? test forced to 'y'\n", e->left.sym->name); in expr_transform()
740 e->type = E_SYMBOL; in expr_transform()
741 e->left.sym = &symbol_yes; in expr_transform()
742 e->right.sym = NULL; in expr_transform()
745 if (e->right.sym == &symbol_yes) { in expr_transform()
746 e->type = E_NOT; in expr_transform()
747 e->left.expr = expr_alloc_symbol(e->left.sym); in expr_transform()
748 e->right.sym = NULL; 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()
758 free(e); in expr_transform()
759 e = tmp; in expr_transform()
760 e = expr_transform(e); in expr_transform()
765 tmp = e->left.expr; in expr_transform()
766 free(e); in expr_transform()
767 e = tmp; in expr_transform()
768 e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL; 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_LEQ ? E_GTH : E_LTH; 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_LTH ? E_GEQ : E_LEQ; in expr_transform()
788 tmp = e->left.expr; in expr_transform()
789 e->type = E_AND; in expr_transform()
790 e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); in expr_transform()
793 e = expr_transform(e); in expr_transform()
797 tmp = e->left.expr; in expr_transform()
798 e->type = E_OR; in expr_transform()
799 e->right.expr = expr_alloc_one(E_NOT, tmp->right.expr); in expr_transform()
802 e = expr_transform(e); in expr_transform()
805 if (e->left.expr->left.sym == &symbol_yes) { in expr_transform()
807 tmp = e->left.expr; in expr_transform()
808 free(e); in expr_transform()
809 e = tmp; in expr_transform()
810 e->type = E_SYMBOL; in expr_transform()
811 e->left.sym = &symbol_no; in expr_transform()
814 if (e->left.expr->left.sym == &symbol_mod) { in expr_transform()
816 tmp = e->left.expr; in expr_transform()
817 free(e); in expr_transform()
818 e = tmp; in expr_transform()
819 e->type = E_SYMBOL; in expr_transform()
820 e->left.sym = &symbol_mod; in expr_transform()
823 if (e->left.expr->left.sym == &symbol_no) { in expr_transform()
825 tmp = e->left.expr; in expr_transform()
826 free(e); in expr_transform()
827 e = tmp; in expr_transform()
828 e->type = E_SYMBOL; in expr_transform()
829 e->left.sym = &symbol_yes; in expr_transform()
840 return e; in expr_transform()
914 struct expr *expr_trans_compare(struct expr *e, enum expr_type type, struct symbol *sym) in expr_trans_compare() argument
918 if (!e) { in expr_trans_compare()
919 e = expr_alloc_symbol(sym); in expr_trans_compare()
921 e = expr_alloc_one(E_NOT, e); in expr_trans_compare()
922 return e; in expr_trans_compare()
924 switch (e->type) { 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()
929 e = expr_alloc_two(E_AND, e1, e2); in expr_trans_compare()
931 e = expr_alloc_two(E_OR, e1, e2); in expr_trans_compare()
933 e = expr_alloc_one(E_NOT, e); in expr_trans_compare()
934 return e; 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()
939 e = expr_alloc_two(E_OR, e1, e2); in expr_trans_compare()
941 e = expr_alloc_two(E_AND, e1, e2); in expr_trans_compare()
943 e = expr_alloc_one(E_NOT, e); in expr_trans_compare()
944 return e; in expr_trans_compare()
946 return expr_trans_compare(e->left.expr, type == E_EQUAL ? E_UNEQUAL : E_EQUAL, sym); in expr_trans_compare()
955 return expr_copy(e); in expr_trans_compare()
959 return expr_alloc_one(E_NOT, expr_copy(e)); in expr_trans_compare()
962 return expr_alloc_one(E_NOT, expr_copy(e)); in expr_trans_compare()
966 return expr_copy(e); in expr_trans_compare()
970 return expr_alloc_comp(type, e->left.sym, sym); in expr_trans_compare()
1026 tristate expr_calc_value(struct expr *e) in expr_calc_value() argument
1034 if (!e) in expr_calc_value()
1037 switch (e->type) { in expr_calc_value()
1039 sym_calc_value(e->left.sym); in expr_calc_value()
1040 return e->left.sym->curr.tri; 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()
1060 printf("expr_calc_value: %d?\n", e->type); in expr_calc_value()
1064 sym_calc_value(e->left.sym); in expr_calc_value()
1065 sym_calc_value(e->right.sym); in expr_calc_value()
1066 str1 = sym_get_string_value(e->left.sym); in expr_calc_value()
1067 str2 = sym_get_string_value(e->right.sym); in expr_calc_value()
1069 if (e->left.sym->type != S_STRING || e->right.sym->type != S_STRING) { in expr_calc_value()
1070 k1 = expr_parse_string(str1, e->left.sym->type, &lval); in expr_calc_value()
1071 k2 = expr_parse_string(str2, e->right.sym->type, &rval); in expr_calc_value()
1077 if (e->type != E_EQUAL && e->type != E_UNEQUAL) { in expr_calc_value()
1087 switch(e->type) { in expr_calc_value()
1101 printf("expr_calc_value: relation %d?\n", e->type); in expr_calc_value()
1140 void expr_print(struct expr *e, in expr_print() argument
1144 if (!e) { in expr_print()
1149 if (expr_compare_type(prevtoken, e->type) > 0) in expr_print()
1151 switch (e->type) { in expr_print()
1153 if (e->left.sym->name) in expr_print()
1154 fn(data, e->left.sym, e->left.sym->name); in expr_print()
1160 expr_print(e->left.expr, fn, data, E_NOT); in expr_print()
1163 if (e->left.sym->name) in expr_print()
1164 fn(data, e->left.sym, e->left.sym->name); in expr_print()
1168 fn(data, e->right.sym, e->right.sym->name); in expr_print()
1172 if (e->left.sym->name) in expr_print()
1173 fn(data, e->left.sym, e->left.sym->name); in expr_print()
1176 fn(data, NULL, e->type == E_LEQ ? "<=" : "<"); in expr_print()
1177 fn(data, e->right.sym, e->right.sym->name); in expr_print()
1181 if (e->left.sym->name) in expr_print()
1182 fn(data, e->left.sym, e->left.sym->name); in expr_print()
1185 fn(data, NULL, e->type == E_GEQ ? ">=" : ">"); in expr_print()
1186 fn(data, e->right.sym, e->right.sym->name); in expr_print()
1189 if (e->left.sym->name) in expr_print()
1190 fn(data, e->left.sym, e->left.sym->name); in expr_print()
1194 fn(data, e->right.sym, e->right.sym->name); 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()
1207 fn(data, e->right.sym, e->right.sym->name); in expr_print()
1208 if (e->left.expr) { in expr_print()
1210 expr_print(e->left.expr, fn, data, E_LIST); in expr_print()
1215 fn(data, e->left.sym, e->left.sym->name); in expr_print()
1217 fn(data, e->right.sym, e->right.sym->name); in expr_print()
1223 sprintf(buf, "<unknown type %d>", e->type); in expr_print()
1228 if (expr_compare_type(prevtoken, e->type) > 0) in expr_print()
1237 void expr_fprint(struct expr *e, FILE *out) in expr_fprint() argument
1239 expr_print(e, expr_print_file_helper, out, E_NONE); in expr_fprint()
1272 void expr_gstr_print(struct expr *e, struct gstr *gs) in expr_gstr_print() argument
1274 expr_print(e, expr_print_gstr_helper, gs, E_NONE); in expr_gstr_print()
1282 static void expr_print_revdep(struct expr *e, in expr_print_revdep() argument
1286 if (e->type == E_OR) { 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()
1289 } else if (expr_calc_value(e) == pr_type) { in expr_print_revdep()
1296 expr_print(e, fn, data, E_NONE); in expr_print_revdep()
1301 void expr_gstr_print_revdep(struct expr *e, struct gstr *gs, in expr_gstr_print_revdep() argument
1304 expr_print_revdep(e, expr_print_gstr_helper, gs, pr_type, &title); in expr_gstr_print_revdep()