Commit Graph

1839 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 9f956d9206
core: Remove core:make-cell.
* src/gc.c (alloc, make_cell, cons): Move from mes.c
* src/mes.c: (make_cell_): Remove.
* src/lib.c (char_to_integer, integer_to_char): New function.
* src/builtins.c (mes_builtins): Add them; remove make_cell_.
* mes/module/mes/type-0.mes (char->integer, integer->char): Remove.
2019-11-17 12:25:33 +01:00
Jan Nieuwenhuizen 7c0cb60709
core: Refactor display. 2019-11-17 12:25:33 +01:00
Jan Nieuwenhuizen f4cbbf620c
core: Upcase register names.
* include/mes/mes.h (R0, R1, R2, R3, M0): Rename from lower case.
Update users.
2019-11-17 12:25:33 +01:00
Jan Nieuwenhuizen d9fccb532a
core: Split-out symbol.c.
* src/mes.c (init_symbol, mes_symbols): Move to ..
* src/symbol.c: New file.
* build-aux/configure-lib.sh (mes_SOURCES): Add it.
* simple.make: Likewise.
* include/mes/mes.h: Declare init_symbols.
2019-11-17 12:25:33 +01:00
Jan Nieuwenhuizen 5f5066aaea
core: Split-out display.c.
* src/lib.c (display_helper, display_, display_error_, display_port_,
write_, write_error_, write_port_, fdisplay_): Move to ..
* src/display.c: New file.
* build-aux/configure-lib.sh (mes_SOURCES): Add it.
* simple.make: Likewise.
2019-11-17 12:25:33 +01:00
Jan Nieuwenhuizen fe4a19c10f
core: eval-apply: Fix formal_p.
* src/eval-apply.c (formal_p): Return boolean.
2019-11-17 12:25:33 +01:00
Jan Nieuwenhuizen 693921e059
core: Split-out eval-apply.c.
* src/mes.c (check_formals, check_apply, pairlis, set_car_x, set_cdr_x,
set_env_x, call_lambda, make_closure_, make_variable_, macro_get_handle,
get_macro, macro_set_x, push_cc, add_formals, formal_p,
expand_variable_, expand_variable, apply_builtin, eval_apply, apply):
Move to ..
* src/eval-apply.c: New file.
* build-aux/configure-lib.sh (mes_SOURCES): Add it.
* simple.make: Likewise.
* src/eval.c (assert_defined): Likewise.
2019-11-17 12:25:32 +01:00
Jan Nieuwenhuizen 50156e6c07
build: Update mes-snarf.
* build-aux/snarf.sh: Support C-style annotations.
2019-11-17 12:25:32 +01:00
Jan Nieuwenhuizen 43197fff3c
mescc: Mes C Library: Prepare for M2-Planet: setenv.
* lib/posix/setenv.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-17 12:25:32 +01:00
Jan Nieuwenhuizen d454fe905d
mescc: Mes C Library: Prepare for M2-Planet: getenv.
* lib/posix/getenv.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-17 12:25:32 +01:00
Jan Nieuwenhuizen 75895950fb
mescc: Mes C Library: Prepare for M2-Planet: ntoab.
* lib/mes/ntoab.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-17 12:25:32 +01:00
Jan Nieuwenhuizen ed29b83575
mescc: Mes C Library: Prepare for M2-Planet: malloc.
* lib/stdlib/malloc.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-17 12:25:32 +01:00
Jan Nieuwenhuizen cdc4256758
mescc: Mes C Library: Prepare for M2-Planet: fdungetc.
* lib/mes/fdungetc.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-17 12:25:32 +01:00
Jan Nieuwenhuizen 790d2ebb91
mescc: Mes C Library: Bugfix __ungetc_clear.
* lib/linux/_open3.c (_open3): Remove __ungetc_init ();
* lib/mes/mes_open.c (mes_open): Likewise.
* lib/mes/fdungetc.c (fdungetc): Likewise.
* lib/mes/fdgetc.c (__ungetc_p, __ungetc_clear, __ungetc_set): Call
__ungetc_init if buffer is uninitialized.
2019-11-17 12:25:31 +01:00
Jan Nieuwenhuizen 3209febc2e
mescc: Mes C Library: Prepare for M2-Planet: fdgetc.
* lib/mes/fdgetc.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-17 12:25:31 +01:00
Jan Nieuwenhuizen 3f5f12201e
mescc: Mes C Library: Prepare for M2-Planet: abtol.
* lib/mes/abtol.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-17 12:25:31 +01:00
Jan Nieuwenhuizen b08281d75e
mescc: Mes C Library: memcmp: bugfix.
* lib/string/memcmp.c (memcmp): Bugfix.
* lib/tests/string/50-memcmp.c: Test it.
* build-aux/check-mescc.sh (TESTS): Add it.
2019-11-17 12:25:31 +01:00
Jan Nieuwenhuizen ce11c855ff
mescc: Mes C Library: Prepare for M2-Planet: memcmp.
* lib/string/memcmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-17 12:25:31 +01:00
Jan Nieuwenhuizen 8ba3abe0c4
mescc: Mes C Library: Prepare for M2-Planet: memcpy.
* lib/string/memcpy.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-17 12:25:31 +01:00
Jan Nieuwenhuizen c536ffb3bf
mescc: Mes C Library: Prepare for M2-Planet: memchr.
* lib/string/memchr.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-17 12:25:31 +01:00
Jan Nieuwenhuizen a5ba54c31f
mescc: Mes C Library: Prepare for M2-Planet: strncmp.
* lib/string/strncmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-17 12:25:30 +01:00
Jan Nieuwenhuizen 6f3c78314d
mescc: Mes C Library: Prepare for M2-Planet: strlen.
* lib/string/strlen.c: : Rewrite C-constructs not supported by M2-Planet.
2019-11-17 12:25:30 +01:00
Jan Nieuwenhuizen da85d20500
mescc: Mes C Library: Prepare for M2-Planet: strcpy.
* lib/string/strcpy.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-17 12:25:30 +01:00
Jan Nieuwenhuizen c3a7033886
mescc: Mes C Library: Prepare for M2-Planet: strcmp.
* lib/string/strcmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-17 12:25:30 +01:00
Jan Nieuwenhuizen 2b8bb1abd2
mescc: Mes C Library: Prepare for M2-Planet: __assert_fail.
Rewrite C-constructs not supported by M2-Planet, such as

    foo ? bar : baz;       -> if (foo) bar; else baz;
    static char foo[1024]  -> __func_buf = malloc (1024); ... char *foo = __func_buf;
    *foo                   -> foo[0]
    foo++                  -> foo = foo + 1   TODO: pointer arithmetic
    foo += 1;              -> foo = foo + 1
    for (int foo = ;       -> int foo; for (foo=
    if (foo)               -> if (foo != 0)
    if (!foo)              -> if (foo == 0)
    ;                      -> 0;

* lib/mes/__assert_fail.c: Rewrite C-constructs not supported by
M2-Planet.
2019-11-17 12:25:30 +01:00
Jan Nieuwenhuizen 2d82d58e82
core: Use assert_msg.
* src/mes.c: Use assert_msg instead of assert.
* src/gc.c: Likewise.
* src/hash.c: Likewise.
* src/lib.c: Likewise.
* src/math.c: Likewise.
* src/module.c: Likewise.
* src/posix.c: Likewise.
* src/reader.c: Likewise.
* src/string.c: Likewise.
* src/struct.c: Likewise.
* src/vector.c: Likewise.
* simple.make (LIB_SOURCES): Add lib/mes/assert_msg.c.
2019-11-17 12:25:30 +01:00
Jan Nieuwenhuizen 6f5d815e7d
mescc: Mes C Library: Add assert_msg.
* lib/mes/assert_msg.c: New file.
2019-11-17 12:25:30 +01:00
Jan Nieuwenhuizen e315162c57
core: Prepare for M2-Planet: vector.c.
* src/vector.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:29 +01:00
Jan Nieuwenhuizen 330e9ba037
core: Prepare for M2-Planet: struct.c.
* src/struct.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:29 +01:00
Jan Nieuwenhuizen a70e82e1d6
core: Prepare for M2-Planet: string.c.
* src/string.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:29 +01:00
Jan Nieuwenhuizen de1725aebd
core: Prepare for M2-Planet: reader.c.
* src/reader.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:29 +01:00
Jan Nieuwenhuizen 42c3c28509
core: Prepare for M2-Planet: posix.c.
* src/posix.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:29 +01:00
Jan Nieuwenhuizen c8fe8f3de5
core: Prepare for M2-Planet: module.c.
* src/module.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:29 +01:00
Jan Nieuwenhuizen eb2136b4b2
core: Prepare for M2-Planet: math.c.
* src/math.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:28 +01:00
Jan Nieuwenhuizen 930519b142
core: Prepare for M2-Planet: lib.c.
* src/lib.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:28 +01:00
Jan Nieuwenhuizen 7225bef283
core: Prepare for M2-Planet: hash.c.
* src/hash.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:28 +01:00
Jan Nieuwenhuizen e51b2339c5
core: Prepare for M2-Planet: gc.c.
* src/gc.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:28 +01:00
Jan Nieuwenhuizen 1aa12c225b
core: Prepare for M2-Planet: builtins.c.
* src/builtins.c: Rewrite C constructs not supported by M2-Planet.
2019-11-17 12:25:28 +01:00
Jan Nieuwenhuizen aea32924b7
core: Prepare for M2-Planet: mes.c.
Rewrite C-constructs not supported by M2-Planet, such as

    foo ? bar : baz;       -> if (foo) bar; else baz;
    static char foo[1024]  -> __func_buf = malloc (1024); ... char *foo = __func_buf;
    *foo                   -> foo[0]
    foo++                  -> foo = foo + 1   TODO: pointer arithmetic
    foo += 1;              -> foo = foo + 1
    for (int foo = ;       -> int foo; for (foo=
    if (foo)               -> if (foo != 0)
    if (!foo)              -> if (foo == 0)
    ;                      -> 0;
    // ...                 -> /* ... */

* src/mes.c: Rewrite C constructs not supported by M2-Planet.
* include/mes/mes.h (__execl_c_argv, __getcwd_buf, __open_boot_buf,
__open_boot_file_name, __setenv_buf, __reader_read_char_buf): Declare
buffers.
(init): Initialize them.
* include/mes/macros.h(__M2_PLANET__): Temporary M2 macros.
2019-11-17 12:25:28 +01:00
Jan Nieuwenhuizen 2471c1f362
build: Run indent for M2.
* src/gc.c: Indented.
* src/string.c: Likewise.
2019-11-17 12:25:28 +01:00
Jan Nieuwenhuizen cf10d97045
build: mes-snarf.scm: Resurrect.
* build-aux/mes-snarf.scm (snarf-functions): Strip whitespace from
parameter list.
(function->source): Use function-scm-name, add (function1_t).
* build-aux/snarf.sh: Resurrect, combined dump to s, h, c.
* include/mes/builtins.h:
2019-11-17 12:25:27 +01:00
Jan Nieuwenhuizen c5f9c3d4b6
core: Split-out builtins.c.
* src/mes.c make_builtin_type, make_builtin, builtin_name,
builtin_arity, builtin_function, builtin_p, builtin_printer,
init_builtin, mes_builtins): Move to ..
* src/builtins.c: New file.
* build-aux/configure-lib.sh (mes_SOURCES): Add it.
* build-aux/snarf.sh: Likewise.
* build-aux/build-mes.sh (mes_sources): Remove.  Include
configure-lib.sh
* include/mes/builtins.h: Remove constants.
* include/mes/mes.h: Add prototypes.
* include/mes/constants.h (cell_symbol_test): Rename from cell_test.
* simple.make: New file.
2019-11-17 12:25:27 +01:00
Jan Nieuwenhuizen 3c71aee7dc
build: simple.make.
* simple.make: New file.
2019-11-17 12:25:27 +01:00
Jan Nieuwenhuizen 504616b68a
tests: Add gc.test.
* tests/gc.test: New file.
* build-aux/check-mes.sh (TESTS): Add it.
* scaffold/gc-test.scm: Remove.
2019-11-17 12:25:27 +01:00
Jan Nieuwenhuizen 06a2527cc9
m2: Add scripts/m2-merge.scm.
* scripts/m2-merge.scm.in: New file.
* configure: Substitute it.
* .gitignore: Update.
2019-11-17 12:25:27 +01:00
Danny Milosavljevic 6a31571d5a
Fix dtoab.
* lib/mes/dtoab.c (dtoab): Fix it.
* lib/tests/mes/90-dtoab.c (main): Fix test.
* build-aux/check-mescc.sh (XFAIL_TESTS: Remove it.
2019-11-17 12:25:27 +01:00
Jan Nieuwenhuizen e0926c6e12
build: Better and friendlier tarball.
* build-aux/GNUmakefile.in (dist): Be friendly to Debian; avoid using
EPOCH.  Cater for file permission differences.
2019-11-17 12:24:48 +01:00
Jan Nieuwenhuizen 4884ba4ad0
doc update 2019-11-17 12:24:47 +01:00
Jan Nieuwenhuizen b03be4a465
build: bootstrap fixes.
* build-aux/config.sh.in (bootstrap): Set up for substitution.
* configure.sh (bootstrap): Substitute.
* build-aux/install.sh.in (_v): Robustify check for V.
(__exclude_go, __exclude_scm): Initialize.
2019-11-17 12:24:47 +01:00
Jan Nieuwenhuizen 265d1c6a64
mescc: Environment setup.
* scripts/mescc.in (MES_ARENA, MES_MAX_ARENA, MES_STACK): Reduce defaults.
* build-aux/check.sh.in (MES_ARENA): Likewise.  Export them.
* build-aux/bootstrap.sh.in (MES_STACK): Likewise.
(MES_PREFIX): Set default.
2019-11-17 12:24:47 +01:00