61
62 extern int __expr_stmt_count;
63
64 struct expression_list *big_condition_stack;
65
66 static void split_conditions(struct expression *expr);
67
68 static int is_logical_and(struct expression *expr)
69 {
70 if (expr->op == SPECIAL_LOGICAL_AND)
71 return 1;
72 return 0;
73 }
74
75 static int handle_zero_comparisons(struct expression *expr)
76 {
77 struct expression *tmp = NULL;
78 struct expression *zero;
79
80 // if left is zero or right is zero
81 if (is_zero(expr->left)) {
82 zero = strip_expr(expr->left);
83 if (zero->type != EXPR_VALUE)
84 __split_expr(expr->left);
85 tmp = expr->right;
86 } else if (is_zero(expr->right)) {
87 zero = strip_expr(expr->left);
88 if (zero->type != EXPR_VALUE)
89 __split_expr(expr->right);
90 tmp = expr->left;
91 } else {
92 return 0;
93 }
94
95 // "if (foo != 0)" is the same as "if (foo)"
96 if (expr->op == SPECIAL_NOTEQUAL) {
97 split_conditions(tmp);
98 return 1;
99 }
100
101 // "if (foo == 0)" is the same as "if (!foo)"
102 if (expr->op == SPECIAL_EQUAL) {
103 split_conditions(tmp);
104 __negate_cond_stacks();
105 return 1;
106 }
|
61
62 extern int __expr_stmt_count;
63
64 struct expression_list *big_condition_stack;
65
66 static void split_conditions(struct expression *expr);
67
68 static int is_logical_and(struct expression *expr)
69 {
70 if (expr->op == SPECIAL_LOGICAL_AND)
71 return 1;
72 return 0;
73 }
74
75 static int handle_zero_comparisons(struct expression *expr)
76 {
77 struct expression *tmp = NULL;
78 struct expression *zero;
79
80 // if left is zero or right is zero
81 if (expr_is_zero(expr->left)) {
82 zero = strip_expr(expr->left);
83 if (zero->type != EXPR_VALUE)
84 __split_expr(expr->left);
85 tmp = expr->right;
86 } else if (expr_is_zero(expr->right)) {
87 zero = strip_expr(expr->left);
88 if (zero->type != EXPR_VALUE)
89 __split_expr(expr->right);
90 tmp = expr->left;
91 } else {
92 return 0;
93 }
94
95 // "if (foo != 0)" is the same as "if (foo)"
96 if (expr->op == SPECIAL_NOTEQUAL) {
97 split_conditions(tmp);
98 return 1;
99 }
100
101 // "if (foo == 0)" is the same as "if (!foo)"
102 if (expr->op == SPECIAL_EQUAL) {
103 split_conditions(tmp);
104 __negate_cond_stacks();
105 return 1;
106 }
|