mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-23 20:33:05 +00:00
option: -force-crc=number, added -info to executor to just show some file info like the crc, and -printfields to print a list of fields along with their type and position
This commit is contained in:
parent
330a801ae9
commit
93e13c3cb1
4 changed files with 66 additions and 5 deletions
3
code.c
3
code.c
|
@ -183,6 +183,9 @@ bool code_write(const char *filename) {
|
|||
code_header.strings.offset = code_header.globals.offset + (sizeof(int32_t) * code_globals_elements);
|
||||
code_header.strings.length = code_chars_elements;
|
||||
code_header.version = 6;
|
||||
if (opts_forcecrc)
|
||||
code_header.crc16 = opts_forced_crc;
|
||||
else
|
||||
code_header.crc16 = 0; /* TODO: */
|
||||
code_header.entfield = code_entfields;
|
||||
|
||||
|
|
45
exec.c
45
exec.c
|
@ -80,6 +80,7 @@ qc_program* prog_load(const char *filename)
|
|||
memset(prog, 0, sizeof(*prog));
|
||||
|
||||
prog->entityfields = header.entfield;
|
||||
prog->crc16 = header.crc16;
|
||||
|
||||
prog->filename = util_strdup(filename);
|
||||
if (!prog->filename) {
|
||||
|
@ -606,6 +607,21 @@ cleanup:
|
|||
*/
|
||||
|
||||
#if defined(QCVM_EXECUTOR)
|
||||
const char *type_name[TYPE_COUNT] = {
|
||||
"void",
|
||||
"string",
|
||||
"float",
|
||||
"vector",
|
||||
"entity",
|
||||
"field",
|
||||
"function",
|
||||
"pointer",
|
||||
#if 0
|
||||
"integer",
|
||||
#endif
|
||||
"variant"
|
||||
};
|
||||
|
||||
bool opts_debug = false;
|
||||
bool opts_memchk = false;
|
||||
|
||||
|
@ -686,6 +702,8 @@ int main(int argc, char **argv)
|
|||
qcint fnmain = -1;
|
||||
qc_program *prog;
|
||||
size_t xflags = VMXF_DEFAULT;
|
||||
bool opts_printfields = false;
|
||||
bool opts_info = false;
|
||||
|
||||
arg0 = argv[0];
|
||||
|
||||
|
@ -703,6 +721,16 @@ int main(int argc, char **argv)
|
|||
++argv;
|
||||
xflags |= VMXF_PROFILE;
|
||||
}
|
||||
else if (!strcmp(argv[1], "-info")) {
|
||||
--argc;
|
||||
++argv;
|
||||
opts_info = true;
|
||||
}
|
||||
else if (!strcmp(argv[1], "-printfields")) {
|
||||
--argc;
|
||||
++argv;
|
||||
opts_printfields = true;
|
||||
}
|
||||
else
|
||||
usage();
|
||||
}
|
||||
|
@ -718,6 +746,8 @@ int main(int argc, char **argv)
|
|||
prog->builtins_count = qc_builtins_count;
|
||||
prog->builtins_alloc = 0;
|
||||
|
||||
printf("Program's system-checksum = 0x%04x\n", (int)prog->crc16);
|
||||
|
||||
for (i = 1; i < prog->functions_count; ++i) {
|
||||
const char *name = prog_getstring(prog, prog->functions[i].name);
|
||||
/* printf("Found function: %s\n", name); */
|
||||
|
@ -725,12 +755,27 @@ int main(int argc, char **argv)
|
|||
fnmain = (qcint)i;
|
||||
}
|
||||
printf("Entity field space: %i\n", (int)prog->entityfields);
|
||||
if (opts_info) {
|
||||
prog_delete(prog);
|
||||
return 0;
|
||||
}
|
||||
if (opts_printfields) {
|
||||
for (i = 0; i < prog->fields_count; ++i) {
|
||||
printf("Field: %8s %-16s at %u\n",
|
||||
type_name[prog->fields[i].type],
|
||||
prog_getstring(prog, prog->fields[i].name),
|
||||
(unsigned int)prog->fields[i].offset);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (fnmain > 0)
|
||||
{
|
||||
prog_exec(prog, &prog->functions[fnmain], xflags, VM_JUMPS_DEFAULT);
|
||||
}
|
||||
else
|
||||
printf("No main function found\n");
|
||||
}
|
||||
|
||||
prog_delete(prog);
|
||||
return 0;
|
||||
|
|
4
gmqcc.h
4
gmqcc.h
|
@ -860,6 +860,8 @@ typedef struct qc_program_s {
|
|||
MEM_VECTOR_MAKE(qcint, entitydata);
|
||||
MEM_VECTOR_MAKE(bool, entitypool);
|
||||
|
||||
uint16_t crc16;
|
||||
|
||||
size_t tempstring_start;
|
||||
size_t tempstring_at;
|
||||
|
||||
|
@ -994,6 +996,8 @@ extern bool opts_debug;
|
|||
extern bool opts_memchk;
|
||||
extern bool opts_dump;
|
||||
extern bool opts_werror;
|
||||
extern bool opts_forcecrc;
|
||||
extern uint16_t opts_forced_crc;
|
||||
|
||||
/*===================================================================*/
|
||||
#define OPTS_FLAG(i) (!! (opts_flags[(i)/32] & (1<< ((i)%32))))
|
||||
|
|
9
main.c
9
main.c
|
@ -33,6 +33,9 @@ bool opts_debug = false;
|
|||
bool opts_memchk = false;
|
||||
bool opts_dump = false;
|
||||
bool opts_werror = false;
|
||||
bool opts_forcecrc = false;
|
||||
|
||||
uint16_t opts_forced_crc;
|
||||
|
||||
static bool opts_output_wasset = false;
|
||||
|
||||
|
@ -63,6 +66,7 @@ static int usage() {
|
|||
printf(" -W<warning> enable a warning\n"
|
||||
" -Wno-<warning> disable a warning\n"
|
||||
" -Wall enable all warnings\n");
|
||||
printf(" -force-crc=num force a specific checksum into the header\n");
|
||||
printf("\n");
|
||||
printf("flags:\n"
|
||||
" -fdarkplaces-string-table-bug\n"
|
||||
|
@ -180,6 +184,11 @@ static bool options_parse(int argc, char **argv) {
|
|||
}
|
||||
continue;
|
||||
}
|
||||
if (options_long_gcc("force-crc", &argc, &argv, &argarg)) {
|
||||
opts_forcecrc = true;
|
||||
opts_forced_crc = strtol(argarg, NULL, 0);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(argv[0]+1, "debug")) {
|
||||
opts_debug = true;
|
||||
continue;
|
||||
|
|
Loading…
Reference in a new issue