]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Remove a ton of dead code and document the one really insane case.
authorDale Weiler <killfieldengine@gmail.com>
Fri, 21 Jun 2013 23:40:51 +0000 (23:40 +0000)
committerDale Weiler <killfieldengine@gmail.com>
Fri, 21 Jun 2013 23:40:51 +0000 (23:40 +0000)
ast.c
ir.c
main.c

diff --git a/ast.c b/ast.c
index 5c42a304e0fa1008eb72b1180e705133783adbe5..a23aa75667710d23f7268ee565a9aa9a30c52150 100644 (file)
--- a/ast.c
+++ b/ast.c
@@ -2934,9 +2934,13 @@ bool ast_loop_codegen(ast_loop *self, ast_function *func, bool lvalue, ir_value
     {
         ir_block *ontrue, *onfalse;
         if      (bprecond)   ontrue = bprecond;
     {
         ir_block *ontrue, *onfalse;
         if      (bprecond)   ontrue = bprecond;
-        else if (bbody)      ontrue = bbody;
+        else                 ontrue = bbody; /* can never be null */
+
+        /* all of this is dead code 
         else if (bincrement) ontrue = bincrement;
         else                 ontrue = bpostcond;
         else if (bincrement) ontrue = bincrement;
         else                 ontrue = bpostcond;
+        */
+
         onfalse = bout;
         if (self->post_not) {
             tmpblock = ontrue;
         onfalse = bout;
         if (self->post_not) {
             tmpblock = ontrue;
diff --git a/ir.c b/ir.c
index 08cedff0cdb7fc714ee6846f7eba7489dc5f590f..09fa186a2f83b0300af949b3c1ed021cec682ff3 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -1800,14 +1800,33 @@ ir_value* ir_block_create_binop(ir_block *self, lex_ctx ctx,
             ot = TYPE_POINTER;
             break;
 #endif
             ot = TYPE_POINTER;
             break;
 #endif
+    /*
+     * after the following default case, the value of opcode can never
+     * be 1, 2, 3, 4, 5, 6, 7, 8, 9, 62, 63, 64, 65
+     */
         default:
             /* ranges: */
             /* boolean operations result in floats */
         default:
             /* ranges: */
             /* boolean operations result in floats */
+            
+            /*
+             * opcode >= 10 takes true branch opcode is at least 10
+             * opcode <= 23 takes false branch opcode is at least 24
+             */
             if (opcode >= INSTR_EQ_F && opcode <= INSTR_GT)
                 ot = TYPE_FLOAT;
             if (opcode >= INSTR_EQ_F && opcode <= INSTR_GT)
                 ot = TYPE_FLOAT;
+                
+            /* 
+             * At condition "opcode <= 23", the value of "opcode" must be 
+             * at least 24.
+             * At condition "opcode <= 23", the value of "opcode" cannot be
+             * equal to any of {1, 2, 3, 4, 5, 6, 7, 8, 9, 62, 63, 64, 65}.
+             * The condition "opcode <= 23" cannot be true.
+             * 
+             * Thus ot=2 (TYPE_FLOAT) can never be true
+             */
+#if 0
             else if (opcode >= INSTR_LE && opcode <= INSTR_GT)
                 ot = TYPE_FLOAT;
             else if (opcode >= INSTR_LE && opcode <= INSTR_GT)
                 ot = TYPE_FLOAT;
-#if 0
             else if (opcode >= INSTR_LE_I && opcode <= INSTR_EQ_FI)
                 ot = TYPE_FLOAT;
 #endif
             else if (opcode >= INSTR_LE_I && opcode <= INSTR_EQ_FI)
                 ot = TYPE_FLOAT;
 #endif
diff --git a/main.c b/main.c
index ab9520ade17bfbb42119d05c398aacca87e8bdf0..feb8aa3886ab128491f9e9af401beea9775e7ba2 100644 (file)
--- a/main.c
+++ b/main.c
@@ -697,9 +697,6 @@ int main(int argc, char **argv) {
         mem_d(line);
     }
 
         mem_d(line);
     }
 
-    if (retval)
-        goto cleanup;
-
     if (vec_size(items)) {
         if (!OPTS_OPTION_BOOL(OPTION_QUIET) &&
             !OPTS_OPTION_BOOL(OPTION_PP_ONLY))
     if (vec_size(items)) {
         if (!OPTS_OPTION_BOOL(OPTION_QUIET) &&
             !OPTS_OPTION_BOOL(OPTION_PP_ONLY))