From 2f67a6f109c884c0cb68b07c3d4669bbca9fee3f Mon Sep 17 00:00:00 2001 From: Mid <> Date: Thu, 2 Oct 2025 13:46:08 +0300 Subject: [PATCH] Fix dumbing bug --- src/x86/dumberdowner.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/x86/dumberdowner.c b/src/x86/dumberdowner.c index 071e623..c2579a5 100644 --- a/src/x86/dumberdowner.c +++ b/src/x86/dumberdowner.c @@ -109,6 +109,10 @@ static void mark_d(ScopeItem *si) { } } +/* + * RULE ONE OF DUMBING: NEVER xopify NOR varify MORE THAN ONCE IN A SINGLE CALL TO VISITOR!!! + * IF YOU DO THIS, stmtPrev WILL FUCK UP AND STATEMENTS WILL BE LOST + */ struct DumbenState { AST *targetTLC; int effective; @@ -129,14 +133,10 @@ static void dumben_visitor(AST **nptr, AST *stmt, AST *stmtPrev, AST *chu, AST * if(is_xop(e->exprBinOp.operands[0]) == XOP_NOT_XOP) { e->exprBinOp.operands[0] = xopify(tlc, chu, stmtPrev, s, e->exprBinOp.operands[0]); this->effective = 1; - } - - if(is_xop(e->exprBinOp.operands[1]) == XOP_NOT_XOP) { + } else if(is_xop(e->exprBinOp.operands[1]) == XOP_NOT_XOP) { e->exprBinOp.operands[1] = xopify(tlc, chu, stmtPrev, s, e->exprBinOp.operands[1]); this->effective = 1; - } - - if(is_xop(e->exprBinOp.operands[0]) == XOP_MEM && is_xop(e->exprBinOp.operands[1]) == XOP_MEM) { + } else if(is_xop(e->exprBinOp.operands[0]) == XOP_MEM && is_xop(e->exprBinOp.operands[1]) == XOP_MEM) { // Can't have two mems; put one in var e->exprBinOp.operands[1] = varify(tlc, chu, stmtPrev, s, e->exprBinOp.operands[1]); @@ -164,7 +164,7 @@ static void dumben_visitor(AST **nptr, AST *stmt, AST *stmtPrev, AST *chu, AST * ast_denoop(tlc, &s->stmtJump.condition); this->effective = 1; - + } else if(e->nodeKind == AST_EXPR_BINARY_OP && e->exprBinOp.operator == BINOP_LOGICAL_OR) { AST *cond0 = e->exprBinOp.operands[0];