From: Dale Weiler Date: Sat, 28 Sep 2013 10:33:15 +0000 (-0400) Subject: It was much easier in the AST, really. X-Git-Tag: 0.3.5~64 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7c25af973cfd743d9e24384a8cbe084208fc5d97;p=xonotic%2Fgmqcc.git It was much easier in the AST, really. --- diff --git a/ast.c b/ast.c index 9f33e22..3fb27d3 100644 --- a/ast.c +++ b/ast.c @@ -518,6 +518,16 @@ ast_unary* ast_unary_new(lex_ctx_t ctx, int op, self->op = op; self->operand = expr; + if (ast_istype(expr, ast_unary)) { + ast_expression *prev = (ast_expression*)((ast_unary*)expr)->operand; + if (ast_istype(prev, ast_unary)) { + ast_expression_delete((ast_expression*)self); + mem_d(self); + ++opts_optimizationcount[OPTIM_PEEPHOLE]; + return (ast_unary*)prev; + } + } + ast_propagate_effects(self, expr); if (op >= INSTR_NOT_F && op <= INSTR_NOT_FNC) {