mes.git
18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

18 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.

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

18 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.

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

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

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

18 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.

18 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.

19 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.

19 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.

19 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

19 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.

19 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.

19 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.

19 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.

19 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.

19 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.

19 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.

19 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.

19 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.

18 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.

18 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.

18 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.

18 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.

18 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.

19 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:

19 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.

19 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.

19 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.

18 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.

18 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.

18 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.

18 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.

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

* configure: Update.

19 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.

19 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.

19 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.

18 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.

19 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

19 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.

19 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.

19 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.

19 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.

19 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.

19 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.

19 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.

19 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.

19 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.

19 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.

19 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__.

19 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.

19 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>
19 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.

19 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.

19 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.

19 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.

19 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.

19 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.

19 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.

19 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.

19 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.

19 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"):

19 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"):

19 months agomes: string-drop: Error on negative droppings.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 16:15:04 +0000 (18:15 +0200)]
mes: string-drop: Error on negative droppings.

* module/srfi/srfi-13.mes (string-drop, string-take,
  string-drop-right): Error on negative droppings.
* tests/srfi-13.test ("string-drop"): Test it.

19 months agocore: reverse!: Handle empty list.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 16:14:01 +0000 (18:14 +0200)]
core: reverse!: Handle empty list.

* src/mes.c (reverse_x_): Handle empty list.
* tests/scm.test ("reverse! ()"): Test it.

19 months agocore: Add string ports.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 15:48:38 +0000 (17:48 +0200)]
core: Add string ports.

* src/mes.c (type_t): Add TPORT.
  (scm_type_port): New symbol.
  (PORT): New macro.
  (MAKE_STRING_PORT): New macro.
  (eval_apply): Handle string ports in primitive-load.
  (mes_symbols): Add scm_type_port.
* src/posix.c (peekchar): Handle string ports.
  (readchar): New function.  Replace all getchar callers.
  (unreadchar): Likewise.
* module/mes/type-0 (port?): New function.
* module/mes/guile.mes (with-input-from-file): Rewrite.
  (open-input-string): Remove.
* module/mes/guile.scm (guile): Update cell types.
* src/gc.c (gc_loop): Support TPORT.
* src/lib.c (display_helper): Support TPORT.
* module/mes/display.mes (display): Support TPORT.

19 months agomes: assq, assoc-ref: Handle non-A-LISTs.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 14:17:07 +0000 (16:17 +0200)]
mes: assq, assoc-ref: Handle non-A-LISTs.

* src/mes.c (assq): Return #f if A-LIST is not a list.
* module/mes/scm.mes (assoc): Likewise.

19 months agocore: Use single definition rule for cell-type.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 11:22:02 +0000 (13:22 +0200)]
core: Use single definition rule for cell-type.

* src/mes.c (scm_type_char, scm_type_closure, scm_type_continuation,
  scm_type_function, scm_type_keyword, scm_type_macro,
  scm_type_number, scm_type_pair, scm_type_ref, scm_type_special,
  scm_type_string, scm_type_symbol, scm_type_values,
  scm_type_variable, scm_type_vector): New symbol.
  (mes_symbols): Add them.
* module/mes/type-0.mes (<cell:char>, <cell:char>, <cell:closure>,
  <cell:continuation>, <cell:function>, <cell:keyword>, <cell:macro>,
  <cell:number>, <cell:pair>, <cell:ref>, <cell:special>,
  <cell:string>, <cell:symbol>, <cell:values>, <cell:variable>,
  <cell:vector>, <cell:broken-heart): Remove.
* module/mes/boot-0.scm: Likewise.
* module/mes/boot-01.scm: Likewise.
* module/mes/boot-02.scm: Likewise.
* scaffold/boot/20-define-quote.scm: Likewise.
* scaffold/boot/37-closure-lambda.scm: Likewise.
* scaffold/boot/38-simple-format.scm: Likewise.
* scaffold/boot/4c-quasiquote.scm:
* scaffold/boot/4e-string-split.scm: Likewise.
* scaffold/boot/51-module.scm: Likewise.
* scaffold/boot/52-define-module.scm: Likewise.
* scaffold/boot/60-let-syntax.scm: Likewise.
* module/mes/guile.scm: Add some of them.

19 months agocore: Fix gc_up_arena for x86_64.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 10:04:18 +0000 (12:04 +0200)]
core: Fix gc_up_arena for x86_64.

* src/gc.c (gc_): Fix gc_up_arena for x86_64.

19 months agocore: Fix compile warnings.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 10:02:23 +0000 (12:02 +0200)]
core: Fix compile warnings.

* src/posix.c: Include sys/stat.h.
  (chmod): Return cell_unspecified.
* include/stdlib.h: Typo.

19 months agomlibc: Declare chmod.
Jan Nieuwenhuizen [Sun, 29 Apr 2018 10:01:25 +0000 (12:01 +0200)]
mlibc: Declare chmod.

* include/sys/stat.h (mode_t, chmod): Declare.