Jan Nieuwenhuizen
c4fe110d1e
core: Remove make_char.
...
* mes.c (MAKE_CHAR): New macro.
(make_char): Remove. Update callers.
* reader.c (peek_char, read_char, unread_char): Remove.
* module/mes/scm.mes (peek-char, read-char, unread-char): New function.
2016-12-23 16:26:00 +01:00
Jan Nieuwenhuizen
c2bfeffe96
core: Remove make_number.
...
* mes.c (MAKE_NUMBER): New macro.
(tmp_num_, tmp_num_2): New function.
(make_number): Remove. Update callers.
2016-12-23 16:22:19 +01:00
Jan Nieuwenhuizen
c2a12c4f34
Remove make_function.
...
* mes.c (make_function): Remove.
2016-12-23 16:02:36 +01:00
Jan Nieuwenhuizen
89e78bec77
core: Remove make_keyword.
...
* mes.c (make_keyword): Remove.
* module/mes/read-0.mes (<cell:keyword>): New global.
(read-word): Use it with make_cell instead fo make-keyword.
* strting.c (symbol_to_keyword): Use make_cell instead of make_keyword.
2016-12-23 15:53:57 +01:00
Jan Nieuwenhuizen
976c86318e
core: Remove make_macro.
...
* module/mes/read-0.mes (<macro>): New global.
(env:macro): Use it with make_cell instead of make_macro.
* mes.c (make_macro): Remove.
* type.c (car_): Rename from mes_car.
(cdr_): Rename from mes_cdr.
2016-12-23 15:47:52 +01:00
Jan Nieuwenhuizen
18ba10e2ae
core: Simplify lookup.
...
* reader.c (lookup_): Rename from lookup. Remove all lookups except
for numbers and symbols. Update callers.
* mes.c (make_symbol_): Rename from internal_make_symbol. Update
callers.
* module/mes/read-0.mes (lookup): New function.
(read-word): Remove all lookup calls, except for numbers and symbols.
2016-12-23 11:31:34 +01:00
Jan Nieuwenhuizen
aa0aaa58ab
core: Cleanup symbol initialization and lookup.
...
* build-aux/mes-snarf.scm (symbol->names): New function
(function->environment): Initialize symbol.
(generate-includes): Also write .symbol-names.i.
* mes.c (mes_symbols): Include it. Remove internal_lookup_symbol.
* display.c (display): Handle display of nil in symbol list.
* reader.c (internal_lookup_symbol): Remove name-fu.
2016-12-23 10:38:41 +01:00
Jan Nieuwenhuizen
ddfaa05149
core: Remove most of reader.
...
* reader.c (append_char, read_block_comment, read_character, read_hex,
read_string): Remove.
(eat_whitespace, read_word)[READER]: Remove.
* mes.c (list_to_symbol): New function.
* module/mes/read-0.mes (list->symbol, read-character, read-hex,
read-string): New functions.
2016-12-22 23:42:28 +01:00
Jan Nieuwenhuizen
b45a3b6f33
core: Disable reader.
...
* mes.c (READER): Switch off.
* module/mes/read-0.mes (eat-whitespace): Handle #;.
2016-12-22 21:23:49 +01:00
Jan Nieuwenhuizen
570eec966e
core: Do some tail call elimination.
...
* mes.c (eval_apply): Use goto instead of return.
2016-12-22 16:50:51 +01:00
Jan Nieuwenhuizen
471bdb0af4
core: One big eval_apply.
...
* mes.c (eval_apply): New function.
(eval_apply_t): New type.
(g_target): New global.
(vm_evlis, vm_apply_env, vm_eval_env, vm_expand_macro_env,
vm_begin_env, vm_if_env, vm_call_with_values_env): Remove. Update callers.
(macro_expand_env): Rename from expand_macro_env.
* guile/mes.mes: Update callers.
* module/mes/base-0.mes: Likewise.
* module/mes/mes-0.mes: Likewise.
* module/mes/psyntax-1.mes: Likewise.
* module/mes/repl.mes: Likewise.
2016-12-22 16:34:28 +01:00
Jan Nieuwenhuizen
cc58cf2e04
core: Remove vm_call_lambda.
...
* mes.c (vm_call_lambda): Remove.
(call_lambda): Use begin_env.
2016-12-22 16:16:09 +01:00
Jan Nieuwenhuizen
8256f2638e
core: Remove quasiquote, quasisyntax.
...
* quasiquote.c: Remove.
* mes.c: Remove callers.
* GNUmakefile (mes.o): Remove dependency on quasiquote.
2016-12-22 15:41:43 +01:00
Jan Nieuwenhuizen
527fd253eb
core: Disable quasiquote.
...
* mes.c (QUASIQUOTE): Switch off.
* tests/read.test: Remove quasiquote tests.
2016-12-22 15:36:29 +01:00
Jan Nieuwenhuizen
6854627391
core: Bugfix append with one argument.
...
* mes.c (append): Handle one argument.
* tests/base.test ("append", "append 0" ... "append 5"): New tests.
2016-12-22 14:22:40 +01:00
Jan Nieuwenhuizen
681a541774
core: Do macro expansion only once.
...
* mes.c (vm_eval_env): I will expand this macro only once.
2016-12-22 08:31:20 +01:00
Jan Nieuwenhuizen
7bf25a7e17
core: Remove define.
...
* base-0.mes (cons*): Refactor.
* module/mes/read-0.mes: Implement define, define-macro using macros.
* define.c: Remove.
* mes.c: Remove callers.
* GNUmakefile (mes.o): Remove dependency on define.
2016-12-21 22:22:34 +01:00
Jan Nieuwenhuizen
23754e6f75
core: Bugfix unread_byte.
...
* mes.c (unread_byte): Return SCM value instead of stray int.
2016-12-20 22:28:29 +01:00
Jan Nieuwenhuizen
15eabee623
Resurrect quasisyntax support.
...
* mes.c (the_unsyntaxers): New symbol.
(mes_builtins)[QUASISYNTAX]: Initialize it, add to environment.
* quasiquote.c (add_unsyntaxers): Use it.
(vm_eval_quasisyntax): New function.
(eval_quasisyntax): Use it.
2016-12-16 15:10:03 +01:00
Jan Nieuwenhuizen
89f771f18a
Support #\alarm, #\vtab.
...
* mes.c (char_alarm): New variable.
(char_vtab): Rename from char_vt.
* reader.c (read_character): Add alarm, update vtab.
* display.c (display): Likewise.
* module/language/c/lexer.mes (read-string): Use vtab.
2016-12-18 15:21:05 +01:00
Jan Nieuwenhuizen
bbeb4708e5
Support => in cond.
...
* module/mes/base-0.mes (cond): Support =>.
* module/mes/rea-0.mes (cond): Update.
* NEWS: Update.
2016-12-16 20:18:38 +01:00
Jan Nieuwenhuizen
46a617f16e
core: Support keywords.
...
* display.c (display): Handle keyword.
* mes.c (type_t): Add KEYWORD.
(eq_p): Handle it.
(make_keyword): New function.
* reader.c (lookup): Use it.
* type.c (keyword_p): New function.
* NEWS: Update.
2016-12-16 23:30:33 +01:00
Jan Nieuwenhuizen
94d1c65bde
core: Make symbols constants.
...
* mes.c (apply_env,eval_env): Rewrite using switch.
* build-aux/mes-snarf.scm (symbol->header): Define constants.
(symbol->source): Only update g_free and init cells.
2016-12-14 19:02:19 +01:00
Jan Nieuwenhuizen
dd1daf92e4
Extend Scheme reader, reduce C reader dependency.
...
* mes.c (bload_env): Mark as internal.
(load_env): Likewise. Load Scheme reader from source. Remove dumping.
(dump): New function.
* (vm_begin_env): Allow for gc while read_input_file_env.
(mes_builtins): Add *dot*.
(read_input_file_env)[!READER]: Invoke read-input-file.
* module/mes/read-0.mes (read-env): New function.
(read-word): Support quasisyntax.
Remove usage of ' thoughout.
* module/mes/repl.mes (repl): Use read instead of read-env.
* guile/mes.scm (environment): Add *dot*.
* guile/reader.mes: Update.
* NEWS: Update.
2016-12-13 19:58:34 +01:00
Jan Nieuwenhuizen
90e5f16ef9
Release 0.3.
...
* configure (VERSION): Bump to 0.3.
* mes.c (main): Likewise.
* module/mes/repl.mes: Likewise.
2016-12-12 21:00:02 +01:00
Jan Nieuwenhuizen
3a72f1f186
core: Resurrect QUASIQUOTE=0.
...
* mes.c (mes_builtins) [!QUASIQUOTE]: Do not add unquoters.
* module/mes/base-0.mes (push!, pop!, load, mes-use-module): Rewrite
without quasiquote.
* module/mes/quasiquote.mes (quasiquote): Rewrite using if, and.
* module/srfi/srfi-0 (cond-expand): Rewrite without quasiquote.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
2b577eaee0
Add loadable modules.
...
* module/mes/base-0.mes (mes-use-module): Implement.
* module/mes: Update users.
* HACKING: Update.
* NEWS: Update.
* configure (main): Use shell expansion for prefix.
* make/install.make (install): Substitute prefix.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
b92a8f17f8
core: use FIXED_PRIMITIVES rather than environment cache.
...
* cache.c: Remove.
* define.c: Remove callers.
* mes.c: Likewise.
(vm_eval_env) [FIXED_PRIMITIVES]: Hardcode car, cdr, cons, null_p.
* GNUmakefile: Update.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
0a614e6543
core: Set max arena size.
...
* mes.c (MAX_ARENA_SIZE): New global.
(gc): Use it.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
753b63818c
core: Make arena size configurable.
...
* mes.c (main): Read MES_ARENA.
* scripts/repl.mes: Set MES_ARENA to 5000000 if not already set.
Fixes repl startup.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
0bdad95f61
core: Grow gc arena gradually.
...
* mes.c: (gc_up_arena): New function.
(gc): Use it when possible.
(gc_init_cells, gc_init_news): New function.
(mes_symbols): Use them.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
e4e29f00b0
core: gc bugfixes.
...
* mes.c (make_tmps): New function.
(make_symbols, gc): Use it.
(vm_call_with_values_env): New vm function.
(call-with-values): Call it.
(eval_env): Do not call eval_env inline.
* define.c (vm_define_env): Use r2 rather than local name.
(g_symbols): Rename from symbols.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
f26c7222b2
core: Split-off cache, display, reader.
...
* mes.c: Remove cache, display, reader functions.
* cache.c: New file.
* display.c: New file.
* reader.c: New file.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
1614d13439
Add reader in Scheme.
...
* module/mes/read-0.mes: New file.
* mes.c (char_to_integer, integer_to_char, null_p): Move to core.
(peek_byte, read_byte, unread_byte): New function.
(main): --dump, --load: New option.
* lib.c (char_to_integer, integer_to_char): Remove.
* NEWS: Update.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
e6a0257a79
core: Cleanup cells.
...
* mes.c: Use accessors rather than g_cell[] access throughout.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
d50b0fe24a
core: Add function indirection.
...
* mes.c (functions): New array.
(scm_t): Change function pointer to index.
(make_cell): Handle function.
(call): Update for function change.
(display_): Likewise.
(make_function): New function.
* build-aux/mes-snarf.scm (function->source): Update declarations.
(function->environment): New function.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen
61e42e8527
core: Number based cells.
...
* mes.c (scm_t): Change car, string, ref, cdr, macro, vector into g_cell index
[WAS]: scm_t pointer.
* define.c: Update.
* lib.c: Update.
* math.c: Update.
* posix.c: Update.
* quasiquote.c: Update.
* string.c: Update.
* type.c: Update.
* build-aux/mes-snarf.mes Update.
* tests/gc-4.test: New test.
* tests/gc-5.test: New test.
* tests/gc-6.test: New test.
2016-12-12 20:35:18 +01:00
Jan Nieuwenhuizen
25c29ecb6d
core: Integrate garbage collector/jam scraper.
...
* mes.c (r0, r1, r2, r3, stack): New globals.
(gc_loop): Handle MACRO and SCM.
(gc_copy): Handle FUNCTION, allow for pre-allocated SCM and SYMBOL.
(assq): Flag any BROKEN_HEARTs.
(vm_call): New function. Enables moving C stack to GC stack.
(evlis_env, apply_env, eval_env, expand_macro_env, begin_env,
if_env): Use vm_call-indirection.
(call_lambda): New function.
(vm_apply_env): Rename from apply_env. Remove parameters, instead
use r1, r2 and r0.
(vm_evlis_env, vm_eval_env, vm_expand_macro_env, vm_begin_env,
vm_if_env): Likewise.
(acons): New function.
(mes_environment) [!MES_FULL, MES_MINI]: Add cpp switches to create minimally
filled environment, for debugging.
(main): Print free value at exit.
* define.c (define_env): Use vm_call-indirection.
(vm_define_env): Rename from define_env.
* quasiquote.c (eval_quasiquote): Use vm_call-indirection.
(vm_eval_quasiquote): Rename from eval_quasiquote.
* tests/gc-2.test: New test.
tests/gc-2a.test: New test.
tests/gc-3.test: New test.
2016-12-12 20:35:18 +01:00
Jan Nieuwenhuizen
c035a59094
Add sicp garbage example: tests/gc-1.test.
2016-12-12 20:35:18 +01:00
Jan Nieuwenhuizen
f3225a77e2
core: Make using GC in switchable, set to off; on dumps core.
2016-12-12 20:35:18 +01:00
Jan Nieuwenhuizen
99cedbfbde
core: Add garbage collector/jam collector experiment.
...
* mes.c (gc, gc_loop, gc_copy, gc_move, gc_relocate_car,
gc_relocate_cdr, gc_flip): New function.
* tests/gc-0.test: New file.
2016-12-12 20:35:18 +01:00
Jan Nieuwenhuizen
376bb5d62b
Release 0.2.
...
* configure (VERSION): Bump to 0.2.
* mes.c (main): Likewise.
* module/mes/repl.mes: Likewise.
2016-12-12 20:33:50 +01:00
Jan Nieuwenhuizen
07778d3b70
core: Show more info on apply error.
...
* mes.c (apply_env): Be more specific about what cannot be applied.
2016-12-12 20:33:50 +01:00
Jan Nieuwenhuizen
ffd2d3df4f
core: Bugfix: report name of undefined variable.
...
* mes.c (assert_defined): Add variable as parmeter, print it. Update
callers.
2016-12-12 20:33:50 +01:00
Jan Nieuwenhuizen
6c70e92276
core: Use switch in display_helper.
...
*mes (display_helper): Use switch.
2016-12-12 20:33:50 +01:00
Jan Nieuwenhuizen
a0709313ca
core: Refactor eval.
...
* mes.c (eval_env): Rename from builtin_eval, Update callers. Use switch.
2016-12-12 20:33:50 +01:00
Jan Nieuwenhuizen
7e8341d76c
core: One SCM type for function.
...
* mes.c (function_t): New struct.
(type): One type for function.
(call): Refactor.
* build-aux/mes-snarf.mes: Use arity annotation. WAS: args. Update
annotations.
2016-12-12 20:33:50 +01:00
Jan Nieuwenhuizen
0eda7383f2
core: Cleanup macro expansion.
...
* mes.c (builtin_eval): Call expand_macro_env after handling primitives.
(expand_macro_env): Include syntax-case expansion, remove skipping
of primitives.
(sc_expand_env): Remove.
2016-12-12 20:33:50 +01:00
Jan Nieuwenhuizen
bcd6cd9dcc
core: Factor-out assert_defined.
...
* mes.c (assert_defined): New function.
(set_env_x): Use it.
(builtin_eval): Use it.
2016-12-12 20:33:50 +01:00
Jan Nieuwenhuizen
97300ef6ae
Implement load.
...
* mes.c (symbol_primitive_load): New symbol.
(builtin_eval): Use it to implement primitive-load.
* module/mes/base-0.mes (push!, pop!): New macro.
(load): New macro.
* tests/data/load.scm: New file.
* tests/base.test (load): New test.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
70bdab7090
posix: Implement open-input-file.
...
* posix.c: New file.
* mes.c: Include posix.environment.h, posix.environment.i, posix.environment.c.
(read_input_file_env): Rename from read_file_env. Update
callers.
(load_env): Rename from load_file_env. Update callers.
* GNUmakefile (mes.o): Add posix.c, posix.environment.h,
posix.environment.i dependencies.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
1e2e2f2a4a
core: Support switching of input stream.
...
* mes.c (g_stdin): New global.
(getchar): New function, use g_stdin.
(ungetchar): Use g_stdin.
(main): Initialize g_stdin to stdin.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
2b373ff40f
Finalize psyntax integration.
...
* mes.c (sc_expand_env): Exclude primitives, expand native macros.
(symbol_expand_macro): New symbol.
* module/mes/psyntax-0.mes (properties-alist): New function.
* module/mes/psyntax-1.mes: Set expand-macro.
(define-syntax, syntax-rules, let-syntax): Remove macro.
* module/language/c/parser.mes: Use psyntax modules, remove syntax module.
* module/language/paren.mes: Likewise.
* scripts/repl.mes: Likewise.
* tests/match.test: Likewise.
* tests/record.test: Likewise.
* tests/psyntax.test (define-syntax swap!): Add test.
* module/mes/let-syntax.mes: Remove.
* module/mes/syntax.mes: Remove.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
c851935d4d
core: Quoted internals are symbols.
...
* mes.c (begin_env): Rename from begin. Update callers.
(scm_begin, scm_if, scm_define, scm_set_x): Rename from symbol_*.
(symbol_begin, symbol_define, symbol_if, scm_lambda, scm_set_x): New symbols.
(mes_environment): Add them to environment, SYMBOL->SCM.
* define.c (define_env): Rename from define. Update callers.
* build-aux/mes-snarf.scm: Shadow internals (SCM) by their symbol.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
f1ae9edd0d
core: Fix quasisyntax reading.
...
* mes.c (readword): Avoid unspecified behaviour in comma list.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
d18542e25f
Initial psyntax integration.
...
* mes.c (sc_expand_env): New function.
(builtin_eval): Use it.
* module/mes/psyntax-0.mes: New file.
* module/mes/psyntax-1.mes: New file.
* tests/psyntax.test: New file.
* GNUmakefile (TESTS): Add it.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
d34dba24f2
core: Add compile time switch for quasisyntax.
...
* mes.c [QUASISYNTAX]: New switch. Default off.
(builtin_eval) [QUASISYNTAX]: Handle syntax, unsyntax, quasisyntax.
* quasiquote.c (syntax, unsyntax, unsyntax_splicing, eval_quasisyntax,
add_unsyntaxers) [QUASISYNTAX]: Available only.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
ad717d4bba
More error handling on apply_env.
...
* mes.c (apply_env): Assert if applying *unspecified*.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
332d2655cf
Bugfix assq_ref_cache for running without environment cache.
...
* mes.c (assq_ref_cache) [!ENV_CACHE]: Return *undefined* if nothing
found.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
2cad00527e
Error handling on failing set!.
...
* mes.c (set_env_x): Produce error message [WAS: dump core].
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
3b4e9f36c8
Simplify toplevel read.
...
* mes.c (read_file_env): Rename from read_file.
(load_file_env): New function.
(main): Use it.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
1f511481a3
Fix values.
...
* mes.c (call): Respect any other non-value arguments.
* tests/scm.test (values, values 2, values 3, call-with-values): New test.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
f593a5c9d7
Define garbage collector/jam collector primitives.
...
* mes.c (make_cell): New primitive alongside make_vector for allocation.
(cons, make_char, make_macro, make_number, make_ref,
internal_make_symbol, make_vector): Use it.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen
16f678a158
Implement strings and symbols as list of characters [WAS: c-string].
...
* mes.c (scm_t): Add string field.
(make_string, internal_lookup_symbol, internal_make_symbol,
make_symbol, lookup, readword): Take scm*. Update callers.
(display_helper): Support string field.
(append_char): New function.
(readstring): Use it. Produce scm*.
(cstring_to_list): New function.
(add_environment, internal_make_symbol): Use it.
(list_of_char_equal_p): New function.
(internal_lookup_symbol): Use it.
* lib.c (list_ref): New function.
* string.c (string_ref): Use it.
(string, string_append, string_length, substring, number_to_string,
string_to_symbol, symbol_to_string): Update to list-of-characters
implementation.
2016-12-12 20:33:48 +01:00
Jan Nieuwenhuizen
d209a18121
Introduce reference type, use vectors of SCM.
...
* mes.c (type): Add REF.
(scm_t): Add ref, change vector to *scm_t. Update users.
(alloc): New function.
(cons, make_char, make_macro, make_number, make_string,
internal_make_symbol, make_vector): Use it.
(make_ref): New function.
(vector_entry): New function.
(make_vector, list_to_vector, vector_set_x): Use it.
(vector_ref): Dereference REF entry.
(display_helper): Handle REF.
* lib.c (vector_to_list): Handle REF.
* type.c (ref_p): New function.
* tests/vector.test (vector list): New test.
Bugfix vector-ref.
* mes.c (vector-ref): Make copies of simple values. Fixes lalr.
* tests/vector.test (vector-set! 3): New test.
2016-12-12 20:33:48 +01:00
Jan Nieuwenhuizen
3849c48f79
Release 0.1.
...
* configure (VERSION): Bump to 0.1.
* mes.c (main): Likewise.
* module/mes/repl.mes: Likewise.
2016-11-20 21:47:47 +01:00
Jan Nieuwenhuizen
2823fca025
Avoid gratuitous consing with begin and quasiquote.
...
* mes.c (apply_env, main): Call begin rather than eval with cons'ed
symbol begin.
* module/mes/mes-0.mes (apply-env): Likewise.
* quasiquote.c (add_unquoters): cons global unquoters rather than
creating it fresh.
* module/mes/mes-0.mes (add-unquoters): Likewise.
2016-10-23 10:08:04 +02:00
Jan Nieuwenhuizen
011102bc12
Remove dead code.
...
* mes.c (mes_environment): Remove dead code.
2016-10-22 20:58:33 +02:00
Jan Nieuwenhuizen
6a4395869b
Move other post-boot and derived functions to lib.c.
...
* mes.c (c*r, length, last_pair, builtin_list, vector_to_list,
integer_to_char, char_to_integer, builtin_exit): Move to lib.c.
* lib.c: New file.
* GNUmakefile (mes.o): Depend on lib snarf output.
2016-10-22 20:51:32 +02:00
Jan Nieuwenhuizen
e282117de9
Move strings to string.c.
...
* mes.c (string, string_append, list_to_string, string_length,
string_ref, substring, number_to_string, string_to_symbol,
symbol_to_string): Move to string.c
* string.c: New file.
* GNUmakefile (mes.o): Depend on string snarf output.
2016-10-22 20:18:03 +02:00
Jan Nieuwenhuizen
be2f3bc274
Move arithmetic functions to math.c.
...
* mes.c (greater_p, less_p, is_p, minus, divide, modulo, multiply,
logior): Move to math.c.
* math.c: New file.
* GNUmakefile (mes.o): Depend on math snarf output.
2016-10-22 20:07:12 +02:00
Jan Nieuwenhuizen
27247383d7
Move define, define-macro to define.c.
...
* mes.c (define, define-macro): Move to define.c
* define.c: New file.
* GNUmakefile (mes.o): Depend on define snarf output.
2016-10-22 19:36:54 +02:00
Jan Nieuwenhuizen
bd7beddcda
Move quasiquote to quasiquote.c.
...
* mes.c (unquote, unquote_splicing, syntax, unsyntax,
unsyntax_splicing, eval_quasiquote, eval_quasisyntax, add_unquoters,
add_unsyntaxers): Move to quasiquote.c
* quasiquote.c: New file.
* GNUmakefile (mes.o): Depend on quasiquote snarf output.
2016-10-22 19:26:12 +02:00
Jan Nieuwenhuizen
2586f0bb2c
Move optional type predicates to type.c.
...
* mes.c (char_p, macro_p, number_p, pair_p, string_p, symbol_p,
vector_p, builtin_p, boolean_p): Move to type.c
* type.c: New file.
* GNUmakefile (mes.o): Depend on type snarf output.
* module/mes/loop-0.mes (cond, map, let, or, and not, evlis-env,
apply-env, eval-expand, uquote, add-unquoters, eval,
expand-macro-env, eval-begin-env, eval-if-env, sexp:define,
env:define, env:macro): Move to mes-0.mes.
* module/mes/mes-0.mes: New file.
* module/mes/type-0.mes: New file.
* scripts/include.mes: If BOOT, also include mes-0.mes. If TYPE0,
also include type-0.mes.
2016-10-22 12:16:19 +02:00
Jan Nieuwenhuizen
3e03a12a4d
Generate C header and includes using snarfing.
...
* mes.c: Move specific renames and n-args to alist annotation.
* build-aux/mes-snarf.scm: New file.
* GNUmakefile (mes.environment.h): Use it.
(mes.h): Remove.
(clean): Update.
(mes.o): New dependency rule.
* .gitignore: Update.
2016-10-21 22:44:50 +02:00
Jan Nieuwenhuizen
18aa0beaa9
Revert "Flip sign of cached symbols: only search cache if symbol is cached."
...
This reverts commit cef058be0d6ef5322f74e644bbcd96f1725c6327.
2016-10-22 18:13:37 +02:00
Jan Nieuwenhuizen
1684564ea1
Flip sign of cached symbols: only search cache if symbol is cached.
...
* mes.c (cache_save): Flip sign when caching and invalidating.
(cache_invalidate): Flip sign when invalidating.
2016-10-21 20:44:18 +02:00
Jan Nieuwenhuizen
2545605a69
Environment cache heuristicts.
...
* mes.c (ENV_HEAD): New define.
(assq_ref_cache): Use it.
2016-10-21 10:43:32 +02:00
Jan Nieuwenhuizen
46eca44fb4
boot: vector support.
...
* mes.c (make_vector): Change to scm interface.
(temp_number): New global.
(list_to_vector): Use it.
* module/mes/scm.mes (c:make-vector): New function.
* tests/scm.test: Remove vector tests.
* tests/vector.test: New file.
* GNUmakefile (TESTS): Add it.
2016-10-21 10:51:09 +02:00
Jan Nieuwenhuizen
c8e87f3021
Switch fat-c/boot using environment variable BOOT.
...
* GNUmakefile: check for BOOT, set CFLAGS.
* mes.c: Remove hardcoded BOOT define.
* scripts/include.mes: include loop-0 when BOOT is set.
2016-10-20 22:03:17 +02:00
Jan Nieuwenhuizen
1d0cbcd59c
Reduce eval/apply in core, extend in Scheme.
...
* mes.c (eval_env_)[BOOT]: Rename from eval_env. Remove define, defin-macro.
(eval_env): New function.
(make_macro): Swap parameter ordering.
(apply_env)[BOOT]: Support label.
2016-10-20 18:43:33 +02:00
Jan Nieuwenhuizen
1e62bbf8c9
Avoid adding top of environment to cache.
...
* mes.c (assq_ref_cache): Only consider caching symbols deeper than
4*CACHE_SIZE depth. 50% speedup.
2016-10-20 00:21:06 +02:00
Jan Nieuwenhuizen
7885096526
Implement environment cache.
...
* mes.c (cache_save, cache_lookup, cache_invalidate,
cache_invalidate_range): Implement cache for environment.
(assq_ref_cache): New function, perform cached lookups.
(builtin_eval,lookup_macro): Use it.
(set_cdr_x): Invalidate cache.
(set_x): Likewise.
(apply_env): Likewise.
2016-10-20 00:11:48 +02:00
Jan Nieuwenhuizen
d1b8f0ff0c
Introduce SCM type for special symbols.
...
* GNUmakefile (mes.h): Also export SCM to symbols.i
* mes.c: Introduce SCM type for special symbols.
(builtin_eval): Rename from eval_env. Update callers.
* module/mes/base-0.mes (eval): Remove.
* module/mes/repl.mes (repl): Use eval.
2016-10-20 19:19:32 +02:00
Jan Nieuwenhuizen
cdd903054c
Remove static primitives hack.
...
* mes.c (internal_primitive_p, internal_p, lookup_primitive,
mes_primitives): Remove.
2016-10-20 09:37:14 +02:00
Jan Nieuwenhuizen
9c986748e1
Refactor primitives lookup.
...
* mes.c (lookup_primitive_): Rename from internal_lookup_primitive,
use scm-compatible signature.
(lookup): Update caller.
(eval_env): Check for builtins first.
2016-10-19 07:22:15 +02:00
Jan Nieuwenhuizen
035b0a8d5d
Remove unused symbol.
...
* mes.c (symbol_cond): Remove.
2016-10-18 20:05:51 +02:00
Jan Nieuwenhuizen
2a8d3c57b7
Differentiate apply asserts.
...
* mes.c (apply_env): Split bool assert into bool, number and string.
2016-10-18 09:21:49 +02:00
Jan Nieuwenhuizen
b9bbac3d0c
Add display tag for builtin procedures.
...
* mes.c (display_helper): Show builtin functions as #<procedure ...>.
2016-10-18 09:08:42 +02:00
Jan Nieuwenhuizen
0eae7674b6
Remove macro expansion from apply.
...
mes.c (apply_env): Remove macro expansion.
2016-10-17 18:26:07 +02:00
Jan Nieuwenhuizen
ac4b1eed3f
Add --help, --version.
...
* mes.c (main): Handle --help, --version.
* scripts/include.mes: Handle --help.
* scripts/elf.mes: Pass any arguments on to mes.
* scripts/mescc.mes: Likewise.
* scripts/paren.mes: Likewise.
* scripts/repl.mes: Likewise.
2016-10-19 00:36:12 +02:00
Jan Nieuwenhuizen
bd2b81755a
Remove evcon (Sorry John).
...
* mes.c (evcon): Remove, remove callers.
* base0-if.mes (cond): Rename from disabled-cond.
2016-10-15 11:56:18 +02:00
Jan Nieuwenhuizen
83970245e5
Support quasisyntax.
...
* mes.c (eval_quasisyntax, add_unsyntaxers): New functions.
(eval_env): Use them.
2016-10-16 01:41:07 +02:00
Jan Nieuwenhuizen
2715e241e5
Add REPL.
...
* mes.c (expand_macro_env, force_output): New function. Use STRING_MAX
for string buffers throughout. (eval_env, eval_begin_env): Rename
from eval, eval_begin. Update callers.
* repl.mes: New file.
* base.mes (list?): Move from scm.mes.
* scm.mes (eval, apply, primitive-eval, expand-macro): New function.
* GNUmakefile: New repl target.
2016-10-16 09:44:52 +02:00
Jan Nieuwenhuizen
422b6e6ce9
Avoid 90% of cdr'ing environment, assuming static primitives.
...
* mes.c (internal_primitive_p)[STATIC_PRIMITIVES: New function.
(lookup_macro)[STATIC_PRIMITIVES]: Use it.
(internal_lookup_primitive)[STATIC_PRIMITIVES]: New function.
(lookup)[STATIC_PRIMITIVES]: Use it.
(mes_primitives)[STATIC_PRIMITIVES]: New function.
(main): Use it.
* base0-if.mes (disabled-cond): Rename from xcond.
* GNUmakefile: Add commented profiling CFLAGS.
2016-10-12 21:14:06 +02:00
Jan Nieuwenhuizen
1bb3d1de11
speedup: use ->car etc.
2016-10-08 17:00:32 +02:00
Jan Nieuwenhuizen
c5e3e3818d
Avoid out-of-spec strncat usage.
...
mes.c (readword): Use character assignment instead of strncat. Fixes
Valgrind nit.
2016-10-11 18:50:14 +02:00
Jan Nieuwenhuizen
513bd09f76
Discern between primitive atoms and symbols.
...
* mes.c (internal_symbol_p): New function.
(eval): Use it.
2016-10-11 07:10:01 +02:00
Jan Nieuwenhuizen
a265f933d8
speedup: use ->car etc.
2016-10-08 17:00:32 +02:00
Jan Nieuwenhuizen
4514be76d9
use IF as primitive, drop using cond/evcon only option.
2016-10-08 16:54:59 +02:00