From: Dale Weiler Date: Sat, 15 Jun 2013 11:04:08 +0000 (+0000) Subject: I added it for a reason, because I was smart. I forgot about it because of life :( X-Git-Tag: v0.3.0~124 X-Git-Url: https://git.xonotic.org/?p=xonotic%2Fgmqcc.git;a=commitdiff_plain;h=5694c77d160eba94e11af74cc429efee0839a5c2 I added it for a reason, because I was smart. I forgot about it because of life :( --- diff --git a/ast.h b/ast.h index ebb29a7..3df25e8 100644 --- a/ast.h +++ b/ast.h @@ -231,6 +231,7 @@ void ast_type_adopt_impl(ast_expression *self, const ast_expression *other); void ast_type_to_string(ast_expression *e, char *buf, size_t bufsize); typedef enum ast_binary_ref_s { + AST_REF_NONE = 0, AST_REF_LEFT = 1 << 1, AST_REF_RIGHT = 1 << 2, AST_REF_ALL = (AST_REF_LEFT | AST_REF_RIGHT) diff --git a/parser.c b/parser.c index b53dba5..7ba3782 100644 --- a/parser.c +++ b/parser.c @@ -1051,6 +1051,19 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy) if(CanConstFold(exprs[0], exprs[1])) { out = (ast_expression*)parser_const_float(parser, (float)((qcint)(ConstF(0)) ^ ((qcint)(ConstF(1))))); } else { + ast_binary *expr = ast_binary_new( + ctx, + INSTR_SUB_F, + (ast_expression*)parser_const_float_neg1(parser), + (ast_expression*)ast_binary_new( + ctx, + INSTR_BITAND, + exprs[0], + exprs[1] + ) + ); + expr->refs = AST_REF_NONE; + out = (ast_expression*) ast_binary_new( ctx, @@ -1061,17 +1074,7 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy) exprs[0], exprs[1] ), - (ast_expression*)ast_binary_new( - ctx, - INSTR_SUB_F, - (ast_expression*)parser_const_float_neg1(parser), - (ast_expression*)ast_binary_new( - ctx, - INSTR_BITAND, - exprs[0], - exprs[1] - ) - ) + (ast_expression*)expr ); } break; @@ -1201,7 +1204,7 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy) } else { ast_binary *eq = ast_binary_new(ctx, INSTR_EQ_F, exprs[0], exprs[1]); - eq->refs = (ast_binary_ref)false; /* references nothing */ + eq->refs = AST_REF_NONE; /* if (lt) { */ out = (ast_expression*)ast_ternary_new(ctx,