Commit Graph

2177 Commits

Author SHA1 Message Date
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
Jan (janneke) Nieuwenhuizen 15859a4def
Mes C Library: m2/ioctl.c: Remove specialization.
* lib/stub/ioctl.c (ioctl3): Move to...
* lib/stub/ioctl3.c: ...new file.
* lib/m2/ioctl3.c: Move to...
* lib/linux/ioctl3.c: ...here.
* include/mes/lib.h (ioctl3): Declare it.
* lib/m2/isatty.c (isatty): Use it.
* build-aux/configure-lib.sh (libc_SOURCES): Include it; move
lib/linux/ioctl.c to ...
(libc_gnu_SOURCES): ... here.
* kaem.run: Update accordingly.
* simple.make (M2_SOURCES): Likewise.
* simple.sh (compiler): Likewise.
2020-12-31 14:00:44 +01:00
Jan (janneke) Nieuwenhuizen b32c20185d
Mes C Library: m2/waitpid.c: Remove specialization.
* lib/linux/waitpid.c: Cater for M2-Planet.
* lib/m2/waitpid.c: Remove.
* kaem.run: Update accordingly.
* simple.make (M2_SOURCES, M2_TODO): Likewise.
2020-12-31 14:00:44 +01:00
Jan (janneke) Nieuwenhuizen 7f10001be0
Mes C Library: m2/ntoab.c: Remove specialization.
* lib/mes/ntoab.c (__mesabi_uldiv)[__M2_PLANET__ || !(__MESC__ &&
__arm__)]:  New function.
* lib/mes/ntoab.c (ntoab): Use it to cater for M2-Planet.
* lib/m2/ntoab.c: Remove.
* kaem.run: Update accordingly.
* simple.make (M2_SOURCES, (M2_TODO): Likewise.
2020-12-31 14:00:44 +01:00
Jan (janneke) Nieuwenhuizen a945c30078
build: Resurrect simple.sh.
* simple.sh: Do not attempt to build multiple C files with mescc.
Update for new and split C files.
2020-12-31 14:00:44 +01:00
Jan (janneke) Nieuwenhuizen 304a1e0ca9
guix: m2-planet: Update to 1.7.0.
* guix/git/mes.scm (m2-planet)[source]: Update to 1.7.0.
[arguments]: Add CC to make-flags.  Update sha256sum patch.
2020-12-31 14:00:44 +01:00
Jan (janneke) Nieuwenhuizen 37565a5eaf
guix: mescc-tools: Update to 1.1.0.
* guix/git/mes.scm (mescc-tools)[source]: Update to 1.1.0.
[arguments]: Update sha256sum patch.
2020-12-31 14:00:44 +01:00
Jan (janneke) Nieuwenhuizen a44d81e560
core: Prepare for M2-Planet 1.7.0.
* src/eval-apply.c (expand_variable_, apply_builtin): Declare variables
at toplevel.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Likewise.
* src/hash.c (hash_table_printer): Likewise.
* src/lib.c (equal2_p): Likewise.
* src/math.c (greater_p, less_p, is_p, minus, plus, divide, multiply,
logand, logior, logxor): Likewise.
* src/posix.c (current_input_port, execl_): Likewise.
* src/reader.c (reader_read_string): Likewise.
* src/stack.c (make_stack): Likewise.
* src/string.c (list_to_cstring, bytes_to_list, string_append):
Likewise.
* src/struct.c (make_struct): Likewise.
* src/vector.c (vector_to_list): Likewise.
2020-12-31 14:00:43 +01:00
Jan (janneke) Nieuwenhuizen e6a5805968
mescc: Mes C Library: Prepare for M2-Planet 1.7.0.
* lib/m2/ntoab.c (ntoab): Declare variables at toplevel.
* lib/mes/abtol.c (abtol): Likewise.
* lib/posix/getenv.c (getenv): Likewise.
* lib/posix/setenv.c (setenv): Likewise.
2020-12-31 14:00:43 +01:00
Jan (janneke) Nieuwenhuizen 9ac91d7980
mescc: Mes C Library: isatty: Use fixed array size for M2-Planet.
* lib/m2/isatty.c (struct ktermios)[c_cc]: Hardcode to size 19.
2020-12-31 14:00:43 +01:00
Jan (janneke) Nieuwenhuizen e3b8757400
mescc: Mes C Library: Update M2-Planet macros.
* lib/m2/x86/x86_defs.M1: Update from M2-Planet 1.7.0.
2020-12-31 14:00:43 +01:00
Jan (janneke) Nieuwenhuizen c58576748d
mes: compatibility: Move (mes pmatch) to (system base pmatch).
* mes/module/system/base/pmatch.scm: Move from mes/pmatch.scm.  Update
users.
2020-12-31 14:00:43 +01:00
Jan (janneke) Nieuwenhuizen ac6b3ba96f
mes: compatibility: Make base.mes pure guile.
* mes/module/mes/type-0.mes (procedure?): New function.  Rewrite
without `cond' from
* mes/module/mes/base.mes (procedure?): here; Remove.
2020-12-31 14:00:43 +01:00
Jan (janneke) Nieuwenhuizen 4bf946e27a
build: Cater for M2-Planet.
* configure: Drop MES_SEED, support M2-Planet.
* kaem.run: Also build bin/mes.
* build-aux/bootstrap.sh.in: Run kaem bootstrap.
* build-aux/build.sh.in: Run kaem bootstrap.  Build bin/mes.  Update
scripts and users.
* build-aux/install.sh.in: Install all built bin/mes-* flavours.
2020-12-31 14:00:42 +01:00
Jan (janneke) Nieuwenhuizen 892f8f8655
guix: Update M2-Planet to 1fc2aeab483208bd2ba117b21df3894c182470ec.
* guix/git/mes.scm (m2-planet): Update to 1fc2aeab483208bd2ba117b21df3894c182470ec.
* lib/m2/x86/x86_defs.M1: Update from M2-Planet.
2020-12-31 14:00:42 +01:00
Jan (janneke) Nieuwenhuizen 966f251f35
guix: Add m2-planet.
* guix/git/mes.scm (m2-planet): New variable.
2020-12-31 14:00:42 +01:00
Jan (janneke) Nieuwenhuizen bcb2cc9dc6
core: Use casting functions.
Silence all casting errors by using casting functions.

* src/cc.c (cast_charp_to_scmp, cast_charp_to_scmpp,
cast_voidp_to_charp, cast_scmp_to_long, cast_scmp_to_charp): New function.
* src/m2.c (cast_charp_to_scmp, cast_charp_to_scmpp,
cast_voidp_to_charp, cast_scmp_to_long, cast_scmp_to_charp): New function.
* include/mes/mes.h: Declare them.
(struct scm): Add car_value, cdr_value, function.
(g_continuations): Change to long.
* src/mes.c: Silence all casting errors by using casting functions.
2020-12-31 14:00:42 +01:00
Jan (janneke) Nieuwenhuizen 19ceda6e20
mescc: Mes C Library: Use casting functions.
Silence all casting errors by using casting functions.

* lib/mes/cast.c: New file.
* build-aux/configure-lib.sh (libmes_SOURCES): Add it.
* lib/m2/cast.c: New file.
* kaem.run: Add it.
* simple.make: Add them both.
* include/mes/lib.h: Add cast prototypes.
* include/m2/lib.h: Likewise.
* lib/linux/_getcwd.c (_getcwd): Use them.
* lib/linux/access.c (access): Likewise.
* lib/linux/brk.c (brk): Likewise.
* lib/linux/chmod.c (chmod): Likewise.
* lib/linux/clock_gettime.c (clock_gettime): Likewise.
* lib/linux/gettimeofday.c (gettimeofday): Likewise.
* lib/linux/unlink.c (unlink): Likewise.
* lib/mes/fdputc.c (fdputc): Likewise.
* lib/stdio/putchar.c (putchar): Likewise.
* lib/stdlib/malloc.c (malloc): Likewise.
2020-12-31 14:00:42 +01:00
Jan (janneke) Nieuwenhuizen fd20ea1e0a
core: Switch to pointer cells.
Run

   build-aux/pointer.sh

* include/mes/macros.h: Remove.
* src/*.c: Update.
* include/mes/*.h: Update.
* simple.make: Update.
* kaem.run: Update.
2020-12-31 14:00:42 +01:00