Lines Matching +full:left +full:- +full:right
1 // SPDX-License-Identifier: GPL-2.0
3 * Copyright (C) 2002 Roman Zippel <zippel@linux-m68k.org>
21 e->type = E_SYMBOL; in expr_alloc_symbol()
22 e->left.sym = sym; in expr_alloc_symbol()
29 e->type = type; in expr_alloc_one()
30 e->left.expr = ce; in expr_alloc_one()
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()
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()
75 switch (org->type) { 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()
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()
154 if (e1->type == type) { 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()
159 if (e2->type == type) { 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()
167 if (e1->type == E_SYMBOL && e2->type == E_SYMBOL && in __expr_eliminate_eq()
168 e1->left.sym == e2->left.sym && in __expr_eliminate_eq()
169 (e1->left.sym == &symbol_yes || e1->left.sym == &symbol_no)) in __expr_eliminate_eq()
196 * ep1: A && B -> ep1: y
197 * ep2: A && B && C -> ep2: C
199 * ep1: A || B -> ep1: n
200 * ep2: A || B || C -> ep2: C
202 * ep1: A && (B && FOO) -> ep1: FOO
203 * ep2: (BAR && B) && A -> ep2: BAR
205 * ep1: A && (B || C) -> ep1: y
206 * ep2: (C || B) && A -> ep2: y
212 * - 'e1', 'e2 || e3', and 'e4 || e5', against each other
213 * - e2 against e3
214 * - e4 against e5
225 switch (e1->type) { in expr_eliminate_eq()
228 __expr_eliminate_eq(e1->type, ep1, ep2); in expr_eliminate_eq()
232 if (e1->type != e2->type) switch (e2->type) { in expr_eliminate_eq()
235 __expr_eliminate_eq(e2->type, ep1, ep2); in expr_eliminate_eq()
263 if (e1->type != e2->type) in expr_eq()
265 switch (e1->type) { in expr_eq()
272 return e1->left.sym == e2->left.sym && e1->right.sym == e2->right.sym; in expr_eq()
274 return e1->left.sym == e2->left.sym; in expr_eq()
276 return expr_eq(e1->left.expr, e2->left.expr); in expr_eq()
283 res = (e1->type == E_SYMBOL && e2->type == E_SYMBOL && in expr_eq()
284 e1->left.sym == e2->left.sym); in expr_eq()
306 * Recursively performs the following simplifications in-place (as well as the
309 * expr && n -> n
310 * expr && y -> expr
311 * expr || n -> expr
312 * expr || y -> y
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()
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()
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()
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()
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()
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()
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()
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()
414 // FOO!=n -> FOO 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()
429 * e1 || e2 -> ?
438 if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT) in expr_join_or()
440 if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT) in expr_join_or()
442 if (e1->type == E_NOT) { in expr_join_or()
443 tmp = e1->left.expr; in expr_join_or()
444 if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL) in expr_join_or()
446 sym1 = tmp->left.sym; in expr_join_or()
448 sym1 = e1->left.sym; in expr_join_or()
449 if (e2->type == E_NOT) { 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()
454 sym2 = e2->left.sym; in expr_join_or()
457 if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE) in expr_join_or()
459 if (sym1->type == S_TRISTATE) { in expr_join_or()
460 if (e1->type == E_EQUAL && e2->type == E_EQUAL && in expr_join_or()
461 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || in expr_join_or()
462 (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) { in expr_join_or()
463 // (a='y') || (a='m') -> (a!='n') in expr_join_or()
466 if (e1->type == E_EQUAL && e2->type == E_EQUAL && in expr_join_or()
467 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || in expr_join_or()
468 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) { in expr_join_or()
469 // (a='y') || (a='n') -> (a!='m') in expr_join_or()
472 if (e1->type == E_EQUAL && e2->type == E_EQUAL && in expr_join_or()
473 ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || in expr_join_or()
474 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) { in expr_join_or()
475 // (a='m') || (a='n') -> (a!='y') in expr_join_or()
479 if (sym1->type == S_BOOLEAN && sym1 == sym2) { 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()
502 if (e1->type != E_EQUAL && e1->type != E_UNEQUAL && e1->type != E_SYMBOL && e1->type != E_NOT) in expr_join_and()
504 if (e2->type != E_EQUAL && e2->type != E_UNEQUAL && e2->type != E_SYMBOL && e2->type != E_NOT) in expr_join_and()
506 if (e1->type == E_NOT) { in expr_join_and()
507 tmp = e1->left.expr; in expr_join_and()
508 if (tmp->type != E_EQUAL && tmp->type != E_UNEQUAL && tmp->type != E_SYMBOL) in expr_join_and()
510 sym1 = tmp->left.sym; in expr_join_and()
512 sym1 = e1->left.sym; in expr_join_and()
513 if (e2->type == E_NOT) { 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()
518 sym2 = e2->left.sym; in expr_join_and()
521 if (sym1->type != S_BOOLEAN && sym1->type != S_TRISTATE) in expr_join_and()
524 if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_yes) || in expr_join_and()
525 (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_yes)) in expr_join_and()
526 // (a) && (a='y') -> (a='y') in expr_join_and()
529 if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_no) || in expr_join_and()
530 (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_no)) in expr_join_and()
531 // (a) && (a!='n') -> (a) in expr_join_and()
534 if ((e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_mod) || in expr_join_and()
535 (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_mod)) in expr_join_and()
536 // (a) && (a!='m') -> (a='y') in expr_join_and()
539 if (sym1->type == S_TRISTATE) { in expr_join_and()
540 if (e1->type == E_EQUAL && e2->type == E_UNEQUAL) { in expr_join_and()
541 // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' in expr_join_and()
542 sym2 = e1->right.sym; in expr_join_and()
543 if ((e2->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST)) in expr_join_and()
544 return sym2 != e2->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2) in expr_join_and()
547 if (e1->type == E_UNEQUAL && e2->type == E_EQUAL) { in expr_join_and()
548 // (a='b') && (a!='c') -> 'b'='c' ? 'n' : a='b' in expr_join_and()
549 sym2 = e2->right.sym; in expr_join_and()
550 if ((e1->right.sym->flags & SYMBOL_CONST) && (sym2->flags & SYMBOL_CONST)) in expr_join_and()
551 return sym2 != e1->right.sym ? expr_alloc_comp(E_EQUAL, sym1, sym2) in expr_join_and()
554 if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && in expr_join_and()
555 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_no) || in expr_join_and()
556 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_yes))) in expr_join_and()
557 // (a!='y') && (a!='n') -> (a='m') in expr_join_and()
560 if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && in expr_join_and()
561 ((e1->right.sym == &symbol_yes && e2->right.sym == &symbol_mod) || in expr_join_and()
562 (e1->right.sym == &symbol_mod && e2->right.sym == &symbol_yes))) in expr_join_and()
563 // (a!='y') && (a!='m') -> (a='n') in expr_join_and()
566 if (e1->type == E_UNEQUAL && e2->type == E_UNEQUAL && in expr_join_and()
567 ((e1->right.sym == &symbol_mod && e2->right.sym == &symbol_no) || in expr_join_and()
568 (e1->right.sym == &symbol_no && e2->right.sym == &symbol_mod))) in expr_join_and()
569 // (a!='m') && (a!='n') -> (a='m') in expr_join_and()
572 if ((e1->type == E_SYMBOL && e2->type == E_EQUAL && e2->right.sym == &symbol_mod) || in expr_join_and()
573 (e2->type == E_SYMBOL && e1->type == E_EQUAL && e1->right.sym == &symbol_mod) || in expr_join_and()
574 (e1->type == E_SYMBOL && e2->type == E_UNEQUAL && e2->right.sym == &symbol_yes) || in expr_join_and()
575 (e2->type == E_SYMBOL && e1->type == E_UNEQUAL && e1->right.sym == &symbol_yes)) in expr_join_and()
604 if (e1->type == type) { 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()
609 if (e2->type == type) { 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()
620 switch (e1->type) { in expr_eliminate_dups1()
622 expr_eliminate_dups1(e1->type, &e1, &e1); in expr_eliminate_dups1()
654 * Rewrites 'e' in-place to remove ("join") duplicate and other redundant
659 * A || B || A -> A || B
660 * A && B && A=y -> A=y && B
673 switch (e->type) { in expr_eliminate_dups()
675 expr_eliminate_dups1(e->type, &e, &e); in expr_eliminate_dups()
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()
763 // !!a -> a in expr_transform()
764 tmp = e->left.expr->left.expr; in expr_transform()
765 free(e->left.expr); in expr_transform()
772 // !a='x' -> a!='x' in expr_transform()
773 tmp = e->left.expr; in expr_transform()
776 e->type = e->type == E_EQUAL ? E_UNEQUAL : E_EQUAL; in expr_transform()
780 // !a<='x' -> a>'x' in expr_transform()
781 tmp = e->left.expr; in expr_transform()
784 e->type = e->type == E_LEQ ? E_GTH : E_LTH; in expr_transform()
788 // !a<'x' -> a>='x' in expr_transform()
789 tmp = e->left.expr; in expr_transform()
792 e->type = e->type == E_LTH ? E_GEQ : E_LEQ; in expr_transform()
795 // !(a || b) -> !a && !b 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()
799 tmp->type = E_NOT; in expr_transform()
800 tmp->right.expr = NULL; in expr_transform()
804 // !(a && b) -> !a || !b 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()
808 tmp->type = E_NOT; in expr_transform()
809 tmp->right.expr = NULL; in expr_transform()
813 if (e->left.expr->left.sym == &symbol_yes) { in expr_transform()
814 // !'y' -> 'n' in expr_transform()
815 tmp = e->left.expr; 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()
823 // !'m' -> 'm' in expr_transform()
824 tmp = e->left.expr; 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()
832 // !'n' -> 'y' in expr_transform()
833 tmp = e->left.expr; in expr_transform()
836 e->type = E_SYMBOL; in expr_transform()
837 e->left.sym = &symbol_yes; in expr_transform()
856 switch (dep->type) { 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()
862 return dep->left.sym == sym; in expr_contains_symbol()
869 return dep->left.sym == sym || in expr_contains_symbol()
870 dep->right.sym == sym; in expr_contains_symbol()
872 return expr_contains_symbol(dep->left.expr, sym); in expr_contains_symbol()
884 switch (dep->type) { 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()
889 return dep->left.sym == sym; in expr_depends_symbol()
891 if (dep->left.sym == sym) { in expr_depends_symbol()
892 if (dep->right.sym == &symbol_yes || dep->right.sym == &symbol_mod) in expr_depends_symbol()
897 if (dep->left.sym == sym) { in expr_depends_symbol()
898 if (dep->right.sym == &symbol_no) in expr_depends_symbol()
914 * A -> A!=n
915 * !A -> A=n
916 * A && B -> !(A=n || B=n)
917 * A || B -> !(A=n && B=n)
918 * A && (B || C) -> !(A=n || (B=n && C=n))
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()
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()
978 return expr_alloc_comp(type, e->left.sym, sym); in expr_trans_compare()
1009 val->s = !strcmp(str, "n") ? 0 : in expr_parse_string()
1011 !strcmp(str, "y") ? 2 : -1; in expr_parse_string()
1014 val->s = strtoll(str, &tail, 10); in expr_parse_string()
1018 val->u = strtoull(str, &tail, 16); in expr_parse_string()
1022 val->s = strtoll(str, &tail, 0); in expr_parse_string()
1026 return !errno && !*tail && tail > str && isxdigit(tail[-1]) in expr_parse_string()
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()
1081 res = (lval.u > rval.u) - (lval.u < rval.u); in expr_calc_value()
1083 res = (lval.s > rval.s) - (lval.s < rval.s); 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()
1132 return -1; in expr_compare_type()
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()
1248 if (gs->max_width) { in expr_print_gstr_helper()
1250 const char *last_cr = strrchr(gs->s, '\n'); in expr_print_gstr_helper()
1257 last_cr = gs->s; in expr_print_gstr_helper()
1259 last_line_length = strlen(gs->s) - (last_cr - gs->s); in expr_print_gstr_helper()
1261 if ((last_line_length + extra_length) > gs->max_width) in expr_print_gstr_helper()
1266 if (sym && sym->type != S_UNKNOWN) in expr_print_gstr_helper()
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()
1293 fn(data, NULL, " - "); in expr_print_revdep()