Commit Graph

1841 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 0705320f53
core: assoc_string: Prepare for M2-Planet.
src/mes.c (assoc_string): Prepare for M2-Planet.
2019-11-02 19:13:11 +01:00
Jan Nieuwenhuizen d46e9dc7a2
build: Add pointer.sh.
* build-aux/pointer.sh: New script.
2019-11-02 19:13:11 +01:00
Jan Nieuwenhuizen 5d18e30b5a
core: Prepare for pointer cells.
* include/mes/cc.h: Prepare for pointer-based cells.
* include/mes/macros.h[POINTER_CELLS]: Alternative set of macros.
* include/mes/mes.h (struct scm)[POINTER_CELLS]: Alternative definition.
* src/gc.c (copy_cell, copy_news): New function.
* include/mes/mes.h: Declare them.
2019-11-02 19:13:11 +01:00
Jan Nieuwenhuizen ad68e7fc60
core: gc: FRAME_SIZE.
* src/gc.c (FRAME_SIZE): New constant.
(gc_loop, gc_): Use it.
2019-11-02 19:13:11 +01:00
Jan Nieuwenhuizen aed4d977ed
core: gc: Fixes.
* src/gc.c (gc_init, gc_up_arena, gc_flip): Change to void function.
Fixes 0 returns.
(make_bytes): Use plain.
(make_string): Add 1 to length, for zero-terminated C strings.
(gc_copy): Use plain bytes length.
(gc_loop): Manually reformat.
2019-11-02 19:13:11 +01:00
Jan Nieuwenhuizen 5b59534f13
core: Create symbols dynamically.
* include/mes/symbols.h: New file.
* include/mes/mes.hh: Include it.
* include/mes/constants.h: Remove symbol constants.
* src/symbols.c (init_symbols): Create symbols dynamically.
2019-11-02 19:13:11 +01:00
Jan Nieuwenhuizen 28d7152cad
core: Remove CBYTES, CSTRING, NCBYTES macros.
* src/gc.c (cell_bytes, news_bytes): New function.
* include/mes/macros.h (CBYTES, CSTRING, NCBYTES): Remove.  Update
users.
* include/mes/m2.h: Likewise.
2019-11-02 19:13:10 +01:00
Jan Nieuwenhuizen 1baa53f089
core: Prepare for conversion to pointer cells.
* src/posix.c (execl_): Prepare for conversion to pointer cells.
2019-11-02 19:13:10 +01:00
Jan Nieuwenhuizen 6dab5cb856
core: Remove dead macros.
* include/mes/macros.h (CSTRING_STRUCT, START, LEN): Remove.
2019-11-02 19:13:10 +01:00
Jan Nieuwenhuizen 95902000fc
core: Remove macros from cell creation: make_char .. make_string.
* src/gc.c (make_char, make_continuation, make_macro, make_number,
make_ref, make_string0, make_string_port): New function.
(make_string): Move from string.c.
* include/mes/macros.h (MAKE_CHAR, MAKE_CONTINUATION, MAKE_MACRO,
MAKE_NUMBER, MAKE_REF, MAKE_STRING0, MAKE_STRING_PORT): Remove macro.
Update users.
* include/mes/m2.h: Likewise.
2019-11-02 19:13:10 +01:00
Jan Nieuwenhuizen 5cbccdbf81
core: Remove macros from cell creation: make_bytes.
* src/gc.c (bytes_cells, make_bytes): Move from string.c.
* include/mes/macros.h (MAKE_BYTES0, NAME_SYMBOL): Remove.
* include/mes/m2.h: Likewise.
2019-11-02 19:13:10 +01:00
Jan Nieuwenhuizen 48c9568386
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-02 19:13:10 +01:00
Jan Nieuwenhuizen 5d76886f4c
core: Refactor display. 2019-11-02 19:13:09 +01:00
Jan Nieuwenhuizen 3b96cc6a5a
core: Upcase register names.
* include/mes/mes.h (R0, R1, R2, R3, M0): Rename from lower case.
Update users.
2019-11-02 19:13:09 +01:00
Jan Nieuwenhuizen de00f08614
core: Split-out symbol.c.
* src/mes.c (init_symbol, mes_symbols): Move to ..
* src/symbol.c: New file.
* simple.make: Add it.
* src/eval.c (assert_defined): Likewise.
* include/mes/mes.h: Declare init_symbols.
2019-11-02 19:13:09 +01:00
Jan Nieuwenhuizen 585f5cf741
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.
* simple.make: Add it.
* src/eval.c (assert_defined): Likewise.
2019-11-02 19:13:09 +01:00
Jan Nieuwenhuizen 1a1a4e4a3a
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.
* simple.make: Add it.
* src/eval.c (assert_defined): Likewise.
2019-11-02 19:13:09 +01:00
Jan Nieuwenhuizen b34613c960
build: Update mes-snarf.
* build-aux/snarf.sh: Support C-style annotations.
2019-11-02 19:13:09 +01:00
Jan Nieuwenhuizen eab429a2b9
mescc: Mes C Library: Prepare for M2-Planet: setenv.
* lib/posix/setenv.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-02 19:13:09 +01:00
Jan Nieuwenhuizen 3eb67a9cf3
mescc: Mes C Library: Prepare for M2-Planet: getenv.
* lib/posix/getenv.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-02 19:13:08 +01:00
Jan Nieuwenhuizen 5d64189bc2
mescc: Mes C Library: Prepare for M2-Planet: ntoab.
* lib/mes/ntoab.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-02 19:13:08 +01:00
Jan Nieuwenhuizen f6396cc15e
mescc: Mes C Library: Prepare for M2-Planet: malloc.
* lib/stdlib/malloc.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-02 19:13:08 +01:00
Jan Nieuwenhuizen ae19ddbb47
mescc: Mes C Library: Prepare for M2-Planet: fdungetc.
* lib/mes/fdungetc.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-02 19:13:08 +01:00
Jan Nieuwenhuizen 4ed9ef7085
mescc: Mes C Library: Prepare for M2-Planet: fdgetc.
* lib/mes/fdgetc.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-02 19:13:08 +01:00
Jan Nieuwenhuizen 53b00e8f4f
mescc: Mes C Library: Prepare for M2-Planet: abtol.
* lib/mes/abtol.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-02 19:13:07 +01:00
Jan Nieuwenhuizen b45bd942ef
mescc: Mes C Library: Prepare for M2-Planet: memcmp.
* lib/string/memcmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-02 19:13:07 +01:00
Jan Nieuwenhuizen c3292b8bce
mescc: Mes C Library: Prepare for M2-Planet: memcpy.
* lib/string/memcpy.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-02 19:13:07 +01:00
Jan Nieuwenhuizen 62a3c67030
mescc: Mes C Library: Prepare for M2-Planet: memchr.
* lib/string/memchr.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-02 13:54:03 +01:00
Jan Nieuwenhuizen 923fa91960
mescc: Mes C Library: Prepare for M2-Planet: strncmp.
* lib/string/strncmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-02 13:54:03 +01:00
Jan Nieuwenhuizen 7133038b50
mescc: Mes C Library: Prepare for M2-Planet: strlen.
* lib/string/strlen.c: : Rewrite C-constructs not supported by M2-Planet.
2019-11-02 13:54:03 +01:00
Jan Nieuwenhuizen dadc4a0927
mescc: Mes C Library: Prepare for M2-Planet: strcpy.
* lib/string/strcpy.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-02 13:54:03 +01:00
Jan Nieuwenhuizen aaee701eb1
mescc: Mes C Library: Prepare for M2-Planet: strcmp.
* lib/string/strcmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-11-02 13:54:03 +01:00
Jan Nieuwenhuizen adde421a0e
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-02 13:54:03 +01:00
Jan Nieuwenhuizen ec66f33631
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-02 13:54:02 +01:00
Jan Nieuwenhuizen 6c94a05c95
mescc: Mes C Library: Add assert_msg.
* lib/mes/assert_msg.c: New file.
2019-11-02 13:54:02 +01:00
Jan Nieuwenhuizen 1765da6764
core: Prepare for M2-Planet: vector.c.
* src/vector.c: Rewrite C constructs not supported by M2-Planet.
2019-11-02 13:54:02 +01:00
Jan Nieuwenhuizen 1984322f01
core: Prepare for M2-Planet: struct.c.
* src/struct.c: Rewrite C constructs not supported by M2-Planet.
2019-11-02 13:54:02 +01:00
Jan Nieuwenhuizen a2c15661e9
core: Prepare for M2-Planet: string.c.
* src/string.c: Rewrite C constructs not supported by M2-Planet.
2019-11-02 13:54:02 +01:00
Jan Nieuwenhuizen 3daaab5f50
core: Prepare for M2-Planet: reader.c.
* src/reader.c: Rewrite C constructs not supported by M2-Planet.
2019-11-02 13:54:02 +01:00
Jan Nieuwenhuizen 9a453ec38a
core: Prepare for M2-Planet: posix.c.
* src/posix.c: Rewrite C constructs not supported by M2-Planet.
2019-11-02 13:54:01 +01:00
Jan Nieuwenhuizen e2d357408c
core: Prepare for M2-Planet: module.c.
* src/module.c: Rewrite C constructs not supported by M2-Planet.
2019-11-02 13:54:01 +01:00
Jan Nieuwenhuizen 5d4976ccfb
core: Prepare for M2-Planet: math.c.
* src/math.c: Rewrite C constructs not supported by M2-Planet.
2019-11-02 13:54:01 +01:00
Jan Nieuwenhuizen ba83a177d2
core: Prepare for M2-Planet: lib.c.
* src/lib.c: Rewrite C constructs not supported by M2-Planet.
2019-11-02 13:54:01 +01:00
Jan Nieuwenhuizen a0e73c52f2
core: Prepare for M2-Planet: hash.c.
* src/hash.c: Rewrite C constructs not supported by M2-Planet.
2019-11-02 13:54:01 +01:00
Jan Nieuwenhuizen 06bb5ff419
core: Prepare for M2-Planet: gc.c.
* src/gc.c: Rewrite C constructs not supported by M2-Planet.
2019-11-02 13:54:01 +01:00
Jan Nieuwenhuizen fd02098d52
core: Prepare for M2-Planet: builtins.c.
* src/builtins.c: Rewrite C constructs not supported by M2-Planet.
2019-11-02 13:54:00 +01:00
Jan Nieuwenhuizen b40a98582a
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-02 13:54:00 +01:00
Jan Nieuwenhuizen 64184055a1
mescc: stack: unbump WIP 2019-11-02 13:53:24 +01:00
Jan Nieuwenhuizen 9001e2aee6
build: Run indent for M2.
* src/gc.c: Indented.
* src/string.c: Likewise.
2019-11-02 13:53:24 +01:00
Jan Nieuwenhuizen 7d3ae63a57
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-02 13:53:24 +01:00