Commit Graph

2195 Commits

Author SHA1 Message Date
Jan (janneke) Nieuwenhuizen a5234728b8
DRAFT mescc: Switch to Guile modules.
* mes/module/mescc/M1.mes,
mes/module/mescc/armv4/as.mes,
mes/module/mescc/armv4/info.mes,
mes/module/mescc/as.mes,
mes/module/mescc/bytevectors.mes,
mes/module/mescc/compile.mes,
mes/module/mescc/i386/as.mes,
mes/module/mescc/i386/info.mes,
mes/module/mescc/info.mes,
mes/module/mescc/mescc.mes,
mes/module/mescc/preprocess.mes,
mes/module/mescc/x86_64/as.mes,
mes/module/mescc/x86_64/info.mes: Remove.
2020-12-31 14:39:41 +01:00
Jan (janneke) Nieuwenhuizen c6a10943ae
mes: pretty-print: Switch to Guile modules.
* mes/module/mes/pretty-print.mes: Move to...
* mes/module/ice-9/pretty-print.scm: ...here.
2020-12-31 14:39:41 +01:00
Jan (janneke) Nieuwenhuizen 5dc08ef45e
mes: Add set-port-encoding!
* module/mescc.scm (set-port-encoding!): Move to...
* mes/module/mes/guile.mes: ...here.
2020-12-31 14:39:41 +01:00
Jan (janneke) Nieuwenhuizen ab6ff203ac
Revert "WIP psyntax.test"
This reverts commit 2e950e304f.
2020-12-31 14:39:41 +01:00
Jan (janneke) Nieuwenhuizen 981c0524b7
DRAFT core: Switch to Guile modules.
TODO XXX:
  * tests/psyntax.test fails
  * mescc

* src/mes.c (open_boot): Default to boot-5.mes.
(try_open_boot): Update messages.
2020-12-31 14:39:41 +01:00
Jan (janneke) Nieuwenhuizen c52d42a750
WIP psyntax.test 2020-12-31 14:39:41 +01:00
Jan (janneke) Nieuwenhuizen 3d4d7fcee5
mes: psyntax.pp: Prune.
* mes/module/mes/psyntax.pp (let*, do, quasiquote, include, unquote,
unquote-splicing, case): Remove.
2020-12-31 14:39:40 +01:00
Jan (janneke) Nieuwenhuizen 17986e879e
DRAFT tests: Switch to Guile modules.
* boot-5, boot-6, boot-0

* mes/module/mes/getopt-long.scm: Movo to ...
* mes/module/ice-9/getopt-long.scm: ...here.
* module/mes/optargs.scm,
mes/module/mes/optargs.mes: Remove.
* mes/module/ice-9/optargs.scm: Add functions used by macros to export
* module/mes/test.scm: Likewise.
* mes/module/mes/guile.mes: Add module header.
* mes/module/mes/main.mes: Likewise.
* mes/module/mes/repl.mes: Likewise.
* mes/module/mes/syntax.mes: Likewise.
* mes/module/srfi/srfi-0.mes: Likewise.
* mes/module/srfi/srfi-1.mes: Likewise.
* mes/module/srfi/srfi-14.mes: Likewise.
* mes/module/srfi/srfi-43.mes: Likewise.
* mes/module/srfi/srfi-8.mes: Likewise.
* mes/module/srfi/srfi-9-struct.mes: Likewise.
* mes/module/srfi/srfi-9/gnu-vector.mes: Likewise.
* mes/module/srfi/srfi-9/gnu.mes: Likewise.
2020-12-31 14:39:40 +01:00
Jan (janneke) Nieuwenhuizen b67a366769
DRAFT mes: match: Switch to Guile module.
* mes/module/mes/match.scm: Move to ...
* mes/module/ice-9/match.scm: ...here.  Add Guile module header.
* tests/match.test (tests): Update accordingly.
2020-12-31 14:39:40 +01:00
Jan (janneke) Nieuwenhuizen 0b07c15430
DRAFT mes: pmatch: Switch to Guile module.
XXX TODO: Convert mescc to Guile module use.

* tests/pmatch.test: Use boot-5.mes.
Remove (mes pmatch).
* mes/module/mes/pmatch.mes: Remove.
2020-12-31 14:39:40 +01:00
Jan (janneke) Nieuwenhuizen 5380b5a4a2
core: Make primitive-load return properly.
* include/mes/symbols.h (cell_vm_primitive_load_return): New variable.
(SYMBOL_MAX): Update.
* src/eval-apply.c (eval_apply): Have primitive-load return properly.
2020-12-31 14:39:40 +01:00
Jan (janneke) Nieuwenhuizen 7abdc50d08
build: check-boot.sh: Allow overriding of TESTS.
* build-aux/check-boot.sh (TESTS): Rename to...
(boot_tests): ...this.
(TESTS): Use boot_tests as fall-back.
(XFAIL_TESTS): Use empty as fall-back.
2020-12-31 14:39:40 +01:00
Jan (janneke) Nieuwenhuizen 01d6092a44
DRAFT test: Resurrect tests with module support.
* mes/module/mes/misc.mes: Remove.
* mes/module/srfi/srfi-26.mes: Remove.
* module/mes/misc.scm (logf, stderr, pk, pke): Remove.
(mes?, guile?, guile-1.8?, guile-2?): Move to...
* module/mes/mes-0.mes: ...new file.
* module/mes/mes-0.scm (%program, pmatch-car, pmatch-cdr): New
variables.
* tests/guile.test: Remove (mes misc) use.
* tests/pmatch.test: Use (mes guile).
* tests/data/bar.scm,
tests/data/foo.scm,: New files.
* tests/module.test: Use them to test basic Guile module support.
* build-aux/check-mes.sh (TESTS): Move it up, also fluids.test,
guile.test.
* mes/module/srfi/srfi-26.mes: Remove.
* mes/module/ice-9/rdelim.mes: New file.
* tests/scm.test ("builtin? car", "builtin? car", "builtin? cdr",
"builtin? cons", "builtin? cdr", "builtin? eq?", "builtin? eval"):
Remove.
2020-12-31 14:39:39 +01:00
Jan (janneke) Nieuwenhuizen 85b6178984
mes: boot-6: Do not redefine exit as quit.
* mes/module/mes/boot-6.mes (exit): Remove redefinition.
2020-12-31 14:39:39 +01:00
Jan (janneke) Nieuwenhuizen 22b93ef4f6
DRAFT boot-6: Define module-procedure.
XXX Does this still work with primitive-load fix?

* mes/module/mes/boot-6.mes (define-module): Also define
module-procedure.
2020-12-31 14:39:39 +01:00
Jan (janneke) Nieuwenhuizen ff2a5be2d5
DRAFT boot-6: Support Guile modules.
XXX TODO:
 * cleanup boot-6.mes
 * resurrect m2-planet build: kaem --verbose --strict

* src/hash.c (hashq_get_handle_): Remove default "dflt" parameter.
(hashq_ref_): Update user.
* src/module.c (module_handle, module_variable, current_module,
module_defines): New functions.
* src/variable.c (lookup_variable): Rename to ...
(lookup_handle): ...this.  Implement module lookup.
(lookup_variable_): Rename to ...
(lookup_ref_); ...this.
(handle_set_x): New function.
* include/mes/builtins.h: Update prototypes.
* src/core.c (error): Update callers.
* src/eval-apply.c (set_x, macro_get_handle, expand_variable_,
eval_apply): Likewise.
* mes/module/mes/boot-00.scm (defined?): Likewise.
* mes/module/mes/boot-01.scm (defined?): Likewise.
* mes/module/mes/boot-02.scm (defined?): Likewise.
* mes/module/mes/boot-03.scm (defined?): Likewise.
* scaffold/boot/53-closure-display.scm: Likewise.
* scaffold/boot/60-let-syntax-expanded.scm: Likewise.
* mes/module/mes/boot-5.mes,
mes/module/mes/boot-6.mes: New files.
2020-12-31 14:39:05 +01:00
Jan (janneke) Nieuwenhuizen 238b0fd460
core: Refactor lookup_variable.
* src/variable.c (lookup_variable, lookup_variable_, lookup_ref): Drop
lookup/env parameter.  Update users.
* mes/module/mes/boot-0.scm (defined?): Update users.
* mes/module/mes/boot-00.scm (defined?): Likewise.
* mes/module/mes/boot-01.scm (defined?): Likewise.
* mes/module/mes/boot-02.scm (defined?): Likewise.
* mes/module/mes/boot-03.scm (defined?): Likewise.
* scaffold/boot/53-closure-display.scm (guile): Likewise.
* scaffold/boot/60-let-syntax-expanded.scm (defined?): Likewise.
* src/builtins.c (mes_builtins): Update registration.
* include/mes/builtins.h: Update declarations.
* include/mes/mes.h: Likewise.
* mes/module/mes/display.mes (display): Update variable display.
2020-12-31 14:18:18 +01:00
Jan (janneke) Nieuwenhuizen ec6f32f80c
core: Remove set-env! as builtin.
* src/eval-apply.c (set_x): Rename from set_env_x.  Drop environment
parameter.
* include/mes/mes.h: Declare it.
* include/mes/builtins.h (set_env_x): Remove declaration.
* src/builtins.c (mes_builtins): Remove registration.
2020-12-31 14:18:18 +01:00
Jan (janneke) Nieuwenhuizen 21cf128175
core: Replace special cell_boot_module with initial-module builtin.
* src/module.c (initial_module): New builtin.
* include/mes/builtins.h: Declare it.
* src/builtins.c (mes_builtins): Register it.
* include/mes/symbols.h (cell_boot_module): Remove.
* src/symbol.c (init_symbols_): Update.
(init_symbols): Likewise.
* src/eval-apply.c (eval_apply): Likewise.
(expand_variable_): Likewise.
* tests/macro.test (make-fluid): Likewise.
* mes/module/mes/fluids.mes (make-fluid):  Likewise.
2020-12-31 14:18:18 +01:00
Jan (janneke) Nieuwenhuizen 79cce24028
core: Remove make_module_type, module_printer, module_variable, module_ref.
* src/module.c (make_module_type, module_printer, module_variable,
module_ref): Remove.
* include/mes/builtins.h: Remove declarations.
* src/builtins.c (mes_builtins): Remove registrations.
* src/eval-apply.c (assert_defined): Remove.
(set_env_x, eval_apply): Use lookup_variable and variable_ref.
* src/core.c (error): Likewise.
* mes/module/mes/boot-01.scm (defined?): Likewise.
* mes/module/mes/boot-02.scm (defined?): Likewise.
* mes/module/mes/boot-03.scm (defined?): Likewise.
* mes/module/mes/boot-0.scm (defined?): Likewise.
* scaffold/boot/53-closure-display.scm (guile): Likewise.
* scaffold/boot/60-let-syntax-expanded.scm (defined?): Likewise.
* src/mes.c (main): Use hash_table_printer for debugging.
2020-12-31 14:18:17 +01:00
Jan (janneke) Nieuwenhuizen 96c83134db
core: Add lookup_variable_, lookup_variable, lookup_ref.
* src/variable.c (lookup_variable, lookup_ref): New builtins, and
(lookup_variable_): New function.
* include/mes/builtins.h: Declare them.
* include/mes/mes.h: Declare it.
* src/builtins.c (mes_builtins): Register them.
2020-12-31 14:18:17 +01:00
Jan (janneke) Nieuwenhuizen ed0dbfa4b0
core: Add hashq_set_handle_x.
* src/hash.c (hash_set_x_): Return handle instead of value.  Update
callers and and use it in ...
(hashq_set_handle_x): New function.
* include/mes/builtins.h: Declare it.
2020-12-31 14:18:17 +01:00
Jan (janneke) Nieuwenhuizen 384372d4ed
mes: Add hash-for-each.
* mes/module/mes/scm.mes (hash-for-each): New function.
2020-12-31 14:18:17 +01:00
Jan (janneke) Nieuwenhuizen b6c2ce37f7
core: Add hash_clear!.
* src/hash.c (hash_clear_x): New builtin.
* include/mes/builtins.h: Declare it.
* src/builtins.c (mes_builtins): Register it.
2020-12-31 14:18:17 +01:00
Jan (janneke) Nieuwenhuizen 319208a916
core: Add hash-table?.
* include/mes/mes.h (scm_hash_table_type): New type.
* src/hash.c (make_hash_table_type): Rename from make_hash_type, and
initialize it.
* src/symbol.c (init_symbols): Add it to environment.
2020-12-31 14:18:17 +01:00
Jan (janneke) Nieuwenhuizen 9db8e3e472
core: Allow non-string hash keys.
This merely allows adding non-string keys to a hash table and puts them
non-string keys in bucket 0.  Efficiency is lost.  TODO: calculate a
proper hash.

* src/hash.c (hash_): Allow non-string keys in bucket 0.
2020-12-31 14:18:16 +01:00
Jan (janneke) Nieuwenhuizen 77683b88ea
mes: Resurrect cell:type-name.
* mes/module/mes/type-0.mes (cell:type-name): Resurrect.
2020-12-31 14:18:16 +01:00
Jan (janneke) Nieuwenhuizen 6092c9a8f7
mes: Add hash-fold.
* mes/module/mes/scm.mes (hash-fold): New function.
2020-12-31 14:18:16 +01:00
Jan (janneke) Nieuwenhuizen be98cabb58
core: Add hash-map->list.
* src/hash.c (hash_map_to_list): New function.
* src/builtins.c (mes_builtins): Update.
* include/mes/builtins.h: Update.
2020-12-31 14:18:16 +01:00
Jan (janneke) Nieuwenhuizen 430d2f98ee
core: variable: Guile interface compliance.
* src/lib.c (assert_variable):
* src/gc.c (make_variable): Move from
* src/eval-apply.c (make_variable): here; Remove.
* include/mes/builtins.h: Update.
* src/builtins.c (mes_builtins): Update.
* mes/module/mes/scm.mes (make-undefined-variable): New function.
* src/variable.c: New file.
* build-aux/configure-lib.sh (mes_SOURCES): Add it.
* kaem.run: Likewise.
* simple.make (LIBMES_SOURCES): Likewise.
* build-aux/snarf.sh (srcdest): Likewise.
2020-12-31 14:18:16 +01:00
Jan (janneke) Nieuwenhuizen 6016deef3c
DRAFT core: Use exceptions instead of asserts.
XXX prototypes

* src/lib.c (assert_num, assert_struct, (assert_range): New functions.
* src/struct.c (struct_ref_): Use them.
* src/hash.c (make_hash_table): Use assert_number.
2020-12-31 14:18:16 +01:00
Jan (janneke) Nieuwenhuizen 9d6ab2de67
core: Add abort.
* lib/stub/__raise.c: New file.
* kaem.run: Use it.
* src/posix.c (__raise)[SYSTEM_LIBC]: New macro.
 (abort_): New function: possibly use it.
* include/mes/builtins.h: Declare it.
* src/builtins.c (mes_builtins): Register it.
2020-12-31 14:18:15 +01:00
Jan (janneke) Nieuwenhuizen 4200e3f472
mes: hash: Guile interface compatibility.
* mes/module/mes/scm.mes (hashq-get-handle, hashq-ref, hash-ref): New
function.
* src/hash.c (hashq_get_handle_): Rename from hashq_get_handle.
Update users.
(hashq_ref_): Likewise.
(hash_ref_): Likewise.
2020-12-31 14:18:15 +01:00
Jan (janneke) Nieuwenhuizen 109aa1f5cb
mes: srfi-9: Guile interface compatibility.
* tests/srfi-9.test: Convert to bootstrap test, do not use
mes-use-module.
* mes/module/srfi/srfi-9-vector.mes: Resurrect.
2020-12-31 14:18:15 +01:00
Jan (janneke) Nieuwenhuizen 613b884fdb
mes: srfi-9: Guile interface compatibility.
* mes/module/srfi/srfi-9-struct.mes (record-type-name): Rename from
record-type.  Update users.
(record-type-descriptor): New function.
* mes/module/srfi/srfi-9/gnu-struct.mes (set-field): Update.
* tests/srfi-9.test ("make-record-type", "record-constructor",
"record?", "record-predicate", "zero?", "zero-one", "zero-one-set!",
"record-type-descriptor", "record-type-name", "record-type-fields"):
New test.
2020-12-31 14:18:15 +01:00
Jan (janneke) Nieuwenhuizen b44271246c
mes: srfi-9: Guile interface compatibility.
* mes/module/srfi/srfi-9-struct.mes (record-type-fields): Rename from
record-field-names.  Update users.
* mes/module/srfi/srfi-9-vector.mes (record-type-fields): Likewise.
* mes/module/srfi/srfi-9/gnu-struct.mes (set-field): Update.
2020-12-31 14:18:15 +01:00
Jan (janneke) Nieuwenhuizen 0ecac6522b
core: make-hash-table: Fix optional argument.
* src/hash.c (make_hash_table): Fix optional argument.
* src/builtins.c (mes_builtins): Update arity.
2020-12-31 14:18:15 +01:00
Jan (janneke) Nieuwenhuizen 7b3a74f898
mes: srfi-9: Guile interface compatibility.
* mes/module/srfi/srfi-9-struct.mes (record-accessor): Rename from
record-getter.  Update users.
* mes/module/srfi/srfi-9-vector.mes (record-modifier): Rename from
record-setter.  Update users.
* mes/module/srfi/srfi-9/gnu-struct.mes: Update.
2020-12-31 14:18:14 +01:00
Jan (janneke) Nieuwenhuizen 4c8ead718c
mes: srfi-9: Guile interface compatibility.
* mes/module/srfi/srfi-9-struct.mes (record-constructor): Remove name
argument, make field-names optional.  Update users.
* mes/module/srfi/srfi-9-vector.mes: Likewise.
* mes/module/srfi/srfi-9/gnu-struct.mes: Update.
2020-12-31 14:18:14 +01:00
Jan (janneke) Nieuwenhuizen b4e8e4a05e
DRAFT doc: Update. 2020-12-31 14:15:28 +01:00
Jan (janneke) Nieuwenhuizen b74f752123
tests: string-join: Be noisy.
* scaffold/boot/50-string-join.scm ("string-join\n"): Avoid exit 0
without output.
2020-12-31 14:15:28 +01:00
Jan (janneke) Nieuwenhuizen 9e0ccc7ded
mes: simple-format: Use core display.
* mes/module/mes/simple-format.mes: Do not import (mes display).
2020-12-31 14:15:27 +01:00
Jan (janneke) Nieuwenhuizen 9fd6d4bd68
mes: Resurrect backtraces.
* mes/module/mes/catch.mes (%eh): Resurrect backtraces.
(display-frame): New function.
(display-backtrace): Use it.
2020-12-31 14:13:47 +01:00
Jan (janneke) Nieuwenhuizen 327e4178d0
mes: Remove PEG.
PEG is not used and mostly broken.

* mes/module/mes/peg.mes,
mes/module/mes/peg/cache.scm,
mes/module/mes/peg/codegen.scm,
mes/module/mes/peg/simplify-tree.scm,
mes/module/mes/peg/string-peg.scm,
mes/module/mes/peg/using-parsers.scm,
tests/peg.test: Remove.
2020-12-31 14:13:47 +01:00
Jan (janneke) Nieuwenhuizen df302e964a
.dir-locals: Add test macro indentation.
* .dir-locals.el (scheme-mode): Add indentation for pass-if,
pass-if-not, pass-if-eq, pass-if-equal, expect-fail, pass-if-timeout.
2020-12-31 14:13:47 +01:00
Jan (janneke) Nieuwenhuizen 34efec9ce9
mescc: Use (format (current-error-port) ...) instead of stderr.
* module/mescc/M1.scm: Use (format (current-error-port) ...) instead of
stderr.
* module/mescc/compile.scm: Likewise.
* module/mescc/mescc.scm: Likewise.
* module/mescc/preprocess.scm: Likewise.
2020-12-31 14:13:46 +01:00
Jan (janneke) Nieuwenhuizen f2a99e4855
core: Add gc-stats.
* include/mes/mes.h (gc_start_time, gc_end_time, gc_time): New
variables.
* src/mes.c (init): Initialize them.
* src/gc.c: Use them.
* src/gc.c (gc_stats): New function.
* include/mes/builtins.h: Declare it.
* src/builtins.c (mes_builtins): Register it.
* tests/gc.test: Use it.
2020-12-31 14:00:45 +01:00
Jan (janneke) Nieuwenhuizen a7827ca598
core: Avoid Floating point exception dividing negative numbers.
This fixes

    kaem --verbose --strict
    bin/mes-m2 -c '(display (/ -1 1))'

* src/math.c (divide): Use signed division.
2020-12-31 14:00:45 +01:00
Jan (janneke) Nieuwenhuizen d0a5e4fcad
Mes C Library: m2/execve.c: Remove specialization.
* lib/linux/execve.c (execve): Cater for M2-Planet.
* lib/m2/execve.c: Remove.
* kaem.run: Update accordingly.
* simple.make (M2_SOURCES): Likewise.
2020-12-31 14:00:45 +01:00
Jan (janneke) Nieuwenhuizen 37f44ce945
Mes C Library: m2/getcwd.c: Remove specialization.
* lib/posix/getcwd.c (getcwd): Cater for M2-Planet.
* lib/m2/getcwd.c: Remove.
* kaem.run: Update accordingly.
* simple.make (M2_SOURCES): Likewise.
2020-12-31 14:00:44 +01:00