mirror of
https://github.com/ashinn/chibi-scheme.git
synced 2025-05-19 05:39:18 +02:00
no more flexible arrays (issue #842)
This commit is contained in:
parent
658244d64e
commit
701cf1d169
2 changed files with 12 additions and 16 deletions
|
@ -460,11 +460,9 @@ struct sexp_struct {
|
||||||
} pair;
|
} pair;
|
||||||
struct {
|
struct {
|
||||||
sexp_uint_t length;
|
sexp_uint_t length;
|
||||||
sexp data SEXP_FLEXIBLE_ARRAY;
|
|
||||||
} vector;
|
} vector;
|
||||||
struct {
|
struct {
|
||||||
sexp_uint_t length;
|
sexp_uint_t length;
|
||||||
char data SEXP_FLEXIBLE_ARRAY;
|
|
||||||
} bytes;
|
} bytes;
|
||||||
struct {
|
struct {
|
||||||
sexp bytes;
|
sexp bytes;
|
||||||
|
@ -477,7 +475,6 @@ struct sexp_struct {
|
||||||
sexp charlens;
|
sexp charlens;
|
||||||
#endif
|
#endif
|
||||||
sexp_uint_t length;
|
sexp_uint_t length;
|
||||||
char data SEXP_FLEXIBLE_ARRAY;
|
|
||||||
#else
|
#else
|
||||||
sexp bytes;
|
sexp bytes;
|
||||||
#if SEXP_USE_STRING_INDEX_TABLE
|
#if SEXP_USE_STRING_INDEX_TABLE
|
||||||
|
@ -488,7 +485,6 @@ struct sexp_struct {
|
||||||
} string;
|
} string;
|
||||||
struct {
|
struct {
|
||||||
sexp_uint_t length;
|
sexp_uint_t length;
|
||||||
char data SEXP_FLEXIBLE_ARRAY;
|
|
||||||
} symbol;
|
} symbol;
|
||||||
struct {
|
struct {
|
||||||
sexp name;
|
sexp name;
|
||||||
|
@ -511,7 +507,6 @@ struct sexp_struct {
|
||||||
struct {
|
struct {
|
||||||
signed char sign;
|
signed char sign;
|
||||||
sexp_uint_t length;
|
sexp_uint_t length;
|
||||||
sexp_uint_t data SEXP_FLEXIBLE_ARRAY;
|
|
||||||
} bignum;
|
} bignum;
|
||||||
struct {
|
struct {
|
||||||
sexp numerator, denominator;
|
sexp numerator, denominator;
|
||||||
|
@ -534,7 +529,6 @@ struct sexp_struct {
|
||||||
struct {
|
struct {
|
||||||
sexp name, literals, source;
|
sexp name, literals, source;
|
||||||
sexp_uint_t length, max_depth;
|
sexp_uint_t length, max_depth;
|
||||||
unsigned char data SEXP_FLEXIBLE_ARRAY;
|
|
||||||
} bytecode;
|
} bytecode;
|
||||||
struct {
|
struct {
|
||||||
sexp bc, vars;
|
sexp bc, vars;
|
||||||
|
@ -578,7 +572,6 @@ struct sexp_struct {
|
||||||
/* compiler state */
|
/* compiler state */
|
||||||
struct {
|
struct {
|
||||||
sexp_uint_t length, top;
|
sexp_uint_t length, top;
|
||||||
sexp data SEXP_FLEXIBLE_ARRAY;
|
|
||||||
} stack;
|
} stack;
|
||||||
struct {
|
struct {
|
||||||
sexp stack, env, parent, child,
|
sexp stack, env, parent, child,
|
||||||
|
@ -1138,8 +1131,11 @@ SEXP_API unsigned long long sexp_bignum_to_uint(sexp x);
|
||||||
#define sexp_cpointer_field(x, field) ((x)->value.cpointer.field)
|
#define sexp_cpointer_field(x, field) ((x)->value.cpointer.field)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#define sexp_flexible_array_field(x, type, field_type) \
|
||||||
|
((field_type*)((char*)(x)+sexp_sizeof(type)))
|
||||||
|
|
||||||
#define sexp_vector_length(x) (sexp_field(x, vector, SEXP_VECTOR, length))
|
#define sexp_vector_length(x) (sexp_field(x, vector, SEXP_VECTOR, length))
|
||||||
#define sexp_vector_data(x) (sexp_field(x, vector, SEXP_VECTOR, data))
|
#define sexp_vector_data(x) sexp_flexible_array_field(x, vector, sexp)
|
||||||
|
|
||||||
#if SEXP_USE_SAFE_VECTOR_ACCESSORS
|
#if SEXP_USE_SAFE_VECTOR_ACCESSORS
|
||||||
#define sexp_vector_ref(x,i) (sexp_unbox_fixnum(i)>=0 && sexp_unbox_fixnum(i)<sexp_vector_length(x) ? sexp_vector_data(x)[sexp_unbox_fixnum(i)] : (fprintf(stderr, "vector-ref length out of range %s on line %d: vector %p (length %lu): %ld\n", __FILE__, __LINE__, x, sexp_vector_length(x), sexp_unbox_fixnum(i)), SEXP_VOID))
|
#define sexp_vector_ref(x,i) (sexp_unbox_fixnum(i)>=0 && sexp_unbox_fixnum(i)<sexp_vector_length(x) ? sexp_vector_data(x)[sexp_unbox_fixnum(i)] : (fprintf(stderr, "vector-ref length out of range %s on line %d: vector %p (length %lu): %ld\n", __FILE__, __LINE__, x, sexp_vector_length(x), sexp_unbox_fixnum(i)), SEXP_VOID))
|
||||||
|
@ -1159,7 +1155,7 @@ SEXP_API unsigned long long sexp_bignum_to_uint(sexp x);
|
||||||
#define sexp_procedure_source(x) sexp_bytecode_source(sexp_procedure_code(x))
|
#define sexp_procedure_source(x) sexp_bytecode_source(sexp_procedure_code(x))
|
||||||
|
|
||||||
#define sexp_bytes_length(x) (sexp_field(x, bytes, SEXP_BYTES, length))
|
#define sexp_bytes_length(x) (sexp_field(x, bytes, SEXP_BYTES, length))
|
||||||
#define sexp_bytes_data(x) (sexp_field(x, bytes, SEXP_BYTES, data))
|
#define sexp_bytes_data(x) sexp_flexible_array_field(x, bytes, char)
|
||||||
#define sexp_bytes_maybe_null_data(x) (sexp_not(x) ? NULL : sexp_bytes_data(x))
|
#define sexp_bytes_maybe_null_data(x) (sexp_not(x) ? NULL : sexp_bytes_data(x))
|
||||||
|
|
||||||
static const unsigned char sexp_uvector_sizes[] = {
|
static const unsigned char sexp_uvector_sizes[] = {
|
||||||
|
@ -1199,7 +1195,7 @@ enum sexp_uniform_vector_type {
|
||||||
#define sexp_string_size(x) (sexp_field(x, string, SEXP_STRING, length))
|
#define sexp_string_size(x) (sexp_field(x, string, SEXP_STRING, length))
|
||||||
#define sexp_string_charlens(x) (sexp_field(x, string, SEXP_STRING, charlens))
|
#define sexp_string_charlens(x) (sexp_field(x, string, SEXP_STRING, charlens))
|
||||||
#if SEXP_USE_PACKED_STRINGS
|
#if SEXP_USE_PACKED_STRINGS
|
||||||
#define sexp_string_data(x) (sexp_field(x, string, SEXP_STRING, data))
|
#define sexp_string_data(x) sexp_flexible_array_field(x, string, char)
|
||||||
#define sexp_string_bytes(x) (x)
|
#define sexp_string_bytes(x) (x)
|
||||||
#else
|
#else
|
||||||
#define sexp_string_bytes(x) (sexp_field(x, string, SEXP_STRING, bytes))
|
#define sexp_string_bytes(x) (sexp_field(x, string, SEXP_STRING, bytes))
|
||||||
|
@ -1217,7 +1213,7 @@ enum sexp_uniform_vector_type {
|
||||||
#define sexp_bytes_ref(x, i) (sexp_make_fixnum((unsigned char)sexp_bytes_data(x)[sexp_unbox_fixnum(i)]))
|
#define sexp_bytes_ref(x, i) (sexp_make_fixnum((unsigned char)sexp_bytes_data(x)[sexp_unbox_fixnum(i)]))
|
||||||
#define sexp_bytes_set(x, i, v) (sexp_bytes_data(x)[sexp_unbox_fixnum(i)] = sexp_unbox_fixnum(v))
|
#define sexp_bytes_set(x, i, v) (sexp_bytes_data(x)[sexp_unbox_fixnum(i)] = sexp_unbox_fixnum(v))
|
||||||
|
|
||||||
#define sexp_lsymbol_data(x) (sexp_field(x, symbol, SEXP_SYMBOL, data))
|
#define sexp_lsymbol_data(x) sexp_flexible_array_field(x, symbol, char)
|
||||||
#define sexp_lsymbol_length(x) (sexp_field(x, symbol, SEXP_SYMBOL, length))
|
#define sexp_lsymbol_length(x) (sexp_field(x, symbol, SEXP_SYMBOL, length))
|
||||||
|
|
||||||
#define sexp_port_stream(p) (sexp_pred_field(p, port, sexp_portp, stream))
|
#define sexp_port_stream(p) (sexp_pred_field(p, port, sexp_portp, stream))
|
||||||
|
@ -1273,7 +1269,7 @@ enum sexp_uniform_vector_type {
|
||||||
#define sexp_bytecode_name(x) (sexp_field(x, bytecode, SEXP_BYTECODE, name))
|
#define sexp_bytecode_name(x) (sexp_field(x, bytecode, SEXP_BYTECODE, name))
|
||||||
#define sexp_bytecode_literals(x) (sexp_field(x, bytecode, SEXP_BYTECODE, literals))
|
#define sexp_bytecode_literals(x) (sexp_field(x, bytecode, SEXP_BYTECODE, literals))
|
||||||
#define sexp_bytecode_source(x) (sexp_field(x, bytecode, SEXP_BYTECODE, source))
|
#define sexp_bytecode_source(x) (sexp_field(x, bytecode, SEXP_BYTECODE, source))
|
||||||
#define sexp_bytecode_data(x) (sexp_field(x, bytecode, SEXP_BYTECODE, data))
|
#define sexp_bytecode_data(x) sexp_flexible_array_field(x, bytecode, unsigned char)
|
||||||
|
|
||||||
#define sexp_env_cell_syntactic_p(x) ((x)->syntacticp)
|
#define sexp_env_cell_syntactic_p(x) ((x)->syntacticp)
|
||||||
|
|
||||||
|
@ -1363,7 +1359,7 @@ enum sexp_uniform_vector_type {
|
||||||
|
|
||||||
#define sexp_stack_length(x) (sexp_field(x, stack, SEXP_STACK, length))
|
#define sexp_stack_length(x) (sexp_field(x, stack, SEXP_STACK, length))
|
||||||
#define sexp_stack_top(x) (sexp_field(x, stack, SEXP_STACK, top))
|
#define sexp_stack_top(x) (sexp_field(x, stack, SEXP_STACK, top))
|
||||||
#define sexp_stack_data(x) (sexp_field(x, stack, SEXP_STACK, data))
|
#define sexp_stack_data(x) sexp_flexible_array_field(x, stack, sexp)
|
||||||
|
|
||||||
#define sexp_promise_donep(x) (sexp_field(x, promise, SEXP_PROMISE, donep))
|
#define sexp_promise_donep(x) (sexp_field(x, promise, SEXP_PROMISE, donep))
|
||||||
#define sexp_promise_value(x) (sexp_field(x, promise, SEXP_PROMISE, value))
|
#define sexp_promise_value(x) (sexp_field(x, promise, SEXP_PROMISE, value))
|
||||||
|
@ -1508,7 +1504,7 @@ SEXP_API sexp sexp_symbol_table[SEXP_SYMBOL_TABLE_SIZE];
|
||||||
|
|
||||||
#define sexp_bignum_sign(x) (sexp_field(x, bignum, SEXP_BIGNUM, sign))
|
#define sexp_bignum_sign(x) (sexp_field(x, bignum, SEXP_BIGNUM, sign))
|
||||||
#define sexp_bignum_length(x) (sexp_field(x, bignum, SEXP_BIGNUM, length))
|
#define sexp_bignum_length(x) (sexp_field(x, bignum, SEXP_BIGNUM, length))
|
||||||
#define sexp_bignum_data(x) (sexp_field(x, bignum, SEXP_BIGNUM, data))
|
#define sexp_bignum_data(x) sexp_flexible_array_field(x, bignum, sexp_uint_t)
|
||||||
|
|
||||||
/****************************** arithmetic ****************************/
|
/****************************** arithmetic ****************************/
|
||||||
|
|
||||||
|
|
4
sexp.c
4
sexp.c
|
@ -264,7 +264,7 @@ static struct sexp_type_struct _sexp_type_specs[] = {
|
||||||
#else
|
#else
|
||||||
{(sexp)"String", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, SEXP_STRING, sexp_offsetof(string, bytes), 1, 1+SEXP_USE_STRING_INDEX_TABLE, 0, 0, sexp_sizeof(string), 0, 0, 0, 0, 0, 0, 0, 0, NULL},
|
{(sexp)"String", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, SEXP_STRING, sexp_offsetof(string, bytes), 1, 1+SEXP_USE_STRING_INDEX_TABLE, 0, 0, sexp_sizeof(string), 0, 0, 0, 0, 0, 0, 0, 0, NULL},
|
||||||
#endif
|
#endif
|
||||||
{(sexp)"Vector", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, SEXP_VECTOR, sexp_offsetof(vector, data), 0, 0, sexp_offsetof(vector, length), 1, sexp_sizeof(vector), sexp_offsetof(vector, length), sizeof(sexp), 0, 0, 0, 0, 0, 0, NULL},
|
{(sexp)"Vector", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, SEXP_VECTOR, sexp_sizeof(vector), 0, 0, sexp_offsetof(vector, length), 1, sexp_sizeof(vector), sexp_offsetof(vector, length), sizeof(sexp), 0, 0, 0, 0, 0, 0, NULL},
|
||||||
{(sexp)"Flonum", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, SEXP_FLONUM, 0, 0, 0, 0, 0, sexp_sizeof(flonum), 0, 0, 0, 0, 0, 0, 0, 0, NULL},
|
{(sexp)"Flonum", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, SEXP_FLONUM, 0, 0, 0, 0, 0, sexp_sizeof(flonum), 0, 0, 0, 0, 0, 0, 0, 0, NULL},
|
||||||
{(sexp)"Bignum", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, SEXP_BIGNUM, 0, 0, 0, 0, 0, sexp_sizeof(bignum), sexp_offsetof(bignum, length), sizeof(sexp_uint_t), 0, 0, 0, 0, 0, 0, NULL},
|
{(sexp)"Bignum", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, SEXP_BIGNUM, 0, 0, 0, 0, 0, sexp_sizeof(bignum), sexp_offsetof(bignum, length), sizeof(sexp_uint_t), 0, 0, 0, 0, 0, 0, NULL},
|
||||||
#if SEXP_USE_STABLE_ABI || SEXP_USE_RATIOS
|
#if SEXP_USE_STABLE_ABI || SEXP_USE_RATIOS
|
||||||
|
@ -297,7 +297,7 @@ static struct sexp_type_struct _sexp_type_specs[] = {
|
||||||
{(sexp)"Set-Syn!", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, (sexp)sexp_write_simple_object, NULL, NULL, SEXP_SET_SYN, sexp_offsetof(set_syn, var), 3, 3, 0, 0, sexp_sizeof(set_syn), 0, 0, 0, 0, 0, 0, 0, 0, NULL},
|
{(sexp)"Set-Syn!", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, (sexp)sexp_write_simple_object, NULL, NULL, SEXP_SET_SYN, sexp_offsetof(set_syn, var), 3, 3, 0, 0, sexp_sizeof(set_syn), 0, 0, 0, 0, 0, 0, 0, 0, NULL},
|
||||||
{(sexp)"Seq", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, (sexp)sexp_write_simple_object, NULL, NULL, SEXP_SEQ, sexp_offsetof(seq, ls), 2, 2, 0, 0, sexp_sizeof(seq), 0, 0, 0, 0, 0, 0, 0, 0, NULL},
|
{(sexp)"Seq", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, (sexp)sexp_write_simple_object, NULL, NULL, SEXP_SEQ, sexp_offsetof(seq, ls), 2, 2, 0, 0, sexp_sizeof(seq), 0, 0, 0, 0, 0, 0, 0, 0, NULL},
|
||||||
{(sexp)"Lit", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, (sexp)sexp_write_simple_object, NULL, NULL, SEXP_LIT, sexp_offsetof(lit, value), 2, 2, 0, 0, sexp_sizeof(lit), 0, 0, 0, 0, 0, 0, 0, 0, NULL},
|
{(sexp)"Lit", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, (sexp)sexp_write_simple_object, NULL, NULL, SEXP_LIT, sexp_offsetof(lit, value), 2, 2, 0, 0, sexp_sizeof(lit), 0, 0, 0, 0, 0, 0, 0, 0, NULL},
|
||||||
{(sexp)"Stack", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, SEXP_STACK, sexp_offsetof(stack, data), 0, 0, sexp_offsetof(stack, top), 1, sexp_sizeof(stack), offsetof(struct sexp_struct, value.stack.length), sizeof(sexp), 0, 0, 0, 0, 0, 0, NULL},
|
{(sexp)"Stack", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, SEXP_STACK, sexp_sizeof(stack), 0, 0, sexp_offsetof(stack, top), 1, sexp_sizeof(stack), offsetof(struct sexp_struct, value.stack.length), sizeof(sexp), 0, 0, 0, 0, 0, 0, NULL},
|
||||||
{(sexp)"Context", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, SEXP_CONTEXT, sexp_offsetof(context, stack), 12+(SEXP_USE_STABLE_ABI||SEXP_USE_DL), 12+(SEXP_USE_STABLE_ABI||SEXP_USE_DL), 0, 0, sexp_sizeof(context), 0, 0, 0, 0, 0, 0, 0, 0, NULL},
|
{(sexp)"Context", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, SEXP_CONTEXT, sexp_offsetof(context, stack), 12+(SEXP_USE_STABLE_ABI||SEXP_USE_DL), 12+(SEXP_USE_STABLE_ABI||SEXP_USE_DL), 0, 0, sexp_sizeof(context), 0, 0, 0, 0, 0, 0, 0, 0, NULL},
|
||||||
{(sexp)"Cpointer", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, SEXP_CPOINTER, sexp_offsetof(cpointer, parent), 1, 0, 0, 0, sexp_sizeof(cpointer), sexp_offsetof(cpointer, length), 1, 0, 0, 0, 0, 0, 0, NULL},
|
{(sexp)"Cpointer", SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, SEXP_FALSE, NULL, NULL, NULL, SEXP_CPOINTER, sexp_offsetof(cpointer, parent), 1, 0, 0, 0, sexp_sizeof(cpointer), sexp_offsetof(cpointer, length), 1, 0, 0, 0, 0, 0, 0, NULL},
|
||||||
#if SEXP_USE_STABLE_ABI || SEXP_USE_UNIFORM_VECTOR_LITERALS
|
#if SEXP_USE_STABLE_ABI || SEXP_USE_UNIFORM_VECTOR_LITERALS
|
||||||
|
|
Loading…
Add table
Reference in a new issue