mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-07-08 13:37:35 +02:00
removing global types
This commit is contained in:
parent
07c5c7a6f8
commit
06b122b33c
3 changed files with 0 additions and 57 deletions
|
@ -91,12 +91,6 @@
|
||||||
/* and are thus thread-safe and independant. */
|
/* and are thus thread-safe and independant. */
|
||||||
/* #define SEXP_USE_GLOBAL_HEAP 1 */
|
/* #define SEXP_USE_GLOBAL_HEAP 1 */
|
||||||
|
|
||||||
/* uncomment this to make type definitions common to all contexts */
|
|
||||||
/* By default types are only global if you don't allow user type */
|
|
||||||
/* definitions, so new types will be local to a given set of */
|
|
||||||
/* contexts sharing their heap. */
|
|
||||||
/* #define SEXP_USE_GLOBAL_TYPES 1 */
|
|
||||||
|
|
||||||
/* uncomment this to make the symbol table common to all contexts */
|
/* uncomment this to make the symbol table common to all contexts */
|
||||||
/* Will still be restricted to all contexts sharing the same */
|
/* Will still be restricted to all contexts sharing the same */
|
||||||
/* heap, of course. */
|
/* heap, of course. */
|
||||||
|
@ -336,10 +330,6 @@
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef SEXP_USE_GLOBAL_TYPES
|
|
||||||
#define SEXP_USE_GLOBAL_TYPES 0
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef SEXP_USE_GLOBAL_SYMBOLS
|
#ifndef SEXP_USE_GLOBAL_SYMBOLS
|
||||||
#if SEXP_USE_BOEHM || SEXP_USE_MALLOC
|
#if SEXP_USE_BOEHM || SEXP_USE_MALLOC
|
||||||
#define SEXP_USE_GLOBAL_SYMBOLS 1
|
#define SEXP_USE_GLOBAL_SYMBOLS 1
|
||||||
|
|
|
@ -864,20 +864,12 @@ SEXP_API sexp_heap sexp_global_heap;
|
||||||
#define sexp_context_symbols(ctx) sexp_vector_data(sexp_global(ctx, SEXP_G_SYMBOLS))
|
#define sexp_context_symbols(ctx) sexp_vector_data(sexp_global(ctx, SEXP_G_SYMBOLS))
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if SEXP_USE_GLOBAL_TYPES
|
|
||||||
SEXP_API struct sexp_type_struct *sexp_type_specs;
|
|
||||||
#define sexp_context_types(ctx) sexp_type_specs
|
|
||||||
#define sexp_type_by_index(ctx,i) (&(sexp_context_types(ctx)[i]))
|
|
||||||
#define sexp_context_num_types(ctx) sexp_num_types
|
|
||||||
#define sexp_context_type_array_size(ctx) sexp_type_array_size
|
|
||||||
#else
|
|
||||||
#define sexp_context_types(ctx) sexp_vector_data(sexp_global(ctx, SEXP_G_TYPES))
|
#define sexp_context_types(ctx) sexp_vector_data(sexp_global(ctx, SEXP_G_TYPES))
|
||||||
#define sexp_type_by_index(ctx,i) (sexp_context_types(ctx)[i])
|
#define sexp_type_by_index(ctx,i) (sexp_context_types(ctx)[i])
|
||||||
#define sexp_context_num_types(ctx) \
|
#define sexp_context_num_types(ctx) \
|
||||||
sexp_unbox_fixnum(sexp_global(ctx, SEXP_G_NUM_TYPES))
|
sexp_unbox_fixnum(sexp_global(ctx, SEXP_G_NUM_TYPES))
|
||||||
#define sexp_context_type_array_size(ctx) \
|
#define sexp_context_type_array_size(ctx) \
|
||||||
sexp_vector_length(sexp_global(ctx, SEXP_G_TYPES))
|
sexp_vector_length(sexp_global(ctx, SEXP_G_TYPES))
|
||||||
#endif
|
|
||||||
|
|
||||||
#define sexp_object_type(ctx,x) (sexp_type_by_index(ctx, ((x)->tag)))
|
#define sexp_object_type(ctx,x) (sexp_type_by_index(ctx, ((x)->tag)))
|
||||||
#define sexp_object_type_name(ctx,x) (sexp_type_name(sexp_object_type(ctx, x)))
|
#define sexp_object_type_name(ctx,x) (sexp_type_name(sexp_object_type(ctx, x)))
|
||||||
|
@ -948,10 +940,8 @@ enum sexp_context_globals {
|
||||||
#if ! SEXP_USE_GLOBAL_SYMBOLS
|
#if ! SEXP_USE_GLOBAL_SYMBOLS
|
||||||
SEXP_G_SYMBOLS,
|
SEXP_G_SYMBOLS,
|
||||||
#endif
|
#endif
|
||||||
#if ! SEXP_USE_GLOBAL_TYPES
|
|
||||||
SEXP_G_TYPES,
|
SEXP_G_TYPES,
|
||||||
SEXP_G_NUM_TYPES,
|
SEXP_G_NUM_TYPES,
|
||||||
#endif
|
|
||||||
SEXP_G_OOM_ERROR, /* out of memory exception object */
|
SEXP_G_OOM_ERROR, /* out of memory exception object */
|
||||||
SEXP_G_OOS_ERROR, /* out of stack exception object */
|
SEXP_G_OOS_ERROR, /* out of stack exception object */
|
||||||
SEXP_G_OPTIMIZATIONS,
|
SEXP_G_OPTIMIZATIONS,
|
||||||
|
|
37
sexp.c
37
sexp.c
|
@ -125,29 +125,16 @@ static struct sexp_type_struct _sexp_type_specs[] = {
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
#if SEXP_USE_GLOBAL_TYPES
|
|
||||||
struct sexp_struct *sexp_type_specs = _sexp_type_specs;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#define SEXP_INIT_NUM_TYPES (SEXP_NUM_CORE_TYPES*2)
|
#define SEXP_INIT_NUM_TYPES (SEXP_NUM_CORE_TYPES*2)
|
||||||
|
|
||||||
#if SEXP_USE_TYPE_DEFS
|
#if SEXP_USE_TYPE_DEFS
|
||||||
|
|
||||||
#if SEXP_USE_GLOBAL_TYPES
|
|
||||||
static sexp_uint_t sexp_num_types = SEXP_NUM_CORE_TYPES;
|
|
||||||
static sexp_uint_t sexp_type_array_size = SEXP_NUM_CORE_TYPES;
|
|
||||||
#endif
|
|
||||||
|
|
||||||
sexp sexp_register_type_op (sexp ctx sexp_api_params(self, n), sexp name,
|
sexp sexp_register_type_op (sexp ctx sexp_api_params(self, n), sexp name,
|
||||||
sexp parent, sexp slots,
|
sexp parent, sexp slots,
|
||||||
sexp fb, sexp felb, sexp flb, sexp flo, sexp fls,
|
sexp fb, sexp felb, sexp flb, sexp flo, sexp fls,
|
||||||
sexp sb, sexp so, sexp sc, sexp w, sexp wb, sexp wo,
|
sexp sb, sexp so, sexp sc, sexp w, sexp wb, sexp wo,
|
||||||
sexp ws, sexp we, sexp_proc2 f) {
|
sexp ws, sexp we, sexp_proc2 f) {
|
||||||
#if SEXP_USE_GLOBAL_TYPES
|
|
||||||
struct sexp_struct *new, *tmp;
|
|
||||||
#else
|
|
||||||
sexp *v1, *v2;
|
sexp *v1, *v2;
|
||||||
#endif
|
|
||||||
sexp_gc_var2(res, type);
|
sexp_gc_var2(res, type);
|
||||||
sexp_uint_t i, len, num_types=sexp_context_num_types(ctx),
|
sexp_uint_t i, len, num_types=sexp_context_num_types(ctx),
|
||||||
type_array_size=sexp_context_type_array_size(ctx);
|
type_array_size=sexp_context_type_array_size(ctx);
|
||||||
|
@ -160,17 +147,6 @@ sexp sexp_register_type_op (sexp ctx sexp_api_params(self, n), sexp name,
|
||||||
if (num_types >= type_array_size) {
|
if (num_types >= type_array_size) {
|
||||||
len = type_array_size*2;
|
len = type_array_size*2;
|
||||||
if (len > SEXP_MAXIMUM_TYPES) len = SEXP_MAXIMUM_TYPES;
|
if (len > SEXP_MAXIMUM_TYPES) len = SEXP_MAXIMUM_TYPES;
|
||||||
#if SEXP_USE_GLOBAL_TYPES
|
|
||||||
new = malloc(len * sizeof(sexp_struct));
|
|
||||||
for (i=0; i<num_types; i++) {
|
|
||||||
new[i].tag = SEXP_TYPE;
|
|
||||||
memcpy(&(new[i].value), &(sexp_type_specs[i]), sizeof(_sexp_type_specs[0]));
|
|
||||||
}
|
|
||||||
tmp = sexp_type_specs;
|
|
||||||
sexp_type_specs = new;
|
|
||||||
if (type_array_size > num_types) free(tmp);
|
|
||||||
sexp_type_array_size = len;
|
|
||||||
#else
|
|
||||||
res = sexp_make_vector(ctx, sexp_make_fixnum(len), SEXP_VOID);
|
res = sexp_make_vector(ctx, sexp_make_fixnum(len), SEXP_VOID);
|
||||||
if (sexp_exceptionp(res)) {
|
if (sexp_exceptionp(res)) {
|
||||||
sexp_gc_release2(ctx);
|
sexp_gc_release2(ctx);
|
||||||
|
@ -181,11 +157,8 @@ sexp sexp_register_type_op (sexp ctx sexp_api_params(self, n), sexp name,
|
||||||
for (i=0; i<num_types; i++)
|
for (i=0; i<num_types; i++)
|
||||||
v1[i] = v2[i];
|
v1[i] = v2[i];
|
||||||
sexp_global(ctx, SEXP_G_TYPES) = res;
|
sexp_global(ctx, SEXP_G_TYPES) = res;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
#if ! SEXP_USE_GLOBAL_TYPES
|
|
||||||
sexp_type_by_index(ctx, num_types) = sexp_alloc_type(ctx, type, SEXP_TYPE);
|
sexp_type_by_index(ctx, num_types) = sexp_alloc_type(ctx, type, SEXP_TYPE);
|
||||||
#endif
|
|
||||||
type = sexp_type_by_index(ctx, num_types);
|
type = sexp_type_by_index(ctx, num_types);
|
||||||
if (!sexp_exceptionp(type)) {
|
if (!sexp_exceptionp(type)) {
|
||||||
sexp_pointer_tag(type) = SEXP_TYPE;
|
sexp_pointer_tag(type) = SEXP_TYPE;
|
||||||
|
@ -221,11 +194,7 @@ sexp sexp_register_type_op (sexp ctx sexp_api_params(self, n), sexp name,
|
||||||
}
|
}
|
||||||
sexp_vector_data(sexp_type_cpl(type))[len] = type;
|
sexp_vector_data(sexp_type_cpl(type))[len] = type;
|
||||||
sexp_type_depth(type) = len;
|
sexp_type_depth(type) = len;
|
||||||
#if SEXP_USE_GLOBAL_TYPES
|
|
||||||
sexp_num_types = num_types + 1;
|
|
||||||
#else
|
|
||||||
sexp_global(ctx, SEXP_G_NUM_TYPES) = sexp_make_fixnum(num_types + 1);
|
sexp_global(ctx, SEXP_G_NUM_TYPES) = sexp_make_fixnum(num_types + 1);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
res = type;
|
res = type;
|
||||||
}
|
}
|
||||||
|
@ -275,10 +244,8 @@ sexp sexp_finalize_c_type (sexp ctx sexp_api_params(self, n), sexp obj) {
|
||||||
/****************************** contexts ******************************/
|
/****************************** contexts ******************************/
|
||||||
|
|
||||||
void sexp_init_context_globals (sexp ctx) {
|
void sexp_init_context_globals (sexp ctx) {
|
||||||
#if ! SEXP_USE_GLOBAL_TYPES
|
|
||||||
sexp type, *vec;
|
sexp type, *vec;
|
||||||
int i;
|
int i;
|
||||||
#endif
|
|
||||||
sexp_context_globals(ctx)
|
sexp_context_globals(ctx)
|
||||||
= sexp_make_vector(ctx, sexp_make_fixnum(SEXP_G_NUM_GLOBALS), SEXP_VOID);
|
= sexp_make_vector(ctx, sexp_make_fixnum(SEXP_G_NUM_GLOBALS), SEXP_VOID);
|
||||||
#if ! SEXP_USE_GLOBAL_SYMBOLS
|
#if ! SEXP_USE_GLOBAL_SYMBOLS
|
||||||
|
@ -299,7 +266,6 @@ void sexp_init_context_globals (sexp ctx) {
|
||||||
sexp_global(ctx, SEXP_G_INTERACTION_ENV_SYMBOL) = sexp_intern(ctx, "interaction-environment", -1);
|
sexp_global(ctx, SEXP_G_INTERACTION_ENV_SYMBOL) = sexp_intern(ctx, "interaction-environment", -1);
|
||||||
sexp_global(ctx, SEXP_G_EMPTY_VECTOR) = sexp_alloc_type(ctx, vector, SEXP_VECTOR);
|
sexp_global(ctx, SEXP_G_EMPTY_VECTOR) = sexp_alloc_type(ctx, vector, SEXP_VECTOR);
|
||||||
sexp_vector_length(sexp_global(ctx, SEXP_G_EMPTY_VECTOR)) = 0;
|
sexp_vector_length(sexp_global(ctx, SEXP_G_EMPTY_VECTOR)) = 0;
|
||||||
#if ! SEXP_USE_GLOBAL_TYPES
|
|
||||||
sexp_global(ctx, SEXP_G_NUM_TYPES) = sexp_make_fixnum(SEXP_NUM_CORE_TYPES);
|
sexp_global(ctx, SEXP_G_NUM_TYPES) = sexp_make_fixnum(SEXP_NUM_CORE_TYPES);
|
||||||
sexp_global(ctx, SEXP_G_TYPES)
|
sexp_global(ctx, SEXP_G_TYPES)
|
||||||
= sexp_make_vector(ctx, sexp_make_fixnum(SEXP_INIT_NUM_TYPES), SEXP_VOID);
|
= sexp_make_vector(ctx, sexp_make_fixnum(SEXP_INIT_NUM_TYPES), SEXP_VOID);
|
||||||
|
@ -309,7 +275,6 @@ void sexp_init_context_globals (sexp ctx) {
|
||||||
memcpy(&(type->value), &(_sexp_type_specs[i]), sizeof(_sexp_type_specs[0]));
|
memcpy(&(type->value), &(_sexp_type_specs[i]), sizeof(_sexp_type_specs[0]));
|
||||||
vec[i] = type;
|
vec[i] = type;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#if ! SEXP_USE_GLOBAL_HEAP
|
#if ! SEXP_USE_GLOBAL_HEAP
|
||||||
|
@ -377,10 +342,8 @@ void sexp_destroy_context (sexp ctx) {
|
||||||
if (sexp_context_heap(ctx)) {
|
if (sexp_context_heap(ctx)) {
|
||||||
heap = sexp_context_heap(ctx);
|
heap = sexp_context_heap(ctx);
|
||||||
sexp_markedp(ctx) = 1;
|
sexp_markedp(ctx) = 1;
|
||||||
#if ! SEXP_USE_GLOBAL_TYPES
|
|
||||||
sexp_markedp(sexp_context_globals(ctx)) = 1;
|
sexp_markedp(sexp_context_globals(ctx)) = 1;
|
||||||
sexp_markedp(sexp_global(ctx, SEXP_G_TYPES)) = 1;
|
sexp_markedp(sexp_global(ctx, SEXP_G_TYPES)) = 1;
|
||||||
#endif
|
|
||||||
sexp_sweep(ctx, &sum_freed); /* sweep w/o mark to run finalizers */
|
sexp_sweep(ctx, &sum_freed); /* sweep w/o mark to run finalizers */
|
||||||
sexp_context_heap(ctx) = NULL;
|
sexp_context_heap(ctx) = NULL;
|
||||||
for ( ; heap; heap=tmp) {
|
for ( ; heap; heap=tmp) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue