Commit Graph

231 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 4003e3b721
build: setup-mes.sh: Cater for Debian/stretch too. Thanks, pdewacht!
* build-aux/setup-mes.sh: Cater for Debian/stretch too.  Thanks,
  pdewacht!
2018-07-12 22:30:00 +02:00
Jan Nieuwenhuizen c5bf550fff
build: Handle CFLAGS, CPPFLAGS for Debian. 2018-07-12 22:30:00 +02:00
Jan Nieuwenhuizen ec7d9f5d57
build: Use GNU style lower case directory configure variable naming.
* GNUmakefile: Use GNU style lower case directory configure variable naming.
* HACKING: Likewise.
* INSTALL: Likewise.
* build-aux/build-cc.sh: Likewise.
* build-aux/build-cc32.sh: Likewise.
* build-aux/cc-mes.sh: Likewise.
* build-aux/cc.sh: Likewise.
* build-aux/cc32-mes.sh: Likewise.
* build-aux/export.make: Likewise.
* build-aux/setup-mes.sh: Likewise.
* build.sh: Likewise.
* check.sh: Likewise.
* configure: Likewise.
* doc/mes.texi: Likewise.
* install.sh: Likewise.
* scripts/mescc: Likewise.
2018-07-12 22:29:59 +02:00
Jan Nieuwenhuizen 69813a6da3
build: Support Debian build, install.
* scripts/mescc: Support Debian build, install.
* lib/libmes.c (fdgetc): Allow Nyacc/ungetc conflict.
* build-aux/export.make (ARCH): Export.
* build-aux/build-mes.sh: Disable full build for non-bootstrap
  x86-only.
* check.sh (total): Use bash to invoke build-aux/check-mescc.sh.
* build-aux/build-guile.sh (SCM_FILES): Support guile-2.0.
* module/mes/guile.scm (guile-2.0): Support guile-2.0.
* build-aux/build-mes.sh: Use bash.
* build-aux/setup-mes.sh: New file.
2018-07-12 22:29:59 +02:00
Jan Nieuwenhuizen b4fa5609fe
build: Support $DESTDIR.
* build-aux/export.make: export DESTDIR.
* install.sh: Support $DESTDIR.
2018-07-12 22:29:59 +02:00
Jan Nieuwenhuizen 72e147f53f
build: Build and install manual pages.
* build-aux/export.make: New file.
* GNUmakefile (man): New target.
  (doc): Depend on man.
  include build-aux/export.make, remove exports.
* guix.scm (mes): Add dependency on help2man.
* configure: Check for help2man.
* install.sh: Install manual pages if built.
2018-07-12 22:29:59 +02:00
Jan Nieuwenhuizen 50d7036e03
mescc: Support binutils 2.10.1: strrchr: Stop at start of string.
* lib/libc+tcc.c (strrchr): Stop at start of string.
* scaffold/tests/88-strrchr.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
2018-06-24 17:25:46 +02:00
Jan Nieuwenhuizen 350d94aa77
build: Support tcc, create tinycc-seed with tcc.
* configure: check for tcc.
* build-aux/cc32-mes.sh: Rename from cc-mes-gcc.sh.  Support
  tcc.  Update users.
* build-aux/build-cc32-mes.sh: Rename from build-mes-gcc.sh.  Update users.
* GNUmakefile (mes-tcc): New target.
* .gitignore: Ignore mes-tcc arch output.
* lib/crt1.c (_start): Add "rm" constraint so satisfy tcc.
* lib/linux-gcc.c (_sys_call, _sys_call1 _sys_call2 _sys_call3): Likewise.
2018-06-24 09:28:23 +02:00
Jan Nieuwenhuizen f245237f83
mescc: Support gnu toolchain: libtcc1.
* lib/libtcc1.c: New file.
* lib/libc+tcc-gcc.c: Remove libtcc1 stubs.
2018-06-19 20:29:25 +02:00
Jan Nieuwenhuizen 8793e0dde3
core: Resurrect loading of boot-0.32-mo. 2018-06-18 18:55:59 +02:00
Jan Nieuwenhuizen 7a42e5e6b0
mescc: Add another fopen test.
* scaffold/tests/98-fopen.c: New file.
* build-aux/check-mescc.sh (tests): Add it.
* AUTHORS: Mention it.
2018-06-16 16:12:51 +02:00
Jan Nieuwenhuizen 584482fb79
mescc: Add fopen test.
* scaffold/tests/97-fopen.c: New file.
* build-aux/check-mescc.sh (tests): Run it.
* include/unistd.h (link): Declare.
2018-06-16 15:18:27 +02:00
Jan Nieuwenhuizen a27770389e
Update for mescc-tools-0.5.
* build-aux/build-mes.sh (HEX2FLAGS): Remove = from flags.
* build.sh (HEX2FLAGS): Likewise.
* module/mescc/mescc.scm (hex2->elf): Likewise.
2018-06-16 06:38:05 +02:00
Jan Nieuwenhuizen b6b93f9f19
build: Resurrect non-bootstrap build.
* configure (parse-opts): Support mixing VAR=VALUE --prefix=PREFIX.
* guix.scm (mes): Remove setting PREFIX in make-flags.
* install.sh: Cater for Guix's setting read-only of scripts/diff.scm.
2018-06-12 07:05:33 +02:00
Jan Nieuwenhuizen c086f67cec
mescc: Support less-patched tcc/gcc: Add crti and crtn.
* lib/crt0.c[__MESC__]: Support MesCC.
* lib/crti.c: New file.
* lib/crtn.c: New file.
* build-aux/build-mes-gcc.sh: Build them.
2018-06-10 16:03:18 +02:00
Jan Nieuwenhuizen cc466662b9
mescc: Support gcc-3.2: Implement integer strto*.
* lib/libc+tcc.c (strtoll, strtoul): Call strtoul.
2018-06-06 22:39:57 +02:00
Jan Nieuwenhuizen 04302b3fe4
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.
2018-06-06 22:14:35 +02:00
Jan Nieuwenhuizen f60cac6e1d
mescc: Support gcc-3.4.0: unsetenv.
* lib/gcc.c (unsetenv): New function.
2018-06-06 19:43:32 +02:00
Jan Nieuwenhuizen 635dfd03a2
mescc: Support glibc-1.06.4.
* lib/glibc.c: New file.
* lib/libc+gnu.c: Include it.
2018-06-03 18:54:26 +02:00
Jan Nieuwenhuizen de964f3e1f
mescc: Support gcc-2.6.3.
* TODO
2018-06-02 11:41:06 +02:00
Jan Nieuwenhuizen f1efaa0e93
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.
2018-05-30 21:55:39 +02:00
Jan Nieuwenhuizen a3a3654d54
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.
2018-05-30 21:49:40 +02:00
Jan Nieuwenhuizen 272b522962
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.
2018-05-29 20:07:46 +02:00
Jan Nieuwenhuizen 2cda87257a
mlibc: Cleanup. 2018-05-29 18:15:22 +02:00
Jan Nieuwenhuizen a10c48735d
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.
2018-05-25 08:05:02 +02:00
Jan Nieuwenhuizen e411d38bbd
doc: Release udpate.
* BOOTSTRAP: Update.
* HACKING: Update.
* NEWS: Update.
* README: Update.
* doc/ANNOUNCE-0.14: New file.
2018-05-19 20:52:24 +02:00
Jan Nieuwenhuizen 948fbf9743
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.
2018-05-20 10:55:44 +02:00
Jan Nieuwenhuizen f8f0aacb61
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.
2018-05-20 08:58:44 +02:00
Jan Nieuwenhuizen def730d74a
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.
2018-05-19 14:53:05 +02:00
Jan Nieuwenhuizen 4faeece057
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.
2018-05-18 23:58:10 +02:00
Jan Nieuwenhuizen 209f9cc599
mescc: Tinycc support: Update some tests. 2018-05-14 21:18:08 +02:00
Jan Nieuwenhuizen 0f87473105
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.
2018-05-13 17:05:28 +02:00
Jan Nieuwenhuizen dae4a30417
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.
2018-05-12 12:03:01 +02:00
Jan Nieuwenhuizen ad9f171c49
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.
2018-05-12 00:20:51 +02:00
Jan Nieuwenhuizen 057607ca0a
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.
2018-05-13 13:50:32 +02:00
Jan Nieuwenhuizen e3a8316184
mescc: Tinycc support: Fix for ?-operator. 2018-05-11 15:13:55 +02:00
Jan Nieuwenhuizen a1862f749f
mescc: Refactor type system: WIP
* module/language/c99/compiler.mes (): WIP
* module/language/c99/info.scm (): WIP
2018-05-10 12:40:07 +02:00
Jan Nieuwenhuizen c9ba7a619b
mescc: Refactor variable declaration.
* module/language/c99/compiler.mes (decl->info): Refactor.
2018-05-05 12:30:06 +02:00
Jan Nieuwenhuizen 1b8d59fd0f
mescc: Handle sizeof expression.
* module/language/c99/compiler.mes (expr->accu): Handle sizeof
  expression.
* scaffold/tests/85-sizeof.c: Test it.
2018-05-05 00:59:31 +02:00
Jan Nieuwenhuizen 2311b8bd20
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.
2018-05-05 00:14:47 +02:00
Jan Nieuwenhuizen 13edbaf4d8
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.
2018-05-04 22:38:01 +02:00
Jan Nieuwenhuizen e53f55f002
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.
2018-05-04 13:58:27 +02:00
Jan Nieuwenhuizen be60b3e49b
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.
2018-05-04 20:45:27 +02:00
Jan Nieuwenhuizen 10bd43d222
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:
2018-05-04 12:44:05 +02:00
Jan Nieuwenhuizen 0ba240a4e0
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.
2018-05-23 18:41:57 +02:00
Jan Nieuwenhuizen a4110e55bb
build: Install naive diff.
* scripts/diff.scm: Move from build-aux.
* install.sh: Install it.
* build-aux/tests.sh: Update location.
2018-05-23 18:41:57 +02:00
Jan Nieuwenhuizen a1a5145a1a
build: Use ../mes-seed/refresh.sh, ../tinycc-seed/refresh.sh.
* GNUmakefile (seed): Use ../mes-seed/refresh.sh, ../tinycc-seed/refresh.sh.
2018-05-10 16:35:49 +02:00
Jan Nieuwenhuizen 62bd70cfb6
mescc: Guile fixes.
* scripts/mescc: Set GODIR.  Add module as expression to Mes
  invokation.  Remove explicit (second) call to main.
2018-05-04 10:12:34 +02:00
Jan Nieuwenhuizen 95fdfb2261
test: Use diff -ub for tinycc tests.
* build-aux/diff.scm: Support -b.
* build-aux/test.sh: Use it.
2018-05-18 18:34:58 +02:00
Jan Nieuwenhuizen cac2ba7b06
check: Also test with i686-unknown-linux-gnu-gcc.
* check.sh (CC32): New variable.
* build-aux/test.sh: Also test with CC32.o
2018-05-04 21:24:39 +02:00
Jan Nieuwenhuizen ba17eeeefe
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.
2018-05-03 20:32:06 +02:00
Jan Nieuwenhuizen ad88aaa5be
build: Rebuild after build from seed.
* build-aux/build-mes.sh: Rebuild after build from seed.
2018-05-03 09:30:03 +02:00
Jan Nieuwenhuizen 98417537a2
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.
2018-05-01 16:50:29 +02:00
Jan Nieuwenhuizen a937d18c38
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.
2018-04-29 18:38:57 +02:00
Jan Nieuwenhuizen 664289c50f
mes-snarf: Support running with Mes.
* build-aux/mes-snarf.scm: Support running with Mes.
2018-04-29 07:56:52 +02:00
Jan Nieuwenhuizen 4b6d11e990
core: append2, append_reverse, reverse, reverse!: Create less garbage.
* src/mes.c (append_reverse): New function.
  (reverse_x_): New function.
  (append2): Use them to create less garbage.
* module/mes/scm.mes (reverse): Create less garbage.
* module/srfi/srfi-1.mes (reverse!): Rewrite, use core:reverse!.
  (append-reverse): Remove.
2018-04-20 14:38:24 +02:00
Jan Nieuwenhuizen ad135d3752 doc: Release udpate.
* HACKING: Update.
* INSTALL: Update.
* NEWS: Update.
* README: Update.
* doc/ANNOUNCE-0.12: New file.
* throughout: (janneke) coming out.
2017-11-21 19:22:26 +01:00
Jan Nieuwenhuizen 0fe6dc1f66 guix: Add manifest.
* build-aux/manifest.scm: New file.
2018-04-05 23:13:23 +02:00
Jan Nieuwenhuizen 83a43b81b3 mescc: Produce M1 output instead of hex2.
Use: ./make.scm [TARGET]
     ./make.scm check

* stage0/x86.M1: New file.
* mlibc/mini-libc-mes.c (exit, write): Use M1 instead of .byte.
* mlibc/libc-mes.c (_start, exit, read, write, open, access, brk,
  fsync, printf): Use M1 instead of .byte.
* module/mes/as-i386.mes: Use M1.
* module/mes/make.scm: New file.
* make.scm: New file.
* guile/guix/records.scm: New File.
* guile/guix/shell-utils.scm: New file.
* module/mes/M1.mes: Rename from hex2.mes.
* module/mes/M1.scm: Rename from hex2.scm.
* scripts/mescc.mes: Update callers.
* guile/mescc.scm: Update callers.
2017-07-02 16:25:14 +02:00
Jan Nieuwenhuizen 0ec15a3220 make: Recompile .go too when included mes is touched.
* build-aux/compile-all.scm (scm->mes): New function.
  (file-needs-compilation?): Use it to hackishly respect (include-[from-path] "<>.mes")
2017-05-02 16:56:14 +02:00
Jan Nieuwenhuizen 38d30a3e42 build: Refactor.
* GNUmakefile (OUT,QUIET,SUBDIRS): New variables.
  include make/common.make
* .gitignore: Remove toplevel targets.
* build-aux/compile-all.scm: Import from GNU Guix.
* configure (gulp-pipe): Check exit status.  Actually test for CC,
  CC32.
* make/bin.make: New file.
* make/check.make: New file.
* make/clean.make: New file.
* make/common.make: New file.
* make/compile.make: New file.
* make/guile.make: New file.
* make/mescc-guile.make: New file.
* make/mescc-mes.make: New file.
* make/reset.make: New file.
* lib/mlibc.c: Rename from top.
* lib/start.c: Rename from top.
* module/module.make: New file.
* scaffold/scaffold.make: New file.
* scripts/scripts.make: New file.
* src/mes.c: Rename from top.
* src/src.make: New file.
* src/mes.c: Rename from top.
* src/gc..c: Rename from top.
* src/lib.c: Rename from top.
* src/posix.c: Rename from top.
* src/reader.c: Rename from top.
* src/vector.c: Rename from top.
* tests/tests.make: New file.
2017-04-12 21:27:59 +02:00
Jan Nieuwenhuizen fc263de433 build: Cleanup, use gcc-specific snarfing.
* .gitignore: Ignore *.o-32, mes-mini-mes.
* scripts/nyacc-calc.mes: Remove.
* scripts/nyacc.mes: Remove.
* scripts/paren.mes: Remove.
* make/install.make (install): Remove them.
p* module/mes/mes-0.mes: Remove.
* module/mes/loop-0.mes: Remove.
* build-aux/mes-snarf.scm (main): Add --mini option.
* GNUmakefile (mini-mes): Use it.
2017-04-02 17:01:22 +02:00
Jan Nieuwenhuizen 30743ce141 mini-mes: Fully remove reader from core.
* scaffold/mini-mes.c (lookup_): Remove.
* mes.c: Likewise.
* reader.c (lookup_): Enable.
* mlib.c (putc): New function.
* module/mes/libc.mes (putc): New function.
2017-03-25 15:58:44 +01:00
Jan Nieuwenhuizen f03a2e7500 mescc: Struct by value.
* build-aux/mes-snarf.scm (symbol->names, function->header,
  function->environment): Remove struct by value assignment
  workarounds.
* module/language/c99/compiler.mes (ast->info): Remove struct by value
  assignment debug printing.
2017-03-17 22:45:48 +01:00
Jan Nieuwenhuizen 03c37b2e22 mescc: Support mini-mes running scheme program with builtins.
Mini-mes, compiled with either gcc or mescc, now runs a memory dump of
this mini-0.mes program

	(begin
	  (write-byte (make-cell 0 0 65))
	  (write-byte (make-cell 0 0 66))
          (write-byte (make-cell 0 0 67))
 	  (write-byte (make-cell 0 0 10))
	  #f)

when read and dumped by (gcc-compiled) mes-32.

* build-aux/mes-snarf.scm: FIXES ..collapse?
* module/language/c99/compiler.mes (ast->info): Bail out on unhandled
  declarations.  Was: verbosely skip.
2017-03-12 12:02:12 +01:00
Jan Nieuwenhuizen 76f1a89cef core+mini-mes: Replace manual snippets by snarfed includes.
* build-aux/mes-snarf.scm (symbol->source, function->header,
  function->source, function->environment): Add workarounds to
  avoid struct-copy initializers.
* GNUmakefile (mini-mes): Snarf symbols and functions.
* scaffold/mini-mes.c: Include mini-mes.h, mini-mes.symbols.h,
  mini-mes.symbols.i, mini-mes.i, mini-mes.environment.i.
  Add snarfable symbol/special definitions.
  (type_t): Prefix all types with `T', update users.
  (assert_defined, gc_push_frame, gc_peek_frame, gc_init_cells): Mark
  as internal.
* mes.c (type_t): Prefix all types with `T', update users.
* scaffold/mini-mes.c (eq_p, type_, car_, cdr_,
  list_of_char_equal_p, lookup_macro, write_byte): New functions (from
  mes.c).
  (assq): Add debugging, workaround.
2017-03-10 20:56:18 +01:00
Jan Nieuwenhuizen f612feec47 core+mini-mes: Move function name to struct function.
* module/language/c99/compiler.mes (expr->arg): Handle char arguments.
* doc/examples/cons-mes.c (struct function): Add name field.
* doc/examples/mini-mes.c: Likewise.
  (mes_builtins): Update.
* mes.c: Likewise.
* build-aux/mes-snarf.scm: Update.
2017-03-09 23:27:12 +01:00
Jan Nieuwenhuizen 78e70f9024 mescc: Support struct assignment.
* module/mes/libc-i386.mes (i386:base-address->accu-address,
  i386:accu+n, i386:base+n): New functions.
* module/mes/libc-i386.scm: Export them.
* module/language/c99/compiler.mes (ast->info): Use them.
* doc/examples/t.c: Test them.
* doc/examples/cons-mes.c: Drop workarounds.
* doc/examples/mini-mes.c: Likewise.
* mes.c:
2017-03-02 20:26:13 +01:00
Jan Nieuwenhuizen 43a1774750 core: Move GNUisms inside #if.
* mes.c: Move GNUisms inside #if, add Nyacc #ifs.
 (tmp_num2, tmp_num3): Remove.
 (make_tmps): Update.
 (g_free): Make simple int.  Update users.
* lib.c: Update users.
* build-aux/mes-snarf.scm (GCC?): New switch to enable GNU extensions.
2017-01-04 08:16:14 +01:00
Jan Nieuwenhuizen 2ae1eec0eb core: Move GNUisms inside #if.
* mes.c: Move GNUisms inside #if, add Nyacc #ifs.
 (tmp_num2, tmp_num3): Remove.
 (make_tmps): Update.
 (g_free): Make simple int.  Update users.
* lib.c: Update users.
* build-aux/mes-snarf.scm (GCC?): New switch to enable GNU extensions.
2017-01-04 10:52:36 +01:00
Jan Nieuwenhuizen 16e3caafcd core: Remove display.
* posix.c (stderr_): New function.
* display.c: Remove.
* mes.c: Remove includes.  Use stderr_ instead of display_.
 (gc_loop): Preserve function's name.
 (arity_): New function.
* GNUmakefile (mes.o): Remove dependency on display.
* module/mes/read-0.mes: Use core:stderr instead of display, newline.
  (newline): New function.
* module/mes/base-0.mes: Use core:stderr instead of display.
  Include (mes display).
* module/mes/display.mes: New file.
* lib.c (assert_defined): Move from mes.c.
  (string_to_cstring): Move from posix.c
* build-aux/mes-snarf.scm (function-environment): Initialize function
  name with scheme string.
2016-12-24 01:23:50 +01:00
Jan Nieuwenhuizen 18ba10e2ae core: Simplify lookup.
* reader.c (lookup_): Rename from lookup.  Remove all lookups except
  for numbers and symbols.  Update callers.
* mes.c (make_symbol_): Rename from internal_make_symbol.  Update
  callers.
* module/mes/read-0.mes (lookup): New function.
  (read-word): Remove all lookup calls, except for numbers and symbols.
2016-12-23 11:31:34 +01:00
Jan Nieuwenhuizen aa0aaa58ab core: Cleanup symbol initialization and lookup.
* build-aux/mes-snarf.scm (symbol->names): New function
  (function->environment): Initialize symbol.
  (generate-includes): Also write .symbol-names.i.
* mes.c (mes_symbols): Include it.  Remove internal_lookup_symbol.
* display.c (display): Handle display of nil in symbol list.
* reader.c (internal_lookup_symbol): Remove name-fu.
2016-12-23 10:38:41 +01:00
Jan Nieuwenhuizen 94d1c65bde core: Make symbols constants.
* mes.c (apply_env,eval_env): Rewrite using switch.
* build-aux/mes-snarf.scm (symbol->header): Define constants.
  (symbol->source): Only update g_free and init cells.
2016-12-14 19:02:19 +01:00
Jan Nieuwenhuizen d50b0fe24a core: Add function indirection.
* mes.c (functions): New array.
  (scm_t): Change function pointer to index.
  (make_cell): Handle function.
  (call): Update for function change.
  (display_): Likewise.
  (make_function): New function.
* build-aux/mes-snarf.scm (function->source): Update declarations.
  (function->environment): New function.
2016-12-12 20:35:19 +01:00
Jan Nieuwenhuizen 61e42e8527 core: Number based cells.
* mes.c (scm_t): Change car, string, ref, cdr, macro, vector into g_cell index
  [WAS]: scm_t pointer.
* define.c: Update.
* lib.c: Update.
* math.c: Update.
* posix.c: Update.
* quasiquote.c: Update.
* string.c: Update.
* type.c: Update.
* build-aux/mes-snarf.mes Update.
* tests/gc-4.test: New test.
* tests/gc-5.test: New test.
* tests/gc-6.test: New test.
2016-12-12 20:35:18 +01:00
Jan Nieuwenhuizen 7e8341d76c core: One SCM type for function.
* mes.c (function_t): New struct.
  (type): One type for function.
  (call): Refactor.
* build-aux/mes-snarf.mes: Use arity annotation.  WAS: args.  Update
  annotations.
2016-12-12 20:33:50 +01:00
Jan Nieuwenhuizen c851935d4d core: Quoted internals are symbols.
* mes.c (begin_env): Rename from begin.  Update callers.
  (scm_begin, scm_if, scm_define, scm_set_x): Rename from symbol_*.
  (symbol_begin, symbol_define, symbol_if, scm_lambda, scm_set_x): New symbols.
  (mes_environment): Add them to environment, SYMBOL->SCM.
* define.c (define_env): Rename from define.  Update callers.
* build-aux/mes-snarf.scm: Shadow internals (SCM) by their symbol.
2016-12-12 20:33:49 +01:00
Jan Nieuwenhuizen 2586f0bb2c Move optional type predicates to type.c.
* mes.c (char_p, macro_p, number_p, pair_p, string_p, symbol_p,
  vector_p, builtin_p, boolean_p): Move to type.c
* type.c: New file.
* GNUmakefile (mes.o): Depend on type snarf output.
* module/mes/loop-0.mes (cond, map, let, or, and not, evlis-env,
  apply-env, eval-expand, uquote, add-unquoters, eval,
  expand-macro-env, eval-begin-env, eval-if-env, sexp:define,
  env:define, env:macro): Move to mes-0.mes.
* module/mes/mes-0.mes: New file.
* module/mes/type-0.mes: New file.
* scripts/include.mes: If BOOT, also include mes-0.mes.  If TYPE0,
  also include type-0.mes.
2016-10-22 12:16:19 +02:00
Jan Nieuwenhuizen 3e03a12a4d Generate C header and includes using snarfing.
* mes.c: Move specific renames and n-args to alist annotation.
* build-aux/mes-snarf.scm: New file.
* GNUmakefile (mes.environment.h): Use it.
  (mes.h): Remove.
  (clean): Update.
  (mes.o): New dependency rule.
* .gitignore: Update.
2016-10-21 22:44:50 +02:00
Jan Nieuwenhuizen 3128c4b976 Prepare for 0.1 release: gnu-build-system.
* configure: New file.
* make/install.make: New file.
* .gitignore: Ignore generated files.
* build-aux/gitlog-to-changelog: New file.
2016-10-16 00:34:23 +02:00