mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-02-17 09:02:25 +00:00
-= operator
This commit is contained in:
parent
3ef6da8e5b
commit
8dd7943768
1 changed files with 10 additions and 5 deletions
15
parser.c
15
parser.c
|
@ -612,14 +612,15 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy)
|
|||
out = (ast_expression*)ast_store_new(ctx, assignop, exprs[0], exprs[1]);
|
||||
break;
|
||||
case opid2('+','='):
|
||||
case opid2('-','='):
|
||||
if (exprs[0]->expression.vtype != exprs[1]->expression.vtype) {
|
||||
parseerror(parser, "invalid types used in expression: cannot add type %s and %s",
|
||||
parseerror(parser, "invalid types used in expression: cannot add or subtract type %s and %s",
|
||||
type_name[exprs[0]->expression.vtype],
|
||||
type_name[exprs[1]->expression.vtype]);
|
||||
return false;
|
||||
}
|
||||
if (exprs[0]->expression.vtype != TYPE_VECTOR && exprs[0]->expression.vtype != TYPE_FLOAT) {
|
||||
parseerror(parser, "invalid types used in expression: cannot add type %s and %s",
|
||||
parseerror(parser, "invalid types used in expression: cannot add or subtract type %s and %s",
|
||||
type_name[exprs[0]->expression.vtype],
|
||||
type_name[exprs[1]->expression.vtype]);
|
||||
return false;
|
||||
|
@ -630,13 +631,17 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy)
|
|||
assignop = type_store_instr[exprs[0]->expression.vtype];
|
||||
switch (exprs[0]->expression.vtype) {
|
||||
case TYPE_FLOAT:
|
||||
out = (ast_expression*)ast_binstore_new(ctx, assignop, INSTR_ADD_F, exprs[0], exprs[1]);
|
||||
out = (ast_expression*)ast_binstore_new(ctx, assignop,
|
||||
(op->id == opid2('+','=') ? INSTR_ADD_F : INSTR_SUB_F),
|
||||
exprs[0], exprs[1]);
|
||||
break;
|
||||
case TYPE_VECTOR:
|
||||
out = (ast_expression*)ast_binstore_new(ctx, assignop, INSTR_ADD_V, exprs[0], exprs[1]);
|
||||
out = (ast_expression*)ast_binstore_new(ctx, assignop,
|
||||
(op->id == opid2('+','=') ? INSTR_ADD_V : INSTR_SUB_V),
|
||||
exprs[0], exprs[1]);
|
||||
break;
|
||||
default:
|
||||
parseerror(parser, "invalid types used in expression: cannot add type %s and %s",
|
||||
parseerror(parser, "invalid types used in expression: cannot add or subtract type %s and %s",
|
||||
type_name[exprs[0]->expression.vtype],
|
||||
type_name[exprs[1]->expression.vtype]);
|
||||
return false;
|
||||
|
|
Loading…
Reference in a new issue