mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-31 12:00:38 +00:00
Check types on + and - operations
This commit is contained in:
parent
5680c661a6
commit
9f151e82df
1 changed files with 12 additions and 0 deletions
12
parser.c
12
parser.c
|
@ -410,6 +410,12 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy)
|
|||
type_name[exprs[1]->expression.vtype]);
|
||||
return false;
|
||||
}
|
||||
if (exprs[0]->expression.vteyp != TYPE_VECTOR && exprs[0]->expression.vtype != TYPE_FLOAT) {
|
||||
parseerror(parser, "type error: %s - %s not defined",
|
||||
type_name[exprs[0]->expression.vtype],
|
||||
type_name[exprs[1]->expression.vtype]);
|
||||
return false;
|
||||
}
|
||||
switch (exprs[0]->expression.vtype) {
|
||||
case TYPE_FLOAT:
|
||||
out = (ast_expression*)ast_binary_new(ctx, INSTR_ADD_F, exprs[0], exprs[1]);
|
||||
|
@ -431,6 +437,12 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy)
|
|||
type_name[exprs[0]->expression.vtype]);
|
||||
return false;
|
||||
}
|
||||
if (exprs[0]->expression.vteyp != TYPE_VECTOR && exprs[0]->expression.vtype != TYPE_FLOAT) {
|
||||
parseerror(parser, "type error: %s - %s not defined",
|
||||
type_name[exprs[0]->expression.vtype],
|
||||
type_name[exprs[1]->expression.vtype]);
|
||||
return false;
|
||||
}
|
||||
switch (exprs[0]->expression.vtype) {
|
||||
case TYPE_FLOAT:
|
||||
out = (ast_expression*)ast_binary_new(ctx, INSTR_SUB_F, exprs[0], exprs[1]);
|
||||
|
|
Loading…
Reference in a new issue