Commit Graph

1539 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen b0e552ac0c
core: Add hashq_get_handle, hash, hash_ref, hash_set_x.
* src/mes.c (scm_symbol_hashq_table, scm_symbol_record_type,
scm_symbol_module, scm_symbol_buckets, scm_symbol_size): New symbols.
Update users.
* src/hash.c (hash_list_of_char): Rename from hashq_.  Respect size,
update callers.
(hashq_, hash_ hash, hashq_get_handle, hash_ref, hash_set_x_,
hash_set_x): New function.
(hashq_ref): Do not return handle.  Update callers.
2018-11-18 14:51:13 +01:00
Jan Nieuwenhuizen 5a8024ca82
mes: Move pair? to core.
* src/lib.c (pair_p): New function.  Gains 8% performance on MesCC.
2018-11-18 14:51:13 +01:00
Jan Nieuwenhuizen f660d149a5
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-11-18 14:51:13 +01:00
Jan Nieuwenhuizen 509ebb038a
Revert "core: Add gc-debug for stack array."
This reverts commit f35084d1dbea889d107824e7596da1701c6b90ad.
2018-11-18 14:51:13 +01:00
Jan Nieuwenhuizen 7838df8d6c
core: Add gc-debug for stack array.
* src/gc.c (gc_debug): New function.
2018-11-18 14:51:13 +01:00
Jan Nieuwenhuizen 613ce2b12a
scaffold: Resurrect mini-mes.
* src/mini-mes.c: Resurrect.
2018-11-18 14:51:13 +01:00
Jan Nieuwenhuizen 75b2590017
core: Use array-based stack.
* src/mes.c (STACK_SIZE)[MES_ARRAY_STACK]: New variable.
(g_stack_array): New variable.
(g_stack): Change type to SCM*.
(gc_push_frame)[MES_ARRAY_STACK]: Use g_stack_array, g_stack.
(gc_peek_frame): Likewise.
(gc_pop_frame): Likewise.
* src/gc.c (gc_check): Likewise.
(gc): Likewise.
2018-11-18 14:51:12 +01:00
Jan Nieuwenhuizen 5427af9754
mes: Resurrect Guile-1.8 support.
* module/mes/mes-0.scm: Resurrect Guile-1.8 support.
2018-11-18 14:51:12 +01:00
Jan Nieuwenhuizen c8c03c19dd
core: expand_variable: Remove weird exceptions: begin, if.
* src/mes.c (expand_variable_): Remove weird exceptions: begin, if.
2018-11-18 14:51:12 +01:00
Jan Nieuwenhuizen cfae3ed7fe
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-11-18 14:51:12 +01:00
Jan Nieuwenhuizen faeab8353e
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-11-18 14:51:12 +01:00
Jan Nieuwenhuizen c4b74ae9e3
core: hashq-table: Refactor to be a record-like struct.
* src/hash.c (hash_table_printer): New function.
(make_hashq_type): New function.
* src/module.c (module_printer): Use it.
(make_module_type): New function.
(make_initial_module): Use them.
2018-11-18 14:51:12 +01:00
Jan Nieuwenhuizen 79383565aa
mescc: Mes C Library: oputs: New function.
* lib/mes/oputc.c: New file.
* lib/libmes.c: Include it.
* include/libmes.h: Declare it.
2018-11-18 14:51:12 +01:00
Jan Nieuwenhuizen 6a720e2323
core: Use hashq-table for macros.
* src/mes.c (lookup_macro_): Remove.
(macro_ref, get_macro, macro_set_x): New function.  Update callers.
2018-11-18 14:51:11 +01:00
Jan Nieuwenhuizen 5144032050
core: Add hashq-table type.
src/hash.c: New file.
src/module.c (char_hash, module_hash): Remove.
* src/module.c (make_initial_module): Use hash primitives.
(module_define_x): Likewise.
(module_variable): Likewise.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.
2018-11-18 14:51:11 +01:00
Jan Nieuwenhuizen 2e5d757aba
core: Add boot-module.
* src/mes.c (scm_symbol_boot_module): New symbol.
(eval_apply): Handle it.
(mes_symbols): Initialize it.
2018-11-18 14:51:11 +01:00
Jan Nieuwenhuizen 64b9eee1bc
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-11-18 14:51:11 +01:00
Jan Nieuwenhuizen 5d2a6c7347
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-11-18 14:51:11 +01:00
Jan Nieuwenhuizen f14d63b621
core: Add module type.
* src/module.c: New file.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.
2018-11-18 14:51:11 +01:00
Jan Nieuwenhuizen 83b0d35f5c
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-11-18 14:51:11 +01:00
Jan Nieuwenhuizen ba6c091549
core: Add struct type.
* src/struct.c: New file.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.
2018-11-18 14:51:10 +01:00
Jan Nieuwenhuizen 24cf9eb4e7
build: factor-out snarfing.
* build-aux/snarf.sh: New file.
* build-aux/build-cc.sh: Use it.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-cc64.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/build-x86_64-mes.sh: Likewise.
* build-aux/snarf.sh: Likewise.
2018-11-18 14:51:10 +01:00
Jan Nieuwenhuizen 0b4a22c4f7
core: core:cdr: Support port type.
* src/mes.c (cdr_): Support port type.
* mes/module/mes/display.mes (display): Add space between fields.
2018-11-18 14:51:10 +01:00
Jan Nieuwenhuizen 8a48e22231
mes: with-fluids: Fix reset.
* mes/module/mes/fluids.mes (with-fluids): Fix reset.
* tests/fluids.test (report): Remove Mes failure expectation.
2018-11-18 14:51:10 +01:00
Jan Nieuwenhuizen fc1e39a505
mescc: Recognize U integer suffix.
* module/mescc/compile.scm (cstring->int): Recognize U integer
suffix.  Thanks, Peter de Wachter!
2018-11-18 14:51:10 +01:00
Peter De Wachter bb5ad2e6f7
mescc: Add INTn_MIN/MAX defines to stdint.h.
* include/stdint.h: Add INTn_MIN/MAX defines.  Move integere size
defines from limits.h
* include/limits.h: Include it.
2018-11-18 14:51:10 +01:00
Peter De Wachter b88d0121c6
mescc: Allow superfluous parentheses in function declarations.
E.g.:  int (f)();
This is obscure but valid C.  It occurs in the csmith headers (thanks
to macro shenanigans).

* module/mescc/compile.scm (fctn-defn:get-name,
fctn-defn:get-statement): Allow superfluous parentheses in function declarations.
2018-11-18 14:51:10 +01:00
Peter De Wachter 29e88ebece
mescc: Implement unary plus operator.
* module/mescc/compile.scm (ast->type, expr->register,
try-expr->number):): Implement unary plus operator.
2018-11-18 14:51:09 +01:00
Peter De Wachter 014712a995
mescc: Add missing assembly defines.
* lib/x86-mes/x86.M1: Add missing assembly defines.
* lib/x86_64-mes/x86_64.M1: Likewise.
2018-11-18 14:51:09 +01:00
Peter De Wachter 93a2d13e7a
mescc: Delete duplicate assembly defines.
* lib/x86-mes/x86.M1: Delete duplicate assembly defines.
* lib/x86_64-mes/x86_64.M1: Likewise.
2018-11-18 14:51:09 +01:00
Peter De Wachter 5ea7d8b6bb
mescc: Exit with non-zero exit code when subprocess fails.
system* returns the result of waitpid. So, suppose that a subprocess
fails with exit code 1. Then the waitpid return value will be 256.
And exit(256) is equivalent to exit(0).

Modified-by: Jan Nieuwenhuizen <janneke@gnu.org>

* mes/module/mes/posix.mes (status:exit-val): New function.
* module/mescc/mescc.scm (assert-system*): Use it.
2018-11-18 14:51:09 +01:00
Jan Nieuwenhuizen 2036a9de0c
mescc: Oops typo.
* module/mescc/M1.scm (hex2:immediate8): Typo.
2018-11-18 14:51:04 +01:00
Jan Nieuwenhuizen 3c9274ce2d
build: configure: Make dot optional.
* configure: Make dot optional.
2018-11-18 14:30:47 +01:00
Jan Nieuwenhuizen 08f04f5596
build: Oops, remove stray lib/linux/x86_64-mes/crt1.
* lib/linux/x86_64-mes/crt1: Remove.
2018-10-11 21:14:14 +02:00
Jan Nieuwenhuizen 33f37f2747
build: x86_64 bootstrap build fixes and workaround.
* configure: Substitute @arch@ (WAS: ARCH).  Update users.
* configure.sh: Substitute @arch@.
* build-aux/build-mes.sh: Use $GUILE for x86_64 build.
* build-aux/install.sh.in: Install mes.S, mes.x86_64-mes-S too.
Prune *.E, *.out.
2018-10-10 22:16:44 +02:00
Jan Nieuwenhuizen 4ae2a111db
doc: Release update. 2018-10-08 18:14:30 +02:00
Jan Nieuwenhuizen 5277669b04
mescc: Oops, delete wrong line of assembly.
* lib/x86-mes/x86.M1 (movzbl_%bx,%ebx): Delete wrong line.  Thanks, pdewacht!
2018-10-08 18:14:30 +02:00
Jan Nieuwenhuizen 44cc97a8a5
admin: Release update.
* doc/announce/ANNOUNCE-0.18: New file.
* guix/git/mes.scm (mes): Update hash.
2018-10-07 17:07:19 +02:00
Jan Nieuwenhuizen 761cdc65ed
Release 0.18.
* configure (VERSION): Update to 0.18.
(main): Likewise.
* configure.sh (VERSION): Likewise.
* guix/git/mes.scm (mes, mes.git): Likewise.
* guix/mescc-tools-boot.patch: New file.
2018-10-04 23:15:25 +02:00
Jan Nieuwenhuizen bb6d786736
doc: Release update.
* BOOTSTRAP: Update.
* HACKING: Update.
* NEWS: Update.
* README: Update.
* doc/mes.texi (Submitting Patches): Fix misquoting, misattribution.
2018-09-05 07:05:08 +02:00
Jan Nieuwenhuizen 9a36cf22d0
mescc: Another attempt at divide.
* module/mescc/i386/as.scm (i386:r0/r1): Never be signed.  Use div for unsigned.
(i386:r0%r1): Likewise.
* module/mescc/x86_64/as.scm (x86_64:r0/r1): Likewise.
(x86_64:r0%r1): Likewise.
* lib/x86-mes/x86.M1: Add div.
* lib/x86_64-mes/x86_64.M1: Likewise.
2018-10-07 15:15:45 +02:00
Jan Nieuwenhuizen a8a32a5280
tests: Expect srfi-13 failure, MesCC more resembles Gcc.
* tests/srfi-13.test (report): Expect INT-MIN failure for x86.
2018-10-07 14:14:50 +02:00
Jan Nieuwenhuizen 183514d103
core: reader: Support 64 bit.
* src/reader.c (reader_read_identifier_or_number): Support 64 bit.
(reader_read_binary): Likewise.
(reader_read_octal): Likewise.
(reader_read_hex): Likewise.
2018-10-07 00:58:31 +02:00
Jan Nieuwenhuizen 8f33bb5c4f
mescc: Mes C Library: Fix execve on x86_64.
* include/linux/x86_64/syscall.h (SYS_execve): Typo.  Fixes execve on
x86_64.
2018-10-06 22:38:28 +02:00
Jan Nieuwenhuizen a238986e43
build: Support make seed for x86_64.
* build-aux/GNUmakefile.in (seed): Support make seed for x86_64.
* build-aux/build-mes.sh[SEED]: Also build src/mes.S.
* build-aux/build-x86_64-mes.sh[SEED]: Also build src/mes.x86_64-mes.S.
2018-10-06 22:26:07 +02:00
Jan Nieuwenhuizen b31d431b5d
mes: Support fold-right 3.
* mes/module/srfi/srfi-1.mes (fold-right): Support fold-right 3.
* tests/srfi-1.test ("fold-right-3"): Test it.
2018-10-06 21:05:43 +02:00
Jan Nieuwenhuizen 6ab9a206bb
mescc: Nyacc comment escapes.
* module/mescc/compile.scm (ast->comment): Nyacc comment escapes.
2018-10-06 20:32:49 +02:00
Jan Nieuwenhuizen dc4b7f3a37
mescc: Fix clobbering of struct by value assign.
* module/mescc/x86_64/as.scm (long-r0->r1-mem): New instruction.
* module/mescc/i386/as.scm: Likewise.
* lib/x86_64-mes/x86_64.M1: Support it.
* module/mescc/compile.scm (r0->r1-mem*n-): Fix clobbering.
2018-10-06 20:23:43 +02:00
Jan Nieuwenhuizen 1f359b07a8
core: Add vector test.
* scaffold/boot/11-vector.scm: New test.
* build-aux/check-boot.sh: Run it.
2018-10-06 07:13:04 +02:00
Jan Nieuwenhuizen eedf2d2381
mescc: Fix obnoxious assignment ERROR message.
* module/mescc/compile.scm (expression->register): Fix assignment
ERROR message.
2018-10-06 19:22:16 +02:00