]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
Don't generate AINSTR_END anymore, use INSTR_DONE
authorWolfgang (Blub) Bumiller <blub@speed.at>
Tue, 18 Dec 2012 10:46:26 +0000 (11:46 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Tue, 18 Dec 2012 10:46:26 +0000 (11:46 +0100)
code.c
exec.c
ir.c

diff --git a/code.c b/code.c
index ca6c3ad655db3b3d8be74e78c52d8bd34c2d181e..964797f8793e57191122f905a6c994c484d18f4c 100644 (file)
--- a/code.c
+++ b/code.c
@@ -213,7 +213,7 @@ bool code_write(const char *filename, const char *lnofile) {
         if (code_functions[it].entry >= 0) {
             util_debug("GEN", "    CODE:\n");
             for (;;) {
         if (code_functions[it].entry >= 0) {
             util_debug("GEN", "    CODE:\n");
             for (;;) {
-                if (code_statements[j].opcode != AINSTR_END)
+                if (code_statements[j].opcode != INSTR_DONE)
                     util_debug("GEN", "        %-12s {% 5i,% 5i,% 5i}\n",
                         asm_instr[code_statements[j].opcode].m,
                         code_statements[j].o1.s1,
                     util_debug("GEN", "        %-12s {% 5i,% 5i,% 5i}\n",
                         asm_instr[code_statements[j].opcode].m,
                         code_statements[j].o1.s1,
diff --git a/exec.c b/exec.c
index 2ddaa3af1793d5365c433e7220a5f0fcb5a406c3..6d66ef2bfe4626dff7a02f131b8f20c6b3f7f6f0 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -986,7 +986,7 @@ void prog_disasm_function(qc_program *prog, size_t id)
         printf("FUNCTION \"%s\"\n", prog_getstring(prog, fdef->name));
 
     st = prog->code + fdef->entry;
         printf("FUNCTION \"%s\"\n", prog_getstring(prog, fdef->name));
 
     st = prog->code + fdef->entry;
-    while (st->opcode != AINSTR_END) {
+    while (st->opcode != INSTR_DONE) {
         prog_print_statement(prog, st);
         ++st;
     }
         prog_print_statement(prog, st);
         ++st;
     }
diff --git a/ir.c b/ir.c
index 2cffb9d6f8238cd1971ce90142db5c4b5e61f62e..9f6abb2ef18cc5303ec111386a022f00708163c3 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -2929,8 +2929,8 @@ static bool gen_function_code(ir_function *self)
         return false;
     }
 
         return false;
     }
 
-    /* otherwise code_write crashes since it debug-prints functions until AINSTR_END */
-    stmt.opcode = AINSTR_END;
+    /* code_write and qcvm -disasm need to know that the function ends here */
+    stmt.opcode = INSTR_DONE;
     stmt.o1.u1 = 0;
     stmt.o2.u1 = 0;
     stmt.o3.u1 = 0;
     stmt.o1.u1 = 0;
     stmt.o2.u1 = 0;
     stmt.o3.u1 = 0;
@@ -3397,15 +3397,15 @@ bool ir_builder_generate(ir_builder *self, const char *filename)
         return false;
     }
 
         return false;
     }
 
-    /* DP errors if the last instruction is not an INSTR_DONE
-     * and for debugging purposes we add an additional AINSTR_END
-     * to the end of functions, so here it goes:
-     */
-    stmt.opcode = INSTR_DONE;
-    stmt.o1.u1 = 0;
-    stmt.o2.u1 = 0;
-    stmt.o3.u1 = 0;
-    code_push_statement(&stmt, vec_last(code_linenums));
+    /* DP errors if the last instruction is not an INSTR_DONE. */
+    if (vec_last(code_statements).opcode != INSTR_DONE)
+    {
+        stmt.opcode = INSTR_DONE;
+        stmt.o1.u1 = 0;
+        stmt.o2.u1 = 0;
+        stmt.o3.u1 = 0;
+        code_push_statement(&stmt, vec_last(code_linenums));
+    }
 
     if (opts.pp_only)
         return true;
 
     if (opts.pp_only)
         return true;