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;
- code_header.crc16 = 0; /* TODO: */
+ if (opts_forcecrc)
+ code_header.crc16 = opts_forced_crc;
+ else
+ code_header.crc16 = 0; /* TODO: */
code_header.entfield = code_entfields;
if (OPTS_FLAG(DARKPLACES_STRING_TABLE_BUG)) {
memset(prog, 0, sizeof(*prog));
prog->entityfields = header.entfield;
+ prog->crc16 = header.crc16;
prog->filename = util_strdup(filename);
if (!prog->filename) {
*/
#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;
qcint fnmain = -1;
qc_program *prog;
size_t xflags = VMXF_DEFAULT;
+ bool opts_printfields = false;
+ bool opts_info = false;
arg0 = argv[0];
++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();
}
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); */
fnmain = (qcint)i;
}
printf("Entity field space: %i\n", (int)prog->entityfields);
- if (fnmain > 0)
- {
- prog_exec(prog, &prog->functions[fnmain], xflags, VM_JUMPS_DEFAULT);
+ 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
- printf("No main function found\n");
+ {
+ 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;
MEM_VECTOR_MAKE(qcint, entitydata);
MEM_VECTOR_MAKE(bool, entitypool);
+ uint16_t crc16;
+
size_t tempstring_start;
size_t tempstring_at;
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))))
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;
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"
}
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;