]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
-= operator
authorWolfgang (Blub) Bumiller <blub@speed.at>
Tue, 14 Aug 2012 15:44:14 +0000 (17:44 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Tue, 14 Aug 2012 15:44:14 +0000 (17:44 +0200)
parser.c

index e83edb75fd5bbda84edb32b606e6e0778700317d..de6248571592deca59c10d5fdbbb1c027e9c3209 100644 (file)
--- a/parser.c
+++ b/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;