Commit Graph

2237 Commits

Author SHA1 Message Date
Timothy Sample 063c244665 mes: boot-03: Define '@' and '@@'.
* mes/module/mes/boot-03.scm (@, @@): New macros.
* mes/module/mes/boot-0.scm (@, @@): New macros.
* mes/module/mes/boot-5.scm (@, @@): New macros.
2022-04-25 14:19:57 -06:00
Jan (janneke) Nieuwenhuizen 8f0832c0e7 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.
2022-04-25 14:19:57 -06:00
Timothy Sample 1d7c6d308a mes: Add Guile-style module support.
This change adds support for Guile-style modules, but does not
enable it by default.  It can be enabled by using the 'boot-5' boot
script.

* mes/module/mes/guile-module.mes: New file.
* mes/module/mes/boot-5.mes: New file.
* mes/module/mes/boot-0.mes (effective-version, include-from-path)
(define-module, use-modules, effective-version): Move these...
* mes/module/mes/guile.scm: ...here.
* mes/module/mes/boot-0.mes: Move '%main' and the command-line
interface code...
* mes/module/mes/main.mes: ...to this new file.
* mes/module/mes/boot-0.mes: Import '(mes guile)' and '(mes main)'.
* mes/module/ice-9/rdelim.scm: New file.
* tests/data/bar.scm: New file.
* tests/data/foo.scm: New file.
* tests/guile-module.test: New file.
* build-aux/check-mes.sh (TESTS): Add it.
2022-04-25 14:19:03 -06:00
Timothy Sample b525923e91 core: Add the 'make-binding' builtin.
* src/eval-apply.c (make_binding): New function.
* include/mes/builtins.h (make_binding): Declare it.
* src/builtins.c (mes_builtins): Register it.
2022-04-25 14:19:03 -06:00
Timothy Sample 2cf520f595 mes: Use a hash table for fluids.
If 'make-fluid' is a macro that calls 'gensym' directly, any attempt
to wrap 'make-fluid' will result in only one symbol being produced
at expansion time.

* mes/module/mes/fluids.mes (make-fluid): Rewrite to generate a
symbol at evaluation time, and use that symbol as a key for a hash
table.
(fluid?, fluid-ref, fluid-set!): Adjust accordingly.
(with-fluid*, with-fluids): Use 'fluid-ref' instead of applying a
fluid directly.
* tests/fluids.test: Add test.
2022-04-25 14:19:03 -06:00
Timothy Sample 411910a711 core: Bind all free variables during expansion.
* src/eval-apply.c (expand_variable_): Process internal definitions
as local variables; ensure all free variables are bound (creating
bindings if necessary).
(eval_apply): When evaluating a pair with a binding in its car,
evaluate the binding before dispatching; when evaluating a binding,
raise an error if the location does not have a value.
* src/mes.c (mes_environment): Bind special symbols to themselves.
* mes/module/mes/boot-0.scm (defined?): Make sure the variable
actually has a value.
* 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/60-let-syntax-expanded.scm (defined?): Likewise.
2022-04-25 14:19:03 -06:00
Timothy Sample 368aa464b9 core: Fix continuations.
* src/eval-apply.c: Do not add a frame to the GC stack while making
a continuation.
* mes/module/mes/catch.mes (catch): Remove workaround.
* tests/boot.test: Add test.
2022-04-25 14:19:03 -06:00
Timothy Sample cb16a92bf0 core: set!: Check for undefined variables.
* src/eval-apply.c (set_x): Add the 'define_p' argument and if it is
not set, signal an error on an undefined variable.
(eval_apply): When evaluating 'set-x!' forms, leave 'define_p'
unset; when evaluating 'define' forms, set 'define_p'.
2022-04-25 14:19:03 -06:00
Timothy Sample c8fc32bc9e core: Make symbol lookup extensible.
* src/module.c (set_current_module): New function.
(module_variable): Remove function.
(module_define_x): Remove function.
(current_module_variable): New function.
* src/eval-apply.c (lookup_binding): Replace 'module_variable' with
'current_module_variable'; add the 'define_p' argument.
(set_x): Adjust for 'define_p'.
(lookup_value): Likewise.
(expand_variable_): Likewise.
(eval_apply): When evaluating defines, replace 'module_define_x' with
'lookup_binding' with 'define_p' set.
* src/gc.c (gc_init)[!M2_PLANET]: Double ARENA_SIZE.
* include/mes/constants.h (MODULE_EVAL_CLOSURE): New constant.
* include/mes/mes.h (current_module_variable): New declaration.
(current_module_define_x): New declaration.
* include/mes/builtins.h (set_current_module): New declaration.
(lookup_binding): Declare the 'define_p' argument.
(module_variable): Remove declaration.
(module_define_x): Remove declaration.
* src/builtins.c (mes_builtins): Register 'set-current-module';
remove 'module-variable' and 'module-define!'.
* mes/module/boot-0.scm (defined?): Do not use 'module-variable'.
* mes/module/boot-00.scm (defined?): Likewise.
* mes/module/boot-01.scm (defined?): Likewise.
* mes/module/boot-02.scm (defined?): Likewise.
* mes/module/boot-03.scm (defined?): Likewise.
* scaffold/boot/60-let-syntax-expanded.scm (defined?): Likewise.
* mes/module/mes/fluids.mes (make-fluid): Do not use
'module-define!', and wrap fluids in a variable record.
* tests/macro.test (make-fluid): Likewise.

Co-authored-by: Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
2022-04-25 14:19:03 -06:00
Timothy Sample 8345d88849 core: Do not hold pointers during variable lookup.
If we want to make variable lookup extensible, we need to call into
Scheme code during lookup.  This might cause the garbage collector
to run, invalidating any pointer held by C code.  This change
updates call sites for variable lookup to avoid holding pointers
into Scheme data.

* src/eval-apply.c (expand_variable_): Store expressions and formals
in GC-managed registers.
(expand_variable): Initialize registers for 'expand_variable_'.
(eval_apply): When evaluating 'define' and 'define-macro' forms, do
not rely on local C variables after calls to 'lookup_binding' or
'expand_variable'.
2022-04-25 14:19:03 -06:00
Timothy Sample d7ea94069a core: Make 'primitive-load' a builtin.
In addition to simplifying the interpreter, this change ensures that
'primitive-load' evaluates the loaded file in the top level
environment.

* include/mes/symbols.h (cell_symbol_primitive_load): Remove
variable.
(cell_vm_begin_primitive_load): Remove variable.
(cell_vm_begin_expand_primitive_load): Remove variable.
(SYMBOL_MAX, CELL_SYMBOL_RECORD_TYPE): Adjust accordingly.
* src/symbol.c (init_symbols): Do not initialize removed variables.
* src/eval-apply.c (eval_apply): Remove primitive load code.
(primitive_load): New function.
* include/mes/builtins.h (primitive_load): Declare it.
* src/builtins.c (mes_builtins): Initialize it.
* mes/module/mes/boot-03.scm: Remove duplicate call to
'primitive-load'.
* mes/module/mes/boot-0.scm: Remove extra call to 'primitive-load';
adjust how the "--main" option is handled.
* tests/base/test.test: Add a test.
* tests/data/load.scm: Set the 'toplevel?' variable to support the
new test.
2022-04-25 14:19:03 -06:00
Timothy Sample 84a4169428 core: Fix internal define bug.
* src/eval-apply.c (eval_apply): When evaluating 'define', recompute
the 'global_p' and 'local_p' flags; when evaluating a local
definition, set the closure directly instead of using 'set_x'.
* tests/base.test: Add a test.
2022-04-25 14:19:03 -06:00
Timothy Sample aab9e925ac srfi-9: Fix record printing.
* mes/module/srfi/srfi-9-struct.mes (print-record-type): New
procedure.
(make-record-type): Add 'printer' as new record type field and use
'print-record-type' as the struct printer.
(record-type-printer): New procedure.
(record-type-fields): Bump index for the 'printer' field.
(record-constructor): Use the record type printer as the struct
printer if it is defined.
(record-printer): Print the record type name instead of the raw
record type.
2022-04-25 14:19:03 -06:00
Timothy Sample 942bb1f3b6 tests: Fix tests to run on Guile.
* scaffold/boot/17-open-input-string.scm: Test 'current-module' to
see if we can lookup 'read-string' in a module.
* scaffold/boot/gc.scm: Skip all tests on Guile.
* tests/gc.test: Rename 'mes?' to 'mes-core?'; use 'current-module'
to check if we need to use core Mes procedures; and adjust all tests
accordingly.
* tests/scm.test (iota -1): Skip on Guile.
* tests/vector.test (make-vector): Adjust for Guile.
2022-04-25 14:19:03 -06:00
Timothy Sample 283c5a559f core: Add an 'M1' register for the current module.
* include/mes/mes.h (M1): New variable.
* src/mes.c (main): Initialize it.
* src/gc.c (gc_flip): Account for it.
(gc_): Copy it.
(gc_dump_state): Dump it.
* src/test/gc.c (test_setup, main): Initialize it.
* src/module.c (current_module): New function.
* src/builtiins.c (mes_builtins): Register it as 'current-module'.
* include/mes/builtins.h (current_module): Declare it.
2022-04-25 14:19:03 -06:00
Timothy Sample 8ec9aa7643 core: Rename the 'current-module' symbol.
This change renames 'current-module' to 'current-environment'.  This
will make way for 'current-module' to actually be a module.

* include/mes/symbols.h (cell_symbol_current_module): Rename this...
(cell_symbol_current_environment): ...to this.
* src/eval-apply.c: Adjust accordingly.
* src/symbol.c: Adjust accordingly, and update the Scheme name to
'current-environment'.
* mes/module/mes/base.mes: Adjust accordingly.
* mes/module/mes/boot-0.scm: Adjust accordingly.
* mes/module/mes/boot-00.scm: Adjust accordingly.
* mes/module/mes/boot-01.scm: Adjust accordingly.
* mes/module/mes/boot-02.scm: Adjust accordingly.
* mes/module/mes/boot-03.scm: Adjust accordingly.
* mes/module/mes/display.mes: Adjust accordingly.
* mes/module/mes/module.mes: Adjust accordingly.
* mes/module/mes/psyntax-0.mes: Adjust accordingly.
* mes/module/mes/repl.mes: Adjust accordingly.
* mes/module/mes/scm.mes: Adjust accordingly.
* mes/module/srfi/srfi-16.scm: Adjust accordingly.
* mes/module/srfi/srfi-26.scm: Adjust accordingly.
* module/mescc/compile.scm: Adjust accordingly.
* scaffold/boot/17-open-input-string.scm: Adjust accordingly.
* scaffold/boot/4c-quasiquote.scm: Adjust accordingly.
* scaffold/boot/4f-string-split.scm: Adjust accordingly.
* scaffold/boot/50-make-string.scm: Adjust accordingly.
* scaffold/boot/50-string-join.scm: Adjust accordingly.
* scaffold/boot/51-module.scm: Adjust accordingly.
* scaffold/boot/52-define-module.scm: Adjust accordingly.
* scaffold/boot/60-let-syntax-expanded.scm: Adjust accordingly.
* scaffold/boot/60-let-syntax.scm: Adjust accordingly.
* scaffold/gc.scm: Adjust accordingly.
* tests/gc.test: Adjust accordingly.
* tests/psyntax.test: Adjust accordingly.
2022-04-25 14:19:03 -06:00
Timothy Sample 67a7f485ef core: Remove '<module>' type.
This change removes the internal '<module>' record type, and changes
the initial module to be a plain hash table.

* src/symbol.c (init_symbols_): Remove 'cell_symbol_module'.
* include/mes/symbols.h (cell_symbol_module): Remove declaration.
(CELL_SYMBOL_MAX, CELL_SYMBOL_RECORD_TYPE): Adjust accordingly.
* src/module.c (make_initial_module): Use a raw hash table instead
of a struct.
(module_variable, module_define_x): Adjust accordingly.
(make_module_type, module_printer): Remove functions.
* src/builtins.c (mes_builtins): Do not register them.
* include/mes/builtins.h (make_module_type, module_printer): Remove
declarations.
* src/eval-apply.c (eval_apply): Replace 'module_printer' with
'hash_table_printer'.
* src/mes.c (main): Likewise, and initialize 'R0' after calling
'make_initial_module'.

Co-authored-by: Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
2022-04-25 14:19:03 -06:00
Timothy Sample 9fa03f6182 core: Use variables for modules.
This change introduces a 'lexical?' field for bindings (called
'lexical_p' and stored in the cdr of the binding cell).  Non-lexical
bindings handle variables transparently, while lexical bindings do
not.

* src/module.c (module_define_x): Wrap value in a variable.
* include/mes/mes.h (scm): Add 'lexical_p' to the cdr union.
* src/eval-apply.c (make_binding_): Add a 'lexical_p' argument.
(lookup_handle): Remove function.
(lookup_binding): Add function.
(lookup_value): Use 'lookup_binding' and return the contents of
variables that are not bound lexically.
(set_env_x): Remove function.
(set_x): New function.
(expand_variable_): Use 'lookup_binding' in place of
'lookup_handle'.
(eval_apply): Likewise; use 'set_x' in place of 'set_env_x'; and
when evaluating a binding, return the contents of variables that are
not bound lexically.
* include/mes/builtins.h (set_env_x): Remove declaration.
* src/builtins.c (mes_builtins): Do not register 'set-env!'.
* scaffold/boot/53-closure-display.scm (closure)[mes]: Rewrite to
avoid 'module-variable'.
2022-04-25 14:19:03 -06:00
Timothy Sample 5edef591b7 core: Implement Guile-style variables.
* src/variable.c: New file.
* simple.make (LIBMES_SOURCES): Add it.
* build-aux/configure-lib.sh (mes_SOURCES): Add it.
* build-aux/snarf.sh: Snarf it.
* kaem.run: Compile it.
* include/mes/builtins.h (make_variable): New function.
(variable_p): New function.
(variable_ref): New function.
(variable_set_x): New function.
(variable_printer): New function.
* src/builtins.c (mes_builtins): Register them.
* include/mes/mes.h (make_variable_type): New function.
(scm_variable_type): New variable.
* src/module.c (make_initial_module): Initialize it.
* src/gc.c (gc_flip, gc_): Keep track of it.
* include/mes/symbols.h (cell_symbol_variable): New variable.
(SYMBOL_MAX): Adjust accordingly.
* src/symbol.c (init_symbols): Initialize 'cell_symbol_variable'.
* mes/module/mes/scm.mes (make-undefined-variable): New procedure.
(variable-bound?): New procedure.
* tests/variable.test: New file.
* build-aux/check-mes.sh (TESTS): Add it.
2022-04-25 14:19:03 -06:00
Jan (janneke) Nieuwenhuizen c317e939b9 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.
2022-04-25 14:19:03 -06:00
Timothy Sample 870256ed3e core: Refactor name resolution.
* src/module.c (module_variable): Do not search local bindings.
(module_ref): Remove function.
* src/eval-apply.c (lookup_handle): New function.
(lookup_value): New function.
(set_env_x, expand_variable_, eval_apply): Use 'lookup-handle' and
'lookup-value' in place of 'module_variable' and 'module_ref'
respectively.
* src/core.c (error): Likewise.
* include/mes/mes.h (lookup_handle, lookup_value): Add declarations.
* include/mes/builtins.h (module_ref): Remove declaration.
* src/builtins.c (mes_builtins): Remove "module-ref".

Co-authored-by: Jan (janneke) Nieuwenhuizen <janneke@gnu.org>
2022-04-25 14:19:03 -06:00
Timothy Sample 895eaa4c5e core: Fix printing bindings.
* src/lib.c (car_): Support taking the car of a binding.
* mes/module/mes/display.mes (display): Do not use 'list->string'
when displaying a binding.
2022-04-25 14:17:57 -06:00
Timothy Sample 91b1c6e233 core: Rename variable type to binding.
This change allows us to use "variable" in the Guile sense, which is
an anonymous box for storing a value.

* include/mes/constants.h (TVARIABLE): Rename this...
(TBINDING): ...to this.
* include/mes/mes.h (scm): Rename the 'variable' field to 'binding'.
* include/mes/symbols.h (cell_type_variable): Rename this...
(cell_type_binding): ...to this.
* src/gc.c (gc_cellcpy, gc_loop, gc_dump_arena): Adjust accordingly.
* src/eval-apply.c (make_variable_): Rename this...
(make_binding_): ...to this.
(set_env_x, expand_variable_, eval_apply): Adjust accordingly.
* src/symbol.c (init_symbol): Adjust accordingly and rename the
'<cell:variable>' symbol to '<cell:binding>'.
* mes/module/mes/type-0.mes (cell:type-alist): Adjust accordingly.
(variable?): Rename this...
(binding?): ...to this.
* src/display.c (display_helper): Adjust accordingly and print
"binding" instead of "variable".
* mes/module/mes/display.mes (display): Likewise.
2022-04-25 09:22:13 -06:00
Jan (janneke) Nieuwenhuizen 07c90bdebd core: Add hashq_create_handle_x.
* src/hash.c (hash_create_handle_x): New function.
* include/mes/builtins.h: Declare it.
* src/builtins.c (mes_builtins): Register it.
* tests/hash.test: Add a test.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2022-04-25 09:22:13 -06:00
Jan (janneke) Nieuwenhuizen 2296972201 mes: Add hash-for-each.
* mes/module/mes/scm.mes (hash-for-each): New function.
2022-04-25 09:22:13 -06:00
Jan (janneke) Nieuwenhuizen 64d6dff810 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.
* tests/hash.test: Add a test.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2022-04-25 09:22:13 -06:00
Jan (janneke) Nieuwenhuizen 858daa625d 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.
* tests/hash.test: Add a test.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2022-04-25 09:22:13 -06:00
Jan (janneke) Nieuwenhuizen 9a5de02f42 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.
* tests/hash.test: Add a test.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2022-04-25 09:22:13 -06:00
Jan (janneke) Nieuwenhuizen 0a905d54d7 mes: Resurrect cell:type-name.
* mes/module/mes/type-0.mes (cell:type-name): Resurrect.
2022-04-25 09:22:13 -06:00
Jan (janneke) Nieuwenhuizen c005d4abd3 mes: Add hash-fold.
* mes/module/mes/scm.mes (hash-fold): New function.
2022-04-25 09:22:13 -06:00
Jan (janneke) Nieuwenhuizen e4d35f5915 core: Add hash-map->list.
* src/hash.c (hash_buckets): New function.
* src/builtins.c (mes_builtins): Initialize it.
* include/mes/builtins.h: Declare it.
* mes/module/mes/scm.mes (hash-map->list): New procedure.
* tests/hash.test: Add a test.
* tests/gc.test: Bump arena size to handle more built-ins.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2022-04-25 09:22:10 -06:00
Jan (janneke) Nieuwenhuizen e8e1851bc6 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.
2022-03-24 12:03:56 -06:00
Jan (janneke) Nieuwenhuizen 3339cd11dd mes: hash: Guile interface compatibility.
* src/hash.c (hashq_get_handle): Remove the dflt argument.
(hashq_ref): Rename this...
(hashq_ref_): ...to this, update for hashq_get_handle, and handle
the dflt argument directly.
(hash_ref): Rename this...
(hash_ref_): ...to this, and fix handling of the dflt argument.
* include/mes/builtins.h: Update accordingly.
* src/eval-apply.c (macro_get_handle): Update for hashq_get_handle.
* src/module.c (module_variable): Likewise.
* src/builtins.c (mes_builtins): Set hashq-get-handle argument count
to 2; rename hashq-ref to core:hashq-ref; and rename hash-ref to
core:hash-ref.
* mes/module/mes/scm.mes (hashq-ref, hash-ref): New procedures.
* tests/hash.test: Add some tests.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2022-03-24 11:51:33 -06:00
Jan (janneke) Nieuwenhuizen eac19abd29 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.
2022-03-23 15:21:47 -06:00
Jan (janneke) Nieuwenhuizen a0757413b9 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.
2022-03-23 15:21:47 -06:00
Jan (janneke) Nieuwenhuizen c32909b959 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.
2022-03-23 15:21:47 -06:00
Jan (janneke) Nieuwenhuizen fb0b01e904 core: make-hash-table: Fix optional argument.
* src/hash.c (make_hash_table): Fix optional argument.
* src/builtins.c (mes_builtins): Update arity.
* tests/hash.test: New file.
* build-aux/check-mes.sh (TESTS): Add it.

Co-authored-by: Timothy Sample <samplet@ngyro.com>
2022-03-23 10:59:32 -06:00
Jan (janneke) Nieuwenhuizen 013c40d165
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.
2021-05-16 09:19:12 +02:00
Jan (janneke) Nieuwenhuizen e96a398ec5
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.
2021-05-16 09:19:12 +02:00
Jan (janneke) Nieuwenhuizen 65fafa6d15
doc: Update `README'.
* README: Mention that we're now bootstrappable.
2019-11-03 16:30:45 +01:00
Jan (janneke) Nieuwenhuizen dffcc908b6
doc: Update 'AUTHORS'.
* AUTHORS: Mention Jeremiah Orians as co-author on ELF heanders and
mention M2-Planet imports.
2021-01-02 13:45:00 +01:00
Jan (janneke) Nieuwenhuizen 9c9824eb10
core: Resurrect gcc-10 support.
* include/mes/mes.h (g_datadir, g_debug, g_buf, g_continuations,
g_symbols, g_symbol_max, g_mini, R0, R1, R2, R3, M0, g_macros, g_ports,
ARENA_SIZE, MAX_ARENA_SIZE, STACK_SIZE, JAM_SIZE, GC_SAFETY, MAX_STRING,
g_arena, cell_arena, cell_zero, g_free, g_symbol, g_stack_array,
g_cells, g_news, g_stack, gc_count, gc_start_time, gc_end_time, gc_time,
__execl_c_argv, __open_boot_buf, __open_boot_file_name, __setenv_buf,
__reader_read_char_buf, g_start_time, __gettimeofday_time,
__get_internal_run_time_ts): Declare extern.
* include/mes/symbols.h ( cell_nil, cell_f, cell_t, cell_dot,
cell_arrow, cell_undefined, cell_unspecified, cell_closure,
cell_circular, cell_vm_apply, cell_vm_apply2, cell_vm_begin,
cell_vm_begin_eval, cell_vm_begin_expand, cell_vm_begin_expand_eval,
cell_vm_begin_expand_macro, cell_vm_begin_expand_primitive_load,
cell_vm_begin_primitive_load, cell_vm_begin_read_input_file,
cell_vm_call_with_current_continuation2, cell_vm_call_with_values2,
cell_vm_eval, cell_vm_eval2, cell_vm_eval_check_func,
cell_vm_eval_define, cell_vm_eval_macro_expand_eval,
cell_vm_eval_macro_expand_expand, cell_vm_eval_pmatch_car,
cell_vm_eval_pmatch_cdr, cell_vm_eval_set_x, cell_vm_evlis,
cell_vm_evlis2, cell_vm_evlis3, cell_vm_if, cell_vm_if_expr,
cell_vm_macro_expand, cell_vm_macro_expand_car,
cell_vm_macro_expand_cdr, cell_vm_macro_expand_define,
cell_vm_macro_expand_define_macro, cell_vm_macro_expand_lambda,
cell_vm_macro_expand_set_x, cell_vm_return, cell_symbol_lambda,
cell_symbol_begin, cell_symbol_if, cell_symbol_quote,
cell_symbol_define, cell_symbol_define_macro, cell_symbol_quasiquote,
cell_symbol_unquote, cell_symbol_unquote_splicing, cell_symbol_syntax,
cell_symbol_quasisyntax, cell_symbol_unsyntax,
cell_symbol_unsyntax_splicing, cell_symbol_set_x, cell_symbol_sc_expand,
cell_symbol_macro_expand, cell_symbol_portable_macro_expand,
cell_symbol_sc_expander_alist, cell_symbol_call_with_values,
cell_symbol_call_with_current_continuation, cell_symbol_boot_module,
cell_symbol_current_module, cell_symbol_primitive_load, cell_symbol_car,
cell_symbol_cdr, cell_symbol_not_a_number, cell_symbol_not_a_pair,
cell_symbol_system_error, cell_symbol_throw,
cell_symbol_unbound_variable, cell_symbol_wrong_number_of_args,
cell_symbol_wrong_type_arg, cell_symbol_buckets, cell_symbol_builtin,
cell_symbol_frame, cell_symbol_hashq_table, cell_symbol_module,
cell_symbol_procedure, cell_symbol_record_type, cell_symbol_size,
cell_symbol_stack, cell_symbol_argv, cell_symbol_mes_datadir,
cell_symbol_mes_version, cell_symbol_internal_time_units_per_second,
cell_symbol_compiler, cell_symbol_arch, cell_symbol_pmatch_car,
cell_symbol_pmatch_cdr, cell_type_bytes, cell_type_char,
cell_type_closure, cell_type_continuation, cell_type_function,
cell_type_keyword, cell_type_macro, cell_type_number, cell_type_pair,
cell_type_port, cell_type_ref, cell_type_special, cell_type_string,
cell_type_struct, cell_type_symbol, cell_type_values,
cell_type_variable, cell_type_vector, cell_type_broken_heart,
cell_symbol_program, cell_symbol_test): Likewise.
* src/globals.c: New file.
* build-aux/configure-lib.sh (mes_SOURCES): Add it.
2021-05-02 14:58:23 +02:00
Jan (janneke) Nieuwenhuizen d4ecee8ac9
guix: m2-planet: Update to 1.7.0-32-gaa3472b.
This adds support for skipping "extern".

* guix/git/mes.scm (m2-planet)[source]: Update to 1.7.0-32-gaa3472b.
2021-05-02 15:52:04 +02:00
Jan (janneke) Nieuwenhuizen bfa9a08562
scaffold: Add local-static-array.c.
GCC gives

    12:35:54 janneke@dundal:~/src/mes/wip-m2 [env]
    $ gcc scaffold/local-static-array.c
    12:36:01 janneke@dundal:~/src/mes/wip-m2 [env]
    $ ./a.out
    hello local static
    hello local static
    12:36:04 janneke@dundal:~/src/mes/wip-m2 [env]

M2-Planet gives

    12:36:04 janneke@dundal:~/src/mes/wip-m2 [env]
    $ kaem --verbose --strict --file scaffold/local-static-array.kaem
     +> M2-Planet --debug --architecture x86 -f lib/mes/globals.c -f lib/linux/x86-mes-m2/mini.c -f lib/mes/mini-write.c -f lib/string/strlen.c -f lib/string/strcpy.c -f lib/mes/eputs.c -f scaffold/local-static-array.c -o scaffold/local-static-array.M1
    scaffold/local-static-array.c:29:static is not a defined symbol
    Subprocess error 256
    ABORTING HARD
    [1]12:36:07 janneke@dundal:~/src/mes/wip-m2 [env]

* scaffold/local-static-array.c: New file.
* scaffold/local-static-array.kaem: New file.
2021-01-09 12:35:22 +01:00
Jan (janneke) Nieuwenhuizen d26bdd328e
scaffold: Add local-array.c.
GCC gives

    12:32:06 janneke@dundal:~/src/mes/wip-m2 [env]
    $ gcc scaffold/local-array.c
    12:34:27 janneke@dundal:~/src/mes/wip-m2 [env]
    $ ./a.out
    hello local
    12:34:31 janneke@dundal:~/src/mes/wip-m2 [env]

M2-Planet gives

    12:34:31 janneke@dundal:~/src/mes/wip-m2 [env]
    $ kaem --verbose --strict --file scaffold/local-array.kaem
     +> M2-Planet --debug --architecture x86 -f lib/mes/globals.c -f lib/linux/x86-mes-m2/mini.c -f lib/mes/mini-write.c -f lib/string/strlen.c -f lib/string/strcpy.c -f lib/mes/eputs.c -f scaffold/local-array.c -o scaffold/local-array.M1
    scaffold/local-array.c:29:ERROR in collect_local
    Missing ;
    Subprocess error 256
    ABORTING HARD
    [1]12:34:42 janneke@dundal:~/src/mes/wip-m2 [env]

* scaffold/local-array.c: New file.
* scaffold/local-array.kaem: New file.
2021-01-09 12:33:26 +01:00
Jan (janneke) Nieuwenhuizen 3e081d2e26
scaffold: Add global-array.c.
GCC gives

    12:30:45 janneke@dundal:~/src/mes/wip-m2 [env]
    $ gcc scaffold/global-array.c
    12:31:53 janneke@dundal:~/src/mes/wip-m2 [env]
    $ ./a.out
    hello global
    12:31:54 janneke@dundal:~/src/mes/wip-m2 [env]

M2-Planet gives

    12:31:54 janneke@dundal:~/src/mes/wip-m2 [env]
    $ kaem --verbose --strict --file scaffold/global-array.kaem
     +> M2-Planet --debug --architecture x86 -f lib/mes/globals.c -f lib/linux/x86-mes-m2/mini.c -f lib/mes/mini-write.c -f lib/string/strlen.c -f lib/string/strcpy.c -f lib/mes/eputs.c -f scaffold/global-array.c -o scaffold/global-array.M1
    scaffold/global-array.c:20:Received [ in program
    Subprocess error 256
    ABORTING HARD
    [1]12:32:06 janneke@dundal:~/src/mes/wip-m2 [env]

* scaffold/global-array.c: New file.
* scaffold/global-array.kaem: New file.
2021-01-09 12:30:59 +01:00
Jan (janneke) Nieuwenhuizen 2746d84f34
doc: Add test hints to `HACKING'.
* HACKING (TESTING): New section.
2021-01-01 11:58:36 +01:00
Jan (janneke) Nieuwenhuizen ef6fda9ab3
Revert "Mes C Library: m2/execve.c: Remove specialization."
This fixes

    gcc-lib/libc+gnu.c: At top level:
    gcc-lib/libc+gnu.c:2694:1: error: conflicting types for ‘execve’
     execve (char const *file_name, char **argv, char **env)
     ^~~~~~
    In file included from gcc-lib/libc+gnu.c:492:0:
    include/unistd.h:66:5: note: previous declaration of ‘execve’ was here
     int execve (char const *file, char *const argv[], char *const env[]);
         ^~~~~~

This reverts commit 828c27a073.
2021-01-02 10:00:35 +01:00
Jan (janneke) Nieuwenhuizen 9f0671cda0
bootstrap: Update M2-Planet x86 definitions from 1.7.0-31-g358b6cf.
* lib/m2/x86/x86_defs.M1: Update.
2021-01-01 19:07:22 +01:00
Jan (janneke) Nieuwenhuizen a3b9e4b22f
guix: m2-planet: Update to 1.7.0-31-g358b6cf.
* guix/git/mes.scm (m2-planet)[source]: Update to 1.7.0-31-g358b6cf.
2021-01-01 18:53:07 +01:00