From 7249c2ec18722c7ea9bb32e2ba9682f3d209b467 Mon Sep 17 00:00:00 2001 From: Dale Weiler Date: Sun, 29 Sep 2013 22:08:09 -0400 Subject: [PATCH] Simplify parse stage for unary - operator. --- parser.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/parser.c b/parser.c index b5f6fe4..15bb921 100644 --- a/parser.c +++ b/parser.c @@ -465,15 +465,15 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy) out = exprs[0]; break; case opid2('-','P'): - if (!(out = fold_op(parser->fold, op, exprs))) { - if (exprs[0]->vtype != TYPE_FLOAT && - exprs[0]->vtype != TYPE_VECTOR) { - compile_error(ctx, "invalid types used in unary expression: cannot negate type %s", - type_name[exprs[0]->vtype]); - return false; - } - out = (ast_expression*)ast_unary_new(ctx, (VINSTR_NEG_F-TYPE_FLOAT) + exprs[0]->vtype, exprs[0]); + if ((out = fold_op(parser->fold, op, exprs))) + break; + if (exprs[0]->vtype != TYPE_FLOAT && + exprs[0]->vtype != TYPE_VECTOR) { + compile_error(ctx, "invalid types used in unary expression: cannot negate type %s", + type_name[exprs[0]->vtype]); + return false; } + out = (ast_expression*)ast_unary_new(ctx, (VINSTR_NEG_F-TYPE_FLOAT) + exprs[0]->vtype, exprs[0]); break; case opid2('!','P'): -- 2.39.2