Exemplo n.º 1
0
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;
}
Exemplo n.º 2
0
int 
main()
{
    cont_p cont;
    cont_p caller_cont;
    object_p scanner, output;

    init_symbol_table();
    init_wellknown_objects();
    init_global_env();
    init_cont_list();

    fill_initial_env();

    scanner = alloc_scanner(stdin);
    output = alloc_output_stream(stdout);

    if (setjmp(error_occured) != 0) {
        // reset continuation list
        continuation_list->next = continuation_list->first;
    }

    // initial continuation
    caller_cont = cont_list_obtain(continuation_list);
    caller_cont->args_locals[0] = output;
    caller_cont->next = finish;

    cont = cont_list_obtain(continuation_list);
    cont->caller = caller_cont;
    cont->args_locals[0] = scanner;
    cont->args_locals[1] = output;
    cont->next = repl;

    trampoline(cont);

    return 0;
}