VECTOR_MAKE(int, code_globals );
VECTOR_MAKE(char, code_chars );
+uint32_t code_entfields;
+
void code_init() {
prog_section_function empty_function = {0,0,0,0,0,0,0,{0}};
prog_section_statement empty_statement = {0,{0},{0},{0}};
int i = 0;
/* omit creation of null code */
- if (opts_omit_nullcode)
+ if (OPTS_FLAG(OMIT_NULL_BYTES))
return;
/*
code_chars_add ('\0');
code_functions_add (empty_function);
code_statements_add(empty_statement);
+
+ code_entfields = 0;
}
uint32_t code_genstring(const char *str)
code_statements_add(s3);
}
+qcint code_alloc_field (size_t qcsize)
+{
+ qcint pos = (qcint)code_entfields;
+ code_entfields += qcsize;
+ return pos;
+}
+
bool code_write(const char *filename) {
prog_header code_header;
FILE *fp = NULL;
size_t it = 2;
/* see proposal.txt */
- if (opts_omit_nullcode) {}
+ if (OPTS_FLAG(OMIT_NULL_BYTES)) {}
code_header.statements.offset = sizeof(prog_header);
code_header.statements.length = code_statements_elements;
code_header.defs.offset = code_header.statements.offset + (sizeof(prog_section_statement) * code_statements_elements);
code_header.strings.length = code_chars_elements;
code_header.version = 6;
code_header.crc16 = 0; /* TODO: */
- code_header.entfield = 0; /* TODO: */
+ code_header.entfield = code_entfields;
- if (opts_darkplaces_stringtablebug) {
+ if (OPTS_FLAG(DARKPLACES_STRING_TABLE_BUG)) {
util_debug("GEN", "Patching stringtable for -fdarkplaces-stringtablebug\n");
/* >= + P */