diff options
| author | Keith Packard <keithp@keithp.com> | 2017-12-12 15:25:51 -0800 | 
|---|---|---|
| committer | Keith Packard <keithp@keithp.com> | 2017-12-12 15:25:51 -0800 | 
| commit | d8c9024f3829dc3f241b16869f165f3ee01764f3 (patch) | |
| tree | ee3038984838551412feeeee5e56c22afe83a99b /src/scheme/ao_scheme_poly.c | |
| parent | a15166c435f65cb36f487ec8e5a4ff558a7e0502 (diff) | |
altos/scheme: Support scheme subsetting via feature settings
This provides for the creation of smaller versions of the interpreter,
leaving out options like floating point numbers and vectors.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/scheme/ao_scheme_poly.c')
| -rw-r--r-- | src/scheme/ao_scheme_poly.c | 33 | 
1 files changed, 20 insertions, 13 deletions
| diff --git a/src/scheme/ao_scheme_poly.c b/src/scheme/ao_scheme_poly.c index 553585db..0bb427b9 100644 --- a/src/scheme/ao_scheme_poly.c +++ b/src/scheme/ao_scheme_poly.c @@ -60,18 +60,33 @@ static const struct ao_scheme_funcs ao_scheme_funcs[AO_SCHEME_NUM_TYPE] = {  		.write = ao_scheme_bool_write,  		.display = ao_scheme_bool_write,  	}, +#ifdef AO_SCHEME_FEATURE_BIGINT  	[AO_SCHEME_BIGINT] = {  		.write = ao_scheme_bigint_write,  		.display = ao_scheme_bigint_write,  	}, +#endif +#ifdef AO_SCHEME_FEATURE_FLOAT  	[AO_SCHEME_FLOAT] = {  		.write = ao_scheme_float_write,  		.display = ao_scheme_float_write,  	}, +#endif +#ifdef AO_SCHEME_FEATURE_VECTOR  	[AO_SCHEME_VECTOR] = {  		.write = ao_scheme_vector_write,  		.display = ao_scheme_vector_display  	}, +#endif +}; + +static void ao_scheme_invalid_write(ao_poly p) { +	printf("??? 0x%04x ???", p); +} + +static const struct ao_scheme_funcs ao_scheme_invalid_funcs = { +	.write = ao_scheme_invalid_write, +	.display = ao_scheme_invalid_write,  };  static const struct ao_scheme_funcs * @@ -81,25 +96,17 @@ funcs(ao_poly p)  	if (type < AO_SCHEME_NUM_TYPE)  		return &ao_scheme_funcs[type]; -	return NULL; +	return &ao_scheme_invalid_funcs;  } -void -ao_scheme_poly_write(ao_poly p) +void (*ao_scheme_poly_write_func(ao_poly p))(ao_poly p)  { -	const struct ao_scheme_funcs *f = funcs(p); - -	if (f && f->write) -		f->write(p); +	return funcs(p)->write;  } -void -ao_scheme_poly_display(ao_poly p) +void (*ao_scheme_poly_display_func(ao_poly p))(ao_poly p)  { -	const struct ao_scheme_funcs *f = funcs(p); - -	if (f && f->display) -		f->display(p); +	return funcs(p)->display;  }  void * | 
