mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 22:22:17 +00:00
NOT for entity, function and string - we're not constant-folding it for functions and entities right now
This commit is contained in:
parent
31a8cd80c8
commit
54dcbc22bf
1 changed files with 14 additions and 0 deletions
14
parser.c
14
parser.c
|
@ -481,6 +481,7 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy)
|
|||
(CanConstFold1(A) && CanConstFold1(B))
|
||||
#define ConstV(i) (asvalue[(i)]->constval.vvec)
|
||||
#define ConstF(i) (asvalue[(i)]->constval.vfloat)
|
||||
#define ConstS(i) (asvalue[(i)]->constval.vstring)
|
||||
switch (op->id)
|
||||
{
|
||||
default:
|
||||
|
@ -564,6 +565,19 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy)
|
|||
else
|
||||
out = (ast_expression*)ast_unary_new(ctx, INSTR_NOT_V, exprs[0]);
|
||||
break;
|
||||
case TYPE_STRING:
|
||||
if (CanConstFold1(exprs[0]))
|
||||
out = (ast_expression*)parser_const_float(parser, !ConstS(0) || !*ConstS(0));
|
||||
else
|
||||
out = (ast_expression*)ast_unary_new(ctx, INSTR_NOT_S, exprs[0]);
|
||||
break;
|
||||
/* we don't constant-fold NOT for these types */
|
||||
case TYPE_ENTITY:
|
||||
out = (ast_expression*)ast_unary_new(ctx, INSTR_NOT_ENT, exprs[0]);
|
||||
break;
|
||||
case TYPE_FUNCTION:
|
||||
out = (ast_expression*)ast_unary_new(ctx, INSTR_NOT_FNC, exprs[0]);
|
||||
break;
|
||||
default:
|
||||
parseerror(parser, "invalid types used in expression: cannot logically negate type %s",
|
||||
type_name[exprs[0]->expression.vtype]);
|
||||
|
|
Loading…
Reference in a new issue