mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-12-18 08:22:13 +00:00
qcvm -printfuns; prog_section_function.nargs is now signed as fteqcc sets builtins with varargs to have -1 params
This commit is contained in:
parent
a9a41a786e
commit
e0a7f8a484
3 changed files with 22 additions and 3 deletions
21
exec.c
21
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)
|
static qcint prog_enterfunction(qc_program *prog, prog_section_function *func)
|
||||||
{
|
{
|
||||||
qc_exec_stack st;
|
qc_exec_stack st;
|
||||||
size_t p, parampos;
|
size_t parampos;
|
||||||
|
int32_t p;
|
||||||
|
|
||||||
/* back up locals */
|
/* back up locals */
|
||||||
st.localsp = vec_size(prog->localstack);
|
st.localsp = vec_size(prog->localstack);
|
||||||
|
@ -814,6 +815,7 @@ int main(int argc, char **argv)
|
||||||
size_t xflags = VMXF_DEFAULT;
|
size_t xflags = VMXF_DEFAULT;
|
||||||
bool opts_printfields = false;
|
bool opts_printfields = false;
|
||||||
bool opts_printdefs = false;
|
bool opts_printdefs = false;
|
||||||
|
bool opts_printfuns = false;
|
||||||
bool opts_disasm = false;
|
bool opts_disasm = false;
|
||||||
bool opts_info = false;
|
bool opts_info = false;
|
||||||
|
|
||||||
|
@ -848,6 +850,11 @@ int main(int argc, char **argv)
|
||||||
++argv;
|
++argv;
|
||||||
opts_printdefs = true;
|
opts_printdefs = true;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(argv[1], "-printfuns")) {
|
||||||
|
--argc;
|
||||||
|
++argv;
|
||||||
|
opts_printfuns = true;
|
||||||
|
}
|
||||||
else if (!strcmp(argv[1], "-printfields")) {
|
else if (!strcmp(argv[1], "-printfields")) {
|
||||||
--argc;
|
--argc;
|
||||||
++argv;
|
++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
|
else
|
||||||
{
|
{
|
||||||
if (fnmain > 0)
|
if (fnmain > 0)
|
||||||
|
|
2
gmqcc.h
2
gmqcc.h
|
@ -443,7 +443,7 @@ typedef struct {
|
||||||
uint32_t profile; /* Always zero (engine uses this) */
|
uint32_t profile; /* Always zero (engine uses this) */
|
||||||
uint32_t name; /* name of function in string table */
|
uint32_t name; /* name of function in string table */
|
||||||
uint32_t file; /* file of the source file */
|
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?) */
|
uint8_t argsize[8]; /* size of arguments (keep 8 always?) */
|
||||||
} prog_section_function;
|
} prog_section_function;
|
||||||
|
|
||||||
|
|
2
ir.c
2
ir.c
|
@ -2841,7 +2841,7 @@ static bool gen_global_function(ir_builder *ir, ir_value *global)
|
||||||
fun.nargs = 8;
|
fun.nargs = 8;
|
||||||
|
|
||||||
for (i = 0;i < 8; ++i) {
|
for (i = 0;i < 8; ++i) {
|
||||||
if (i >= fun.nargs)
|
if ((int32_t)i >= fun.nargs)
|
||||||
fun.argsize[i] = 0;
|
fun.argsize[i] = 0;
|
||||||
else
|
else
|
||||||
fun.argsize[i] = type_sizeof[irfun->params[i]];
|
fun.argsize[i] = type_sizeof[irfun->params[i]];
|
||||||
|
|
Loading…
Reference in a new issue