mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-09 22:17:34 +02:00
re-creating ports on image loading
This commit is contained in:
parent
4f9903db00
commit
93696841ed
2 changed files with 8 additions and 1 deletions
4
gc.c
4
gc.c
|
@ -517,6 +517,10 @@ void sexp_offset_heap_pointers (sexp_heap heap, sexp_heap from_heap, sexp* types
|
||||||
/* if (sexp_context_heap(p) - off != from_heap) */
|
/* if (sexp_context_heap(p) - off != from_heap) */
|
||||||
/* fprintf(stderr, "unexpected heap: %p\n", sexp_context_heap(p)); */
|
/* fprintf(stderr, "unexpected heap: %p\n", sexp_context_heap(p)); */
|
||||||
sexp_context_heap(p) = heap;
|
sexp_context_heap(p) = heap;
|
||||||
|
} else if (sexp_portp(p) && sexp_port_stream(p)) {
|
||||||
|
sexp_port_stream(p) = 0;
|
||||||
|
sexp_port_openp(p) = 0;
|
||||||
|
sexp_freep(p) = 0;
|
||||||
} else if (loadp && sexp_dlp(p)) {
|
} else if (loadp && sexp_dlp(p)) {
|
||||||
sexp_dl_handle(p) = NULL;
|
sexp_dl_handle(p) = NULL;
|
||||||
}
|
}
|
||||||
|
|
5
main.c
5
main.c
|
@ -35,6 +35,7 @@ struct sexp_image_header_t {
|
||||||
sexp_uint_t size, base, context;
|
sexp_uint_t size, base, context;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
sexp sexp_gc (sexp ctx, size_t *sum_freed);
|
||||||
void sexp_offset_heap_pointers (sexp_heap heap, sexp_heap from_heap, sexp* types, sexp flags);
|
void sexp_offset_heap_pointers (sexp_heap heap, sexp_heap from_heap, sexp* types, sexp flags);
|
||||||
|
|
||||||
static sexp sexp_load_image (const char* file) {
|
static sexp sexp_load_image (const char* file) {
|
||||||
|
@ -85,6 +86,7 @@ static int sexp_save_image (sexp ctx, const char* path) {
|
||||||
header.base = (sexp_uint_t)heap;
|
header.base = (sexp_uint_t)heap;
|
||||||
header.context = (sexp_uint_t)ctx;
|
header.context = (sexp_uint_t)ctx;
|
||||||
fwrite(&header, sizeof(header), 1, file);
|
fwrite(&header, sizeof(header), 1, file);
|
||||||
|
sexp_gc(ctx, NULL);
|
||||||
fwrite(heap, heap->size, 1, file);
|
fwrite(heap, heap->size, 1, file);
|
||||||
fclose(file);
|
fclose(file);
|
||||||
return 1;
|
return 1;
|
||||||
|
@ -298,6 +300,7 @@ void run_main (int argc, char **argv) {
|
||||||
exit_failure();
|
exit_failure();
|
||||||
}
|
}
|
||||||
env = sexp_context_env(ctx);
|
env = sexp_context_env(ctx);
|
||||||
|
sexp_load_standard_ports(ctx, env, stdin, stdout, stderr, 0);
|
||||||
init_loaded++;
|
init_loaded++;
|
||||||
break;
|
break;
|
||||||
case 'd':
|
case 'd':
|
||||||
|
@ -338,7 +341,7 @@ void run_main (int argc, char **argv) {
|
||||||
else
|
else
|
||||||
args = sexp_cons(ctx, tmp=sexp_c_string(ctx,argv[0],-1), args);
|
args = sexp_cons(ctx, tmp=sexp_c_string(ctx,argv[0],-1), args);
|
||||||
sexp_env_define(ctx, env, sexp_intern(ctx, sexp_argv_symbol, -1), args);
|
sexp_env_define(ctx, env, sexp_intern(ctx, sexp_argv_symbol, -1), args);
|
||||||
/* sexp_eval_string(ctx, sexp_argv_proc, -1, env); */
|
sexp_eval_string(ctx, sexp_argv_proc, -1, env);
|
||||||
if (i < argc) { /* script usage */
|
if (i < argc) { /* script usage */
|
||||||
sexp_context_tracep(ctx) = 1;
|
sexp_context_tracep(ctx) = 1;
|
||||||
check_exception(ctx, sexp_load(ctx, tmp=sexp_c_string(ctx, argv[i], -1), env));
|
check_exception(ctx, sexp_load(ctx, tmp=sexp_c_string(ctx, argv[i], -1), env));
|
||||||
|
|
Loading…
Add table
Reference in a new issue