mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 14:12:36 +00:00
I'm in a state of confusion as to why constant folding was never done on comparisions, now it is ;)
This commit is contained in:
parent
d6ca5673dc
commit
2c975fe48f
1 changed files with 6 additions and 2 deletions
8
parser.c
8
parser.c
|
@ -1326,7 +1326,9 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)
|
||||||
type_name[exprs[1]->vtype]);
|
type_name[exprs[1]->vtype]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out = (ast_expression*)ast_binary_new(ctx, type_ne_instr[exprs[0]->vtype], exprs[0], exprs[1]);
|
out = CanConstFold(exprs[0], exprs[1])
|
||||||
|
? (ast_expression*)parser_const_float(parser, ConstF(0) != ConstF(1))
|
||||||
|
: (ast_expression*)ast_binary_new(ctx, type_ne_instr[exprs[0]->vtype], exprs[0], exprs[1]);
|
||||||
break;
|
break;
|
||||||
case opid2('=', '='):
|
case opid2('=', '='):
|
||||||
if (exprs[0]->vtype != exprs[1]->vtype) {
|
if (exprs[0]->vtype != exprs[1]->vtype) {
|
||||||
|
@ -1335,7 +1337,9 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)
|
||||||
type_name[exprs[1]->vtype]);
|
type_name[exprs[1]->vtype]);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
out = (ast_expression*)ast_binary_new(ctx, type_eq_instr[exprs[0]->vtype], exprs[0], exprs[1]);
|
out = CanConstFold(exprs[0], exprs[1])
|
||||||
|
? (ast_expression*)parser_const_float(parser, ConstF(0) == ConstF(1))
|
||||||
|
: (ast_expression*)ast_binary_new(ctx, type_eq_instr[exprs[0]->vtype], exprs[0], exprs[1]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case opid1('='):
|
case opid1('='):
|
||||||
|
|
Loading…
Reference in a new issue