[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Tinycc-devel] incremental compilation
From: |
brian |
Subject: |
[Tinycc-devel] incremental compilation |
Date: |
Tue, 13 May 2003 20:37:55 +0900 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.0; ko-KR; rv:1.2b) Gecko/20021016 |
Well, I've had a play with tinycc today, and added (fairly primitive)
incremental compilation (for the memory target).
The *addenda stuff is a bit of a hack, and should be cleaned up soon.
If anyone is particularly interested the next stage involves rendering
into custom memory arenas, and after that - type introspection.
--- example of of incremental in-memory compilation ---
char my_program[] = "int fib(int n) { if (n <= 2) return 1; else return
fib(n-1) + fib(n-2); }";
char my_program2[] = "int noo() { return printf(\"This is noo! (fib =
%d)\\n\", fib(32)); }";
int main(argc, char **argv)
{
TCCState *s;
int (*func)(int);
int (*func2)(void);
s = tcc_new();
tcc_set_output_type(s, TCC_OUTPUT_MEMORY);
tcc_compile_string(s, my_program);
tcc_relocate(s);
func = tcc_get_symbol(s, "fib"); printf("fib 32 = %d\n", fib(32));
tcc_compile_string(s, my_program2);
tcc_relocate_addenda(s);
func2 = tcc_get_symbol(s, "noo");
if (func2) func2();
tcc_delete(s);
return 0;
}