mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-04-16 06:52:18 +00:00
Prefix ++,--
This commit is contained in:
parent
9a43eb6370
commit
38f5090778
1 changed files with 23 additions and 1 deletions
24
parser.c
24
parser.c
|
@ -413,7 +413,7 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy)
|
|||
ast_expression *exprs[3];
|
||||
ast_block *blocks[3];
|
||||
ast_value *asvalue[3];
|
||||
size_t i, assignop;
|
||||
size_t i, assignop, addop;
|
||||
qcint generated_op = 0;
|
||||
|
||||
char ty1[1024];
|
||||
|
@ -878,6 +878,28 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy)
|
|||
}
|
||||
out = (ast_expression*)ast_store_new(ctx, assignop, exprs[0], exprs[1]);
|
||||
break;
|
||||
case opid3('+','+','P'):
|
||||
case opid3('-','-','P'):
|
||||
/* prefix ++ */
|
||||
if (exprs[0]->expression.vtype != TYPE_FLOAT) {
|
||||
ast_type_to_string(exprs[0], ty1, sizeof(ty1));
|
||||
parseerror(parser, "invalid type for prefix increment: %s", ty1);
|
||||
return false;
|
||||
}
|
||||
if (op->id == opid3('+','+','P'))
|
||||
addop = INSTR_ADD_F;
|
||||
else
|
||||
addop = INSTR_SUB_F;
|
||||
if (ast_istype(exprs[0], ast_entfield)) {
|
||||
out = (ast_expression*)ast_binstore_new(ctx, INSTR_STOREP_F, addop,
|
||||
exprs[0],
|
||||
(ast_expression*)parser_const_float(parser, 1));
|
||||
} else {
|
||||
out = (ast_expression*)ast_binstore_new(ctx, INSTR_STORE_F, addop,
|
||||
exprs[0],
|
||||
(ast_expression*)parser_const_float(parser, 1));
|
||||
}
|
||||
break;
|
||||
case opid2('+','='):
|
||||
case opid2('-','='):
|
||||
if (exprs[0]->expression.vtype != exprs[1]->expression.vtype ||
|
||||
|
|
Loading…
Reference in a new issue