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
82df50eae9
mescc: unlink: Move to libc.
...
* lib/linux/libc.c (unlink): New function.
* lib/linux/tcc.c (unlink): Remove.
2018-11-11 11:00:42 +01:00
Jan Nieuwenhuizen
e660665dfd
mescc: dup, dup2: Move to libc.
...
* lib/linux/libc.c (dup, dup2): New function.
* lib/linux/gnu.c (dup, dup2): Remove.
2018-11-11 10:13:01 +01:00
Jan Nieuwenhuizen
6e2f941573
mescc: getcwd: Move to libc.
...
* lib/linux/libc.c (getcwd): New function.
* lib/linux/tcc.c (getcwd): Remove.
2018-11-11 10:12:19 +01:00
Jan Nieuwenhuizen
68441476e0
mescc: Support GNU make with POSIX.
...
* include/linux/x86/syscall.h (SYS_sigprocmask): New macro.
* include/linux/x86_64/syscall.h (SYS_rt_sigprocmask): New macro.
* include/signal.h (SIG_BLOCK, SIG_UNBLOCK, SIG_SETMASK): New macro.
(sigprocmask): Declare.
* lib/linux/gnu.c (sigprocmask): New function.
2018-11-10 08:32:42 +01:00
Jan Nieuwenhuizen
9ecc11ee52
mescc: Support GNU Bash.
...
* include/errno.h (EACCES, ENOSPC, ESPIPE): New macro.
* include/linux/x86/syscall.h (SYS_setuid, SYS_geteuid, SYS_getegid,
SYS_setgid): New macro.
* include/linux/x86_64/syscall.h: Likewise.
* include/stdint.h (LLONG_MIN, LLONG_MAX, SIZE_MAX): New macro.
* include/sys/stat.h (S_ISUID, S_ISGID, S_IXGRP, S_IXOTH, S_IRGRP,
S_IROTH, S_IWGRP, S_IWOTH, S_IRWXG, S_IRWXO): New macro.
* include/termio.h: New file.
* include/unistd.h (_POSIX_VERSION): New macro.
* lib/linux/gnu.c (geteuid, getegid, setuid, setgid): New function.
* lib/string/memchr.c: New file.
* lib/stub/getpwuid.c: New file.
* lib/stub/rand.c: New file.
* lib/stub/ttyname.c: New file.
* include/string.h (memchr): Declare.
* include/unistd.h (geteuid, getegid, setuid, setgid): Declare.
2018-11-09 21:26:10 +01:00
Jan Nieuwenhuizen
6b5ac57602
build: Simplify: cater for one compiler at a time.
...
* build-aux/build-cc.sh: Remove.
* build-aux/build-cc32.sh: Remove.
* build-aux/build-cc64.sh: Remove.
* build-aux/build-x86_64-mes.sh: Remove.
* build-aux/cc-mes.sh: Remove.
* build-aux/cc-x86_64-mes.sh: Remove.
* build-aux/cc32-mes.sh: Remove.
* build-aux/cc64-mes.sh: Remove.
* build-aux/test64.sh: Remove.
* build-aux/bootstrap-mes.sh: New file.
* build-aux/config.make.in: New file.
* build-aux/config.status.in: New file.
* build-aux/test-cc.sh: New file.
* .gitignore: Update.
* build-aux/GNUmakefile.in: Update.
* build-aux/build-guile.sh: Update.
* build-aux/build-mes.sh: Update.
* build-aux/build.sh.in: Update.
* build-aux/cc.sh: Update.
* build-aux/check-boot.sh: Update.
* build-aux/check-mes.sh: Update.
* build-aux/check-mescc.sh: Update.
* build-aux/check-tcc.sh: Update.
* build-aux/check.sh.in: Update.
* build-aux/config.sh: Update.
* build-aux/export.make: Update.
* build-aux/install.sh.in: Update.
* build-aux/pre-inst-env.in: Update.
* build-aux/test.sh: Update.
* build-aux/uninstall.sh.in: Update.
* configure: Update.
* configure.sh: Update.
* module/mescc/i386/as.scm: Update.
* module/mescc/preprocess.scm: Update.
* module/mescc/x86_64/as.scm: Update.
* scripts/mescc.in: Update.
* tests/psyntax.test: Update.
2018-11-06 20:29:35 +01:00
Jan Nieuwenhuizen
172879360e
mescc: Add missing define.
...
* lib/x86-mes/x86.M1: Add missing define.
2018-11-09 16:56:54 +01:00
Jan Nieuwenhuizen
cd70c63a40
mescc: Exit if library cannot be found.
...
* module/mescc/mescc.scm (arch-find): Exit upon failure.
2018-11-08 14:46:46 +01:00
Jan Nieuwenhuizen
aa8fd3da9e
mescc: Accept -O, --std, -x.
...
* scripts/mescc.in (parse-opts): Accept -O, --std, -x.
2018-11-08 14:07:27 +01:00
Jan Nieuwenhuizen
21887b9a8e
mescc: Support -dumpmachine.
...
* scripts/mescc.in (parse-opts): Support -dumpmachine.
2018-11-08 22:41:20 +01:00
Jan Nieuwenhuizen
3d528b0257
mescc: vsnprintf: Compliant implementation.
...
* lib/stdio/vsnprintf.c (vsnprintf): New, complient implementation,
replacing vsnprint.
* lib/stdio/vsprintf.c (vsnprint): Forward to vsnprint.
* lib/stdio/snprintf.c (snprintf): Likewise.
* scaffold/tests/9a-snprintf.c: Test it.
* build-aux/check-mescc.sh (tests): Run it.
2018-10-22 18:33:40 +02:00
Jan Nieuwenhuizen
5d8e44de2c
test: Add performance test.
...
* module/mes/test.scm (pass-if-timeout): New macro.
* tests/perform.test: New test.
* build-aux/check-mes.sh (tests): Run it.
2018-10-21 12:04:25 +02: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
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
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
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
5826f75c7b
scaffold: Resurrect mini-mes.
...
* src/mini-mes.c: Resurrect.
2018-10-19 20:20:00 +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
a8ae42ff3c
mes: Resurrect Guile-1.8 support.
...
* module/mes/mes-0.scm: Resurrect Guile-1.8 support.
2018-10-17 09:47:20 +02: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
999642052b
mescc: Mes C Library: oputs: New function.
...
* lib/mes/oputc.c: New file.
* lib/libmes.c: Include it.
* include/libmes.h: Declare it.
2018-10-15 15:44:47 +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
8df367b3a2
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-10-15 13:48:50 +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