]> git.xonotic.org Git - xonotic/gmqcc.git/commitdiff
qcvm -printfuns; prog_section_function.nargs is now signed as fteqcc sets builtins...
authorWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 30 Nov 2012 19:20:13 +0000 (20:20 +0100)
committerWolfgang (Blub) Bumiller <blub@speed.at>
Fri, 30 Nov 2012 19:20:13 +0000 (20:20 +0100)
exec.c
gmqcc.h
ir.c

diff --git a/exec.c b/exec.c
index 5e8d8bd9bd323a271053edd17577b02291b5da3c..cd2ef6e46e27f1b74aa96ab6a85b15b19ca13315 100644 (file)
--- a/exec.c
+++ b/exec.c
@@ -477,7 +477,8 @@ static void prog_print_statement(qc_program *prog, prog_section_statement *st)
 static qcint prog_enterfunction(qc_program *prog, prog_section_function *func)
 {
     qc_exec_stack st;
 static qcint prog_enterfunction(qc_program *prog, prog_section_function *func)
 {
     qc_exec_stack st;
-    size_t p, parampos;
+    size_t  parampos;
+    int32_t p;
 
     /* back up locals */
     st.localsp  = vec_size(prog->localstack);
 
     /* back up locals */
     st.localsp  = vec_size(prog->localstack);
@@ -814,6 +815,7 @@ int main(int argc, char **argv)
     size_t      xflags = VMXF_DEFAULT;
     bool        opts_printfields = false;
     bool        opts_printdefs   = false;
     size_t      xflags = VMXF_DEFAULT;
     bool        opts_printfields = false;
     bool        opts_printdefs   = false;
+    bool        opts_printfuns   = false;
     bool        opts_disasm      = false;
     bool        opts_info  = false;
 
     bool        opts_disasm      = false;
     bool        opts_info  = false;
 
@@ -848,6 +850,11 @@ int main(int argc, char **argv)
             ++argv;
             opts_printdefs = true;
         }
             ++argv;
             opts_printdefs = true;
         }
+        else if (!strcmp(argv[1], "-printfuns")) {
+            --argc;
+            ++argv;
+            opts_printfuns = true;
+        }
         else if (!strcmp(argv[1], "-printfields")) {
             --argc;
             ++argv;
         else if (!strcmp(argv[1], "-printfields")) {
             --argc;
             ++argv;
@@ -926,6 +933,18 @@ int main(int argc, char **argv)
                    (unsigned int)prog->fields[i].offset);
         }
     }
                    (unsigned int)prog->fields[i].offset);
         }
     }
+    else if (opts_printfuns) {
+        for (i = 0; i < vec_size(prog->functions); ++i) {
+            int32_t a;
+            printf("Function: %-16s taking %i parameters:",
+                   prog_getstring(prog, prog->functions[i].name),
+                   (unsigned int)prog->functions[i].nargs);
+            for (a = 0; a < prog->functions[i].nargs; ++a) {
+                printf(" %i", prog->functions[i].argsize[a]);
+            }
+            printf("\n");
+        }
+    }
     else
     {
         if (fnmain > 0)
     else
     {
         if (fnmain > 0)
diff --git a/gmqcc.h b/gmqcc.h
index 0e4f4bd3b00ef0309bc88d058314326ab87ec0a1..cc265053d9155a6d13532bf3bafc9ef4532decc1 100644 (file)
--- a/gmqcc.h
+++ b/gmqcc.h
@@ -443,7 +443,7 @@ typedef struct {
     uint32_t  profile;    /* Always zero (engine uses this)       */
     uint32_t  name;       /* name of function in string table     */
     uint32_t  file;       /* file of the source file              */
     uint32_t  profile;    /* Always zero (engine uses this)       */
     uint32_t  name;       /* name of function in string table     */
     uint32_t  file;       /* file of the source file              */
-    uint32_t  nargs;      /* number of arguments                  */
+    int32_t   nargs;      /* number of arguments                  */
     uint8_t   argsize[8]; /* size of arguments (keep 8 always?)   */
 } prog_section_function;
 
     uint8_t   argsize[8]; /* size of arguments (keep 8 always?)   */
 } prog_section_function;
 
diff --git a/ir.c b/ir.c
index a203d170a69d07449226b77f6cc5c671011f7661..ffaa76289189207bbb23b5074faf4fb5a72ab08b 100644 (file)
--- a/ir.c
+++ b/ir.c
@@ -2841,7 +2841,7 @@ static bool gen_global_function(ir_builder *ir, ir_value *global)
         fun.nargs = 8;
 
     for (i = 0;i < 8; ++i) {
         fun.nargs = 8;
 
     for (i = 0;i < 8; ++i) {
-        if (i >= fun.nargs)
+        if ((int32_t)i >= fun.nargs)
             fun.argsize[i] = 0;
         else
             fun.argsize[i] = type_sizeof[irfun->params[i]];
             fun.argsize[i] = 0;
         else
             fun.argsize[i] = type_sizeof[irfun->params[i]];