Simplify parse stage for unary - operator.

This commit is contained in:
Dale Weiler 2013-09-29 22:08:09 -04:00
parent 353455e1ad
commit 7249c2ec18

View file

@ -465,15 +465,15 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)
out = exprs[0]; out = exprs[0];
break; break;
case opid2('-','P'): case opid2('-','P'):
if (!(out = fold_op(parser->fold, op, exprs))) { if ((out = fold_op(parser->fold, op, exprs)))
if (exprs[0]->vtype != TYPE_FLOAT && break;
exprs[0]->vtype != TYPE_VECTOR) { if (exprs[0]->vtype != TYPE_FLOAT &&
compile_error(ctx, "invalid types used in unary expression: cannot negate type %s", exprs[0]->vtype != TYPE_VECTOR) {
type_name[exprs[0]->vtype]); compile_error(ctx, "invalid types used in unary expression: cannot negate type %s",
return false; type_name[exprs[0]->vtype]);
} return false;
out = (ast_expression*)ast_unary_new(ctx, (VINSTR_NEG_F-TYPE_FLOAT) + exprs[0]->vtype, exprs[0]);
} }
out = (ast_expression*)ast_unary_new(ctx, (VINSTR_NEG_F-TYPE_FLOAT) + exprs[0]->vtype, exprs[0]);
break; break;
case opid2('!','P'): case opid2('!','P'):