Commit Graph

115 Commits

Author SHA1 Message Date
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