Commit Graph

64 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen ef29ade04b
mescc: Mes C Library: Add buffered read.
* lib/mes/__buffered_read.c: New file.
* build-aux/configure-lib.sh (libc_SOURCES): Add it.  Also add memmove.c.
(libc_tcc_SOURCES): Remove memmove.c
* lib/linux/close.c (close): Clear read buffer.
* lib/linux/_open3.c (_open3): Likewise.
* lib/linux/lseek.c (lseek): Correct for read buffer.
* lib/stdio/fwrite.c (fwrite): Likewise.
* lib/posix/read.c (read): Call __buffered_read.
* lib/posix/write.c (write): Add FIXME note about buffered reads.
* simple.sh: Update.
2019-07-27 22:58:49 +02:00
Jan Nieuwenhuizen 7670d6be38
mes: Update to Nyacc 0.93.
* mes/module/nyacc/lang/c99/util.mes: New file.
* mes/module/nyacc/lang/c99/parser.mes: Use it.
* module/mescc/compile.scm (ast->info): Update for Nyacc 0.93.0.
* module/mescc/preprocess.scm (need-progress):  Likewise.
(ast-strip-comment): Likewise.
2019-06-09 19:42:42 +02:00
Jan Nieuwenhuizen dd34569751
mes: string->number: Support #x-prefixed hex numbers.
* mes/module/mes/scm.mes (string->number): Support "#x"-prefix.
* tests/math.test ("string->number #hex"): Test it.
2019-08-02 22:52:46 +02:00
Jan Nieuwenhuizen 81849edb86
mes: Remove broken copy of simple-format.
* mes/module/mes/simple-format.mes: New file.
* mes/module/mes/guile.mes: Use it.
(with-output-to-string, simple-format): Remove broken copies.
* mes/module/mes/display.mes (with-output-to-string, simple-format,
format): Remove.
2019-07-19 15:36:36 +02:00
Danny Milosavljevic 4b5d5017c4
Fix remainder handling.
* mes/module/mes/scm.mes (number->string): Fix remainder handling.
* build-aux/check-mescc.sh (XFAIL_TESTS): Remove
lib/tests/scaffold/60-math.c.
2019-07-05 15:52:04 +02:00
Jan Nieuwenhuizen 5dc245e739
build: Simplify.
core: Make mes src/ c files separate compilation units.

* include/mes/constants.h: New file.
* include/mes/macros.h: New file.
* include/mes/mes.h: New file.
* src/gc.c: Update.
* src/hash.c: Update.
* src/lib.c: Update.
* src/math.c: Update.
* src/mes.c: Update.
* src/module.c: Update.
* src/posix.c: Update.
* src/reader.c: Update.
* src/string.c: Update.
* src/struct.c: Update.
* src/vector.c: Update.

    mes: Update datadir.

* src/mes.c (g_datadir): New global.
(open_boot): Rename from read_boot.
(read_boot): New function.
* mes/module/mes/boot-0.scm: Move from boot-0.scm.in
* configure: Update.
* configure.sh: Update.

    mescc: Create libraries from separate files.

* .gitignore: Update.
* build-aux/bootstrap-mes.sh: Remove.
* build-aux/bootstrap.sh.in: Remove.
* build-aux/build-guile.sh: Update.
* build-aux/build-mes.sh: Update.
* build-aux/build-scaffold.sh: New file.
* build-aux/build.sh.in: Update.
* build-aux/cc.sh: Update.
* build-aux/check-tcc.sh: Remove.
* build-aux/config.sh.in: New file.
* build-aux/config.sh: Remove.
* build-aux/install.sh.in: Update.
* build-aux/test-boot.sh: New file.
* build-aux/test-c.sh: New file.
* build-aux/test-driver: New file.
* build-aux/test-suite.sh: New file.
* build-aux/trace.sh: Update.
* build-aux/uninstall.sh.in: Update.
* configure: Update.
* configure.sh: Update.
* lib/linux/x86-mes-mescc/crt1.c: Move from lib/linux/x86-mes.
* lib/linux/x86-mes-mescc/mini.c: Likewise.
* lib/linux/x86_64-mes-mescc/crt1.c: Move from lib/linux/x86_64-mes.
* lib/linux/x86_64-mes-mescc/mini.c: Likewise.
* lib/linux/x86-mes-gcc/syscall.c: Rename from mes.c.
* lib/linux/x86-mes-mescc/syscall.c: Likewise.
* lib/linux/x86_64-mes-gcc/syscall.c: Likewise.
* lib/linux/x86_64-mes-mescc/syscall.c: Likewise.
* lib/mes/mes_open.c: Include config.h.
* lib/tests/stdio/70-printf-hello.c: Likewise.
* lib/tests/stdio/70-printf-simple.c: Likewise.
* scaffold/gc-test.sh: New file.
* simple.sh: Update.
2019-06-08 15:36:22 +02:00
Jan Nieuwenhuizen 77e75c3142
mes: Bugfix for search-path. Fixes running MesCC on Guile.
* module/mescc/mescc.scm (arch-find): Also look in cwd.
* mes/module/mes/posix.mes (search-path): Do not look in cwd.
2019-05-27 21:51:37 +02:00
Jan (janneke) Nieuwenhuizen 1d56567c50
mes: Support -c EXPR.
* mes/module/mes/boot-0.scm.in: Support -c EXPR.
2019-05-16 00:04:45 +02:00
Jan (janneke) Nieuwenhuizen b969c08205
mes: Support optional port on read.
* mes/module/mes/scm.mes (read): Support optional port on read.
2019-05-16 00:05:47 +02:00
Jan (janneke) Nieuwenhuizen e0eee55bf3
build: Fix mescc installation on Debian.
* build-aux/pre-inst-env.in: Set bindir.
* scripts/mescc.in: Fix configure/prefix issues.
* mes/module/mes/boot-01.scm (integer->char): Remove.
(newline): Use "\n".
(%moduledir): Use string-append.
* mes/module/mes/boot-02.scm: Likewise.
* mes/module/mes/boot-0.scm: Likewise.
2019-05-15 23:26:52 +02:00
Jan Nieuwenhuizen 829cc9cca5
mes: m2: Move force-output to Scheme.
* mes/module/mes/posix.mes (force-output): New function.
* src/posix.c (force_output): Remove.
* src/mes.c (mes_builtins): Remove adding of force-output.
2019-05-05 13:11:33 +02:00
Jan Nieuwenhuizen c5e098bc35
mescc: Mes C Library: Fix isatty.
* lib/posix/isatty.c (isatty): Test ioctl == 0.
* mes/module/mes/boot-0.scm.in: Update: no tty?: read from stdin.
2019-03-02 22:27:39 +01:00
Jan Nieuwenhuizen 90b384def3
mes: Support map and for-each with lists of unequal length.
* mes/module/mes/base.mes (map): Support lists of unequal length.
* mes/module/mes/scm.mes (for-each): Likewise.
* module/mescc/compile.scm (expr->register): Fix compile warning.
* tests/scm.test ("map 1,2", "map 2,1", "for-each 1,2", "for-each
2,1": Test it.
2019-03-02 14:33:58 +01:00
Jan Nieuwenhuizen a9bf3bfb12
mes: Remove stray debugging newline output.
* mes/module/mes/guile.mes (open-input-file): Move debugging newline
into debug clause.
2019-02-24 10:49:56 +01:00
Jan Nieuwenhuizen 99ac7b59c4
core: Remove struct definitions for builtins, drop snarfing.
After making a change to the list of builtin functions, run

    cat src/*.i

and move the into

    src/mes.c:mes_builtins ()

and, or also after changing the list of fixed symbols in src/mes.c:mes_symbols (), do

    cat src/*.h > src/builtins.h

* build-aux/build.sh.in: Remove snarfing.
* build-aux/bootstrap.sh.in: Likewise.
* mes/module/mes/display.mes (display):
* mes/module/mes/type-0.mes (cell:type-alist): Remove <cell:function>.
(function?, builtin?): Remove.
* src/builtins.h: New file.
* src/mes.c (TFUNCTION): Remove.
(struct function): Remove.
(apply_builtin): Rewrite from call.
(mes_builtins): Rewrite.
(init_builtin, make_builtin_type, make_builtin, builtin_name,
builtin_arity, builtin, builtin_p, builtin_printer): New function.
2019-01-04 09:55:16 +01:00
Jan Nieuwenhuizen df27830846
mes: Add take-while.
* mes/module/srfi/srfi-1.mes (take-while): New function.
2018-12-27 16:36:22 +01:00
Jan Nieuwenhuizen 00289fb651
core: Remove --dump, --load.
* mes/module/mes/boot-0.scm.in (tty?): Remove --dump, --load.
* src/mes.c (bload_env): Remove.
* src/reader.c (dump): Remove.
2018-12-27 16:47:56 +01:00
Jan Nieuwenhuizen 32dcd3a575
doc: Release update.
* AUTHORS: Update.
* HACKING: Update.
* NEWS: Update.
* doc/mes.guix: Update.
* scripts/mescc.in: Update.
* mes/module/mes/boot-0.scm.in: Update.
* doc/announce/ANNOUNCE-0.19: New file.
2018-10-20 09:53:44 +02:00
Jan Nieuwenhuizen e90aed9d1b
mes: assq-ref, assoc-ref: Support alist == #f.
* mes/module/mes/scm.mes (assq-ref): Support alist == #f.
(assoc-ref): Likewise.
2018-12-15 12:56:15 +01:00
Jan Nieuwenhuizen 6b841a0cab
mescc: Run without shell.
* mes/module/mescc.mes: New file.
* module/mescc.scm: Include it.
* scripts/mescc.scm.in: New file.
* scripts/mescc.in: Use it; Make pure shell.
* configure: Substitute it.
* configure.sh: Substitute it.
* build-aux/install.sh.in: Install it.
2018-11-25 13:21:03 +01:00
Jan Nieuwenhuizen 1ab054002c
core: Add string-ref.
* src/strings.c (string_ref): New function.
* mes/module/mes/scm.mes (string-ref): Remove.
2018-11-16 00:15:50 +01:00
Jan Nieuwenhuizen 6af0b49f09
core: Add string-length.
* src/strings.c (string_length): New function.
* mes/module/mes/scm.mes (string-length): Remove.
2018-11-15 23:51:29 +01:00
Jan Nieuwenhuizen 819b32e61c
core: Add string-append.
* src/strings.c (string_append): New function.
* mes/module/mes/boot-0.scm.in (string-append): Remove.
* mes/module/mes/boot-03.scm (string-append): Remove.
* scaffold/boot/50-make-string.scm (string-append): Remove.
* scaffold/boot/50-string-append.scm (string-append): Remove.
* scaffold/boot/50-string-join.scm (string-append): Remove.
* scaffold/boot/51-module.scm (string-append): Remove.
* scaffold/boot/52-define-module.scm (string-append): Remove.
* tests/macro.test (string-append): Remove.
* scaffold/boot/17-string-append.scm: Move from 50-string-append.scm.
2018-11-15 23:09:56 +01:00
Jan Nieuwenhuizen 149f2a3e51
core: String as array of bytes.
* src/strings.c: New file.
* src/mes.c: Use it.  Update users.
2018-11-11 16:25:36 +01:00
Jan Nieuwenhuizen 0be3bea141
mes: Remove copy of make-string.
* mes/module/mes/guile.mes (make-string): Remove copy.
2018-11-14 08:19:01 +01:00
Jan Nieuwenhuizen e27e7af055
mes: Oops, %moduledir debug info.
* mes/module/mes/boot-0.scm.in: Oops, %moduledir debug info.
2018-11-11 14:47:14 +01:00
Jan Nieuwenhuizen fb8a6f3408
mes; Add read-line.
* mes/module/mes/guile.mes (read-line): New function.
2018-11-11 16:57:58 +01:00
Jan Nieuwenhuizen c61c6866b5
mes: dirname: Fix for absolute file names.
* mes/module/mes/guile.mes (dirname): Fix absolute files.
2018-11-11 10:15:12 +01:00
Jan Nieuwenhuizen e0a2d540f4
mes: Add file-exists?.
* mes/module/mes/guile.mes (file-exists?): New function.
2018-11-11 10:14:50 +01:00
Jan Nieuwenhuizen e95c5742be
mes: Add with-error-to-file.
* mes/module/mes/guile.mes (with-error-to-file): New function.
2018-11-11 10:14:10 +01:00
Jan Nieuwenhuizen 9da1fd92b6
mes: Add string-downcase, string-upcase, string-tokenize.
* mes/module/srfi/srfi-13.mes (string-downcase, string-upcase,
string-tokenize): New function.
2018-11-11 10:00:04 +01:00
Jan Nieuwenhuizen 9543962ece
mes: Add char-downcase, char-upcase.
* mes/module/srfi/srfi-14.mes (char-downcase, char-upcase): New
function.
2018-11-11 10:10:43 +01:00
Jan Nieuwenhuizen b7f5e1a8f9
mes: Add char-set:digit, char-set:lower-case, char-set:upper-case.
* mes/module/srfi/srfi-14.mes (char-set:digit, char-set:lower-case,
char-set:upper-case): New variable.
2018-11-11 10:09:41 +01:00
Jan Nieuwenhuizen b9534cb287
mes: Add char-set-adjoin, char-set-complement.
* mes/module/srfi/srfi-14.mes (char-set-adjoin, char-set-complement):
New function.
2018-11-11 10:08:03 +01:00
Jan Nieuwenhuizen 1f1fa33eaa
mes: system*: Support redirection.
* mes/module/mes/posix.mes (system*): Support redirection.
2018-11-11 10:00:50 +01:00
Jan Nieuwenhuizen 7d2e0f1215
core: Support redirection of stderr.
* include/libmes-mini.h (g_stderr): New global.
* lib/mes/eputc.c (eputc): Use it.
* lib/mes/eputs.c (eputs): Likewise.
* lib/mes/oputc.c (oputc): Likewise.
* lib/mes/oputs.c (oputs): Likewise.
* src/lib.c (display_error_, write_error_): Likewise.
* src/posix.c (write_byte): Likewise.
* src/mes.c (mes_builtins): Likewise.
(main): Iniitalize g_stderr.
* src/posix.c (current_error_port, set_current_error_port): New
function.
* mes/module/mes/boot-0.scm.in (current-output-port,
current-error-port): Remove.
2018-11-11 10:04:03 +01:00
Jan Nieuwenhuizen 06bf0fd6a3
mes: Add ceil, floor, round, inexact->exact.
* mes/module/mes/scm.mes (ceil, floor, round, inexact->exact,
exact->inexact): New function.
2018-10-21 12:07:06 +02:00
Jan Nieuwenhuizen 0e1d98963c
mes: read-string: Take optional port argument.
* src/posix.c (read_string): Take optional port argument.
* mes/module/mes/guile.mes (read-string): Remove.
2018-10-21 12:00:00 +02:00
Jan Nieuwenhuizen 00dc02757b
mes: Print backtrace upon exception.
* mes/module/mes/catch.mes (display-backtrace,
frame-function): New function.
(%eh): Use them.
2018-10-20 18:24:37 +02:00
Jan Nieuwenhuizen 67046e1b00
mes: Move pair? to core.
* src/lib.c (pair_p): New function.  Gains 8% performance on MesCC.
2018-10-18 20:06:10 +02:00
Jan Nieuwenhuizen 5ed45a4e24
mes: Move assoc to core.
* mes/mes.c (assoc_string, assoc): New function.
* mes/module/mes/scm.mes (assoc): Remove.  Gains 12% performance for
MesCC.
2018-10-19 22:38:19 +02:00
Jan Nieuwenhuizen b226a175f8
mes: Switch to srfi-9 based on structs.
* mes/module/srfi/srfi-9.mes: Swap symlink to srfi-9-struct.mes.
* mes/module/srfi/srfi-9/gnu.mes: Swap symlink to gnu-struct.mes.
* src/module.c (make_module_type): Update to match srfi-9-struct
records.  Update users.
* src/hash.c (make_hashq_type): Likewise.
2018-10-15 20:42:10 +02:00
Jan Nieuwenhuizen 4ff9b36f26
mes: srfi-9: Add implementation based on struct.
* mes/module/srfi/srfi-9-struct.mes: New file.
* mes/module/srfi/srfi-9-vector.mes: Rename from srfi-9.mes
* mes/module/srfi/srfi-9.mes: Symlink to srfi-9-vector.mes.
* mes/module/srfi/srfi-9/gnu-struct.mes: Add srfi-9-struct
implementation.
* mes/module/srfi/srfi-9/gnu-vector.mes: Rename from gnu.mes.
* mes/module/srfi/srfi-9/gnu.mes: Symlink to gnu-vector.mes.
2018-10-15 16:57:00 +02:00
Jan Nieuwenhuizen 7da67941e2
core: Add module-define!
* src/module.c (module_define_x, module_printer): New function.
(make_initial_module): Use them.
* tests/srfi-0.test: Test it.
* src/mes.c (display_m0): Remove.  Update callers.
* mes/module/mes/fluids.mes (make-fluid): Rewrite.
* tests/macro.test: Test it.
* mes/module/mes/boot-0.scm.in (module-define!): Remove.
* mes/module/mes/boot-02.scm: Likewise.
* module/mes/misc.scm (pk, warn): New function.
* build-aux/check-mes.sh (tests): Run tests.
2018-10-14 09:10:30 +02:00
Jan Nieuwenhuizen 16934697f7
core: Add module indirection for variable lookup.
* src/module.c (module_ref, module_variable): New function.
* src/mes.c: Thoughout: Use them.
(assq_ref_env): Remove.
* mes/module/mes/boot-0.scm.in (defined?): Use module-variable.
* mes/module/mes/boot-00.scm (defined?): Likewise.
* mes/module/mes/boot-01.scm (defined?): Likewise.
* mes/module/mes/boot-02.scm (defined?): Likewise.
* scaffold/boot/53-closure-display.scm: Likewise.
2018-10-14 08:30:18 +02:00
Jan Nieuwenhuizen 79c1fe0466
core: Add module type.
* src/module.c: New file.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.
2018-10-14 08:15:22 +02:00
Jan Nieuwenhuizen 96ca5b4e4b
core: Add cstring_to_symbol.
* src/mes.c (make_symbol): Rename from lookup_symbol_.  Update
callers.
(cstring_to_symbol): New function.
* src/reader.c (reader_read_identifier_or_number): Use it.
2018-10-14 07:38:51 +02:00
Jan Nieuwenhuizen 0068fe533d
core: Add struct type.
* src/struct.c: New file.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.
2018-10-13 17:34:27 +02:00
Jan Nieuwenhuizen 2d882ee7bb
core: core:cdr: Support port type.
* src/mes.c (cdr_): Support port type.
* mes/module/mes/display.mes (display): Add space between fields.
2018-10-15 12:28:02 +02:00
Jan Nieuwenhuizen 3e5d775b3b
mes: with-fluids: Fix reset.
* mes/module/mes/fluids.mes (with-fluids): Fix reset.
* tests/fluids.test (report): Remove Mes failure expectation.
2018-10-15 10:39:02 +02:00