self->op = op;
self->left = left;
self->right = right;
+ self->right_first = false;
ast_propagate_effects(self, left);
ast_propagate_effects(self, right);
if ((OPTS_FLAG(SHORT_LOGIC) || OPTS_FLAG(PERL_LOGIC)) &&
(self->op == INSTR_AND || self->op == INSTR_OR))
{
+ /* NOTE: The short-logic path will ignore right_first */
+
/* short circuit evaluation */
ir_block *other, *merge;
ir_block *from_left, *from_right;
return true;
}
- cgen = self->left->codegen;
- if (!(*cgen)((ast_expression*)(self->left), func, false, &left))
- return false;
-
- cgen = self->right->codegen;
- if (!(*cgen)((ast_expression*)(self->right), func, false, &right))
- return false;
+ if (self->right_first) {
+ cgen = self->right->codegen;
+ if (!(*cgen)((ast_expression*)(self->right), func, false, &right))
+ return false;
+ cgen = self->left->codegen;
+ if (!(*cgen)((ast_expression*)(self->left), func, false, &left))
+ return false;
+ } else {
+ cgen = self->left->codegen;
+ if (!(*cgen)((ast_expression*)(self->left), func, false, &left))
+ return false;
+ cgen = self->right->codegen;
+ if (!(*cgen)((ast_expression*)(self->right), func, false, &right))
+ return false;
+ }
*out = ir_block_create_binop(func->curblock, ast_ctx(self), ast_function_label(func, "bin"),
self->op, left, right);