mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-08 13:37:35 +02:00
adding (gc) to (chibi ast) module
This commit is contained in:
parent
078ee010aa
commit
78ac092a49
2 changed files with 16 additions and 1 deletions
|
@ -4,6 +4,10 @@
|
||||||
|
|
||||||
#include <chibi/eval.h>
|
#include <chibi/eval.h>
|
||||||
|
|
||||||
|
#if ! SEXP_USE_BOEHM
|
||||||
|
extern sexp sexp_gc (sexp ctx, size_t *sum_freed);
|
||||||
|
#endif
|
||||||
|
|
||||||
static void sexp_define_type_predicate (sexp ctx, sexp env, char *cname, sexp_uint_t type) {
|
static void sexp_define_type_predicate (sexp ctx, sexp env, char *cname, sexp_uint_t type) {
|
||||||
sexp_gc_var2(name, op);
|
sexp_gc_var2(name, op);
|
||||||
sexp_gc_preserve2(ctx, name, op);
|
sexp_gc_preserve2(ctx, name, op);
|
||||||
|
@ -181,6 +185,16 @@ static sexp sexp_optimize (sexp ctx sexp_api_params(self, n), sexp x) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static sexp sexp_gc_op (sexp ctx sexp_api_params(self, n)) {
|
||||||
|
size_t sum_freed=0;
|
||||||
|
#if SEXP_USE_BOEHM
|
||||||
|
GC_gcollect();
|
||||||
|
#else
|
||||||
|
sexp_gc(ctx, &sum_freed);
|
||||||
|
#endif
|
||||||
|
return sexp_make_unsigned_integer(ctx, sum_freed);
|
||||||
|
}
|
||||||
|
|
||||||
#define sexp_define_type(ctx, name, tag) \
|
#define sexp_define_type(ctx, name, tag) \
|
||||||
sexp_env_define(ctx, env, sexp_intern(ctx, name, -1), sexp_type_by_index(ctx, tag));
|
sexp_env_define(ctx, env, sexp_intern(ctx, name, -1), sexp_type_by_index(ctx, tag));
|
||||||
|
|
||||||
|
@ -270,6 +284,7 @@ sexp sexp_init_library (sexp ctx sexp_api_params(self, n), sexp env) {
|
||||||
sexp_define_foreign(ctx, env, "type-cpl", 1, sexp_type_cpl_op);
|
sexp_define_foreign(ctx, env, "type-cpl", 1, sexp_type_cpl_op);
|
||||||
sexp_define_foreign(ctx, env, "type-slots", 1, sexp_type_slots_op);
|
sexp_define_foreign(ctx, env, "type-slots", 1, sexp_type_slots_op);
|
||||||
sexp_define_foreign(ctx, env, "object-size", 1, sexp_object_size);
|
sexp_define_foreign(ctx, env, "object-size", 1, sexp_object_size);
|
||||||
|
sexp_define_foreign(ctx, env, "gc", 0, sexp_gc_op);
|
||||||
return SEXP_VOID;
|
return SEXP_VOID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
opcode-variadic?
|
opcode-variadic?
|
||||||
procedure-code procedure-vars procedure-name bytecode-name
|
procedure-code procedure-vars procedure-name bytecode-name
|
||||||
type? type-name type-cpl type-parent type-slots
|
type? type-name type-cpl type-parent type-slots
|
||||||
object-size)
|
object-size gc)
|
||||||
(import-immutable (scheme))
|
(import-immutable (scheme))
|
||||||
(include-shared "ast")
|
(include-shared "ast")
|
||||||
(include "ast.scm"))
|
(include "ast.scm"))
|
||||||
|
|
Loading…
Add table
Reference in a new issue