Commit Graph

2182 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 40ea76e231
HACK: flat-variable. 2020-12-30 11:59:34 +01:00
Jan Nieuwenhuizen 674bed609b
display: <var> 2020-12-30 11:59:34 +01:00
Jan Nieuwenhuizen a455aa8f5b
core: Refactor lookup_variable.
* src/variable.c (lookup_variable, lookup_variable_, lookup_ref): Drop
lookup/env parameter.  Update users.
* src/builtins.c (mes_builtins): Update registration.
* include/mes/builtins.h: Update declarations.
* include/mes/mes.h: Likewise.
2020-12-30 11:59:32 +01:00
Jan Nieuwenhuizen 9091d70aad
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-30 11:59:16 +01:00
Jan Nieuwenhuizen 2c6f5dc3b9
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-30 11:59:16 +01:00
Jan Nieuwenhuizen f612d8eb45
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-30 11:59:14 +01:00
Jan Nieuwenhuizen 3b752d4ef6
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-30 11:58:45 +01:00
Jan Nieuwenhuizen a35bb1c9eb
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-30 11:58:45 +01:00
Jan Nieuwenhuizen ff97c556c0
WIP: variable 2020-12-30 11:58:45 +01:00
Jan Nieuwenhuizen 554d9525d0
Revert "display: <var>"
This reverts commit cb28b55f886dd8ebb50b2336d8dc440a953b2897.
2020-12-30 11:58:45 +01:00
Jan Nieuwenhuizen 03ef34bfd3
display: <var> 2020-12-30 11:58:45 +01:00
Jan Nieuwenhuizen 70010bfa4d
mes: Add hash-for-each.
* mes/module/mes/scm.mes (hash-for-each): New function.
2020-12-30 11:58:45 +01:00
Jan Nieuwenhuizen f123b8b75b
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-30 11:58:44 +01:00
Jan Nieuwenhuizen 3dfbeb9c8d
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-30 11:58:44 +01:00
Jan Nieuwenhuizen 6d380c4cb5
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-30 11:58:44 +01:00
Jan Nieuwenhuizen 6d8b4c989a
mes: Resurrect cell:type-name.
* mes/module/mes/type-0.mes (cell:type-name): Resurrect.
2020-12-30 11:58:44 +01:00
Jan Nieuwenhuizen d54c96afdf
Revert "mes: Add hash-for-each. WIP! split me: fixup hash/make-hash table hacks."
This reverts commit ef63ad04f8.
2020-12-30 11:58:44 +01:00
Jan Nieuwenhuizen 9b3934d332
mes: Add hash-for-each. WIP! split me: fixup hash/make-hash table hacks.
* mes/module/mes/scm.mes (hash-for-each): New function.
* mes/module/mes/type-0.mes (cell:type-name): Resurrect.
* src/hash.c (hash_): Hack: allow non-string keys.
(make_hash_table_type): Rename from make_hash_type.  WIP
(hash_table_p): New function.
(hash_clear_x): New function.
* src/module.c (make_module_type): Rewrite.
(module_p): x
(get_pre_modules_obarray): x
2020-12-30 11:58:44 +01:00
Jan Nieuwenhuizen 0dac89a95a
mes: Add hash-fold.
* mes/module/mes/scm.mes (hash-fold): New function.
2020-12-30 11:58:43 +01:00
Jan Nieuwenhuizen 0d77236aa8
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-30 11:58:43 +01:00
Jan Nieuwenhuizen cdeb8b2974
struct debug 2020-12-30 11:58:43 +01:00
Jan Nieuwenhuizen 6b5145ad53
core: variable: Guile interface compliancy. WIP
* 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-30 11:58:43 +01:00
Jan Nieuwenhuizen 022666a8ff
core: Use exceptions instead of asserts. WIP
* src/lib.c (assert_num, assert_struct): New function.
* src/struct.c (struct_ref_): Use them.
2020-12-30 11:58:43 +01:00
Jan Nieuwenhuizen 5e17a0bcbe
mes: Resurrect backtraces.
* mes/module/mes/catch.mes (%eh): Resurrect backtraces.
(display-frame): New function.
(display-backtrace): Use it.
2020-12-30 11:58:42 +01:00
Jan Nieuwenhuizen fd83f6d05e
core: Add abort.
* build-aux/configure-lib.sh (libmes_SOURCES): Add abort.c.
* src/posix.c (abort_): New function: use it.
* include/mes/builtins.h: Declare it.
* kaem.run: Add it.
* simple.make (M2_SOURCES): Likewise.
2020-12-30 11:58:42 +01:00
Jan Nieuwenhuizen 3afd6044a9
mes: hash: Guile interface compliancy.
* 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-30 11:58:42 +01:00
Jan Nieuwenhuizen bd7353298e
hash-table: use erro iso assert... 2020-12-30 11:58:42 +01:00
Jan Nieuwenhuizen 23ba160476
core: WIP exceptions 2020-12-30 11:58:42 +01:00
Jan Nieuwenhuizen 18df035abc
mes: srfi-9: Guile interface compliancy.
* tests/srfi-9.test: Convert to bootstrap test, do not use
mes-use-module.
* mes/module/srfi/srfi-9-vector.mes: Resurrect.
2020-12-30 11:58:42 +01:00
Jan Nieuwenhuizen e8c81f283b
mes: srfi-9: Guile interface compliancy.
* 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-30 11:58:41 +01:00
Jan Nieuwenhuizen c31a597143
mes: srfi-9: Guile interface compliancy.
* 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-30 11:58:41 +01:00
Jan Nieuwenhuizen bd58f2a258
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-30 11:58:41 +01:00
Jan Nieuwenhuizen bb0e34a8ff
mes: srfi-9: Guile interface compliancy.
* 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-30 11:58:41 +01:00
Jan Nieuwenhuizen f5b0e0f1fa
mes: srfi-9: Guile interface compliancy.
* 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-30 11:58:41 +01:00
Jan Nieuwenhuizen 127093a392
m2: Add scripts/m2-merge.scm.
* scripts/m2-merge.scm.in: New file.
* configure: Substitute it.
* .gitignore: Update.
2020-12-30 11:57:57 +01:00
Jan (janneke) Nieuwenhuizen 1f56ef6c33
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-29 22:41:24 +01:00
Jan (janneke) Nieuwenhuizen 29b574271e
DRAFT doc: Update. 2020-12-29 19:51:15 +01:00
Jan (janneke) Nieuwenhuizen f046b2df44
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-29 19:51:15 +01:00
Jan (janneke) Nieuwenhuizen cef2b41b47
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-29 19:18:03 +01:00
Jan (janneke) Nieuwenhuizen d4a5dc339b
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-29 19:15:38 +01:00
Jan (janneke) Nieuwenhuizen ec0123f855
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-29 19:15:33 +01:00
Jan (janneke) Nieuwenhuizen 309e3800c0
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-29 19:15:23 +01:00
Jan (janneke) Nieuwenhuizen aa1a6cd9ca
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-29 18:25:58 +01:00
Jan (janneke) Nieuwenhuizen c2a0b5b9d3
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-29 18:25:58 +01:00
Jan (janneke) Nieuwenhuizen 8d8cec0965
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-29 18:25:57 +01:00
Jan (janneke) Nieuwenhuizen 0c697453b7
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-29 18:25:57 +01:00
Jan (janneke) Nieuwenhuizen b4bce47963
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-29 18:25:57 +01:00
Jan (janneke) Nieuwenhuizen aa55de78f3
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-29 18:25:57 +01:00
Jan (janneke) Nieuwenhuizen 228d2b3382
mescc: Mes C Library: Update M2-Planet macros.
* lib/m2/x86/x86_defs.M1: Update from M2-Planet 1.7.0.
2020-12-29 18:25:57 +01:00
Jan (janneke) Nieuwenhuizen 8850c16ca5
mes: compatibility: Move (mes pmatch) to (system base pmatch).
* mes/module/system/base/pmatch.scm: Move from mes/pmatch.scm.  Update
users.
2020-12-29 18:25:57 +01:00