Commit Graph

317 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen d2cba60eb4
core: read_string: Allow for gc.
* src/posix.c (read_char): Add optional port parameter.
(read_string): Allow for gc.
2018-11-11 10:17:50 +01:00
Jan Nieuwenhuizen af328a444a
core: Add delete_file.
* src/posix.c (delete_file): New function.
2018-11-11 11:03:03 +01:00
Jan Nieuwenhuizen 35c8408df4
core: Add dup, dup2.
* src/posix.c (dup_, dup2_): New function.
2018-11-11 10:18:50 +01:00
Jan Nieuwenhuizen 7c63d3df47
core: Add getcwd.
* src/posix.c (getcwd_): New function.
2018-11-11 10:16:19 +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 331a0c29e6
core: Assert g_free in alloc.
* src/mes.c (alloc): Assert g_free.
2018-11-11 10:01:49 +01: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 d6660a5d83
core: eval_apply: Order gotos according to frequency.
* src/mes.c (eval_apply): Order gotos according to frequency.
2018-10-21 08:50:45 +02:00
Jan Nieuwenhuizen fc78b41a10
Revert "core: eval_apply profile."
This reverts commit d61e6be0b18459a8e3c262eab448b428dc81937a.
2018-10-21 08:43:35 +02:00
Jan Nieuwenhuizen a048a452e5
core: eval_apply profile.
* src/mes.c: Poor man's eval_apply profile.
2018-10-21 08:25:07 +02:00
Jan Nieuwenhuizen 9d1d85e041
core: Fix displaying of closure.
* src/lib.c (display_helper): Fix displaying of closure.
2018-10-20 20:01:45 +02:00
Jan Nieuwenhuizen a233287c07
core: Set procedure in stack frame.
* src/mes.c (eval_apply): Set procedure in stack frame.
2018-10-20 18:27:13 +02:00
Jan Nieuwenhuizen c2c361bf1a
core: Implement stack and frame.
* src/lib.c (frame_printer make_frame_type, make_frame,
make_stack_type, make_stack, stack_length, stack_ref): New function.
2018-10-20 18:23:20 +02:00
Jan Nieuwenhuizen 094bdac0bd
core: Support time functions.
* lib/linux/clock_gettime.c: New file, move from gnu.c.
* lib/linux/gettimeofday.c: New file, move from tcc.c.
* lib/linux/time.c: New file, move from tcc.c.
* lib/linux/libc.c: Include them.
* lib/linux/gnu.c (clock_gettime): Remove.
* lib/linux/tcc.c (time, gettimeofday): Remove.
* include/time.h (CLOCK_PROCESS_CPUTIME_ID): New define.
* src/posix.c (init_time, current_time, gettimeofday_,
seconds_and_nanoseconds_to_long, get_internal_run_time): New function.
* src/mes.c (scm_symbol_internal_time_units_per_second): New symbol.
(main): Call init_time.
2018-10-20 14:18:04 +02:00
Jan Nieuwenhuizen ddb74e0a4a
core: Use hash table for symbols.
* src/mes.c (mes_symbols): Use hash table for symbols.  Update users.
2018-10-18 18:50:09 +02:00
Jan Nieuwenhuizen 8e2a688a8c
core: Use assert before failure exit.
* src/mes.c (error): Use assert before failure exit.  Helps debugging.
2018-10-19 23:01:59 +02:00
Jan Nieuwenhuizen 7efd949304
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-10-18 07:55:28 +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 4e0e4c83d8
Revert "core: Add gc-debug for stack array."
This reverts commit f35084d1dbea889d107824e7596da1701c6b90ad.
2018-10-20 10:58:56 +02:00
Jan Nieuwenhuizen e032f6c70f
core: Add gc-debug for stack array.
* src/gc.c (gc_debug): New function.
2018-10-19 21:23:17 +02:00
Jan Nieuwenhuizen d73df09ab6
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.
2017-12-14 07:05:53 +01:00
Jan Nieuwenhuizen a99f9c6df9
core: expand_variable: Remove weird exceptions: begin, if.
* src/mes.c (expand_variable_): Remove weird exceptions: begin, if.
2018-10-16 17:13:04 +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 8c0a517edf
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-10-15 15:45:41 +02:00
Jan Nieuwenhuizen d472c4b6f2
core: Use hashq-table for macros.
* src/mes.c (lookup_macro_): Remove.
(macro_ref, get_macro, macro_set_x): New function.  Update callers.
2018-10-15 14:13:51 +02:00
Jan Nieuwenhuizen d552ef7c67
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-10-15 13:36:19 +02:00
Jan Nieuwenhuizen bba17734d8
core: Add boot-module.
* src/mes.c (scm_symbol_boot_module): New symbol.
(eval_apply): Handle it.
(mes_symbols): Initialize it.
2018-10-15 10:44:47 +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 a155a0a9a2
core: Support \xNN in reader. Fixes tcc-boot running on Mes.
* src/reader.c (reader_read_string): Support \xNN.  Fixes Guix
bootstrap chain; i.e., compilation of gcc-2.95.3 using tcc-boot.
* tests/base.test ("reader: \\x08"): Test it.
* scaffold/tests/17-compare-char.c: Likewise, for mescc.
* build-aux/check-mescc.sh (tests): Run it.
2018-12-13 18:19:43 +01: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 f7e208dd7b
core: Avoid 64bit zero divide.
* src/math.c (divide): Avoid (64bit) 0 divide.
(modulo): Likewise.
2018-10-07 00:25:33 +02:00
Jan Nieuwenhuizen d0a1cc5096
core: Use proper name for %compiler.
* src/mes.c (mes_symbols, bload_env): : Use proper name for %compiler.
2018-10-06 08:43:26 +02:00
Jan Nieuwenhuizen e4e41a30b4
core: Resurrect MES_MINI for non-POSIX.
src/mes.c[MES_MINI,!POSIX]: Resurrect.
2018-10-06 07:25:39 +02:00
Jan Nieuwenhuizen 133013a3d2
core: Support x86_64.
* src/lib.c: Support x86_64.
* src/math.c: Likewise.
* src/mes.c: Likewise.
* src/reader.c: Likewise.
* src/vector.c Likewise.
2018-10-04 21:43:45 +02:00
Jan Nieuwenhuizen bc094d0e1f
core: mes: Prepare for M2-Planet.
* src/mes.c (cal): Refactor to use if instead of switch.
(eval_apply): Likewise.
2018-08-12 16:53:21 +02:00
Jan Nieuwenhuizen 1e787637d8
core: lib: Prepare for M2-Planet.
* src/lib.c (display_helper): Refactor to use if instead of switch.
(memq): Likewise.
2018-08-12 16:41:07 +02:00
Jan Nieuwenhuizen 03ee240904
core: reader: Prepare for M2-Planet.
* src/reader.c (MAX_STRING): New define.
(read_input_file_env_): Remove dead code.
(reader_read_line_comment): Refactor to remove recursion.
(reader_read_line_sexp_): Refactor to use if instead of switch.
(reader_read_hash): Likewise.
(reader_read_character): Refactor: cache peekchar () value, make
M2-Planet friendly.
(reader_read_binary): Make M2-Planet friendly.
(reader_read_octal): Likewise.
(reader_read_hex): Likewise.
(reader_read_string): Refactor.
(dump): Make M2-Planet friendly.
2018-08-12 14:53:06 +02:00
Jan Nieuwenhuizen 5a6d8c21e0
mescc: Mes C Library: Add x86_64 libc support.
* include/linux/x86_64/syscall.h: New file.
* include/linux/x86/syscall.h: New file.
* lib/linux/x86_64-mes-gcc/mes.c: New file.
* lib/linux/x86-mes/mes.c: Rename from lib/linux/mes.c.
* lib/linux/x86-mes-gcc/mes.c: Rename from lib/linux/gcc.c.
* lib/linux/libc.c: Update includes.
(waitpid)[__x86_64__]: Use wait4.
* build-aux/build-cc.sh: Build libc too.
* lib/x86-mes/x86.M1 (mov____0x8(%ebp),%esi): New macro.
2018-08-11 11:42:30 +02:00
Jan Nieuwenhuizen 46e0641e9c
mescc: Mes C Library: Add x86_64 libc-mini support.
* lib/linux/x86-mes-gcc/mini.c: Rename from lib/linux/mini-gcc.c.
* lib/linux/x86-mes/mini.c: Rename from lib/linux/mini-mes.c.
* lib/linux/x86_64-mes-gcc/crt1.c: Rename from lib/linux/x86_64/crt1.c.
* lib/linux/x86_64-mes-gcc/mini.c: New file.
* build-aux/build-cc.sh: Build libc-mini, scaffold/main, scaffold/hello.
* build-aux/cc64.sh: New file.
2018-08-10 17:05:01 +02:00
Jan Nieuwenhuizen f18e1fea36
build: Make build more autotools-like.
* build-aux/build.sh.in: Move from ./build.sh
* build-aux/check.sh.in: Likewise.
* build-aux/GNUmakefile.in: Likewise.
* build-aux/install.sh.in: Likewise.
* build-aux/uninstall.sh.in: Likewise.
* configure: Substitute them.
* configure.sh: Likewise.
* build-aux/build-cc.sh: Update: use ${srcdest} instead of ${top_builddest}.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-guile.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/cc-mes.sh: Likewise.
* build-aux/cc.sh: Likewise.
* build-aux/cc32-mes.sh: Likewise.
* build-aux/check-boot.sh: Likewise.
* build-aux/check-mes.sh: Likewise.
* build-aux/check-mescc.sh: Likewise.
* build-aux/config.sh: Likewise.
* build-aux/export.make: Likewise.
* build-aux/mes-snarf.scm: Likewise.
* build-aux/pre-inst-env.in: Likewise.
* build-aux/test.sh: Likewise.
* build-aux/trace.sh: Likewise.
* module/mescc/mescc.scm: Likewise.
* scripts/mescc.in: Likewise.
* src/mes.c: Likewise.
* .gitignore: Likewise.
2018-07-25 08:14:13 +02:00
Jan Nieuwenhuizen 72cb975213
GNU Mes.
Throughout, make these changes

   Copyright headers: GNU Mes
   First mention of name: GNU Mes
   Website: https://www.gnu.org/software/mes
   Git:     git://git.savannah.gnu.org/mes.git
2018-07-22 14:24:36 +02:00
Jan Nieuwenhuizen 4203a427d0
build: Support --srcdir build.
* build-aux/config.sh: New file.
* build-aux/trace.sh: New file.
* build-aux/GNUmakefile.in: New file.
* configure: Support srcdir configure.
* GNUmakefile: Support srcdir build.
* build-aux/build-cc.sh: Likewise.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-guile.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/cc-mes.sh: Likewise.
* build-aux/cc.sh: Likewise.
* build-aux/cc32-mes.sh: Likewise.
* build-aux/check-mes.sh: Likewise.
* build-aux/check-mescc.sh: Likewise.
* build-aux/export.make: Likewise.
* build-aux/mes-snarf.scm: Likewise.
* build-aux/pre-inst-env.in: Likewise.
* build-aux/test.sh: Likewise.
* build.sh: Likewise.
* check.sh: Likewise.
* install.sh: Likewise.
* module/mescc/mescc.scm: Likewise.
* scripts/mescc.in: Likewise.
* src/mes.c: Likewise.
2018-07-22 00:43:39 +02:00
Jan Nieuwenhuizen 87269a16f6
core: Document number->string INT-MIN failure with gcc-x86.
* src/mes.c (scm_symbol_arch, scm_symbol_compiler): New symbol.
  (mes_symbols, bload_env): Add them.
  (scm_symbol_gnuc, scm_symbol_mesc): Remove.
* scaffold/mini-mes.c: Likewise.
* module/mes/mes-0.scm (%arch, %compiler): New public variable.
* tests/srfi-13.test: Expect number->string INT-MIN to fail for
  gcc-x86.
* HACKING (Bugs): Add it.
2018-07-21 15:20:01 +02:00
Jan Nieuwenhuizen 57cb608b6a
core: Resurrect gcc support.
* src/mes.c (MES_ARENA)[POSIX]: Default to 100000000.
2018-07-21 10:48:31 +02:00
Jan Nieuwenhuizen 542289a3c6
build: Separate Mes and Guile modules.
* scaffold/gc.scm: Move from guile/gc.scm.
* guile/: Remove.
* module/language/paren.mes: Remove.
* mes/module/mes/base.mes: Move from module/mes/.
* mes/module/mes/boot-0.scm: Likewise.
* mes/module/mes/boot-00.scm: Likewise.
* mes/module/mes/boot-01.scm: Likewise.
* mes/module/mes/boot-02.scm: Likewise.
* mes/module/mes/catch.mes: Likewise.
* mes/module/mes/display.mes: Likewise.
* mes/module/mes/fluids.mes: Likewise.
* mes/module/mes/getopt-long.mes: Likewise.
* mes/module/mes/guile.mes: Likewise.
* mes/module/mes/lalr.mes: Likewise.
* mes/module/mes/lalr.scm: Likewise.
* mes/module/mes/let.mes: Likewise.
* mes/module/mes/match.mes: Likewise.
* mes/module/mes/match.scm: Likewise.
* mes/module/mes/mescc.mes: Likewise.
* mes/module/mes/misc.mes: Likewise.
* mes/module/mes/module.mes: Likewise.
* mes/module/mes/optargs.mes: Likewise.
* mes/module/mes/optargs.scm: Likewise.
* mes/module/mes/peg.mes: Likewise.
* mes/module/mes/peg/cache.scm: Likewise.
* mes/module/mes/peg/codegen.scm: Likewise.
* mes/module/mes/peg/simplify-tree.scm: Likewise.
* mes/module/mes/peg/string-peg.scm: Likewise.
* mes/module/mes/peg/using-parsers.scm: Likewise.
* mes/module/mes/pmatch.mes: Likewise.
* mes/module/mes/pmatch.scm: Likewise.
* mes/module/mes/posix.mes: Likewise.
* mes/module/mes/pretty-print.mes: Likewise.
* mes/module/mes/pretty-print.scm: Likewise.
* mes/module/mes/psyntax-0.mes: Likewise.
* mes/module/mes/psyntax-1.mes: Likewise.
* mes/module/mes/psyntax.mes: Likewise.
* mes/module/mes/psyntax.pp: Likewise.
* mes/module/mes/psyntax.ss: Likewise.
* mes/module/mes/quasiquote.mes: Likewise.
* mes/module/mes/quasisyntax.mes: Likewise.
* mes/module/mes/quasisyntax.scm: Likewise.
* mes/module/mes/repl.mes: Likewise.
* mes/module/mes/scm.mes: Likewise.
* mes/module/mes/syntax.mes: Likewise.
* mes/module/mes/syntax.scm: Likewise.
* mes/module/mes/test.mes: Likewise.
* mes/module/mes/tiny-0.mes: Likewise.
* mes/module/mes/type-0.mes: Likewise.
* mes/module/mescc/M1.mes: Likewise.
* mes/module/mescc/as.mes: Likewise.
* mes/module/mescc/bytevectors.mes: Likewise.
* mes/module/mescc/compile.mes: Likewise.
* mes/module/mescc/i386/as.mes: Likewise.
* mes/module/mescc/info.mes: Likewise.
* mes/module/mescc/mescc.mes: Likewise.
* mes/module/mescc/preprocess.mes: Likewise.
* mes/module/nyacc/lalr.mes: Likewise.
* mes/module/nyacc/lang/c99/cpp.mes: Likewise.
* mes/module/nyacc/lang/c99/parser.mes: Likewise.
* mes/module/nyacc/lang/c99/pprint.mes: Likewise.
* mes/module/nyacc/lang/calc/parser.mes: Likewise.
* mes/module/nyacc/lang/util.mes: Likewise.
* mes/module/nyacc/lex.mes: Likewise.
* mes/module/nyacc/parse.mes: Likewise.
* mes/module/nyacc/util.mes: Likewise.
* mes/module/rnrs/arithmetic/bitwise.mes: Likewise.
* mes/module/srfi/srfi-0.mes: Likewise.
* mes/module/srfi/srfi-1.mes: Likewise.
* mes/module/srfi/srfi-1.scm: Likewise.
* mes/module/srfi/srfi-13.mes: Likewise.
* mes/module/srfi/srfi-14.mes: Likewise.
* mes/module/srfi/srfi-16.mes: Likewise.
* mes/module/srfi/srfi-16.scm: Likewise.
* mes/module/srfi/srfi-26.mes: Likewise.
* mes/module/srfi/srfi-26.scm: Likewise.
* mes/module/srfi/srfi-43.mes: Likewise.
* mes/module/srfi/srfi-8.mes: Likewise.
* mes/module/srfi/srfi-9.mes: Likewise.
* mes/module/srfi/srfi-9/gnu.mes: Likewise.
* mes/module/sxml/xpath.mes: Likewise.
* mes/module/sxml/xpath.scm: Likewise.
* module/mes/mes-0.scm: Likewise.
* build-aux/build-guile.sh: Update for new layout.
* build-aux/build-mes.sh: Likewise.
* build-aux/check-boot.sh: Likewise.
* build-aux/check-mescc.sh: Likewise.
* install.sh: Likewise.
* scaffold/boot/51-module.scm: Likewise.
* scaffold/boot/52-define-module.scm: Likewise.
* scripts/mescc: Likewise.
* src/mes.c: Likewise.
* tests/base.test-guile: Likewise.
* tests/boot.test: Likewise.
* tests/srfi-9.test: Likewise.
* mes/include: New symlink.
* mes/lib: New symlink.
* AUTHORS: Update file names.
2018-07-21 07:15:52 +02:00
Jan Nieuwenhuizen f6d5578174
core: Fix segfault on Debian/strectch. Thanks, pdewacht!
* src/posix.c (execl_): Typo in initialization.  Fixes segfault on
  Debian/strectch.  Thanks, pdewacht!
2018-07-12 22:30:00 +02:00
Jan Nieuwenhuizen 16f4adfbc2
core: Fix compile warnings.
* lib/libmes.c: Fix warning.
* src/posix.c (execl_): Fix warning, add debug printing.
2018-06-26 06:19:51 +02:00
Jan Nieuwenhuizen 7be16f51b3
core: execl_: Allow 1000 arguments.
* src/posix.c (execl_): Allow 1000 arguments.
2018-06-26 06:05:20 +02:00
Jan Nieuwenhuizen a1334148ca
core: Resurrect dump-tiny.
* src/reader.c (dump): Resurrect dump-tiny.
2018-06-18 22:55:23 +02:00
Jan Nieuwenhuizen 8793e0dde3
core: Resurrect loading of boot-0.32-mo. 2018-06-18 18:55:59 +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 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 58a0b97991
core: Refactor boot-0 loading.
* src/mes.c (load_boot): New function.
  (load_env): Use it.
2018-05-28 18:53:25 +02:00
Jan Nieuwenhuizen 4ee1c9595e
Revert "fork/exec: debug."
This reverts commit f0315ac0d9acd66a30dbb192334f443459b7ed16.
2018-05-25 11:21:26 +02:00
Jan Nieuwenhuizen 342195bbbd
fork/exec: debug. 2018-05-25 11:21:06 +02:00
Jan Nieuwenhuizen e4d0298d1b
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.
2018-05-24 19:54:42 +02:00
Jan Nieuwenhuizen c4abd50a53
core: Add logxor.
* src/math.c (logxor): New function.
* tests/math.test ("logxor"): Test it.
2018-05-16 22:30:08 +02:00
Jan Nieuwenhuizen 04860cca6b
core: reader: Support binary #b101.
* src/reader.c (reader_read_binary): New function.
  (reader_read_hash): Use it.
* tests/scm.test ("binary"): Test it.
2018-05-16 22:32:59 +02:00
Jan Nieuwenhuizen 7b476693c2
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.
2018-04-28 18:31:10 +02:00
Jan Nieuwenhuizen 1400489a94
Revert "core: Remove pmatch-car, pmatch-cdr hack."
This reverts commit be1e84624ea4a158173f34af923e3c4a3793412a.
2018-04-29 07:46:40 +02:00
Jan Nieuwenhuizen c03449ac5a
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.
2018-04-28 12:19:40 +02:00
Jan Nieuwenhuizen 99718a8b7a
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.
2018-05-02 23:11:27 +02:00
Jan Nieuwenhuizen 6d3fee91b9
Revert "core: length: Check parameter."
This reverts commit 1f52ed35c66febcce16e06868e803a39be7eda41.
2018-04-30 20:47:05 +02:00
Jan Nieuwenhuizen ec85612ac4
core: length: Check parameter.
* src/mes.c (length): Check parameter.
2018-04-30 19:31:00 +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 3e6319058a
core: Use length__.
* src/mes.c (check_formals): Use length__.
2018-04-30 21:17:10 +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 41fe739463
core: reverse!: Handle empty list.
* src/mes.c (reverse_x_): Handle empty list.
* tests/scm.test ("reverse! ()"): Test it.
2018-04-29 18:14:01 +02:00
Jan Nieuwenhuizen dc24a7f76f
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.
2018-04-29 17:48:38 +02:00
Jan Nieuwenhuizen c20ef52f6f
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.
2018-04-29 16:17:07 +02:00
Jan Nieuwenhuizen 8911af4aa8
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.
2018-04-29 13:22:02 +02:00
Jan Nieuwenhuizen a56d5e3efe
core: Fix gc_up_arena for x86_64.
* src/gc.c (gc_): Fix gc_up_arena for x86_64.
2018-04-29 12:04:18 +02:00
Jan Nieuwenhuizen 865e72ae8a
core: Fix compile warnings.
* src/posix.c: Include sys/stat.h.
  (chmod): Return cell_unspecified.
* include/stdlib.h: Typo.
2018-04-29 12:02:23 +02:00
Jan Nieuwenhuizen 2cc6f166db
core: Add chmod.
* src/posix.c (chmod_): New function.
2018-04-27 23:31:45 +02:00
Jan Nieuwenhuizen e3b929aa87
core: jam-scaper/garbage-collector: Use only one arena.
* src/mes.c (ARENA_SIZE): Lower to 200000.
  (MES_MAX_ARENA): Bump to 300000000.
  (JAM_SIZE): New global.
  (make_cell__): Remove ARENA assert.
  (gc_init_cells): Alloc ARENA_SIZE + JAM_SIZE.
  (mes_symbols): Do not init news.
  (gc_init_news): Remove.
  (main): Initialize JAM_SIZE, consider MES_JAM environment variable.
* src/gc.c (gc_init_news): Move from mes.c.  Start at g_free.
  (gc_flip): Do not flip to g_news, instead copy g_news to cells.
  (gc_up_arena): Realloc to ARENA_SIZE + JAM_SIZE.
  (gc_): Init news.  Only up arena if g_news is safe.
2018-04-25 08:35:05 +02:00
Jan Nieuwenhuizen 18d143aa62
core: last_pair: Move to core.
* src/lib.c (last_pair): New function.
* module/mes/scm.mes (last-pair): Remove.
2018-04-24 07:00:35 +02:00
Jan Nieuwenhuizen 4fa6acc480
core: equal2_p: Add short-circuit and eliminate tail call.
* src/lib.c (equal2_p): Add short-circuit and eliminate tail call.
2018-04-24 06:59:18 +02:00
Jan Nieuwenhuizen 630718f134
mes: Guile-like command-line interface.
* module/mes/boot-0.scm (tty?): Guile-like command-line interface.
* scripts/repl.mes: Remove.
* scripts/mescc.mes: Update.
* tests/*.test: Update scripts.
* module/mes/repl.mes (repl): Add ,quit.
2018-04-22 11:51:28 +02:00
Jan Nieuwenhuizen bb45012c39
mes: Add isatty?.
* src/posix.c (isatty_p): New function.
2018-04-22 11:48:38 +02:00
Jan Nieuwenhuizen 75444afc21
core: Compile minimal mes with MES_MINI=1.
* src/mes.c: Compile minimal mes with MES_MINI=1.
2018-04-10 21:43:19 +02:00
Jan Nieuwenhuizen 3f943c8cfa
core; reader_read_string: Support escaped characters.
* src/reader.c (reader_read_string): Support escaped characters.
2018-04-22 00:33:50 +02:00
Jan Nieuwenhuizen 6be49a294b
core: display_helper: Display escaped characters.
* src/lib.c (display_helper): Display escaped characters.
2018-04-21 23:58:28 +02:00
Jan Nieuwenhuizen 7ecec93a88
mes: Resurrect macros in repl.
* src/mes.c (scm_vm_begin_expand): Rename to core:begin-expand.
 (eval_apply): Expose it.
* module/mes/repl.mes (repl): Use it to resurrect macros.
2018-04-21 17:30:14 +02:00
Jan Nieuwenhuizen 833fe991cb
core: Fixes for garbage collector/jam scraper.
* src/gc.c (gc_loop): Do not relocate car of TCLOSURE, TCONTINUATION.
  Check for TBROKEN_HEART.
* src/mes.c (make_closure_): Set car to 0.
  (check_apply): Check for TBROKEN_HEART.  Fixes reporting artificial
  out-of-memory error.
  (eval_apply): Likewise.
* src/vector.c (vector_entry): Only copy TCHAR and TNUMBER.
2018-04-21 13:31:12 +02:00
Jan Nieuwenhuizen 0be441446e
core: drop global_p from variable.
* src/mes (struct scm): Remove field global_p.
 (VARIABLE_GLOBAL_P): Remove.
 (make_variable_): Remove global_p parameter.  Update callers.
* src/lib.c (display_helper): Drop VARIABLE_GLOBAL_P support.
2018-04-21 13:19:54 +02:00
Jan Nieuwenhuizen 82db3a941a
core: Reenable full printing of lists.
* src/lib.c (display_helper): Reenable full printing of lists.
2018-04-21 08:54:14 +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 62a369e6de
core: vector_to_list: Create less garbage.
* src/vector.c (vector_to_list): Create less garbage.
2018-04-20 13:22:47 +02:00
Jan Nieuwenhuizen ac0baf84d4
core: Cleanup make_cell, remove tmp cells.
* src/mes.c (make_cell__): New function.
  (make_cell_): Use it.
  (length__): New function.
  (tmp, tmp_num, tmp_num2, tmp_num_, tmp_num2_, make_tmps): Remove.
  Update callers to use make_cell__ directly.
 * src/vector.c (make_vector__): New function.
  (make_vector_): Use it.
2018-04-14 08:15:49 +02:00
Jan Nieuwenhuizen 0d0c7a415b
mes: Move base-0.mes int boot-0.scm.
* module/mes/boot-02.scm: New file, rename from boot-0.scm.
* module/mes/boot-0.scm: Add base-0.mes.
* module/mes/base-0.mes: Remove.
2018-04-14 22:06:28 +02:00
Jan Nieuwenhuizen b200366f27
mes: Unify mlibc-gcc and mes builds.
* make.scm (bin.gcc): Remove stray slash.
* src/mes.c: Unify mlibc-gcc and mes builds.
(gc_init_cells):
(gc_init_news):
(bload_env):
* src/reader.c (reader_read_character):
(reader_read_string):
2018-04-13 08:18:19 +02:00
Jan Nieuwenhuizen 3dc72ce20d
core: Remove local variables from gc.
* src/gc.c (gl_loop): Remove local variables.
2018-04-12 21:33:38 +02:00
Jan Nieuwenhuizen a342791f2b
core: Listen to MES_SAFETY environment variable. 2018-04-12 07:08:09 +02:00
Jan Nieuwenhuizen 1bc4bc7894
core: Remove local variables from eval/apply.
* src/mes.c (eval_apply): Move all variables to global scope.
2018-04-12 07:07:24 +02:00
Jan Nieuwenhuizen 9b9a27b743
core: Remove MesCC reminder. 2018-04-12 07:06:40 +02:00
Jan Nieuwenhuizen 5b30d234cb
core: Update default memory settings.
* src/mes.c (MAX_ARENA_SIZE)[__MESC__]: Set to maximum 172100000.
2018-04-11 20:46:06 +02:00
Jan Nieuwenhuizen b65e57be31
core: Tune debug printing.
* src/mes.c: Tune debug printing.
* src/gc.c: Likewise.
* module/mes/guile.mes: Likewise.
* HACKING: Describe it.
2018-04-09 07:12:38 +02:00
Jan Nieuwenhuizen 72fc46a572
core: Rewrite reader to create less garbage.
* src/reader.c (reader_read_line_comment): Rename from read_line_comment.
(reader_identifier_p): New function.
(reader_end_of_word_p): New function.
(reader_read_identifier_or_number): New function.
(reader_read_sexp_): Rewrite.  Update callers.
(reader_read_list): Rewrite.
(reader_lookup_): Remove.
2018-04-09 08:41:30 +02:00
Jan Nieuwenhuizen 45e347588c
core: Rewrite string reader.
* src/reader.c (reader_read_string): Rewrite, create much less
  garbage.
  (append_char): Remove.
2018-04-08 23:14:45 +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 20f66238c5 core: Workaround for mescc.
* src/mes.c (eval_apply)[__MESC__]: Add reminder for macro_p, global_p.
2018-04-08 07:50:12 +02:00
Jan Nieuwenhuizen c4b0879bc9 mes: Allow tick as part of identifier.
* src/reader.c (reader_read_sexp_): Do not treat tick as special.
2018-04-07 13:36:23 +02:00
Jan Nieuwenhuizen da724cdaa1 Revert "core: Add member."
This reverts commit 921686a0a3b06281f1804d04e6d4a0344dda507a.
2018-04-07 13:15:26 +02:00
Jan Nieuwenhuizen f33d23bca1 core: Add member.
* src/lib.c (member): New function.
* module/mes/scm.mes (member): Remove.
2018-04-07 12:18:50 +02:00
Jan Nieuwenhuizen 6932d83d82 mes: Add setenv.
* src/posix.c (setenv_): New function.
* tests/base.test ("setenv, getenv"): Test it.
2018-04-07 09:34:02 +02:00
Jan Nieuwenhuizen b5c2bdec00 core: Cleanup reader.
* src/reader.c (reader_read_sexp_): Rename from reader_read_word_.  Cleanup.
  (read_hash): Cleanup.
2018-04-05 22:41:53 +02:00
Jan Nieuwenhuizen 35bb5869f9 mes: Cleanup formatting. 2018-04-05 21:35:31 +02:00
Jan Nieuwenhuizen 0a4030838c core: Add equal2?.
* src/lib.c (equal2_p): New function.
* module/mes/base.mes (equal2?): Remove.
2018-04-05 20:01:04 +02:00
Jan Nieuwenhuizen 6a9621ebf3 core: Add memq.
* lib/mes.c (memq): New function.
* module/mes/scm.mes (memq): Remove.
2018-04-05 11:03:09 +02:00
Jan Nieuwenhuizen 9fc27ee25a mes: Single environment lookup for variables, SICP chapter 3.
* src/mes.c (t): Add TVARIABLE.
  (scm_vm_eval_deref): New vm special.
  (make_vref_): New internal function.
  (eval_apply): WIP: replace symbols with their variable reference.
* src/gc.c (gc_loop): Handle TVARIABLE.
* src/lib.c (display_helper): Handle TVARIABLE.
* module/mes/type-0.mes (<cell:variable>): New variable.
  (cell:type-alist): Add it.
  (variable?): New function.
* module/mes/display.mes (display): Handle <variable>.
2017-12-09 08:33:50 +01:00
Jan Nieuwenhuizen d1444ead65 core: Remove override hook for read-input-file.
* src/reader.c (read_input_file_env): Remove override hook for
read-input-file.
2018-04-03 07:45:12 +02:00
Jan Nieuwenhuizen 4c9690996c mes: Iterative recursive macro expand.
* src/mes.c (eval_apply): Iterative recursive macro expand.
* src/posix.c (set_current_input_port): Return previous port.
* module/mes/catch.mes (%eh): Use core:display.
* module/mes/display.mes (display-cut, display-cut2): Move macro
  definitions to toplevel.
2018-03-04 10:05:55 +01:00
Jan Nieuwenhuizen 459e4f6a57 mes: Boot from MES_BOOT, boot-0.scm.
* src/mes.c (load_env): Softcode loading of boot-0.scm from
  environment variabl MES_BOOT.
* module/mes/boot-00.scm: New file.
* module/mes/boot-01.scm: New file.
* module/mes/boot-0.scm: Rename from read-0.mes.
* module/mes/module.mes: New file.
2018-02-03 21:43:52 +01:00
Jan Nieuwenhuizen f077364bce mes: reader: reader_ prefix; read/write char/string in core.
* src/posix.c (peek_char, read_char, read_string, unread_char, write_char): New function.
* src/reader.c: Use reader_ prefix.

r#	bootstrappable.org
2018-01-06 07:58:23 +01:00
Jan Nieuwenhuizen 91070593e9 mes: More informative error reporting for number asserts.
* src/math.c (assert_number): New function.  Update assert () users.
2018-01-25 07:00:48 +01:00
Jan Nieuwenhuizen d176d1bf6c core: Display and write string and char compliance.
* src/lib.c (display_helper): Display and write char and string compliance.
2018-01-22 23:45:46 +01:00
Jan Nieuwenhuizen 5a7db9749d mes: display: Support keyword.
* src/lib.c (display_helper): Support keyword.
2018-02-03 21:57:30 +01:00
Jan Nieuwenhuizen 3161f039b2 mes: display: vector.
* src/lib.c (display_helper): Display vector.
2018-01-12 18:24:42 +01:00
Jan Nieuwenhuizen 63e8b49d9e mes: display: closure names.
* src/lib.c (display_helper): Display closure names.
2018-01-14 09:11:19 +01:00
Jan Nieuwenhuizen 7b8f69972e mes: Rename make-vector to core:make-vector.
* src/vector.c (make_vector_): Rename from make_vector.  Update callers.
2018-01-07 16:26:36 +01:00
Jan Nieuwenhuizen a5ede4d4d6 mes: Better error reporting.
* src/lib.c (write_error_): New function.
* src/mes.c (error, check_apply): Use it.
  (append2, set_car_x): Upon error, call error (WAS: assert).
2018-01-07 16:08:11 +01:00
Jan Nieuwenhuizen 81404179c1 mes: Add write, core:write.
* src/lib.c (display_helper, fdisplay_): Add parameter, write_p.
  Update callers.  When write_p: write quoted strings.
  (write_, write_port_): New function.
* module/mes/read-0.mes (write): New function.
2018-01-01 21:10:15 +01:00
Jan Nieuwenhuizen c092aeb7f7 mes: gc_safety. 2018-01-01 20:00:06 +01:00
Jan Nieuwenhuizen 08562b168d test: Add syntax tests.
* tests/syntax.test: New file.
* tests/syntax.test-guile: New file.

fixup: 1b0696f9 (Jan Nieuwenhuizen 2018-01-01 15:53:13 +0100 40) ,        (lambda ()
2018-01-01 15:53:13 +01:00
Jan Nieuwenhuizen 562d91466c Revert "mes: use array-based stack. WIP: will not survice gc."
This reverts commit 7fb653f68c2dbf8bc83cce4bd138439c600b538f.
2017-12-17 07:42:49 +01:00
Jan Nieuwenhuizen da20d92c77 mes: use array-based stack. WIP: will not survice gc.
* 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.
2017-12-14 07:05:53 +01:00
Jan Nieuwenhuizen 90249f595f mes: Fix assq to improve performance.
* src/mes.c (assq): Special case eq_p to improve performance.
2017-12-12 20:25:48 +01:00
Jan Nieuwenhuizen eb0505300c mes: Fix display of closure.
* module/mes/display.mes (display): Drop extra ( at start of *closure*, *circ*.
* src/lib.c (display_helper): Likewise.
2017-12-11 07:06:21 +01:00
Jan Nieuwenhuizen 30efe5ffbc mes: Resurrect define, define-macro in C core.
* make.scm (bin.gcc, bin.mescc): Use MES_C_READER=1.
* src/mes.c (scm_symbol_define, scm_symbol_define_macro): New symbol.
  (scm_vm_eval_define): New special.
  (scm_symbol_c_define): New symbol.
  (MAKE_MACRO): New define.
  (eval_apply)[MES_C_DEFINE]: Handle define, define-macro.
  (mes_symbols): Define %c-define for use in read-0.mes.
* module/mes/read-0.mes: Do not implement full scheme define if %c-define.
* module/mes/quasiquote.mes (sexp:define, env:define, env:macro): New function.
  (define-macro): New macro.  FIXME
* module/mes/psyntax.mes (define): New macro.  FIXME
2017-12-09 08:24:38 +01:00
Jan Nieuwenhuizen aec2f68118 mes: Fix compile warning in reader.
* src/reader.c[MES_C_READER]: Declare read_block_comment, read_hash.
  Fixes compile warning.
2017-12-11 04:52:00 +01:00
Jan Nieuwenhuizen a2f6511f5e mescc: Allow invoking git mescc.mes from elsewhere.
* src/mes.c (load_env): Look in MES_PREFIX too.  Add debug printing.
* scripts/mescc.mes: Consider MES_PREFIX.
* guile/mescc.scm (%prefix): Consider MES_PREFIX.
* module/mes/base-0.mes (string->list): New function, move from type-0.mes.
  (%moduledir): Consider MES_PREFIX.
* module/mes/type-0.mes (string->list): Remove.
2017-12-09 22:38:51 +01:00
Jan Nieuwenhuizen ccddde9a84 mescc: Output performance hacks: use core:display.
* src/lib.c (display_): Write to g_stdout (WAS: STDOUT).
* module/mes/guile.scm (guile): Declare and export core:display core:display-error.
* module/mes/M1.mes (object->M1): Use core:display and string-append
  instead of format.
* module/mes/guile.mes (with-input-from-string): Add debugging.
  (open-input-string): Likewise.
  (read-string): Likewise.  Re-implement.
  (drain-input): Use read-string.
2017-12-09 20:10:57 +01:00
Jan Nieuwenhuizen 85b5422c35 mes: Nyacc support: Read old characters.
* src/reader.c (read_character)[MES_C_READER]: Support reading old
  characters: #\bel, #\bs, #\vt.
2017-12-09 22:36:53 +01:00
Jan Nieuwenhuizen 18b57b68aa mes: resurrect running MesCC: handle \t in strings.
* src/reader.c (read-string): Handle \t.  Fixex M1 output.
2017-12-09 19:33:10 +01:00
Jan Nieuwenhuizen 808af5001f mlibc: New library layout; remove duplication.
* lib/libc+tcc-gcc.c: New file: Libc bits for GCC from libc-mes+tcc.c.
* lib/libc+tcc-mes.c: New file: Libc bits for MesCC from libc-mes+tcc.c.
* lib/libc+tcc.c: New file: Libc bits from libc-mes+tcc.c.
* lib/libc.c: New file: Merged from libc-mes.c, libc-gcc.c.
  (abtoi): New function: Rename from _atoi.
* lib/linux+tcc-gcc.c: New file:  Linux bits from libc-gcc+tcc.c.
* lib/linux+tcc-mes.c: New file: Linux bits from libc-mes+tcc.c.
* lib/linux-gcc.c: New file: Linux bits from libc-gcc.c.
* lib/linux-mes.c: New file: Linux bits from libc-mes.c.
* lib/mini-libc-gcc.c: New file.
* lib/mini-libc.c: New file: Libc bits from mini-libc-mes.c.
* lib/mini-linux-gcc.c: New file.
* lib/mini-linux-mes.c: New file: Linux bits from mini-libc-mes.c.
* lib/libc-gcc.c: Remove duplication using include now.
* lib/libc-mes.c: Likewise.
* lib/mini-libc-mes.c: Likewise.
* include/stdio.h (puts)[POSIX]: Remomve macro.
  (fputc, fputs)[!POSIX]: New macro.
  (fputc, fputs): Remove declaration.
* scaffold/tests/7j-strtoull.c (strtoull, test): Use abtoi.
* src/lib.c (fputs)[__MESC__]: Remove define.
* guile/guix/make.scm: Update for new library layout.
* make.scm: Likewise.
* build.sh: Likewise.
* install.sh: Likewise.
2017-12-03 13:56:21 +01:00
Jan Nieuwenhuizen c3fdfedb20 mes: resurrect full reader in C core.
* module/mes/read-0.mes (defined?): New function.
  (eat-whitespace, read-env, read-word, read-block-comment,
  read-line-comment, read-list, read-character, read-hex, read-octal,
  reader:read-string, lookup, read-hash, read-word): Only define if
  not %c-reader.
* module/mes/base-0.mes (defined?): Remove.
* src/mes.c[MES_C_READER]: Set ARENA_SIZE=10000000.
  (scm_symbol_quasiquote scm_symbol_unquote,
  scm_symbol_unquote_splicing, scm_symbol_syntax,
  scm_symbol_quasisyntax, scm_symbol_unsyntax,
  scm_symbol_unsyntax_splicing): New symbol.
  (scm_symbol_c_reader): New symbol.
  (MAKE_KEYWORD)[MES_C_READER]: New define.
  (mes_symbols): Define %c_reader.
* src/reader.c (read_word_)[MES_C_READER]: Extend to full Scheme
  reader.
  (eat_whitespace)[MES_C_READER]: Likewise.
  (read_block_comment, read_hash, read_word, read_character,
  read_octal, read_hex, append_char, read_string)[MES_C_READER]:
  Likewise.
* make.scm (bin.gcc,bin.mescc): Define MES_C_READER=1.
2017-11-29 21:42:50 +01:00
Jan Nieuwenhuizen efdae700b5 bootstrap: Unbundle necessary M1 sources.
* mlibc/crt1.M1: Remove.
* mlibc/libc-mes.M1: Remove.
* src/mes.M1: Remove.
2017-11-20 06:47:46 +01:00
Jan Nieuwenhuizen 35b1be535a bootstrap: Update necessary M1 sources.
M1 -f stage0/x86.M1 -f mlibc/crt1.M1 --LittleEndian --Architecture=1 > mlibc/crt1.hex2
   M1 -f stage0/x86.M1 -f mlibc/mini-libc-mes.M1 --LittleEndian --Architecture=1  > mlibc/libc-mes.hex2
   M1 -f stage0/x86.M1 -f src/mes.M1 --LittleEndian --Architecture=1 > src/mes.hex2
   hex2 --LittleEndian --Architecture=1 --BaseAddress=0x1000000 -f stage0/elf32-header.hex2 -f mlibc/crt1.hex2 -f mlibc/libc-mes.hex2 -f src/mes.hex2 -f stage0/elf32-footer-single-main.hex2 > src/mes-mes
   exec_enable src/mes-mes

* mlibc/libc-mes.M1: Update.
* src/mes.M1: Udate.
2017-11-18 12:14:07 +01:00
Jan Nieuwenhuizen 6c55f4bd28 bootstrap: Include necessary M1 sources.
M1 -f stage0/x86.M1 -f mlibc/crt1.M1 --LittleEndian --Architecture=1 > mlibc/crt1.hex2
   M1 -f stage0/x86.M1 -f mlibc/mini-libc-mes.M1 --LittleEndian --Architecture=1  > mlibc/libc-mes.hex2
   M1 -f stage0/x86.M1 -f src/mes.M1 --LittleEndian --Architecture=1 > src/mes.hex2
   hex2 --LittleEndian --Architecture=1 --BaseAddress=0x1000000 -f stage0/elf32-header.hex2 -f mlibc/crt1.hex2 -f mlibc/libc-mes.hex2 -f src/mes.hex2 -f stage0/elf32-footer-single-main.hex2 > src/mes-mes
   exec_enable src/mes-mes

* mlibc/crt1.M1: New File.
* mlibc/libc-mes.M1: New File.
* src/mes.M1: New File.
2017-09-10 21:17:17 +02:00
Jan Nieuwenhuizen 4175579d08 core: Add logand, lognot.
* src/math.c (logand, lognot): New function.
2017-08-27 12:53:01 +02:00
Jan Nieuwenhuizen 4b1de28449 build: Install and installed-run fixes.
* guile/mescc.scm (%datadir,%docdir,%moduledir,%version): Remove.
* scripts/mescc.mes: Likewise.
* module/language/c99/compiler.mes: Likewise.
 (%prefix): Prefer environment setting.
 (c99-input->full-ast): Remove unnecessary includes.
 Remove unnecessary defines.
* make.scm (%scm-files): Add mes/guile.scm.
 (src/mes.gcc, src/mes.mlibc-gcc, src/mes.guile):  Update  MODULEDIR,
 add -I src.
* src/mes.c (load_env): Use temporary variable for MODULEDIR concatenation.
  (bload_env): Likewise.
2017-07-26 15:57:38 +02:00
Jan Nieuwenhuizen fa4fdad623 build: Remove make.
* GNUmakefile: trivial convenience-frontend to ./make.scm
* make/*.make: Remove.
* */*.make: Remove.
2017-07-02 12:03:29 +02:00
Jan Nieuwenhuizen 766cfeab9a core: %moduledir ends with /.
* make/install.make (MODULEDIR): Append /.
  (install): Remove /.
* src/mes.c (load_env, bload_env): Update.
2017-06-12 17:18:31 +02:00
Jan Nieuwenhuizen 2c0f5c346c build: Bugfix add prepocess dependency on snarfing mes.
* src/src.make ($(OUT)/$(DIR)/mes.guile-E, $(OUT)/$(DIR)/mes.mes-E):
  Depend on mes snarfing.
2017-06-08 06:57:24 +02:00
Jan Nieuwenhuizen 4d1df9cbcb mescc: move include into share/mlibc, allows installing alongside gcc.
* mlibc: Rename from libc.
* HACKING: Update for name change.
* make/bin.make: Likewise.
* make/mescc-guile.make: Likewise.
* make/mescc-mes.make: Likewise.
* scaffold/scaffold.make: Likewise.
* make/install.make: Likewise.
  (install): Install mlibc into share/mlibc.
2017-06-03 12:27:53 +02:00
Jan Nieuwenhuizen 3a240221f0 build: Skip gcc, mlibc, guile or mes builds using CC=, CC32=, GUILE= or MES=.
* GNUmakefile (build-scripts): New target
  (HELP_TOP): Mention it.
* configure (main): Write GUILE_FOR_BUILD.
* make/bin-mlibc.make: Skip if CC32 is not set.
* make/bin.make: Skip if CC is not set.
* make/install.make (install): Only install $(OUT)/mes.mes if
  MES_BOOTSTRAP is set.
* make/mescc-guile.make: Skip if GUILE is not set.
* make/mescc-mes.make: Skip if MES is not set.
* HACKING: write something about
2017-05-28 18:32:53 +02:00
Jan Nieuwenhuizen 9f56b8b102 core: Always include reader.c, drop binary read-0-32.mo dependency.
* module/language/c99/compiler.mes (c99-input->full-ast): Remove
  obsolete __NYACC__ and MES_FULL defines.
* src/mes.c [!MES_FULL]: Include reader-mes.h.
  (mes_builtins) [!MES_FULL]: Include reader.mes.i, reader.me.environment.i.
  [!MES_FULL]: Include reader.c.
  (main) [!MES_FULL]: By default call load_env, only call bload_env
  when --load is supplied.  WAS: Always bload read-0-32.mo.
* src/reader.c (__end_of__mes_): Remove.
  (dump): Remove option of dumping tiny test program.
* make/mescc-mes.make ($(OUT)/$(TARGET), mescc.mes-ccompile,
  mescc.mes.c-compile-E): Depend on $(OUT)/mes, scripts/mes.
* src/src.make (mes.guile): Remove module/mes/read-32-0 dependency.
  Do not build $(OUT)/mes.mes.
* module/module.make (module/mes/read-0.mo, module/mes/read-0-32.mo,
  module/mes/tiny-0-32.mo): Remove targets.
  (CLEAN): Do not add them.  Neither install $(OUT)/mes.mes.
* .gitignore: Remove exceptions for them.
* make/install.make (install): Do not install them.
* HACKING: Update info about creating module/mes/read-32-0.mo.
* scaffold/mini-mes.c: Remove.
* scaffold/tiny-mes.c: Remove.
* scaffold/cons-mes.c: Remove.
* scaffold/scaffold.make (tiny-mes.libc, tiny-mes.guile, tiny-mes.mes,
  mini-mes.libc, mini-mes.guile, mini-mes.mes): Reemove targets.
2017-05-28 16:03:45 +02:00
Jan Nieuwenhuizen 6af7556d51 mescc: C99 header files and declaraions.
* libc/include/assert.h (assert_fail):
* libc/include/stdio.h:
+int eputs (char const* s);
+int fputs (char const* s);
+int puts (char const* s);
+int putchar (int c);
+int fputc (int c, int fd);
+int getchar ();
* libc/include/stdlib.h:
+char* getenv (char const* s)
+int atoi (char const *s);
+int *malloc (size_t);
+int *realloc (int *p, int size);
* libc/include/unistd.h (access):
* src/lib.c (display_helper):
* src/mes.c (read_input_file_env):
* src/posix.c: Include unistd.h.
2017-05-23 07:16:08 +02:00
Jan Nieuwenhuizen 3c880bbb56 mescc: Refactor mlibc compilation.
* libc/libc-mes.c: New file.  Contents from module/mes/libc.mes, module/mes/libc-i386.mes.
* libc/libc-gcc.c: Rename from libc/mlibc.c, include libc/mstart.c
* libc/mstart.c: Remove.
* module/mes/libc-i386.mes: Remove.
* module/mes/libc-i386.scm: Remove.
* module/mes/libc.mes: Remove.
* module/mes/libc.scm: Remove.
* GNUmakefile (CFLAGS): Include libc-gcc.c (WAS: mlibc.c).
* make/bin-mlibc.make (C_FLAGS): Remove start.c include.
* make/mescc-guile.make: Rewrite using compile, link.
* make/mescc-mes.make: Likewise.
* scaffold/m.c: Update.
2017-05-21 22:25:02 +02:00
Jan Nieuwenhuizen 45ce77df85 core: Add current-output-port, open-output-file, set-current-output-port.
* libc/include/fcntl.h: Declare it.  Add some fcntl defines.
* libc/include/stdio.h: Remove fcntl defines, Declare g_stdout.
* module/language/c99/compiler.mes (c99-input->ast): Define O_WRONLY, O_RDWR.
* module/mes/guile.mes (with-output-to-file, with-output-to-port): New functions.
* src/posix.c (current_output_port, open_output_file,
  set_current_output_port): New functions.
* libc/mlibc.c (open): Add optional mode parameter.
* module/mes/libc-i386.mes (i386:open): Forward third parameter.
* scaffold/mini-mes.c (main): Init g_stdout.
* src/mes.c (main): Likewise.
2017-05-19 06:56:47 +02:00
Jan Nieuwenhuizen fe727301c5 mescc: Support regular C99 compile, headers + mlibc.
* libc/include/assert.h: New file.
* libc/include/ctype.h: New file.
* libc/include/errno.h: New file.
* libc/include/fcntl.h: New file.
* libc/include/limits.h: New file.
* libc/include/mlibc.h: New file.
* libc/include/stdio.h: New file.
* libc/include/stdlib: New file.
* libc/include/string.h: New file.
* libc/include/unistd.h: New file.
* libc/mlibc.c: Remove declarations.
* make/bin.make (INCLUDES): Factor out standard includes.
* make/bin-mlibc.make: New file.
* scaffold/scaffold.make: Use it.
* src/src.make: Use it.
* module/language/c99/compiler.mes (ast-info): Handle more function declarations.
* scaffold/cons-mes.c: Remove mlibc definitionsa and mlibc.c include.
  Instead include <mlibc.h>.
* scaffold/hello.c: Likewise.
* scaffold/m.c: Likewise.
* scaffold/malloc.c: Likewise.
* scaffold/micro-mes.c: Likewise.
* scaffold/mini-mes.c: Likewise.
* scaffold/t.c: Likewise.
* scaffold/tiny-mes.c: Likewise.
* src/gc.c: Likewise.
* src/lib.c: Likewise.
* src/math.c: Likewise.
* src/mes.c: Likewise.
* src/posix.c: Likewise.
* src/reader.c: Likewise.
2017-05-02 23:30:46 +02:00
Jan Nieuwenhuizen e16a74d74f build: Resolve MODULEDIR confusion. Fixes mes installation.
* make/install.make (GUILEDIR): New variable.  Was MODULEDIR.
  (MODULEDIR): Mes' module dir.
* guile/mescc.scm: Update.
* src/mes.c (load_env, bload_env): Update.
2017-05-05 22:45:59 +02:00
Jan Nieuwenhuizen d9e5e2d21f doc: Release update.
* AUTHORS: Mention Nyacc and GuixSD.
* NEWS: Update.
* README: Update.
* doc/ANNOUNCE-0.5 New file.
* HACKING: Add pointers, update TODO/DONE.
2017-04-27 12:08:16 +02:00
Jan Nieuwenhuizen 2418540c67 core: Set argv for mescc too.
* src/mes.c (main)[!__MESC__]: Remove branch.
2017-04-24 07:22:04 +02:00
Jan Nieuwenhuizen e0a0a3798a core: Move some debugging to MES_DEBUG=2.
* module/mes/base-0.mes (load): Add ;;;.
* src/gc.c (gc_flip): Test on g_debug > 1.
  (gc): Likewise.
* src/mes.c (mes_builtins): Likewise.
  (main): Likewise.
* src/reader.c (dump): Likewise.
2017-04-17 23:32:02 +02:00
Jan Nieuwenhuizen 996c449a81 mescc: Add getenv.
* module/mes/libc-i386.mes (i386:_start): Push environment pointer.
* module/mes/libc.mes (g_environment): New global.
  (_env): New function.
  (_start): Use it to set g_environment.
  (getenv): New function.
* lib/mlibc.c (strncmp): New function.
  (getenv): Implement.
* lib/mstart.c (_start): Set g_environment.
* module/mes/libc.mes (strncmp): New function.
  (libc): Add it.
* scaffold/t.c: (array_ref): Test it.
2017-04-17 02:24:20 +02:00
Jan Nieuwenhuizen 9918ffab92 Add access?
* libc/mlibc.c (access): New function.
* module/mes/libc-i386.mes (i386:access): New function.
  (i386:libc): Add it.
* src/posix.c (access_p): New function.
* module/mes/posix.mes: New file.
* module/mes/base-0.mes (mes): Include it.
* module/mes/read-0-32.mo: Regenerate.
2017-04-16 09:51:45 +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