From: Wolfgang (Blub) Bumiller Date: Fri, 30 Nov 2012 19:20:13 +0000 (+0100) Subject: qcvm -printfuns; prog_section_function.nargs is now signed as fteqcc sets builtins... X-Git-Tag: 0.1.9~162 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=e0a7f8a484868ce3c8d9898d5cfb7edc7956019b;p=xonotic%2Fgmqcc.git qcvm -printfuns; prog_section_function.nargs is now signed as fteqcc sets builtins with varargs to have -1 params --- diff --git a/exec.c b/exec.c index 5e8d8bd..cd2ef6e 100644 --- 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; - size_t p, parampos; + size_t parampos; + int32_t p; /* 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; + bool opts_printfuns = false; bool opts_disasm = false; bool opts_info = false; @@ -848,6 +850,11 @@ int main(int argc, char **argv) ++argv; opts_printdefs = true; } + else if (!strcmp(argv[1], "-printfuns")) { + --argc; + ++argv; + opts_printfuns = true; + } else if (!strcmp(argv[1], "-printfields")) { --argc; ++argv; @@ -926,6 +933,18 @@ int main(int argc, char **argv) (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) diff --git a/gmqcc.h b/gmqcc.h index 0e4f4bd..cc26505 100644 --- 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 nargs; /* number of arguments */ + int32_t nargs; /* number of arguments */ uint8_t argsize[8]; /* size of arguments (keep 8 always?) */ } prog_section_function; diff --git a/ir.c b/ir.c index a203d17..ffaa762 100644 --- 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) { - if (i >= fun.nargs) + if ((int32_t)i >= fun.nargs) fun.argsize[i] = 0; else fun.argsize[i] = type_sizeof[irfun->params[i]];