mes.git
12 months agomescc: Compile fixes.
Jan Nieuwenhuizen [Wed, 14 Nov 2018 12:07:59 +0000 (13:07 +0100)]
mescc: Compile fixes.

* include/libmes-mini.h[WITH_GLIBC]: Do not declare strlen, write, types.

12 months agomes: Oops, %moduledir debug info.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 13:47:14 +0000 (14:47 +0100)]
mes: Oops, %moduledir debug info.

* mes/module/mes/boot-0.scm.in: Oops, %moduledir debug info.

12 months agobuild: configure: Support Mes.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:38:02 +0000 (10:38 +0100)]
build: configure: Support Mes.

* configure: Support Mes.

12 months agomes; Add read-line.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 15:57:58 +0000 (16:57 +0100)]
mes; Add read-line.

* mes/module/mes/guile.mes (read-line): New function.

12 months agomes: dirname: Fix for absolute file names.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:15:12 +0000 (10:15 +0100)]
mes: dirname: Fix for absolute file names.

* mes/module/mes/guile.mes (dirname): Fix absolute files.

12 months agomes: Add file-exists?.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:14:50 +0000 (10:14 +0100)]
mes: Add file-exists?.

* mes/module/mes/guile.mes (file-exists?): New function.

12 months agomes: Add with-error-to-file.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:14:10 +0000 (10:14 +0100)]
mes: Add with-error-to-file.

* mes/module/mes/guile.mes (with-error-to-file): New function.

12 months agomes: Add string-downcase, string-upcase, string-tokenize.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:00:04 +0000 (10:00 +0100)]
mes: Add string-downcase, string-upcase, string-tokenize.

* mes/module/srfi/srfi-13.mes (string-downcase, string-upcase,
string-tokenize): New function.

12 months agomes: Add char-downcase, char-upcase.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:10:43 +0000 (10:10 +0100)]
mes: Add char-downcase, char-upcase.

* mes/module/srfi/srfi-14.mes (char-downcase, char-upcase): New
function.

12 months agomes: Add char-set:digit, char-set:lower-case, char-set:upper-case.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:09:41 +0000 (10:09 +0100)]
mes: Add char-set:digit, char-set:lower-case, char-set:upper-case.

* mes/module/srfi/srfi-14.mes (char-set:digit, char-set:lower-case,
char-set:upper-case): New variable.

12 months agomes: Add char-set-adjoin, char-set-complement.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:08:03 +0000 (10:08 +0100)]
mes: Add char-set-adjoin, char-set-complement.

* mes/module/srfi/srfi-14.mes (char-set-adjoin, char-set-complement):
New function.

12 months agomes: system*: Support redirection.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:00:50 +0000 (10:00 +0100)]
mes: system*: Support redirection.

* mes/module/mes/posix.mes (system*): Support redirection.

12 months agocore: read_string: Allow for gc.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:17:50 +0000 (10:17 +0100)]
core: read_string: Allow for gc.

* src/posix.c (read_char): Add optional port parameter.
(read_string): Allow for gc.

12 months agocore: Add delete_file.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 10:03:03 +0000 (11:03 +0100)]
core: Add delete_file.

* src/posix.c (delete_file): New function.

12 months agocore: Add dup, dup2.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:18:50 +0000 (10:18 +0100)]
core: Add dup, dup2.

* src/posix.c (dup_, dup2_): New function.

12 months agocore: Add getcwd.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:16:19 +0000 (10:16 +0100)]
core: Add getcwd.

* src/posix.c (getcwd_): New function.

12 months agocore: Support redirection of stderr.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:04:03 +0000 (10:04 +0100)]
core: Support redirection of stderr.

* include/libmes-mini.h (g_stderr): New global.
* lib/mes/eputc.c (eputc): Use it.
* lib/mes/eputs.c (eputs): Likewise.
* lib/mes/oputc.c (oputc): Likewise.
* lib/mes/oputs.c (oputs): Likewise.
* src/lib.c (display_error_, write_error_): Likewise.
* src/posix.c (write_byte): Likewise.
* src/mes.c (mes_builtins): Likewise.
(main): Iniitalize g_stderr.
* src/posix.c (current_error_port, set_current_error_port): New
function.
* mes/module/mes/boot-0.scm.in (current-output-port,
current-error-port): Remove.

12 months agocore: Assert g_free in alloc.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:01:49 +0000 (10:01 +0100)]
core: Assert g_free in alloc.

* src/mes.c (alloc): Assert g_free.

12 months agomescc: unlink: Move to libc.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 10:00:42 +0000 (11:00 +0100)]
mescc: unlink: Move to libc.

* lib/linux/libc.c (unlink): New function.
* lib/linux/tcc.c (unlink): Remove.

12 months agomescc: dup, dup2: Move to libc.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:13:01 +0000 (10:13 +0100)]
mescc: dup, dup2: Move to libc.

* lib/linux/libc.c (dup, dup2): New function.
* lib/linux/gnu.c (dup, dup2): Remove.

12 months agomescc: getcwd: Move to libc.
Jan Nieuwenhuizen [Sun, 11 Nov 2018 09:12:19 +0000 (10:12 +0100)]
mescc: getcwd: Move to libc.

* lib/linux/libc.c (getcwd): New function.
* lib/linux/tcc.c (getcwd): Remove.

12 months agomescc: Support GNU make with POSIX.
Jan Nieuwenhuizen [Sat, 10 Nov 2018 07:32:42 +0000 (08:32 +0100)]
mescc: Support GNU make with POSIX.

* include/linux/x86/syscall.h (SYS_sigprocmask): New macro.
* include/linux/x86_64/syscall.h (SYS_rt_sigprocmask): New macro.
* include/signal.h (SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK): New macro.
(sigprocmask): Declare.
* lib/linux/gnu.c (sigprocmask): New function.

12 months agomescc: Support GNU Bash.
Jan Nieuwenhuizen [Fri, 9 Nov 2018 20:26:10 +0000 (21:26 +0100)]
mescc: Support GNU Bash.

* include/errno.h (EACCES, ENOSPC, ESPIPE): New macro.
* include/linux/x86/syscall.h (SYS_setuid, SYS_geteuid, SYS_getegid,
SYS_setgid): New macro.
* include/linux/x86_64/syscall.h: Likewise.
* include/stdint.h (LLONG_MIN, LLONG_MAX, SIZE_MAX): New macro.
* include/sys/stat.h (S_ISUID, S_ISGID, S_IXGRP, S_IXOTH, S_IRGRP,
S_IROTH, S_IWGRP, S_IWOTH, S_IRWXG, S_IRWXO): New macro.
* include/termio.h: New file.
* include/unistd.h (_POSIX_VERSION): New macro.
* lib/linux/gnu.c (geteuid, getegid, setuid, setgid): New function.
* lib/string/memchr.c: New file.
* lib/stub/getpwuid.c: New file.
* lib/stub/rand.c: New file.
* lib/stub/ttyname.c: New file.
* include/string.h (memchr): Declare.
* include/unistd.h (geteuid, getegid, setuid, setgid): Declare.

12 months agobuild: Simplify: cater for one compiler at a time.
Jan Nieuwenhuizen [Tue, 6 Nov 2018 19:29:35 +0000 (20:29 +0100)]
build: Simplify: cater for one compiler at a time.

* build-aux/build-cc.sh: Remove.
* build-aux/build-cc32.sh: Remove.
* build-aux/build-cc64.sh: Remove.
* build-aux/build-x86_64-mes.sh: Remove.
* build-aux/cc-mes.sh: Remove.
* build-aux/cc-x86_64-mes.sh: Remove.
* build-aux/cc32-mes.sh: Remove.
* build-aux/cc64-mes.sh: Remove.
* build-aux/test64.sh: Remove.
* build-aux/bootstrap-mes.sh: New file.
* build-aux/config.make.in: New file.
* build-aux/config.status.in: New file.
* build-aux/test-cc.sh: New file.
* .gitignore: Update.
* build-aux/GNUmakefile.in: Update.
* build-aux/build-guile.sh: Update.
* build-aux/build-mes.sh: Update.
* build-aux/build.sh.in: Update.
* build-aux/cc.sh: Update.
* build-aux/check-boot.sh: Update.
* build-aux/check-mes.sh: Update.
* build-aux/check-mescc.sh: Update.
* build-aux/check-tcc.sh: Update.
* build-aux/check.sh.in: Update.
* build-aux/config.sh: Update.
* build-aux/export.make: Update.
* build-aux/install.sh.in: Update.
* build-aux/pre-inst-env.in: Update.
* build-aux/test.sh: Update.
* build-aux/uninstall.sh.in: Update.
* configure: Update.
* configure.sh: Update.
* module/mescc/i386/as.scm: Update.
* module/mescc/preprocess.scm: Update.
* module/mescc/x86_64/as.scm: Update.
* scripts/mescc.in: Update.
* tests/psyntax.test: Update.

12 months agomescc: Add missing define.
Jan Nieuwenhuizen [Fri, 9 Nov 2018 15:56:54 +0000 (16:56 +0100)]
mescc: Add missing define.

* lib/x86-mes/x86.M1: Add missing define.

12 months agomescc: Exit if library cannot be found.
Jan Nieuwenhuizen [Thu, 8 Nov 2018 13:46:46 +0000 (14:46 +0100)]
mescc: Exit if library cannot be found.

* module/mescc/mescc.scm (arch-find): Exit upon failure.

12 months agomescc: Accept -O, --std, -x.
Jan Nieuwenhuizen [Thu, 8 Nov 2018 13:07:27 +0000 (14:07 +0100)]
mescc: Accept -O, --std, -x.

* scripts/mescc.in (parse-opts): Accept -O, --std, -x.

12 months agomescc: Support -dumpmachine.
Jan Nieuwenhuizen [Thu, 8 Nov 2018 21:41:20 +0000 (22:41 +0100)]
mescc: Support -dumpmachine.

* scripts/mescc.in (parse-opts): Support -dumpmachine.

12 months agomescc: vsnprintf: Compliant implementation.
Jan Nieuwenhuizen [Mon, 22 Oct 2018 16:33:40 +0000 (18:33 +0200)]
mescc: vsnprintf: Compliant implementation.

* lib/stdio/vsnprintf.c (vsnprintf): New, complient implementation,
replacing vsnprint.
* lib/stdio/vsprintf.c (vsnprint): Forward to vsnprint.
* lib/stdio/snprintf.c (snprintf): Likewise.
* scaffold/tests/9a-snprintf.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.

12 months agotest: Add performance test.
Jan Nieuwenhuizen [Sun, 21 Oct 2018 10:04:25 +0000 (12:04 +0200)]
test: Add performance test.

* module/mes/test.scm (pass-if-timeout): New macro.
* tests/perform.test: New test.
* build-aux/check-mes.sh (tests): Run it.

12 months agomes: Add ceil, floor, round, inexact->exact.
Jan Nieuwenhuizen [Sun, 21 Oct 2018 10:07:06 +0000 (12:07 +0200)]
mes: Add ceil, floor, round, inexact->exact.

* mes/module/mes/scm.mes (ceil, floor, round, inexact->exact,
exact->inexact): New function.

12 months agomes: read-string: Take optional port argument.
Jan Nieuwenhuizen [Sun, 21 Oct 2018 10:00:00 +0000 (12:00 +0200)]
mes: read-string: Take optional port argument.

* src/posix.c (read_string): Take optional port argument.
* mes/module/mes/guile.mes (read-string): Remove.

12 months agocore: eval_apply: Order gotos according to frequency.
Jan Nieuwenhuizen [Sun, 21 Oct 2018 06:50:45 +0000 (08:50 +0200)]
core: eval_apply: Order gotos according to frequency.

* src/mes.c (eval_apply): Order gotos according to frequency.

12 months agoRevert "core: eval_apply profile."
Jan Nieuwenhuizen [Sun, 21 Oct 2018 06:43:35 +0000 (08:43 +0200)]
Revert "core: eval_apply profile."

This reverts commit d61e6be0b18459a8e3c262eab448b428dc81937a.

12 months agocore: eval_apply profile.
Jan Nieuwenhuizen [Sun, 21 Oct 2018 06:25:07 +0000 (08:25 +0200)]
core: eval_apply profile.

* src/mes.c: Poor man's eval_apply profile.

12 months agocore: Fix displaying of closure.
Jan Nieuwenhuizen [Sat, 20 Oct 2018 18:01:45 +0000 (20:01 +0200)]
core: Fix displaying of closure.

* src/lib.c (display_helper): Fix displaying of closure.

12 months agomes: Print backtrace upon exception.
Jan Nieuwenhuizen [Sat, 20 Oct 2018 16:24:37 +0000 (18:24 +0200)]
mes: Print backtrace upon exception.

* mes/module/mes/catch.mes (display-backtrace,
frame-function): New function.
(%eh): Use them.

12 months agocore: Set procedure in stack frame.
Jan Nieuwenhuizen [Sat, 20 Oct 2018 16:27:13 +0000 (18:27 +0200)]
core: Set procedure in stack frame.

* src/mes.c (eval_apply): Set procedure in stack frame.

12 months agocore: Implement stack and frame.
Jan Nieuwenhuizen [Sat, 20 Oct 2018 16:23:20 +0000 (18:23 +0200)]
core: Implement stack and frame.

* src/lib.c (frame_printer make_frame_type, make_frame,
make_stack_type, make_stack, stack_length, stack_ref): New function.

12 months agocore: Support time functions.
Jan Nieuwenhuizen [Sat, 20 Oct 2018 12:18:04 +0000 (14:18 +0200)]
core: Support time functions.

* lib/linux/clock_gettime.c: New file, move from gnu.c.
* lib/linux/gettimeofday.c: New file, move from tcc.c.
* lib/linux/time.c: New file, move from tcc.c.
* lib/linux/libc.c: Include them.
* lib/linux/gnu.c (clock_gettime): Remove.
* lib/linux/tcc.c (time, gettimeofday): Remove.
* include/time.h (CLOCK_PROCESS_CPUTIME_ID): New define.
* src/posix.c (init_time, current_time, gettimeofday_,
seconds_and_nanoseconds_to_long, get_internal_run_time): New function.
* src/mes.c (scm_symbol_internal_time_units_per_second): New symbol.
(main): Call init_time.

13 months agocore: Use hash table for symbols.
Jan Nieuwenhuizen [Thu, 18 Oct 2018 16:50:09 +0000 (18:50 +0200)]
core: Use hash table for symbols.

* src/mes.c (mes_symbols): Use hash table for symbols.  Update users.

12 months agocore: Use assert before failure exit.
Jan Nieuwenhuizen [Fri, 19 Oct 2018 21:01:59 +0000 (23:01 +0200)]
core: Use assert before failure exit.

* src/mes.c (error): Use assert before failure exit.  Helps debugging.

13 months agocore: Add hashq_get_handle, hash, hash_ref, hash_set_x.
Jan Nieuwenhuizen [Thu, 18 Oct 2018 05:55:28 +0000 (07:55 +0200)]
core: Add hashq_get_handle, hash, hash_ref, hash_set_x.

* src/mes.c (scm_symbol_hashq_table, scm_symbol_record_type,
scm_symbol_module, scm_symbol_buckets, scm_symbol_size): New symbols.
Update users.
* src/hash.c (hash_list_of_char): Rename from hashq_.  Respect size,
update callers.
(hashq_, hash_ hash, hashq_get_handle, hash_ref, hash_set_x_,
hash_set_x): New function.
(hashq_ref): Do not return handle.  Update callers.

13 months agomes: Move pair? to core.
Jan Nieuwenhuizen [Thu, 18 Oct 2018 18:06:10 +0000 (20:06 +0200)]
mes: Move pair? to core.

* src/lib.c (pair_p): New function.  Gains 8% performance on MesCC.

12 months agomes: Move assoc to core.
Jan Nieuwenhuizen [Fri, 19 Oct 2018 20:38:19 +0000 (22:38 +0200)]
mes: Move assoc to core.

* mes/mes.c (assoc_string, assoc): New function.
* mes/module/mes/scm.mes (assoc): Remove.  Gains 12% performance for
MesCC.

12 months agoRevert "core: Add gc-debug for stack array."
Jan Nieuwenhuizen [Sat, 20 Oct 2018 08:58:56 +0000 (10:58 +0200)]
Revert "core: Add gc-debug for stack array."

This reverts commit f35084d1dbea889d107824e7596da1701c6b90ad.

12 months agocore: Add gc-debug for stack array.
Jan Nieuwenhuizen [Fri, 19 Oct 2018 19:23:17 +0000 (21:23 +0200)]
core: Add gc-debug for stack array.

* src/gc.c (gc_debug): New function.

12 months agoscaffold: Resurrect mini-mes.
Jan Nieuwenhuizen [Fri, 19 Oct 2018 18:20:00 +0000 (20:20 +0200)]
scaffold: Resurrect mini-mes.

* src/mini-mes.c: Resurrect.

23 months agocore: Use array-based stack.
Jan Nieuwenhuizen [Thu, 14 Dec 2017 06:05:53 +0000 (07:05 +0100)]
core: Use array-based stack.

* src/mes.c (STACK_SIZE)[MES_ARRAY_STACK]: New variable.
(g_stack_array): New variable.
(g_stack): Change type to SCM*.
(gc_push_frame)[MES_ARRAY_STACK]: Use g_stack_array, g_stack.
(gc_peek_frame): Likewise.
(gc_pop_frame): Likewise.
* src/gc.c (gc_check): Likewise.
(gc): Likewise.

13 months agomes: Resurrect Guile-1.8 support.
Jan Nieuwenhuizen [Wed, 17 Oct 2018 07:47:20 +0000 (09:47 +0200)]
mes: Resurrect Guile-1.8 support.

* module/mes/mes-0.scm: Resurrect Guile-1.8 support.

13 months agocore: expand_variable: Remove weird exceptions: begin, if.
Jan Nieuwenhuizen [Tue, 16 Oct 2018 15:13:04 +0000 (17:13 +0200)]
core: expand_variable: Remove weird exceptions: begin, if.

* src/mes.c (expand_variable_): Remove weird exceptions: begin, if.

13 months agomes: Switch to srfi-9 based on structs.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 18:42:10 +0000 (20:42 +0200)]
mes: Switch to srfi-9 based on structs.

* mes/module/srfi/srfi-9.mes: Swap symlink to srfi-9-struct.mes.
* mes/module/srfi/srfi-9/gnu.mes: Swap symlink to gnu-struct.mes.
* src/module.c (make_module_type): Update to match srfi-9-struct
records.  Update users.
* src/hash.c (make_hashq_type): Likewise.

13 months agomes: srfi-9: Add implementation based on struct.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 14:57:00 +0000 (16:57 +0200)]
mes: srfi-9: Add implementation based on struct.

* mes/module/srfi/srfi-9-struct.mes: New file.
* mes/module/srfi/srfi-9-vector.mes: Rename from srfi-9.mes
* mes/module/srfi/srfi-9.mes: Symlink to srfi-9-vector.mes.
* mes/module/srfi/srfi-9/gnu-struct.mes: Add srfi-9-struct
implementation.
* mes/module/srfi/srfi-9/gnu-vector.mes: Rename from gnu.mes.
* mes/module/srfi/srfi-9/gnu.mes: Symlink to gnu-vector.mes.

13 months agocore: hashq-table: Refactor to be a record-like struct.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 13:45:41 +0000 (15:45 +0200)]
core: hashq-table: Refactor to be a record-like struct.

* src/hash.c (hash_table_printer): New function.
(make_hashq_type): New function.
* src/module.c (module_printer): Use it.
(make_module_type): New function.
(make_initial_module): Use them.

13 months agomescc: Mes C Library: oputs: New function.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 13:44:47 +0000 (15:44 +0200)]
mescc: Mes C Library: oputs: New function.

* lib/mes/oputc.c: New file.
* lib/libmes.c: Include it.
* include/libmes.h: Declare it.

13 months agocore: Use hashq-table for macros.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 12:13:51 +0000 (14:13 +0200)]
core: Use hashq-table for macros.

* src/mes.c (lookup_macro_): Remove.
(macro_ref, get_macro, macro_set_x): New function.  Update callers.

13 months agocore: Add hashq-table type.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 11:36:19 +0000 (13:36 +0200)]
core: Add hashq-table type.

src/hash.c: New file.
src/module.c (char_hash, module_hash): Remove.
* src/module.c (make_initial_module): Use hash primitives.
(module_define_x): Likewise.
(module_variable): Likewise.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.

13 months agocore: Add boot-module.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 08:44:47 +0000 (10:44 +0200)]
core: Add boot-module.

* src/mes.c (scm_symbol_boot_module): New symbol.
(eval_apply): Handle it.
(mes_symbols): Initialize it.

13 months agocore: Add module-define!
Jan Nieuwenhuizen [Sun, 14 Oct 2018 07:10:30 +0000 (09:10 +0200)]
core: Add module-define!

* src/module.c (module_define_x, module_printer): New function.
(make_initial_module): Use them.
* tests/srfi-0.test: Test it.
* src/mes.c (display_m0): Remove.  Update callers.
* mes/module/mes/fluids.mes (make-fluid): Rewrite.
* tests/macro.test: Test it.
* mes/module/mes/boot-0.scm.in (module-define!): Remove.
* mes/module/mes/boot-02.scm: Likewise.
* module/mes/misc.scm (pk, warn): New function.
* build-aux/check-mes.sh (tests): Run tests.

13 months agocore: Add module indirection for variable lookup.
Jan Nieuwenhuizen [Sun, 14 Oct 2018 06:30:18 +0000 (08:30 +0200)]
core: Add module indirection for variable lookup.

* src/module.c (module_ref, module_variable): New function.
* src/mes.c: Thoughout: Use them.
(assq_ref_env): Remove.
* mes/module/mes/boot-0.scm.in (defined?): Use module-variable.
* mes/module/mes/boot-00.scm (defined?): Likewise.
* mes/module/mes/boot-01.scm (defined?): Likewise.
* mes/module/mes/boot-02.scm (defined?): Likewise.
* scaffold/boot/53-closure-display.scm: Likewise.

13 months agocore: Add module type.
Jan Nieuwenhuizen [Sun, 14 Oct 2018 06:15:22 +0000 (08:15 +0200)]
core: Add module type.

* src/module.c: New file.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.

13 months agocore: Add cstring_to_symbol.
Jan Nieuwenhuizen [Sun, 14 Oct 2018 05:38:51 +0000 (07:38 +0200)]
core: Add cstring_to_symbol.

* src/mes.c (make_symbol): Rename from lookup_symbol_.  Update
callers.
(cstring_to_symbol): New function.
* src/reader.c (reader_read_identifier_or_number): Use it.

13 months agocore: Add struct type.
Jan Nieuwenhuizen [Sat, 13 Oct 2018 15:34:27 +0000 (17:34 +0200)]
core: Add struct type.

* src/struct.c: New file.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.

13 months agobuild: factor-out snarfing.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 11:48:50 +0000 (13:48 +0200)]
build: factor-out snarfing.

* build-aux/snarf.sh: New file.
* build-aux/build-cc.sh: Use it.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-cc64.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/build-x86_64-mes.sh: Likewise.
* build-aux/snarf.sh: Likewise.

13 months agocore: core:cdr: Support port type.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 10:28:02 +0000 (12:28 +0200)]
core: core:cdr: Support port type.

* src/mes.c (cdr_): Support port type.
* mes/module/mes/display.mes (display): Add space between fields.

13 months agomes: with-fluids: Fix reset.
Jan Nieuwenhuizen [Mon, 15 Oct 2018 08:39:02 +0000 (10:39 +0200)]
mes: with-fluids: Fix reset.

* mes/module/mes/fluids.mes (with-fluids): Fix reset.
* tests/fluids.test (report): Remove Mes failure expectation.

12 months agomescc: Recognize U integer suffix.
Jan Nieuwenhuizen [Fri, 19 Oct 2018 21:31:30 +0000 (23:31 +0200)]
mescc: Recognize U integer suffix.

* module/mescc/compile.scm (cstring->int): Recognize U integer
suffix.  Thanks, Peter de Wachter!

13 months agomescc: Add INTn_MIN/MAX defines to stdint.h.
Peter De Wachter [Tue, 16 Oct 2018 18:40:41 +0000 (20:40 +0200)]
mescc: Add INTn_MIN/MAX defines to stdint.h.

* include/stdint.h: Add INTn_MIN/MAX defines.  Move integere size
defines from limits.h
* include/limits.h: Include it.

13 months agomescc: Allow superfluous parentheses in function declarations.
Peter De Wachter [Tue, 16 Oct 2018 18:40:40 +0000 (20:40 +0200)]
mescc: Allow superfluous parentheses in function declarations.

E.g.:  int (f)();
This is obscure but valid C.  It occurs in the csmith headers (thanks
to macro shenanigans).

* module/mescc/compile.scm (fctn-defn:get-name,
fctn-defn:get-statement): Allow superfluous parentheses in function declarations.

13 months agomescc: Implement unary plus operator.
Peter De Wachter [Tue, 16 Oct 2018 18:40:38 +0000 (20:40 +0200)]
mescc: Implement unary plus operator.

* module/mescc/compile.scm (ast->type, expr->register,
try-expr->number):): Implement unary plus operator.

13 months agomescc: Add missing assembly defines.
Peter De Wachter [Tue, 16 Oct 2018 18:40:37 +0000 (20:40 +0200)]
mescc: Add missing assembly defines.

* lib/x86-mes/x86.M1: Add missing assembly defines.
* lib/x86_64-mes/x86_64.M1: Likewise.

13 months agomescc: Delete duplicate assembly defines.
Peter De Wachter [Tue, 16 Oct 2018 18:40:36 +0000 (20:40 +0200)]
mescc: Delete duplicate assembly defines.

* lib/x86-mes/x86.M1: Delete duplicate assembly defines.
* lib/x86_64-mes/x86_64.M1: Likewise.

13 months agomescc: Exit with non-zero exit code when subprocess fails.
Peter De Wachter [Tue, 16 Oct 2018 18:40:35 +0000 (20:40 +0200)]
mescc: Exit with non-zero exit code when subprocess fails.

system* returns the result of waitpid. So, suppose that a subprocess
fails with exit code 1. Then the waitpid return value will be 256.
And exit(256) is equivalent to exit(0).

Modified-by: Jan Nieuwenhuizen <janneke@gnu.org>
* mes/module/mes/posix.mes (status:exit-val): New function.
* module/mescc/mescc.scm (assert-system*): Use it.

13 months agomescc: Oops typo.
Jan Nieuwenhuizen [Fri, 12 Oct 2018 07:37:10 +0000 (09:37 +0200)]
mescc: Oops typo.

* module/mescc/M1.scm (hex2:immediate8): Typo.

11 months agocore: Support \xNN in reader. Fixes tcc-boot running on Mes. fix
Jan Nieuwenhuizen [Thu, 13 Dec 2018 17:19:19 +0000 (18:19 +0100)]
core: Support \xNN in reader.  Fixes tcc-boot running on Mes.

* src/reader.c (reader_read_string): Support \xNN.  Fixes Guix
bootstrap chain; i.e., compilation of gcc-2.95.3 using tcc-boot.
* tests/base.test ("reader: \\x08"): Test it.
* scaffold/tests/17-compare-char.c: Likewise, for mescc.
* build-aux/check-mescc.sh (tests): Run it.

12 months agobuild: configure: Make dot optional.
Jan Nieuwenhuizen [Sun, 18 Nov 2018 13:30:47 +0000 (14:30 +0100)]
build: configure: Make dot optional.

* configure: Make dot optional.

13 months agobuild: Oops, remove stray lib/linux/x86_64-mes/crt1.
Jan Nieuwenhuizen [Thu, 11 Oct 2018 19:14:14 +0000 (21:14 +0200)]
build: Oops, remove stray lib/linux/x86_64-mes/crt1.

* lib/linux/x86_64-mes/crt1: Remove.

13 months agobuild: x86_64 bootstrap build fixes and workaround.
Jan Nieuwenhuizen [Tue, 9 Oct 2018 17:22:51 +0000 (19:22 +0200)]
build: x86_64 bootstrap build fixes and workaround.

* configure: Substitute @arch@ (WAS: ARCH).  Update users.
* configure.sh: Substitute @arch@.
* build-aux/build-mes.sh: Use $GUILE for x86_64 build.
* build-aux/install.sh.in: Install mes.S, mes.x86_64-mes-S too.
Prune *.E, *.out.

13 months agodoc: Release update.
Jan Nieuwenhuizen [Sun, 7 Oct 2018 15:19:04 +0000 (17:19 +0200)]
doc: Release update.

13 months agomescc: Oops, delete wrong line of assembly.
Jan Nieuwenhuizen [Mon, 8 Oct 2018 05:53:09 +0000 (07:53 +0200)]
mescc: Oops, delete wrong line of assembly.

* lib/x86-mes/x86.M1 (movzbl_%bx,%ebx): Delete wrong line.  Thanks, pdewacht!

13 months agoadmin: Release update.
Jan Nieuwenhuizen [Sun, 7 Oct 2018 13:29:42 +0000 (15:29 +0200)]
admin: Release update.

* doc/announce/ANNOUNCE-0.18: New file.
* guix/git/mes.scm (mes): Update hash.

13 months agoRelease 0.18. v0.18
Jan Nieuwenhuizen [Thu, 4 Oct 2018 21:15:25 +0000 (23:15 +0200)]
Release 0.18.

* configure (VERSION): Update to 0.18.
(main): Likewise.
* configure.sh (VERSION): Likewise.
* guix/git/mes.scm (mes, mes.git): Likewise.
* guix/mescc-tools-boot.patch: New file.

14 months agodoc: Release update.
Jan Nieuwenhuizen [Wed, 5 Sep 2018 05:05:08 +0000 (07:05 +0200)]
doc: Release update.

* BOOTSTRAP: Update.
* HACKING: Update.
* NEWS: Update.
* README: Update.
* doc/mes.texi (Submitting Patches): Fix misquoting, misattribution.

13 months agomescc: Another attempt at divide.
Jan Nieuwenhuizen [Sun, 7 Oct 2018 13:15:45 +0000 (15:15 +0200)]
mescc: Another attempt at divide.

* module/mescc/i386/as.scm (i386:r0/r1): Never be signed.  Use div for unsigned.
(i386:r0%r1): Likewise.
* module/mescc/x86_64/as.scm (x86_64:r0/r1): Likewise.
(x86_64:r0%r1): Likewise.
* lib/x86-mes/x86.M1: Add div.
* lib/x86_64-mes/x86_64.M1: Likewise.

13 months agotests: Expect srfi-13 failure, MesCC more resembles Gcc.
Jan Nieuwenhuizen [Sun, 7 Oct 2018 12:14:50 +0000 (14:14 +0200)]
tests: Expect srfi-13 failure, MesCC more resembles Gcc.

* tests/srfi-13.test (report): Expect INT-MIN failure for x86.

13 months agocore: reader: Support 64 bit.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 22:58:31 +0000 (00:58 +0200)]
core: reader: Support 64 bit.

* src/reader.c (reader_read_identifier_or_number): Support 64 bit.
(reader_read_binary): Likewise.
(reader_read_octal): Likewise.
(reader_read_hex): Likewise.

13 months agomescc: Mes C Library: Fix execve on x86_64.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 20:38:28 +0000 (22:38 +0200)]
mescc: Mes C Library: Fix execve on x86_64.

* include/linux/x86_64/syscall.h (SYS_execve): Typo.  Fixes execve on
x86_64.

13 months agobuild: Support make seed for x86_64.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 20:26:07 +0000 (22:26 +0200)]
build: Support make seed for x86_64.

* build-aux/GNUmakefile.in (seed): Support make seed for x86_64.
* build-aux/build-mes.sh[SEED]: Also build src/mes.S.
* build-aux/build-x86_64-mes.sh[SEED]: Also build src/mes.x86_64-mes.S.

13 months agomes: Support fold-right 3.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 19:05:43 +0000 (21:05 +0200)]
mes: Support fold-right 3.

* mes/module/srfi/srfi-1.mes (fold-right): Support fold-right 3.
* tests/srfi-1.test ("fold-right-3"): Test it.

13 months agomescc: Nyacc comment escapes.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 18:32:49 +0000 (20:32 +0200)]
mescc: Nyacc comment escapes.

* module/mescc/compile.scm (ast->comment): Nyacc comment escapes.

13 months agomescc: Fix clobbering of struct by value assign.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 18:23:43 +0000 (20:23 +0200)]
mescc: Fix clobbering of struct by value assign.

* module/mescc/x86_64/as.scm (long-r0->r1-mem): New instruction.
* module/mescc/i386/as.scm: Likewise.
* lib/x86_64-mes/x86_64.M1: Support it.
* module/mescc/compile.scm (r0->r1-mem*n-): Fix clobbering.

13 months agocore: Add vector test.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 05:13:04 +0000 (07:13 +0200)]
core: Add vector test.

* scaffold/boot/11-vector.scm: New test.
* build-aux/check-boot.sh: Run it.

13 months agomescc: Fix obnoxious assignment ERROR message.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 17:22:16 +0000 (19:22 +0200)]
mescc: Fix obnoxious assignment ERROR message.

* module/mescc/compile.scm (expression->register): Fix assignment
ERROR message.

13 months agocore: Avoid 64bit zero divide.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 22:25:33 +0000 (00:25 +0200)]
core: Avoid 64bit zero divide.

* src/math.c (divide): Avoid (64bit) 0 divide.
(modulo): Likewise.

13 months agomescc: Support negative divide.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 15:28:08 +0000 (17:28 +0200)]
mescc: Support negative divide.

* module/mescc/i386/as.scm (i386:r0/r1, i386:r0%r1): Support
negative divide.
* module/mescc/x86_64/as.scm (x86_64:r0/r1, x86_64:r0%r1): Likewise.
* lib/x86-mes/x86.M1: Likewise.
* lib/x86_64-mes/x86_64.M1: Likewise.
* scaffold/tests/a0-math-divide-signed-negative.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.

13 months agomescc: Support --align, off by default.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 13:56:14 +0000 (15:56 +0200)]
mescc: Support --align, off by default.

* scripts/mescc.in (parse-opts): Add --align.
* module/mescc/mescc.scm (mescc:compile): Support --align, off by
default.
* module/mescc/M1.scm (infos->M1): Add #:align parameter.
(M1:merge-infos): Likewise.  Keep types.
(info->M1): Likewise.  Make alignment switchable.
* module/mescc/compile.scm (r->ident):  Do not clobber.
(ident-add): Likewise.
(clean-info): Keep types.
* module/mescc/i386/as.scm (i386:r->byte-label): New instruction.
* lib/x86-mes/x86.M1: Add instructions.
* lib/x86_64-mes/x86_64.M1: Add instructions.
* module/mescc/x86_64/as.scm (x86_64:r->byte-label,
x86_64:r->word-label, x86_64:r->long-label): New instruction.

13 months agoRevert "mescc: Make globals at least reg-size."
Jan Nieuwenhuizen [Sat, 6 Oct 2018 13:57:52 +0000 (15:57 +0200)]
Revert "mescc: Make globals at least reg-size."

This reverts commit 30544316c35ed4a2472f2029beb27e007d913792.

13 months agomescc: Make globals at least reg-size.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 13:36:32 +0000 (15:36 +0200)]
mescc: Make globals at least reg-size.

* module/mescc/compile.scm (global->info): Make globals at least reg-size.

13 months agomescc: Support 64-bit immediates.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 12:51:57 +0000 (14:51 +0200)]
mescc: Support 64-bit immediates.

* module/mescc/M1.scm (hex2:address8, hex2:immediate8): New function.
(info->M1): Support 64-bit.
* module/mescc/compile.scm (convert-r0): FIXME!
* module/mescc/x86_64/as.scm (x86_64:value->r, x86_64:r->local,
x86_64:label->arg, x86_64:label->r, x86_64:r+value,
x86_64:r-cmp-value, x86_64:r-long-mem-add, x86_64:r-and): Support
64-bit immediates.
* lib/x86_64-mes/x86_64.M1: Likewise.
* scaffold/tests/17-compare-unsigned-char-le.c: Test it.
* scaffold/tests/17-compare-unsigned-short-le.c: Test it.
* build-aux/check-mescc.sh (tests): Run them.

13 months agocore: Use proper name for %compiler.
Jan Nieuwenhuizen [Sat, 6 Oct 2018 06:43:26 +0000 (08:43 +0200)]
core: Use proper name for %compiler.

* src/mes.c (mes_symbols, bload_env): : Use proper name for %compiler.