mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-23 20:33:05 +00:00
for compile-time constants << and >> are now available
This commit is contained in:
parent
06101d48e4
commit
428453a132
2 changed files with 12 additions and 2 deletions
3
lexer.h
3
lexer.h
|
@ -250,6 +250,9 @@ static const oper_info fte_operators[] = {
|
||||||
{ "+", 2, opid1('+'), ASSOC_LEFT, 12, 0 },
|
{ "+", 2, opid1('+'), ASSOC_LEFT, 12, 0 },
|
||||||
{ "-", 2, opid1('-'), ASSOC_LEFT, 12, 0 },
|
{ "-", 2, opid1('-'), ASSOC_LEFT, 12, 0 },
|
||||||
|
|
||||||
|
{ "<<", 2, opid2('<','<'), ASSOC_LEFT, 11, 0 },
|
||||||
|
{ ">>", 2, opid2('>','>'), ASSOC_LEFT, 11, 0 },
|
||||||
|
|
||||||
{ "<", 2, opid1('<'), ASSOC_LEFT, 10, 0 },
|
{ "<", 2, opid1('<'), ASSOC_LEFT, 10, 0 },
|
||||||
{ ">", 2, opid1('>'), ASSOC_LEFT, 10, 0 },
|
{ ">", 2, opid1('>'), ASSOC_LEFT, 10, 0 },
|
||||||
{ "<=", 2, opid2('<','='), ASSOC_LEFT, 10, 0 },
|
{ "<=", 2, opid2('<','='), ASSOC_LEFT, 10, 0 },
|
||||||
|
|
11
parser.c
11
parser.c
|
@ -929,14 +929,21 @@ static bool parser_sy_apply_operator(parser_t *parser, shunt *sy)
|
||||||
exprs[0], exprs[1]);
|
exprs[0], exprs[1]);
|
||||||
break;
|
break;
|
||||||
case opid1('^'):
|
case opid1('^'):
|
||||||
parseerror(parser, "TODO: bitxor");
|
compile_error(ast_ctx(exprs[0]), "Not Yet Implemented: bit-xor via ^");
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case opid2('<','<'):
|
case opid2('<','<'):
|
||||||
case opid2('>','>'):
|
case opid2('>','>'):
|
||||||
|
if (CanConstFold(exprs[0], exprs[1]) && ! NotSameType(TYPE_FLOAT)) {
|
||||||
|
if (op->id == opid2('<','<'))
|
||||||
|
out = (ast_expression*)parser_const_float(parser, (double)((int)(ConstF(0)) << (int)(ConstF(1))));
|
||||||
|
else
|
||||||
|
out = (ast_expression*)parser_const_float(parser, (double)((int)(ConstF(0)) >> (int)(ConstF(1))));
|
||||||
|
break;
|
||||||
|
}
|
||||||
case opid3('<','<','='):
|
case opid3('<','<','='):
|
||||||
case opid3('>','>','='):
|
case opid3('>','>','='):
|
||||||
parseerror(parser, "TODO: shifts");
|
compile_error(ast_ctx(exprs[0]), "Not Yet Implemented: bit-shifts");
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
case opid2('|','|'):
|
case opid2('|','|'):
|
||||||
|
|
Loading…
Reference in a new issue