mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2025-01-31 03:50:36 +00:00
tidying up, using the original typenames from code.c, renamed JUMPS_DEFAULT to VM_JUMPS_DEFAULT
This commit is contained in:
parent
f1a2ac624f
commit
9e148df23f
3 changed files with 43 additions and 47 deletions
26
exec.c
26
exec.c
|
@ -71,10 +71,10 @@ qc_program* prog_load(const char *filename)
|
|||
}
|
||||
#define read_data1(x, y) read_data(x, x, y)
|
||||
|
||||
read_data (statements, code, prog_statement);
|
||||
read_data1(defs, prog_def);
|
||||
read_data1(fields, prog_def);
|
||||
read_data1(functions, prog_function);
|
||||
read_data (statements, code, prog_section_statement);
|
||||
read_data1(defs, prog_section_def);
|
||||
read_data1(fields, prog_section_def);
|
||||
read_data1(functions, prog_section_function);
|
||||
read_data1(strings, char);
|
||||
read_data1(globals, qcint);
|
||||
|
||||
|
@ -132,7 +132,7 @@ char* prog_getstring(qc_program *prog, qcint str)
|
|||
return prog->strings + str;
|
||||
}
|
||||
|
||||
prog_def* prog_entfield(qc_program *prog, qcint off)
|
||||
prog_section_def* prog_entfield(qc_program *prog, qcint off)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < prog->fields_count; ++i) {
|
||||
|
@ -142,7 +142,7 @@ prog_def* prog_entfield(qc_program *prog, qcint off)
|
|||
return NULL;
|
||||
}
|
||||
|
||||
prog_def* prog_getdef(qc_program *prog, qcint off)
|
||||
prog_section_def* prog_getdef(qc_program *prog, qcint off)
|
||||
{
|
||||
size_t i;
|
||||
for (i = 0; i < prog->defs_count; ++i) {
|
||||
|
@ -191,7 +191,7 @@ qcint prog_tempstring(qc_program *prog, const char *_str)
|
|||
static void trace_print_global(qc_program *prog, unsigned int glob, int vtype)
|
||||
{
|
||||
static char spaces[16+1] = " ";
|
||||
prog_def *def;
|
||||
prog_section_def *def;
|
||||
qcany *value;
|
||||
int len;
|
||||
|
||||
|
@ -236,7 +236,7 @@ static void trace_print_global(qc_program *prog, unsigned int glob, int vtype)
|
|||
}
|
||||
}
|
||||
|
||||
static void prog_print_statement(qc_program *prog, prog_statement *st)
|
||||
static void prog_print_statement(qc_program *prog, prog_section_statement *st)
|
||||
{
|
||||
if (st->opcode >= (sizeof(asm_instr)/sizeof(asm_instr[0]))) {
|
||||
printf("<illegal instruction %d>\n", st->opcode);
|
||||
|
@ -296,10 +296,10 @@ static void prog_print_statement(qc_program *prog, prog_statement *st)
|
|||
}
|
||||
}
|
||||
|
||||
static qcint prog_enterfunction(qc_program *prog, prog_function *func)
|
||||
static qcint prog_enterfunction(qc_program *prog, prog_section_function *func)
|
||||
{
|
||||
qc_exec_stack st;
|
||||
prog_function *cur = NULL;
|
||||
prog_section_function *cur = NULL;
|
||||
|
||||
if (prog->stack_count)
|
||||
cur = prog->stack[prog->stack_count-1].function;
|
||||
|
@ -345,10 +345,10 @@ static qcint prog_leavefunction(qc_program *prog)
|
|||
return st.stmt;
|
||||
}
|
||||
|
||||
bool prog_exec(qc_program *prog, prog_function *func, size_t flags, long maxjumps)
|
||||
bool prog_exec(qc_program *prog, prog_section_function *func, size_t flags, long maxjumps)
|
||||
{
|
||||
long jumpcount = 0;
|
||||
prog_statement *st;
|
||||
prog_section_statement *st;
|
||||
|
||||
st = prog->code + prog_enterfunction(prog, func);
|
||||
--st;
|
||||
|
@ -421,7 +421,7 @@ int main(int argc, char **argv)
|
|||
}
|
||||
if (fnmain > 0)
|
||||
{
|
||||
prog_exec(prog, &prog->functions[fnmain], VMXF_TRACE, JUMPS_DEFAULT);
|
||||
prog_exec(prog, &prog->functions[fnmain], VMXF_TRACE, VM_JUMPS_DEFAULT);
|
||||
}
|
||||
else
|
||||
printf("No main function found\n");
|
||||
|
|
62
exec.h
62
exec.h
|
@ -45,10 +45,6 @@ typedef union {
|
|||
typedef char qcfloat_size_is_correct [sizeof(qcfloat) == 4 ?1:-1];
|
||||
typedef char qcint_size_is_correct [sizeof(qcint) == 4 ?1:-1];
|
||||
|
||||
typedef prog_section_both prog_def;
|
||||
typedef prog_section_function prog_function;
|
||||
typedef prog_section_statement prog_statement;
|
||||
|
||||
enum {
|
||||
VMERR_OK,
|
||||
VMERR_TEMPSTRING_ALLOC,
|
||||
|
@ -56,7 +52,7 @@ enum {
|
|||
VMERR_END
|
||||
};
|
||||
|
||||
#define JUMPS_DEFAULT 1000000
|
||||
#define VM_JUMPS_DEFAULT 1000000
|
||||
|
||||
/* execute-flags */
|
||||
#define VMXF_DEFAULT 0x0000 /* default flags - nothing */
|
||||
|
@ -68,21 +64,21 @@ struct qc_program_s;
|
|||
typedef int (*prog_builtin)(struct qc_program_s *prog);
|
||||
|
||||
typedef struct {
|
||||
qcint stmt;
|
||||
size_t localsp;
|
||||
prog_function *function;
|
||||
qcint stmt;
|
||||
size_t localsp;
|
||||
prog_section_function *function;
|
||||
} qc_exec_stack;
|
||||
|
||||
typedef struct qc_program_s {
|
||||
char *filename;
|
||||
|
||||
MEM_VECTOR_MAKE(prog_statement, code);
|
||||
MEM_VECTOR_MAKE(prog_def, defs);
|
||||
MEM_VECTOR_MAKE(prog_def, fields);
|
||||
MEM_VECTOR_MAKE(prog_function, functions);
|
||||
MEM_VECTOR_MAKE(char, strings);
|
||||
MEM_VECTOR_MAKE(qcint, globals);
|
||||
MEM_VECTOR_MAKE(qcint, entitydata);
|
||||
MEM_VECTOR_MAKE(prog_section_statement, code);
|
||||
MEM_VECTOR_MAKE(prog_section_def, defs);
|
||||
MEM_VECTOR_MAKE(prog_section_def, fields);
|
||||
MEM_VECTOR_MAKE(prog_section_function, functions);
|
||||
MEM_VECTOR_MAKE(char, strings);
|
||||
MEM_VECTOR_MAKE(qcint, globals);
|
||||
MEM_VECTOR_MAKE(qcint, entitydata);
|
||||
|
||||
size_t tempstring_start;
|
||||
size_t tempstring_at;
|
||||
|
@ -104,19 +100,19 @@ typedef struct qc_program_s {
|
|||
|
||||
int argc; /* current arg count for debugging */
|
||||
} qc_program;
|
||||
MEM_VEC_FUNCTIONS(qc_program, prog_statement, code)
|
||||
MEM_VEC_FUNCTIONS(qc_program, prog_def, defs)
|
||||
MEM_VEC_FUNCTIONS(qc_program, prog_def, fields)
|
||||
MEM_VEC_FUNCTIONS(qc_program, prog_function, functions)
|
||||
MEM_VEC_FUNCTIONS(qc_program, char, strings)
|
||||
_MEM_VEC_FUN_APPEND(qc_program, char, strings)
|
||||
_MEM_VEC_FUN_RESIZE(qc_program, char, strings)
|
||||
MEM_VEC_FUNCTIONS(qc_program, qcint, globals)
|
||||
MEM_VEC_FUNCTIONS(qc_program, qcint, entitydata)
|
||||
MEM_VEC_FUNCTIONS(qc_program, prog_section_statement, code)
|
||||
MEM_VEC_FUNCTIONS(qc_program, prog_section_def, defs)
|
||||
MEM_VEC_FUNCTIONS(qc_program, prog_section_def, fields)
|
||||
MEM_VEC_FUNCTIONS(qc_program, prog_section_function, functions)
|
||||
MEM_VEC_FUNCTIONS(qc_program, char, strings)
|
||||
_MEM_VEC_FUN_APPEND(qc_program, char, strings)
|
||||
_MEM_VEC_FUN_RESIZE(qc_program, char, strings)
|
||||
MEM_VEC_FUNCTIONS(qc_program, qcint, globals)
|
||||
MEM_VEC_FUNCTIONS(qc_program, qcint, entitydata)
|
||||
|
||||
MEM_VEC_FUNCTIONS(qc_program, qcint, localstack)
|
||||
_MEM_VEC_FUN_APPEND(qc_program, qcint, localstack)
|
||||
_MEM_VEC_FUN_RESIZE(qc_program, qcint, localstack)
|
||||
MEM_VEC_FUNCTIONS(qc_program, qcint, localstack)
|
||||
_MEM_VEC_FUN_APPEND(qc_program, qcint, localstack)
|
||||
_MEM_VEC_FUN_RESIZE(qc_program, qcint, localstack)
|
||||
MEM_VEC_FUNCTIONS(qc_program, qc_exec_stack, stack)
|
||||
|
||||
MEM_VEC_FUNCTIONS(qc_program, size_t, profile)
|
||||
|
@ -125,12 +121,12 @@ _MEM_VEC_FUN_RESIZE(qc_program, size_t, profile)
|
|||
qc_program* prog_load(const char *filename);
|
||||
void prog_delete(qc_program *prog);
|
||||
|
||||
bool prog_exec(qc_program *prog, prog_function *func, size_t flags, long maxjumps);
|
||||
bool prog_exec(qc_program *prog, prog_section_function *func, size_t flags, long maxjumps);
|
||||
|
||||
char* prog_getstring(qc_program *prog, qcint str);
|
||||
prog_def* prog_entfield(qc_program *prog, qcint off);
|
||||
prog_def* prog_getdef(qc_program *prog, qcint off);
|
||||
qcany* prog_getedict(qc_program *prog, qcint e);
|
||||
qcint prog_tempstring(qc_program *prog, const char *_str);
|
||||
char* prog_getstring (qc_program *prog, qcint str);
|
||||
prog_section_def* prog_entfield (qc_program *prog, qcint off);
|
||||
prog_section_def* prog_getdef (qc_program *prog, qcint off);
|
||||
qcany* prog_getedict (qc_program *prog, qcint e);
|
||||
qcint prog_tempstring(qc_program *prog, const char *_str);
|
||||
|
||||
#endif /* GMQCC_EXEC_HDR */
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
|
||||
while (1)
|
||||
{
|
||||
prog_function *newf;
|
||||
prog_section_function *newf;
|
||||
qcany *ed;
|
||||
qcany *ptr;
|
||||
|
||||
|
|
Loading…
Reference in a new issue