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;
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;