mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-03-01 06:21:04 +00:00
unary NOT operator for float and vector
This commit is contained in:
parent
1a3a0014c5
commit
31a8cd80c8
1 changed files with 22 additions and 0 deletions
22
parser.c
22
parser.c
|
@ -549,6 +549,28 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy)
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case opid2('!','P'):
|
||||||
|
switch (exprs[0]->expression.vtype) {
|
||||||
|
case TYPE_FLOAT:
|
||||||
|
if (CanConstFold1(exprs[0]))
|
||||||
|
out = (ast_expression*)parser_const_float(parser, !ConstF(0));
|
||||||
|
else
|
||||||
|
out = (ast_expression*)ast_unary_new(ctx, INSTR_NOT_F, exprs[0]);
|
||||||
|
break;
|
||||||
|
case TYPE_VECTOR:
|
||||||
|
if (CanConstFold1(exprs[0]))
|
||||||
|
out = (ast_expression*)parser_const_float(parser,
|
||||||
|
(!ConstV(0).x && !ConstV(0).y && !ConstV(0).z));
|
||||||
|
else
|
||||||
|
out = (ast_expression*)ast_unary_new(ctx, INSTR_NOT_V, exprs[0]);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
parseerror(parser, "invalid types used in expression: cannot logically negate type %s",
|
||||||
|
type_name[exprs[0]->expression.vtype]);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
case opid1('+'):
|
case opid1('+'):
|
||||||
if (exprs[0]->expression.vtype != exprs[1]->expression.vtype ||
|
if (exprs[0]->expression.vtype != exprs[1]->expression.vtype ||
|
||||||
(exprs[0]->expression.vtype != TYPE_VECTOR && exprs[0]->expression.vtype != TYPE_FLOAT) )
|
(exprs[0]->expression.vtype != TYPE_VECTOR && exprs[0]->expression.vtype != TYPE_FLOAT) )
|
||||||
|
|
Loading…
Reference in a new issue