mes.git
2 years agomescc: Support binutils-2.10.1: Stubs set errno to 0.
Jan Nieuwenhuizen [Sat, 9 Jun 2018 09:28:31 +0000 (11:28 +0200)]
mescc: Support binutils-2.10.1: Stubs set errno to 0.

2 years agomescc: Silence some stubs.
Jan Nieuwenhuizen [Sat, 9 Jun 2018 05:40:07 +0000 (07:40 +0200)]
mescc: Silence some stubs.

* lib/libc+tcc.c: [!NOISY_FLOATS, !NOISY_TIMES]: Silence stubs.
* lib/gcc.c: Likewise.
* lib/binutils.c: Likewise.

2 years agomescc: Add debug printing: fopen, fwrite.
Jan Nieuwenhuizen [Sun, 10 Jun 2018 05:51:56 +0000 (07:51 +0200)]
mescc: Add debug printing: fopen, fwrite.

* lib/libc+tcc.c (fopen, fwrite)[MESC_DEBUG]: Print debug info.

2 years agomescc: Support binutils-2.10.1: opentype `r+'.
Jan Nieuwenhuizen [Sun, 10 Jun 2018 05:51:10 +0000 (07:51 +0200)]
mescc: Support binutils-2.10.1: opentype `r+'.

* lib/libc+tcc.c (fopen): Support opentype `r+'.

2 years agomescc: syscall: return only ever error -1, set errno.
Jan Nieuwenhuizen [Fri, 8 Jun 2018 05:17:51 +0000 (07:17 +0200)]
mescc: syscall: return only ever error -1, set errno.

2 years agomescc: Support gcc-2.95: Add getpwnam stub.
Jan Nieuwenhuizen [Thu, 7 Jun 2018 16:04:17 +0000 (18:04 +0200)]
mescc: Support gcc-2.95: Add getpwnam stub.

* lib/gcc.c (getpwnam): New stub.

2 years agomescc: Support gcc-3.0: Implement alarm, setitimer.
Jan Nieuwenhuizen [Thu, 7 Jun 2018 16:03:51 +0000 (18:03 +0200)]
mescc: Support gcc-3.0: Implement alarm, setitimer.

2 years agomescc: Support gcc-3.0: Implement atexit.
Jan Nieuwenhuizen [Thu, 7 Jun 2018 16:02:21 +0000 (18:02 +0200)]
mescc: Support gcc-3.0: Implement atexit.

2 years agomescc: Support gcc-3.0: Implement dup2, fcntl, getrusage.
Jan Nieuwenhuizen [Thu, 7 Jun 2018 06:02:32 +0000 (08:02 +0200)]
mescc: Support gcc-3.0: Implement dup2, fcntl, getrusage.

* include/sys/resource.h: New file.
* lib/linux+gnu.c (fcntl, dup2, getrusage): New function.
* lib/binutils.c (fcntl): Remove stub.

2 years agomescc: Support gcc-3.2: Implement getuid, getgid.
Jan Nieuwenhuizen [Thu, 7 Jun 2018 05:19:01 +0000 (07:19 +0200)]
mescc: Support gcc-3.2: Implement getuid, getgid.

* lib/linux+gnu.c (getuid, getdid): New function.
* lib/binutils.c (getuid, getdid): Remove stub.

2 years agomescc: Support gcc-3.2: Reset errno.
Jan Nieuwenhuizen [Thu, 7 Jun 2018 05:16:43 +0000 (07:16 +0200)]
mescc: Support gcc-3.2: Reset errno.

* lib/linux-gcc.c (_sys_call, _sys_call1, _sys_call2, _sys_call3):
  Reset errno.
* lib/linux-mes.c (__sys_call, __sys_call1, __sys_call2 ,
  __sys_call3): Rename from _*.
   (_sys_call, _sys_call1, _sys_call2, _sys_call3): New function.
  Reset errno.

2 years agomescc: Support gcc-3.2: Implement integer strto*.
Jan Nieuwenhuizen [Wed, 6 Jun 2018 20:39:57 +0000 (22:39 +0200)]
mescc: Support gcc-3.2: Implement integer strto*.

* lib/libc+tcc.c (strtoll, strtoul): Call strtoul.

2 years agomescc: Support gcc-3.2: Add getpid, signal.
Jan Nieuwenhuizen [Wed, 6 Jun 2018 20:14:35 +0000 (22:14 +0200)]
mescc: Support gcc-3.2: Add getpid, signal.

* lib/linux+gnu.c (getpid, signal): New function.
* include/signal.h: Declare signal.
* include/unistd.h: Declare getpid.
* scaffold/tests/95-signal.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.

2 years agomescc: Support gcc-3.4.0: *printf: Support `%n'.
Jan Nieuwenhuizen [Wed, 6 Jun 2018 17:29:32 +0000 (19:29 +0200)]
mescc: Support gcc-3.4.0: *printf: Support `%n'.

* lib/libc+tcc.c (vfprintf, vsprintf): Support `%n'.  For Gcc 3.4.0.
* scaffold/tests/70-printf.c: Test it.

2 years agomescc: Support gcc-3.4.0: alloca.
Jan Nieuwenhuizen [Wed, 6 Jun 2018 17:44:29 +0000 (19:44 +0200)]
mescc: Support gcc-3.4.0: alloca.

* lib/alloca.c: New file.
* AUTHORS: Mention it.
* lib/libc+gnu.c: Add it.
* include/stdlib.h: Declare alloca.

2 years agomescc: Support gcc-3.4.0: unsetenv.
Jan Nieuwenhuizen [Wed, 6 Jun 2018 17:43:32 +0000 (19:43 +0200)]
mescc: Support gcc-3.4.0: unsetenv.

* lib/gcc.c (unsetenv): New function.

2 years agomescc: Support gcc-3.2: Add __divdi3, __moddi3 stubs.
Jan Nieuwenhuizen [Wed, 6 Jun 2018 15:02:01 +0000 (17:02 +0200)]
mescc: Support gcc-3.2: Add __divdi3, __moddi3 stubs.

* lib/gcc.c (__divdi3, __moddi3): New stubs.

2 years agomescc: Support gcc-3.2: puts with newline.
Jan Nieuwenhuizen [Wed, 6 Jun 2018 13:55:03 +0000 (15:55 +0200)]
mescc: Support gcc-3.2: puts with newline.

* lib/libc-mini.c (oputs): Rename from puts.
  (puts): New function: Add newline.

2 years agomescc: Support binutils-2.10.1.
Jan Nieuwenhuizen [Wed, 6 Jun 2018 11:16:25 +0000 (13:16 +0200)]
mescc: Support binutils-2.10.1.

xx

2 years agomescc: Support glibc-1.06.4.
Jan Nieuwenhuizen [Sun, 3 Jun 2018 16:54:26 +0000 (18:54 +0200)]
mescc: Support glibc-1.06.4.

* lib/glibc.c: New file.
* lib/libc+gnu.c: Include it.

2 years agomescc: Support gcc-2.6.3.
Jan Nieuwenhuizen [Sat, 2 Jun 2018 09:41:06 +0000 (11:41 +0200)]
mescc: Support gcc-2.6.3.

* TODO

2 years agomescc: Support binutils-2.5.1.
Jan Nieuwenhuizen [Wed, 30 May 2018 19:55:39 +0000 (21:55 +0200)]
mescc: Support binutils-2.5.1.

* include/stdint.h: #undef types before typedef'ing them.
* include/sys/types.h: Likewise.
* include/string.h (NULL): New define.
* include/stdio.h (BUFSIZ): New define.

2 years agotests: Remove tinycc-imported non-free grep test.
Jan Nieuwenhuizen [Fri, 1 Jun 2018 13:35:05 +0000 (15:35 +0200)]
tests: Remove tinycc-imported non-free grep test.

* scaffold/tinycc/46_grep.c: Remove.
* scaffold/tinycc/46_grep.expect: Remove.

2 years agomescc: Implement fflush, sscanf, vsscanf.
Jan Nieuwenhuizen [Wed, 30 May 2018 19:49:40 +0000 (21:49 +0200)]
mescc: Implement fflush, sscanf, vsscanf.

* lib/libc+tcc.c (vsscanf): New function.
  (sscanf): Use it.
  (fflush): Remove stub notice; we have no buffering.
* include/stdarg.h: Declare it.
* scaffold/tests/87-sscanf.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.

2 years agobuild: Use arch-dir.
Jan Nieuwenhuizen [Tue, 29 May 2018 18:07:46 +0000 (20:07 +0200)]
build: Use arch-dir.

* lib/x86-mes: Move from stage0.
* build-aux/build-cc.sh: Create libraries in lib/gcc.  Update users.
* build-aux/build-mes.sh: Create libraries in lib/x86-mes.  Update users.
* build-aux/build-mes-gcc.sh: Rename from build-mlibc.sh.  Create
  libraries in lib/x86-mes-gcc.  Update callers.
* build-aux/cc-mes-gcc.sh: Rename from cc-mlibc.sh.  Update callers.

2 years agomlibc: Implement strstr.
Jan Nieuwenhuizen [Tue, 29 May 2018 17:35:20 +0000 (19:35 +0200)]
mlibc: Implement strstr.

* lib/libc+tcc.c (_memmem, memmem): New function.  Import from GNU
  LilyPond.
  (strstr): Implement using memmem.
* include/string.h (_memmem, memmem): Declare.
* AUTHORS: Add Han-Wen Nienhuys.

2 years agomlibc: Implement ftell, fseek.
Jan Nieuwenhuizen [Tue, 29 May 2018 17:33:32 +0000 (19:33 +0200)]
mlibc: Implement ftell, fseek.

* lib/libc+tcc.c (ftell, fseek): Implement.

2 years agomlibc: Cleanup.
Jan Nieuwenhuizen [Tue, 29 May 2018 16:15:22 +0000 (18:15 +0200)]
mlibc: Cleanup.

2 years agomescc: m4 support: WIP
Jan Nieuwenhuizen [Sun, 27 May 2018 08:28:30 +0000 (10:28 +0200)]
mescc: m4 support: WIP

2 years agocore: Refactor boot-0 loading.
Jan Nieuwenhuizen [Mon, 28 May 2018 16:53:25 +0000 (18:53 +0200)]
core: Refactor boot-0 loading.

* src/mes.c (load_boot): New function.
  (load_env): Use it.

2 years agomescc: Out of the box Geiser support.
Jan Nieuwenhuizen [Sat, 26 May 2018 18:54:51 +0000 (20:54 +0200)]
mescc: Out of the box Geiser support.

* .dir-locals.el: New file.  Out of the box Geiser support for mescc.

2 years agomescc: Posixify interface.
Jan Nieuwenhuizen [Fri, 25 May 2018 06:05:02 +0000 (08:05 +0200)]
mescc: Posixify interface.

* module/mescc/compile.mes: Move from language/c99/compiler.mes.
* module/mescc: New module..
* module/mescc/M1.scm: Move from mes/M1.mes.
* module/mescc/as.scm: Likewise.
* module/mescc/bytevectors.scm: Likewise.
* module/mescc/mescc.scm: New file.
* scripts/mescc: Update to new layout and posixy interface.
* GNUmakefile: Likewise.
* build-aux/build-cc.sh: Likewise.
* build-aux/build-guile.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/build-mlibc.sh: Likewise.
* build-aux/cc-mes.sh: Likewise.
* build-aux/cc-mlibc.sh: Likewise.
* build-aux/cc.sh: Likewise.
* build-aux/check-mescc.sh: Likewise.
* build-aux/test.sh: Likewise.
* build.sh: Likewise.
* .gitignore: Update for posixy extensions.

2 years agomes: Add drop, drop-right.
Jan Nieuwenhuizen [Sat, 26 May 2018 18:47:33 +0000 (20:47 +0200)]
mes: Add drop, drop-right.

* module/srfi/srfi-1.mes (drop, drop-right): New function.

2 years agoRevert "fork/exec: debug."
Jan Nieuwenhuizen [Fri, 25 May 2018 09:21:26 +0000 (11:21 +0200)]
Revert "fork/exec: debug."

This reverts commit f0315ac0d9acd66a30dbb192334f443459b7ed16.

2 years agofork/exec: debug.
Jan Nieuwenhuizen [Fri, 25 May 2018 09:21:06 +0000 (11:21 +0200)]
fork/exec: debug.

2 years agocore: Support fork, waitpid, execve.
Jan Nieuwenhuizen [Thu, 24 May 2018 17:54:42 +0000 (19:54 +0200)]
core: Support fork, waitpid, execve.

* stage0/x86.M1 (SYS_fork, SYS_waitpid, SYS_execve): New define.
* lib/linux-gcc.c (fork, waitpid, execve): New function.
* lib/linux-mes.c (fork, waitpid, execve): New function.
* lib/libc.c (wait): New function.
* include/unistd.h (fork, execve): Declare.
* include/sys/wait.h (waitpid, wait): Declare.
* module/mes/posix.mes (search-path, execlp, system*, waitpid): New function.
* src/posix.c (primitive_fork, execl): New function.

2 years agomescc: Oops, alignment.
Jan Nieuwenhuizen [Sun, 27 May 2018 06:20:00 +0000 (08:20 +0200)]
mescc: Oops, alignment.

* module/mes/M1.mes (object->M1): Oops, alignment: only add alignment
  when not aligned.

2 years agomescc: Add fopen.
Jeremiah Orians [Sat, 26 May 2018 20:33:00 +0000 (16:33 -0400)]
mescc: Add fopen.

* lib/libc+tcc.c (fopen)[!POSIX]: Remove stub.
* lib/libc.c (fopen)[!POSIX]: New function.
* AUTHORS: Add Jeremiah.

2 years agobuild: Remove function declarations from M1.
Jan Nieuwenhuizen [Sun, 27 May 2018 05:12:33 +0000 (07:12 +0200)]
build: Remove function declarations from M1.

* module/language/c99/compiler.mes (info->object): Remove function
  declarations.

2 years agobuild: Check for mes-seed, tinycc-seed.
Jan Nieuwenhuizen [Sun, 27 May 2018 04:59:36 +0000 (06:59 +0200)]
build: Check for mes-seed, tinycc-seed.

* configure: Check for guile-tools, mes-seed, tinycc-seed.  Bugfix:
  Add cwd to load path.

2 years agoguix: mes: Update to 0.14.
Jan Nieuwenhuizen [Tue, 22 May 2018 19:02:24 +0000 (21:02 +0200)]
guix: mes: Update to 0.14.

* guix.scm (mes): Update to 0.14.
  (mes.git): Likewise.

2 years agoguix: Add nyacc-for-mes.
Jan Nieuwenhuizen [Wed, 23 May 2018 11:12:02 +0000 (13:12 +0200)]
guix: Add nyacc-for-mes.

* guix.scm (nyacc-for-mes): New variable.

2 years agoRelease 0.14. v0.14
Jan Nieuwenhuizen [Sun, 20 May 2018 10:47:01 +0000 (12:47 +0200)]
Release 0.14.

* configure (VERSION): Bump to 0.14.

2 years agodoc: Release udpate.
Jan Nieuwenhuizen [Sat, 19 May 2018 18:52:24 +0000 (20:52 +0200)]
doc: Release udpate.

* BOOTSTRAP: Update.
* HACKING: Update.
* NEWS: Update.
* README: Update.
* doc/ANNOUNCE-0.14: New file.

2 years agomescc: Tinycc support: Handle short struct initializer.
Jan Nieuwenhuizen [Tue, 22 May 2018 16:24:32 +0000 (18:24 +0200)]
mescc: Tinycc support: Handle short struct initializer.

* module/language/c99/compiler.mes (array-init-element->data): Handle
  short struct initializer.

2 years agomescc: Align global data.
Jan Nieuwenhuizen [Mon, 21 May 2018 19:54:54 +0000 (21:54 +0200)]
mescc: Align global data.

* module/mes/M1.mes (object->M1): Align globals.

2 years agomescc: Tinycc support: strncpy.
Jan Nieuwenhuizen [Sun, 20 May 2018 08:55:44 +0000 (10:55 +0200)]
mescc: Tinycc support: strncpy.

* lib/libc+tcc.c (strncpy): New function.
* scaffold/tests/86-strncpy.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
* build-aux/cc-mlibc.sh (LIBC): Acknowlegde.
* build-aux/test.sh (LIBC): Export it.

2 years agotinycc: Add stubs: __fixdfdi, __fixxfdi, __fixsfdi.
Jan Nieuwenhuizen [Mon, 21 May 2018 06:43:58 +0000 (08:43 +0200)]
tinycc: Add stubs: __fixdfdi, __fixxfdi, __fixsfdi.

* lib/libc+tcc-gcc.c (__fixdfdi, __fixxfdi, __fixsfdi): New stub.

2 years agotinycc: Add stubs: __floatundixf __fixunsxfdi.
Jan Nieuwenhuizen [Sun, 20 May 2018 08:38:13 +0000 (10:38 +0200)]
tinycc: Add stubs: __floatundixf __fixunsxfdi.

* lib/libc+tcc-gcc.c (__floatundixf, __fixunsxfdi): New stub.

2 years agomescc: Tinycc support: workaround for tcc; this breaks: Structured type with char...
Jan Nieuwenhuizen [Sun, 20 May 2018 06:58:44 +0000 (08:58 +0200)]
mescc: Tinycc support: workaround for tcc; this breaks: Structured type with char or short on heap.

* module/language/c99/compiler.mes (int->bv): Always use 32bit byte
  vector.

2 years agomescc: Tinycc support: Structured type with char or short on heap.
Jan Nieuwenhuizen [Sat, 19 May 2018 12:53:05 +0000 (14:53 +0200)]
mescc: Tinycc support: Structured type with char or short on heap.

* module/language/c99/compiler.mes (int->bv): New function.
  (init->data): Use it.  Add parameter.  Update callers.
  (array-init->data): Add type parmeter.
  (array-init-element->data): Likewise.
* module/mes/bytevectors.mes (bytevector-u8-set!): New function.
* module/mes/bytevectors.scm (mes): Export it.
* module/mes/as.mes (int->bv8): New function.

2 years agomescc: Fix size ERROR message.
Jan Nieuwenhuizen [Sun, 20 May 2018 06:51:15 +0000 (08:51 +0200)]
mescc: Fix size ERROR message.

* module/language/c99/compiler.mes (expr->accu): Fix size ERROR message.

2 years agomescc: Fix itoa.
Jan Nieuwenhuizen [Sun, 20 May 2018 06:33:06 +0000 (08:33 +0200)]
mescc: Fix itoa.

* lib/libc.c (itoa): Use function-static buffer.  Increase to 12 to
  handle INT_MIN.
  (itoab): Likewise.

2 years agomescc: Tinycc support: Export nested struct definitions.
Jan Nieuwenhuizen [Sat, 19 May 2018 18:49:56 +0000 (20:49 +0200)]
mescc: Tinycc support: Export nested struct definitions.

* module/language/c99/compiler.mes (struct-field): Support nested,
  named and anonymous enums.
  (field->info): New function.
  (type->info): Use it to reap nestedly defined enums, structs, unions.
  (decl->info): Likewise.
* scaffold/tests/t.c: Test it.

2 years agomescc: Tinycc support: Unsigned comparison.
Jan Nieuwenhuizen [Sat, 19 May 2018 09:41:53 +0000 (11:41 +0200)]
mescc: Tinycc support: Unsigned comparison.

* stage0/x86.M1 (ja32, jae32, jb32, jbe32): New macro.
* module/mes/as-i386.mes (i386:jump-a, i386:jump-ae, i386:jump-b,
  i386:jump-be): Use it in new function.
* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes (test-jump-label->info): Use them to
  support unsigned comparison.
* scaffold/tests/7s-unsigned-compare.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.

2 years agomescc: Tinycc support: Char and short sign extend.
Jan Nieuwenhuizen [Fri, 18 May 2018 21:58:10 +0000 (23:58 +0200)]
mescc: Tinycc support: Char and short sign extend.

* module/mes/as-i386.mes (i386:accu*n->local, i386:byte-accu->local+n,
  i386:word-accu->local+n): Remove.
  (i386:byte-accu, i386:signed-byte-accu, i386:word-accu,
  i386:signed-word-accu): New function.
* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes (accu->local+n-text): Simplify.
  (mem->accu, convert-accu): New function.
  (expr->accu): Use them.
* stage0/x86.M1 (mov____%al,0x32(%ebp), mov____%al,0x8(%ebp),
  mov____%ax,0x32(%ebp), mov____%ax,0x8(%ebp), movzbl_0x32(%ebp),%eax,
  movzbl_0x8(%ebp),%eax, movzwl_0x32(%ebp),%eax,
  movzwl_0x8(%ebp),%eax): Deprecate.
* scaffold/tests/7r-sign-extend.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.

2 years agomes: string->number: Support upper case hex.
Jan Nieuwenhuizen [Mon, 21 May 2018 04:51:21 +0000 (06:51 +0200)]
mes: string->number: Support upper case hex.

* module/mes/scm.mes (string->number): Support upper case hex.

2 years agomescc: Tinycc support: Minimal float support.
Jan Nieuwenhuizen [Fri, 18 May 2018 13:28:05 +0000 (15:28 +0200)]
mescc: Tinycc support: Minimal float support.

* lib/libc+tcc.c (ldexp, strtod, strtof, strtold): New stub.
* include/math.h (ldexp): Declare.
* include/stdlib.h (strtod, strtof, strtold): Declare.
* module/mes/scm.mes (string->number): Minimal float support.
  (inexact->exact): New function.
* tests/math.test ("string->number"): Test it.
* module/language/c99/compiler.mes (ast->type): Handle float type.
  (type->info): Likewise.
  (cstring->int): Rename from cstring->number.  Update callers.
  (cstring->float): New function.
  (expr->accu): Use it.

2 years agomescc: Tinycc support: Switch with heterogeneous body, non-last default.
Jan Nieuwenhuizen [Thu, 17 May 2018 05:40:01 +0000 (07:40 +0200)]
mescc: Tinycc support: Switch with heterogeneous body, non-last default.

* module/language/c99/compiler.mes (switch->info): New function.
  (ast->info): Use it for switch.
  (clause->info, statements->clauses): Remove.
* scaffold/tests/44-switch.c (default_first): Test it.

2 years agomes: Support fold 3.
Jan Nieuwenhuizen [Sun, 20 May 2018 21:20:27 +0000 (23:20 +0200)]
mes: Support fold 3.

* module/srfi/srfi-1.mes (fold): Support fold 3.

2 years agomescc: Tinycc support: Compound strings as function argument.
Jan Nieuwenhuizen [Mon, 14 May 2018 20:37:53 +0000 (22:37 +0200)]
mescc: Tinycc support: Compound strings as function argument.

* module/language/c99/compiler.mes (expr->accu): Handle compound
  strings as function argument.
* module/mes/M1.mes (object->M1): Call error when string not found.
* scaffold/tests/t.c: Test it.

2 years agomescc: Tinycc support: Update some tests.
Jan Nieuwenhuizen [Mon, 14 May 2018 19:18:08 +0000 (21:18 +0200)]
mescc: Tinycc support: Update some tests.

2 years agomescc: Tinycc support: Add __lshrdi3, __ashldi3, __ashrdi3.
Jan Nieuwenhuizen [Mon, 14 May 2018 20:36:14 +0000 (22:36 +0200)]
mescc: Tinycc support: Add __lshrdi3, __ashldi3, __ashrdi3.

* lib/libc+tcc-gcc.c (__lshrdi3, __ashldi3, __ashrdi3): New function.

2 years agomescc: Tinycc support: Fix sizeof interesting expressions.
Jan Nieuwenhuizen [Mon, 14 May 2018 18:14:42 +0000 (20:14 +0200)]
mescc: Tinycc support: Fix sizeof interesting expressions.

* module/language/c99/compiler.mes (ast->type): Return type for
  sizeof-expr, sizeof-type.
* scaffold/tests/85-sizeof.c: Test it.

2 years agomescc: Tinycc support: Support bit-fields.
Jan Nieuwenhuizen [Sun, 13 May 2018 15:05:28 +0000 (17:05 +0200)]
mescc: Tinycc support: Support bit-fields.

* module/language/c99/compiler.mes (struct->fields): Support bit-fields.
  (ast->type):
  (field-field):
  (field-offset):
  (expr->accu*):
  (expr->accu):
  (struct-field):
  (->size):
* module/language/c99/info.scm (<bit-field>): New type.
* stage0/x86.M1 (and____$i32,%eax, and____(%edx),%eax,
  mov____(%edx),%eax, or____(%edx),%eax): New macro.
* module/mes/as-i386.mes (i386:base-mem->accu): Use
  it.
  (i386:accu-and, i386:accu-and-base-mem, i386:accu-or-base-mem): New
  function.
* module/mes/as-i386.scm: Export them.
* scaffold/tests/7q-bit-field.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.

2 years agomescc: Tinycc support: Anonymous string array.
Jan Nieuwenhuizen [Sat, 12 May 2018 10:03:01 +0000 (12:03 +0200)]
mescc: Tinycc support: Anonymous string array.

* module/language/c99/compiler.mes (global->info): Anonymous string
  array.
  (local->info): Likewise.
  (array-init->string): Support array of char.
  (init-local): Likewise.
  (->size): Fix for array.
* scaffold/tests/4a-char-array.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.

2 years agomescc: Tinycc support: sizeof: Bugfix for c-array.
Jan Nieuwenhuizen [Sat, 12 May 2018 09:25:35 +0000 (11:25 +0200)]
mescc: Tinycc support: sizeof: Bugfix for c-array.

* module/language/c99/compiler.mes (->size): Bugfix for c-array.
* scaffold/tests/85-sizeof.c: Test it.

2 years agomescc: Tinycc support: Implement ((struct foo*)p)->bar.
Jan Nieuwenhuizen [Fri, 11 May 2018 22:20:51 +0000 (00:20 +0200)]
mescc: Tinycc support: Implement ((struct foo*)p)->bar.

* module/language/c99/compiler.mes (expr->accu*):
* scaffold/tests/7p-struct-cast.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.

2 years agomescc: Tinycc support: Implement (foo--)->bar and permutations.
Jan Nieuwenhuizen [Sun, 13 May 2018 11:50:32 +0000 (13:50 +0200)]
mescc: Tinycc support: Implement (foo--)->bar and permutations.

* module/language/c99/info.scm (clone): Add post field.
  (make): Handle post parameter.
* module/language/c99/compiler.mes (clone): Handle post parameter.
  (expr->accu*): Set it to support foo--/foo--.
  (expr->accu): Read it to support foo--/foo--.
* scaffold/tests/7o-struct-pre-post.c: Test it.
* build-aux/check-mescc.sh: Run it.

2 years agomescc: Tinycc support: Function addresses.
Jan Nieuwenhuizen [Fri, 11 May 2018 17:46:26 +0000 (19:46 +0200)]
mescc: Tinycc support: Function addresses.

2 years agomescc: Tinycc support: Numeric constant expressions.
Jan Nieuwenhuizen [Fri, 11 May 2018 17:27:33 +0000 (19:27 +0200)]
mescc: Tinycc support: Numeric constant expressions.

2 years agomescc: Tinycc support: Function variables.
Jan Nieuwenhuizen [Fri, 11 May 2018 16:53:54 +0000 (18:53 +0200)]
mescc: Tinycc support: Function variables.

2 years agomescc: Tinycc support: Pointer typedefs.
Jan Nieuwenhuizen [Fri, 11 May 2018 16:36:35 +0000 (18:36 +0200)]
mescc: Tinycc support: Pointer typedefs.

2 years agomescc: Tinycc support: Array typedefs.
Jan Nieuwenhuizen [Fri, 11 May 2018 16:26:01 +0000 (18:26 +0200)]
mescc: Tinycc support: Array typedefs.

2 years agomescc: Tinycc support: Sizeof struct destruct.
Jan Nieuwenhuizen [Fri, 11 May 2018 15:13:07 +0000 (17:13 +0200)]
mescc: Tinycc support: Sizeof struct destruct.

2 years agomescc: Tinycc support: Anonymous union initialization.
Jan Nieuwenhuizen [Fri, 11 May 2018 13:52:30 +0000 (15:52 +0200)]
mescc: Tinycc support: Anonymous union initialization.

2 years agomescc: Tinycc support: Fix for ?-operator.
Jan Nieuwenhuizen [Fri, 11 May 2018 13:13:55 +0000 (15:13 +0200)]
mescc: Tinycc support: Fix for ?-operator.

2 years agomescc: Tinycc support: Valued function assign.
Jan Nieuwenhuizen [Fri, 11 May 2018 11:34:45 +0000 (13:34 +0200)]
mescc: Tinycc support: Valued function assign.

2 years agomescc: Refactor type system: WIP
Jan Nieuwenhuizen [Thu, 10 May 2018 10:40:07 +0000 (12:40 +0200)]
mescc: Refactor type system: WIP

* module/language/c99/compiler.mes (): WIP
* module/language/c99/info.scm (): WIP

2 years agomescc: Refactor type system: struct/enum fields: (name . <type>).
Jan Nieuwenhuizen [Thu, 10 May 2018 15:11:21 +0000 (17:11 +0200)]
mescc: Refactor type system: struct/enum fields: (name . <type>).

* module/language/c99/compiler.mes (struct-field): Refactor.
  (field:name): Update.
  (field:pointer): Update.
  (field:size): Update.
  (field:type): Remove.
  (->size): New function.

2 years agomescc: Refactor type system: introduce <array>, <pointer>, <var>.
Jan Nieuwenhuizen [Wed, 9 May 2018 19:31:23 +0000 (21:31 +0200)]
mescc: Refactor type system: introduce <array>, <pointer>, <var>.

* module/language/c99/info.scm (<array>, <pointer>, <var>): New type.
* module/language/c99/compiler.mes (ast-><type>): New function.
  (ast-type): Use it.

2 years agomescc: Refactor variable declaration.
Jan Nieuwenhuizen [Sat, 5 May 2018 10:30:06 +0000 (12:30 +0200)]
mescc: Refactor variable declaration.

* module/language/c99/compiler.mes (decl->info): Refactor.

2 years agomescc: Handle sizeof expression.
Jan Nieuwenhuizen [Fri, 4 May 2018 22:59:31 +0000 (00:59 +0200)]
mescc: Handle sizeof expression.

* module/language/c99/compiler.mes (expr->accu): Handle sizeof
  expression.
* scaffold/tests/85-sizeof.c: Test it.

2 years agomescc: Handle struct field lists.
Jan Nieuwenhuizen [Fri, 4 May 2018 22:14:47 +0000 (00:14 +0200)]
mescc: Handle struct field lists.

* module/language/c99/compiler.mes (struct-field): Return list of
  fields.  Update callers.
* scaffold/tests/84-struct-field-list.c: Test it.
* build-aux/check-mescc.sh (tests): Add it.

2 years agomescc: Support heterogeneous variable init.
Jan Nieuwenhuizen [Fri, 4 May 2018 20:38:01 +0000 (22:38 +0200)]
mescc: Support heterogeneous variable init.

* module/language/c99/compiler.mes (decl->info): Support heterogeneous
  variable init.
* scaffold/tests/83-heterogenoous-init.c: Test it.
* build-aux/check-mescc.sh (tests): Add it.

2 years agomescc: Handle (Skip) global static.
Jan Nieuwenhuizen [Fri, 4 May 2018 18:40:04 +0000 (20:40 +0200)]
mescc: Handle (Skip) global static.

* module/language/c99/compiler.mes (decl->info): Handle (Skip) global
  static.
* scaffold/tests/48-global-static.c: Test it.

2 years agomescc: Support functions in expression.
Jan Nieuwenhuizen [Fri, 4 May 2018 11:58:27 +0000 (13:58 +0200)]
mescc: Support functions in expression.

* module/language/c99/info.scm (<function>): New type.
* module/language/c99/compiler.mes (ast->type): Support function.
  (expr->type-size): Likewise.
  (expr->type): Likewise.
  (expr->accu*): Likewise.
  (function->info): Create <function>.
* module/mes/M1.mes (object->M1): Grok <function>.
* scaffold/tests/47-function-expression.c: Test it.
* build-aux/check-mescc.sh: Add it.

2 years agomescc: Support function-static variables.
Jan Nieuwenhuizen [Fri, 4 May 2018 18:45:27 +0000 (20:45 +0200)]
mescc: Support function-static variables.

* module/language/c99/info.scm (make): Add statics field.
  (<global>): Add name and function fields.  Update callers.
  (global->string): New function.
* module/mes/M1.mes (object->M1): Update.
* module/language/c99/compiler.mes (clone): Add statics field.
  (ident->accu): For <global>, use global in text (WAS: name).
  (ident-address->accu): Likewise.
  (ident-address->base): Likewise.
  (decl-local->info): New function.
  (decl->info): New function.
  (ast->info): Use them.
  (function->info): Keep globals in object (WAS: global:value only).
* scaffold/tests/46-function-static.c: Test it.

2 years agomes: Add unfold.
Jan Nieuwenhuizen [Sun, 20 May 2018 11:04:20 +0000 (13:04 +0200)]
mes: Add unfold.

* module/srfi/srfi-1.mes (unfold): New function.

2 years agomes: Add const.
Jan Nieuwenhuizen [Sun, 20 May 2018 11:18:36 +0000 (13:18 +0200)]
mes: Add const.

* module/mes/scm.mes (const): New function.
* tests/scm.test ("const"): Test it.

2 years agocore: Add logxor.
Jan Nieuwenhuizen [Wed, 16 May 2018 20:30:08 +0000 (22:30 +0200)]
core: Add logxor.

* src/math.c (logxor): New function.
* tests/math.test ("logxor"): Test it.

2 years agomes: string-join: Support optional delimiter, support grammar.
Jan Nieuwenhuizen [Wed, 16 May 2018 21:31:39 +0000 (23:31 +0200)]
mes: string-join: Support optional delimiter, support grammar.

* module/srfi/srfi-13.mes (string-join): Support optional infix and
  grammar.
* tests/srfi-13.test ("string-join"): Test it.

2 years agocore: reader: Support binary #b101.
Jan Nieuwenhuizen [Wed, 16 May 2018 20:32:59 +0000 (22:32 +0200)]
core: reader: Support binary #b101.

* src/reader.c (reader_read_binary): New function.
  (reader_read_hash): Use it.
* tests/scm.test ("binary"): Test it.

2 years agomes: Support srfi-9-gnu.
Jan Nieuwenhuizen [Fri, 4 May 2018 10:44:05 +0000 (12:44 +0200)]
mes: Support srfi-9-gnu.

* module/srfi/srfi-9/gnu.mes: New file.  Support srfi-9-gnu.
* tests/srfi-9.test: Test it.
* tests/srfi-9.test-guile:

2 years agocore: Have core:eval expand macros.
Jan Nieuwenhuizen [Sat, 28 Apr 2018 16:31:10 +0000 (18:31 +0200)]
core: Have core:eval expand macros.

* src/mes.c (core:eval-expand): Remove
  (core:eval-expanded): New variable.
  (eval_apply): Have core:eval expand macros; core:eval-expanded evals
  expanded sexps.

2 years agoRevert "core: Remove pmatch-car, pmatch-cdr hack."
Jan Nieuwenhuizen [Sun, 29 Apr 2018 05:46:40 +0000 (07:46 +0200)]
Revert "core: Remove pmatch-car, pmatch-cdr hack."

This reverts commit be1e84624ea4a158173f34af923e3c4a3793412a.

2 years agocore: Remove pmatch-car, pmatch-cdr hack.
Jan Nieuwenhuizen [Sat, 28 Apr 2018 10:19:40 +0000 (12:19 +0200)]
core: Remove pmatch-car, pmatch-cdr hack.

* src/mes.c (scm_vm_eval_pmatch_car, scm_vm_eval_pmatch_cdr): Remove
  (eval_apply): Remove cell_vm_eval_pmatch_car,
  cell_vm_eval_pmatch_cdr hack.
  (mes_symbols): Remove cell_symbol_pmatch_car, cell_symbol_pmatch_cdr.
* scaffold/mini-mes.c: Likewise.
* module/mes/guile.scm (mes): Remove pmatch-car, pmatch-cdr.
* module/mes/pmatch.scm (ppat): Use plain car, cdr.

2 years agobuild: Do not assume /bin/sh, basename/dirname.
Jan Nieuwenhuizen [Wed, 23 May 2018 18:28:43 +0000 (20:28 +0200)]
build: Do not assume /bin/sh, basename/dirname.

* install.sh: Do not assume /bin/sh, basename/dirname.
* scripts/diff.scm: Likewise.

2 years agobuild: Build mini-libc and libc+tcc-gcc too.
Jan Nieuwenhuizen [Wed, 23 May 2018 11:37:55 +0000 (13:37 +0200)]
build: Build mini-libc and libc+tcc-gcc too.

* include/getopt.h[__GNUC__ && POSIX]: Only use include_next.
* lib/libc+tcc-gcc.c[POSIX](longjmp, setjmp, __udivdi3, __umoddi3):
  Remove.
* build-aux/build-cc.sh: Build mini-libc-gcc and libc+tcc-gcc too.
* build-aux/build-mlibc.sh: Build mini-libc-gcc too.

2 years agoboot: Bugfix for diff on mes.
Jan Nieuwenhuizen [Wed, 23 May 2018 07:24:52 +0000 (09:24 +0200)]
boot: Bugfix for diff on mes.

* scripts/diff.scm (diff-files): Rename from diff; Avoids name clash
  with module to allow using -e '(<module>)' hack.