mes.git
21 months 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.

21 months 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.

21 months 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.

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

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

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

21 months 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.

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

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

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

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months 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:

22 months 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.

21 months 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.

22 months 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.

21 months 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.

21 months 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.

21 months 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.

21 months agobuild: Install naive diff.
Jan Nieuwenhuizen [Wed, 23 May 2018 04:54:33 +0000 (06:54 +0200)]
build: Install naive diff.

* scripts/diff.scm: Move from build-aux.
* install.sh: Install it.
* build-aux/tests.sh: Update location.

21 months agobuild: Update configure.
Jan Nieuwenhuizen [Sun, 20 May 2018 22:06:39 +0000 (00:06 +0200)]
build: Update configure.

* configure: Update.

21 months agomes: Remove debugging.
Jan Nieuwenhuizen [Wed, 2 May 2018 20:52:31 +0000 (22:52 +0200)]
mes: Remove debugging.

* module/mes/module.mes (mes-load-module-env): Remove debugging.

21 months agobuild: Use ../mes-seed/refresh.sh, ../tinycc-seed/refresh.sh.
Jan Nieuwenhuizen [Thu, 10 May 2018 14:35:49 +0000 (16:35 +0200)]
build: Use ../mes-seed/refresh.sh, ../tinycc-seed/refresh.sh.

* GNUmakefile (seed): Use ../mes-seed/refresh.sh, ../tinycc-seed/refresh.sh.

21 months agomescc: Guile fixes.
Jan Nieuwenhuizen [Fri, 4 May 2018 08:12:34 +0000 (10:12 +0200)]
mescc: Guile fixes.

* scripts/mescc: Set GODIR.  Add module as expression to Mes
  invokation.  Remove explicit (second) call to main.

21 months agotest: Use diff -ub for tinycc tests.
Jan Nieuwenhuizen [Fri, 18 May 2018 16:34:58 +0000 (18:34 +0200)]
test: Use diff -ub for tinycc tests.

* build-aux/diff.scm: Support -b.
* build-aux/test.sh: Use it.

21 months agocheck: Also test with i686-unknown-linux-gnu-gcc.
Jan Nieuwenhuizen [Fri, 4 May 2018 19:24:39 +0000 (21:24 +0200)]
check: Also test with i686-unknown-linux-gnu-gcc.

* check.sh (CC32): New variable.
* build-aux/test.sh: Also test with CC32.o

21 months agobuild: configure: Handle VAR=VALUE. Update help.
Jan Nieuwenhuizen [Sun, 6 May 2018 06:46:32 +0000 (08:46 +0200)]
build: configure: Handle VAR=VALUE.  Update help.

* configure: Handle VAR=VALUE.  Update help.

21 months agobuild: Fixes for Debian and /bin/sh == dash.
Jan Nieuwenhuizen [Thu, 3 May 2018 18:32:06 +0000 (20:32 +0200)]
build: Fixes for Debian and /bin/sh == dash.

* build.sh: Use separate export stanzas.  Use command -v (WAS: type
  -p).  Fixes sh, /bin/sh == dash.
* 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/check-mescc.sh: Likewise.
* check.sh: Likewise.
* install.sh: Likewise.
* scripts/mescc: Likewise.

21 months agobuild: Rebuild after build from seed.
Jan Nieuwenhuizen [Thu, 3 May 2018 07:30:03 +0000 (09:30 +0200)]
build: Rebuild after build from seed.

* build-aux/build-mes.sh: Rebuild after build from seed.

21 months agomescc: Use file-name as global prefix.
Jan Nieuwenhuizen [Thu, 3 May 2018 07:01:00 +0000 (09:01 +0200)]
mescc: Use file-name as global prefix.

* module/mes/M1.mes (object->M1): Add file-name parameter.

21 months agocore: Fixes for int-max, int-min.
Jan Nieuwenhuizen [Wed, 2 May 2018 21:11:27 +0000 (23:11 +0200)]
core: Fixes for int-max, int-min.

* src/math.c (greater_p): Fix INT_MAX > 0.
  (less_p): Fix INT_MIN < 0.
* tests/math.test ("< INT-MIN"): Test it.
  ("< INT-MAX"):
  ("> INT-MAX"):
  ("> INT-MAX 0"):
  ("> INT-MIN"):
* tests/srfi-13.test ("string->number INT-MAX"): Test it.
  ("string->number INT-MIN"):
  ("number->string INT-MAX"):
  ("number->string INT-MIN"):
* scaffold/tests/60-math.c (test): Test it.

21 months agomescc: Fix dumping of strings > M1_STRING_MAX.
Jan Nieuwenhuizen [Wed, 2 May 2018 13:53:37 +0000 (15:53 +0200)]
mescc: Fix dumping of strings > M1_STRING_MAX.

* module/mes/M1.mes (object->M1): Skip opening quote.

21 months agoRevert "core: length: Check parameter."
Jan Nieuwenhuizen [Mon, 30 Apr 2018 18:47:05 +0000 (20:47 +0200)]
Revert "core: length: Check parameter."

This reverts commit 1f52ed35c66febcce16e06868e803a39be7eda41.

21 months agocore: length: Check parameter.
Jan Nieuwenhuizen [Mon, 30 Apr 2018 17:31:00 +0000 (19:31 +0200)]
core: length: Check parameter.

* src/mes.c (length): Check parameter.

21 months agotest: enable all tests, use expect count, add tinycc tests.
Jan Nieuwenhuizen [Tue, 1 May 2018 14:50:29 +0000 (16:50 +0200)]
test: enable all tests, use expect count, add tinycc tests.

* build-aux/check-mescc.sh (tests): Add tinycc tests.
* build-aux/diff.scm: Naive diff for tinycc tests.
* build-aux/test.sh: Run diff when .expect found.

21 months agobuild: Simplify, drop make.scm experiment.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 16:38:57 +0000 (18:38 +0200)]
build: Simplify, drop make.scm experiment.

* build.sh: Rewrite.
* build-aux/build-cc.sh: New file.
* build-aux/build-mes.sh: New file.
* build-aux/build-mlibc.sh: New file.
* build-aux/cc.sh: New file.
* build-aux/cc-mes.sh: New file.
* build-aux/cc-mlibc.sh: New file.
* install.sh: Update.
* make.scm: Remove.
* guile/guix/make.scm: Remove.
* guile/guix/records.scm: Remove.
* guile/guix/shell-utilsg.scm: Remove.

21 months agocore: Use length__.
Jan Nieuwenhuizen [Mon, 30 Apr 2018 19:17:10 +0000 (21:17 +0200)]
core: Use length__.

* src/mes.c (check_formals): Use length__.

21 months agomes-snarf: Support running with Mes.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 05:56:52 +0000 (07:56 +0200)]
mes-snarf: Support running with Mes.

* build-aux/mes-snarf.scm: Support running with Mes.

21 months agomes: Support -C and -L for Guile compatibility.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 17:06:11 +0000 (19:06 +0200)]
mes: Support -C and -L for Guile compatibility.

* module/mes/boot-0.scm): Support -C and -L for Guile compatibility.

Signed-off-by: Jan Nieuwenhuizen <janneke@gnu.org>
21 months agomes: Support -e,--main option.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 16:37:00 +0000 (18:37 +0200)]
mes: Support -e,--main option.

* module/mes/boot-0.scm: Support -e,--main option.

21 months agomes: Upgrade Guile module support.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 16:35:22 +0000 (18:35 +0200)]
mes: Upgrade Guile module support.

* module/mes/boot-0.scm (define-module): New macro with minimal Guile support.
  (use-modules): New macro.

21 months agomes: Add srfi-8.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 21:31:22 +0000 (23:31 +0200)]
mes: Add srfi-8.

* module/srfi/srfi-8.mes: New file.

21 months agomes: string-join: Handle empty list.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 16:34:21 +0000 (18:34 +0200)]
mes: string-join: Handle empty list.

* module/mes/boot-0.scm (string-join): Handle empty list.

21 months agomes: Add basename.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 16:33:14 +0000 (18:33 +0200)]
mes: Add basename.

* module/mes/posix.mes (basename): New function.

21 months agomes: Add delete-duplicates.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 16:32:35 +0000 (18:32 +0200)]
mes: Add delete-duplicates.

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

21 months agomes: filter-map: Handle two lists.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 16:29:26 +0000 (18:29 +0200)]
mes: filter-map: Handle two lists.

* module/srfi/srfi-1.mes (filter-map): Handle two lists, add error
  when called with three or more.

21 months agomes: Add string-replace.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 16:27:29 +0000 (18:27 +0200)]
mes: Add string-replace.

* module/srfi/srfi-13.mes (string-replace): New function.
* tests/srfi-13.test ("string-replace"): Test it.

21 months agomes: Add string-map.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 16:26:46 +0000 (18:26 +0200)]
mes: Add string-map.

* module/srfi/srfi-13.mes (string-map): New function.
* tests/srfi-13.test ("string-map"): Test it.

21 months agomes: Add string-trim, string-trim-right, string-trim-both.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 16:24:29 +0000 (18:24 +0200)]
mes: Add string-trim, string-trim-right, string-trim-both.

* module/srfi/srfi-13.mes (string-trim, string-trimn-right,
  string-trim-both): New function.
* tests/srfi-13.test ("string-trim"): Test it.
  ("string-trim-right"):
  ("string-trim-both"):

21 months agomes: Add string-contains.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 16:21:52 +0000 (18:21 +0200)]
mes: Add string-contains.

* module/srfi/srfi-13.mes (string-contains): New function.
* tests/srfi-13.test ("string-contains"): Test it.
  ("string-contains not"):