1 #include "lib.h" 2 3 int ArgC; 4 char **ArgV; 5 Str *ProgName; 6 StrArr *Args; 7 8 Initializer *initializers = NULL; 9 InitSystem()10void InitSystem() { 11 for (Initializer *init = initializers; init; init = init->next) { 12 init->init(); 13 } 14 } 15 16 extern void Main(); 17 run_with_gc(void * arg)18void *run_with_gc(void *arg) { 19 InitSystem(); 20 GCVar(ProgName, S(ArgV[0])); 21 GCVar(Args, new StrArr(ArgC - 1)); 22 for (int i = 1; i < ArgC; i++) 23 Args->add(new Str(ArgV[i])); 24 Main(); 25 return NULL; 26 } 27 28 static void *dummy[1] = { NULL }; 29 main(int argc,char ** argv)30int main(int argc, char **argv) { 31 GC_INIT(); 32 // We need at least one global variable for Tiny GC to work. 33 GCVar(dummy); 34 ArgC = argc; 35 ArgV = argv; 36 GC_call_with_gc_active(run_with_gc, NULL); 37 return 0; 38 } 39