static lex_ctx_t empty_ctx = {0, 0, 0};
static prog_section_function_t empty_function = {0,0,0,0,0,0,0,{0,0,0,0,0,0,0,0}};
static prog_section_statement_t empty_statement = {0,{0},{0},{0}};
static prog_section_def_t empty_def = {0, 0, 0};
static lex_ctx_t empty_ctx = {0, 0, 0};
static prog_section_function_t empty_function = {0,0,0,0,0,0,0,{0,0,0,0,0,0,0,0}};
static prog_section_statement_t empty_statement = {0,{0},{0},{0}};
static prog_section_def_t empty_def = {0, 0, 0};
- memset(code, 0, sizeof(code_t));
- code->entfields = 0;
- code->string_cache = util_htnew(OPTS_OPTIMIZATION(OPTIM_OVERLAP_STRINGS) ? 0x100 : 1024);
+ // The way progs.dat is suppose to work is odd, there needs to be
+ // some null (empty) statements, functions, and 28 globals
+ globals.insert(globals.begin(), 28, 0);
- /*
- * The way progs.dat is suppose to work is odd, there needs to be
- * some null (empty) statements, functions, and 28 globals
- */
- for(; i < 28; i++)
- code->globals.push_back(0);
+ chars.push_back('\0');
+ functions.push_back(empty_function);
- code_push_statement(code, &empty_statement, empty_ctx);
-
- code->defs.push_back(empty_def);
- code->fields.push_back(empty_def);
+ defs.push_back(empty_def);
+ fields.push_back(empty_def);
+}
CODE_HASH_LEAVE(existing) = code->chars.size();
code->chars.insert(code->chars.end(), str, str + strlen(str) + 1);
CODE_HASH_LEAVE(existing) = code->chars.size();
code->chars.insert(code->chars.end(), str, str + strlen(str) + 1);
util_htseth(code->string_cache, str, hash, CODE_HASH_ENTER(existing));
return CODE_HASH_LEAVE(existing);
util_htseth(code->string_cache, str, hash, CODE_HASH_ENTER(existing));
return CODE_HASH_LEAVE(existing);
bool code_write(code_t *code, const char *filename, const char *lnofile) {
prog_header_t code_header;
bool code_write(code_t *code, const char *filename, const char *lnofile) {
prog_header_t code_header;
code_create_header(code, &code_header, filename, lnofile);
code_create_header(code, &code_header, filename, lnofile);
code_stats(filename, lnofile, code, &code_header);
return true;
}
code_stats(filename, lnofile, code, &code_header);
return true;
}