]> git.rm.cloudns.org Git - xonotic/gmqcc.git/commitdiff
get rid of more duplicate code
authorWolfgang (Blub) Bumiller <blub@speed.at>
Tue, 14 Aug 2012 20:34:20 +0000 (22:34 +0200)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Tue, 14 Aug 2012 20:34:20 +0000 (22:34 +0200)
parser.c

index 6e72ba1df535e877e83d56f58ba52da94d5d08db..27e7f707abddd1ec39fd2fcb20f30c04b655ab4d 100644 (file)
--- a/parser.c
+++ b/parser.c
@@ -431,13 +431,9 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy)
             return true;
 
         case opid1('+'):
-            if (exprs[0]->expression.vtype != exprs[1]->expression.vtype) {
-                parseerror(parser, "invalid types used in expression: cannot add 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) {
+            if (exprs[0]->expression.vtype != exprs[1]->expression.vtype ||
+                (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",
                            type_name[exprs[0]->expression.vtype],
                            type_name[exprs[1]->expression.vtype]);
@@ -458,18 +454,14 @@ static bool parser_sy_pop(parser_t *parser, shunt *sy)
             };
             break;
         case opid1('-'):
-            if (exprs[0]->expression.vtype != exprs[1]->expression.vtype) {
+            if (exprs[0]->expression.vtype != exprs[1]->expression.vtype ||
+                (exprs[0]->expression.vtype != TYPE_VECTOR && exprs[0]->expression.vtype != TYPE_FLOAT) )
+            {
                 parseerror(parser, "invalid types used in expression: cannot subtract type %s from %s",
                            type_name[exprs[1]->expression.vtype],
                            type_name[exprs[0]->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 subtract type %s from %s",
-                           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]);