mirror of
https://github.com/DarkPlacesEngine/gmqcc.git
synced 2024-11-27 22:22:17 +00:00
Merge branch 'master' into blub/bc3
This commit is contained in:
commit
3d21db9896
4 changed files with 28 additions and 4 deletions
2
ast.c
2
ast.c
|
@ -416,7 +416,7 @@ void ast_call_delete(ast_call *self)
|
|||
}
|
||||
|
||||
ast_store* ast_store_new(lex_ctx ctx, int op,
|
||||
ast_value *dest, ast_expression *source)
|
||||
ast_expression *dest, ast_expression *source)
|
||||
{
|
||||
ast_instantiate(ast_store, ctx, ast_store_delete);
|
||||
ast_expression_init((ast_expression*)self, (ast_expression_codegen*)&ast_store_codegen);
|
||||
|
|
4
ast.h
4
ast.h
|
@ -220,11 +220,11 @@ struct ast_store_s
|
|||
{
|
||||
ast_expression_common expression;
|
||||
int op;
|
||||
ast_value *dest; /* When we add pointers this might have to change to expression */
|
||||
ast_expression *dest;
|
||||
ast_expression *source;
|
||||
};
|
||||
ast_store* ast_store_new(lex_ctx ctx, int op,
|
||||
ast_value *d, ast_expression *s);
|
||||
ast_expression *d, ast_expression *s);
|
||||
void ast_store_delete(ast_store*);
|
||||
|
||||
bool ast_store_codegen(ast_store*, ast_function*, bool lvalue, ir_value**);
|
||||
|
|
24
exec.c
24
exec.c
|
@ -22,6 +22,8 @@ MEM_VEC_FUNCTIONS(qc_program, qc_exec_stack, stack)
|
|||
MEM_VEC_FUNCTIONS(qc_program, size_t, profile)
|
||||
MEM_VEC_FUN_RESIZE(qc_program, size_t, profile)
|
||||
|
||||
MEM_VEC_FUNCTIONS(qc_program, prog_builtin, builtins)
|
||||
|
||||
static void loaderror(const char *fmt, ...)
|
||||
{
|
||||
int err = errno;
|
||||
|
@ -134,6 +136,11 @@ void prog_delete(qc_program *prog)
|
|||
MEM_VECTOR_CLEAR(prog, localstack);
|
||||
MEM_VECTOR_CLEAR(prog, stack);
|
||||
MEM_VECTOR_CLEAR(prog, profile);
|
||||
|
||||
if (prog->builtins_alloc) {
|
||||
MEM_VECTOR_CLEAR(prog, builtins);
|
||||
}
|
||||
/* otherwise the builtins were statically allocated */
|
||||
mem_d(prog);
|
||||
}
|
||||
|
||||
|
@ -451,6 +458,19 @@ cleanup:
|
|||
*/
|
||||
|
||||
#if defined(QCVM_EXECUTOR)
|
||||
static int qc_print(qc_program *prog)
|
||||
{
|
||||
qcany *str = (qcany*)(prog->globals + OFS_PARM0);
|
||||
printf("%s", prog_getstring(prog, str->string));
|
||||
return 0;
|
||||
}
|
||||
|
||||
static prog_builtin qc_builtins[] = {
|
||||
NULL,
|
||||
&qc_print
|
||||
};
|
||||
static size_t qc_builtins_count = sizeof(qc_builtins) / sizeof(qc_builtins[0]);
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
size_t i;
|
||||
|
@ -468,6 +488,10 @@ int main(int argc, char **argv)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
prog->builtins = qc_builtins;
|
||||
prog->builtins_count = qc_builtins_count;
|
||||
prog->builtins_alloc = 0;
|
||||
|
||||
for (i = 1; i < prog->functions_count; ++i) {
|
||||
const char *name = prog_getstring(prog, prog->functions[i].name);
|
||||
printf("Found function: %s\n", name);
|
||||
|
|
|
@ -42,7 +42,7 @@ do { \
|
|||
} while(0)
|
||||
|
||||
#define ASSIGN(op, a, b) \
|
||||
(ast_expression*)ast_store_new(ctx, INSTR_##op, (a), (ast_expression*)(b))
|
||||
(ast_expression*)ast_store_new(ctx, INSTR_##op, (ast_expression*)(a), (ast_expression*)(b))
|
||||
|
||||
#define BIN(op, a, b) \
|
||||
(ast_expression*)ast_binary_new(ctx, INSTR_##op, (ast_expression*)(a), (ast_expression*)(b))
|
||||
|
|
Loading…
Reference in a new issue