int main(int argc, char* argv[]) { init_symbol_table(); init_builtin_types(); init_global_env(); init_singleton_objects(); init_primitive_procs(); struct vm_context *global_ctx = make_vm_context(NULL, NULL, global_env); INC_REF(&global_ctx->obj); struct vm_context **pctx = &global_ctx; struct object *value; value = load("prelude.scm", pctx); YIELD_OBJ(value); init_compiler(); value = load("stage2.scm", pctx); YIELD_OBJ(value); struct vm_context *repl_ctx; repl_ctx = make_vm_context(NULL, make_stack(1024), make_environment(global_env)); INC_REF(&repl_ctx->obj); pctx = &repl_ctx; struct object *ret = env_lookup(global_env, "initial-repl"); assert(ret->type->code == PROCEDURE_TYPE); struct procedure *repl = container_of(ret, struct procedure, obj); apply_and_run(repl, NIL, pctx); return 0; }
RState* r_state_new (RAllocFunc alloc_fn, rpointer aux) { RState* r; RState zero = { { 0 } }; r = alloc_fn (NULL, NULL, sizeof (RState)); if (!r) goto exit; *r = zero; /* Initialize memory allocator */ r->alloc_fn = alloc_fn; r->alloc_aux = aux; /* Initialize error handling facilities */ r->last_error = R_UNDEFINED; gc_init (r); init_builtin_types (r); init_global_objects (r); vm_init (r); gc_enable (r); exit: return r; }