diff options
author | Keith Packard <keithp@keithp.com> | 2018-01-06 17:29:10 -0800 |
---|---|---|
committer | Keith Packard <keithp@keithp.com> | 2018-01-06 17:31:43 -0800 |
commit | 16061947d4376b41e596d87f97ec53ec29d17644 (patch) | |
tree | f7ad08f8810b0ea78cf282048eacb46d441a2ee1 /src/scheme/tiny-test | |
parent | 39df849f0717d92a7d5bdf8aa5904bd4db1b467f (diff) |
altos/scheme: Add ports. Split scheme code up.
And lots of other changes, including freeing unreferenced atoms.
Signed-off-by: Keith Packard <keithp@keithp.com>
Diffstat (limited to 'src/scheme/tiny-test')
-rw-r--r-- | src/scheme/tiny-test/Makefile | 6 | ||||
-rw-r--r-- | src/scheme/tiny-test/ao_scheme_os.h | 14 | ||||
-rw-r--r-- | src/scheme/tiny-test/ao_scheme_test.c | 35 |
3 files changed, 9 insertions, 46 deletions
diff --git a/src/scheme/tiny-test/Makefile b/src/scheme/tiny-test/Makefile index 6b1fe003..ca71a665 100644 --- a/src/scheme/tiny-test/Makefile +++ b/src/scheme/tiny-test/Makefile @@ -3,6 +3,8 @@ include ../Makefile-inc vpath %.o . vpath %.c .. vpath %.h .. +vpath %.scheme .. +vpath ao_scheme_make_const ../make-const DEFS= @@ -18,8 +20,8 @@ ao-scheme-tiny: $(OBJS) $(OBJS): $(HDRS) -ao_scheme_const.h: ../make-const/ao_scheme_make_const ao_scheme_tiny_const.scheme - ../make-const/ao_scheme_make_const -o $@ -d FLOAT,VECTOR,QUASI,BIGINT ao_scheme_tiny_const.scheme +ao_scheme_const.h: ao_scheme_make_const ao_scheme_basic_syntax.scheme ao_scheme_finish.scheme + $^ -o $@ -d FLOAT,VECTOR,QUASI,BIGINT,PORT,POSIX,GPIO,UNDEF clean:: rm -f $(OBJS) ao-scheme-tiny ao_scheme_const.h diff --git a/src/scheme/tiny-test/ao_scheme_os.h b/src/scheme/tiny-test/ao_scheme_os.h index b9f3e31f..17d66ae3 100644 --- a/src/scheme/tiny-test/ao_scheme_os.h +++ b/src/scheme/tiny-test/ao_scheme_os.h @@ -23,14 +23,6 @@ #include <time.h> #define AO_SCHEME_POOL_TOTAL 4096 -#define AO_SCHEME_SAVE 1 - -extern int ao_scheme_getc(void); - -static inline void -ao_scheme_os_flush(void) { - fflush(stdout); -} static inline void ao_scheme_abort(void) @@ -38,12 +30,6 @@ ao_scheme_abort(void) abort(); } -static inline void -ao_scheme_os_led(int led) -{ - printf("leds set to 0x%x\n", led); -} - #define AO_SCHEME_JIFFIES_PER_SECOND 100 static inline void diff --git a/src/scheme/tiny-test/ao_scheme_test.c b/src/scheme/tiny-test/ao_scheme_test.c index 45068369..89b8e5fa 100644 --- a/src/scheme/tiny-test/ao_scheme_test.c +++ b/src/scheme/tiny-test/ao_scheme_test.c @@ -15,9 +15,6 @@ #include "ao_scheme.h" #include <stdio.h> -static FILE *ao_scheme_file; -static int newline = 1; - static char save_file[] = "scheme.image"; int @@ -70,42 +67,20 @@ ao_scheme_os_restore(void) } int -ao_scheme_getc(void) -{ - int c; - - if (ao_scheme_file) - return getc(ao_scheme_file); - - if (newline) { - if (ao_scheme_read_list) - printf("+ "); - else - printf("> "); - newline = 0; - } - c = getchar(); - if (c == '\n') - newline = 1; - return c; -} - -int main (int argc, char **argv) { (void) argc; while (*++argv) { - ao_scheme_file = fopen(*argv, "r"); - if (!ao_scheme_file) { + FILE *in = fopen(*argv, "r"); + if (!in) { perror(*argv); exit(1); } - ao_scheme_read_eval_print(); - fclose(ao_scheme_file); - ao_scheme_file = NULL; + ao_scheme_read_eval_print(in, stdout, false); + fclose(in); } - ao_scheme_read_eval_print(); + ao_scheme_read_eval_print(stdin, stdout, true); #ifdef DBG_MEM_STATS printf ("collects: full: %lu incremental %lu\n", |