From: Wolfgang (Blub) Bumiller Date: Thu, 16 Aug 2012 14:24:47 +0000 (+0200) Subject: NOT for entity, function and string - we're not constant-folding it for functions... X-Git-Tag: 0.1-rc1~245 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=54dcbc22bf4388ce13e1463cf949ed640e4d35e5;p=xonotic%2Fgmqcc.git NOT for entity, function and string - we're not constant-folding it for functions and entities right now --- diff --git a/parser.c b/parser.c index 121b39f..4105ce7 100644 --- a/parser.c +++ b/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]);