mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 22:22:17 +00:00
Merge branch 'master' of github.com:graphitemaster/gmqcc
This commit is contained in:
commit
6a8494f21b
5 changed files with 33 additions and 4 deletions
2
ast.c
2
ast.c
|
@ -940,7 +940,7 @@ const char* ast_function_label(ast_function *self, const char *prefix)
|
||||||
size_t len;
|
size_t len;
|
||||||
char *from;
|
char *from;
|
||||||
|
|
||||||
if (!opts_dump)
|
if (!opts_dump && !opts_dumpfin)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
id = (self->labelcount++);
|
id = (self->labelcount++);
|
||||||
|
|
1
gmqcc.h
1
gmqcc.h
|
@ -830,6 +830,7 @@ extern const char *opts_output; /* -o file */
|
||||||
extern int opts_standard;
|
extern int opts_standard;
|
||||||
extern bool opts_debug;
|
extern bool opts_debug;
|
||||||
extern bool opts_memchk;
|
extern bool opts_memchk;
|
||||||
|
extern bool opts_dumpfin;
|
||||||
extern bool opts_dump;
|
extern bool opts_dump;
|
||||||
extern bool opts_werror;
|
extern bool opts_werror;
|
||||||
extern bool opts_forcecrc;
|
extern bool opts_forcecrc;
|
||||||
|
|
23
ir.c
23
ir.c
|
@ -542,7 +542,6 @@ bool ir_function_finalize(ir_function *self)
|
||||||
|
|
||||||
if (!ir_function_calculate_liferanges(self))
|
if (!ir_function_calculate_liferanges(self))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
if (!ir_function_allocate_locals(self))
|
if (!ir_function_allocate_locals(self))
|
||||||
return false;
|
return false;
|
||||||
return true;
|
return true;
|
||||||
|
@ -3330,6 +3329,26 @@ void ir_instr_dump(ir_instr *in, char *ind,
|
||||||
ind[strlen(ind)-1] = 0;
|
ind[strlen(ind)-1] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ir_value_dump_string(const char *str, int (*oprintf)(const char*, ...))
|
||||||
|
{
|
||||||
|
oprintf("\"");
|
||||||
|
for (; *str; ++str) {
|
||||||
|
switch (*str) {
|
||||||
|
case '\n': oprintf("\\n"); break;
|
||||||
|
case '\r': oprintf("\\r"); break;
|
||||||
|
case '\t': oprintf("\\t"); break;
|
||||||
|
case '\v': oprintf("\\v"); break;
|
||||||
|
case '\f': oprintf("\\f"); break;
|
||||||
|
case '\b': oprintf("\\b"); break;
|
||||||
|
case '\a': oprintf("\\a"); break;
|
||||||
|
case '\\': oprintf("\\\\"); break;
|
||||||
|
case '"': oprintf("\\\""); break;
|
||||||
|
default: oprintf("%c", *str); break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
oprintf("\"");
|
||||||
|
}
|
||||||
|
|
||||||
void ir_value_dump(ir_value* v, int (*oprintf)(const char*, ...))
|
void ir_value_dump(ir_value* v, int (*oprintf)(const char*, ...))
|
||||||
{
|
{
|
||||||
if (v->isconst) {
|
if (v->isconst) {
|
||||||
|
@ -3354,7 +3373,7 @@ void ir_value_dump(ir_value* v, int (*oprintf)(const char*, ...))
|
||||||
oprintf("(entity)");
|
oprintf("(entity)");
|
||||||
break;
|
break;
|
||||||
case TYPE_STRING:
|
case TYPE_STRING:
|
||||||
oprintf("\"%s\"", v->constval.vstring);
|
ir_value_dump_string(v->constval.vstring, oprintf);
|
||||||
break;
|
break;
|
||||||
#if 0
|
#if 0
|
||||||
case TYPE_INTEGER:
|
case TYPE_INTEGER:
|
||||||
|
|
5
main.c
5
main.c
|
@ -32,6 +32,7 @@ const char *opts_output = "progs.dat";
|
||||||
int opts_standard = COMPILER_GMQCC;
|
int opts_standard = COMPILER_GMQCC;
|
||||||
bool opts_debug = false;
|
bool opts_debug = false;
|
||||||
bool opts_memchk = false;
|
bool opts_memchk = false;
|
||||||
|
bool opts_dumpfin = false;
|
||||||
bool opts_dump = false;
|
bool opts_dump = false;
|
||||||
bool opts_werror = false;
|
bool opts_werror = false;
|
||||||
bool opts_forcecrc = false;
|
bool opts_forcecrc = false;
|
||||||
|
@ -237,6 +238,10 @@ static bool options_parse(int argc, char **argv) {
|
||||||
opts_dump = true;
|
opts_dump = true;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(argv[0]+1, "dumpfin")) {
|
||||||
|
opts_dumpfin = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!strcmp(argv[0]+1, "memchk")) {
|
if (!strcmp(argv[0]+1, "memchk")) {
|
||||||
opts_memchk = true;
|
opts_memchk = true;
|
||||||
continue;
|
continue;
|
||||||
|
|
6
parser.c
6
parser.c
|
@ -3921,6 +3921,10 @@ bool parser_finish(const char *output)
|
||||||
ir_builder_delete(ir);
|
ir_builder_delete(ir);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (opts_dump)
|
||||||
|
ir_builder_dump(ir, con_out);
|
||||||
|
for (i = 0; i < vec_size(parser->functions); ++i) {
|
||||||
if (!ir_function_finalize(parser->functions[i]->ir_func)) {
|
if (!ir_function_finalize(parser->functions[i]->ir_func)) {
|
||||||
con_out("failed to finalize function %s\n", parser->functions[i]->name);
|
con_out("failed to finalize function %s\n", parser->functions[i]->name);
|
||||||
ir_builder_delete(ir);
|
ir_builder_delete(ir);
|
||||||
|
@ -3929,7 +3933,7 @@ bool parser_finish(const char *output)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retval) {
|
if (retval) {
|
||||||
if (opts_dump)
|
if (opts_dumpfin)
|
||||||
ir_builder_dump(ir, con_out);
|
ir_builder_dump(ir, con_out);
|
||||||
|
|
||||||
generate_checksum(parser);
|
generate_checksum(parser);
|
||||||
|
|
Loading…
Reference in a new issue