Commit Graph

1845 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 185f0da91f
core: apply_builtin: Prepare for M2-Planet.
* src/eval-apply.c (apply_builtin): Prepare for M2-Planet.
2019-10-26 20:33:47 +02:00
Jan Nieuwenhuizen 85098da0ba
core: formal_p: Prepare for M2-Planet.
* src/eval-apply.c (formal_p): Prepare for M2-Planet.
2019-10-26 20:33:47 +02:00
Jan Nieuwenhuizen 332209303b
core: builtin_p: Prepare for M2-Planet.
* src/builtins.c (builtin_p): Prepare for M2-Planet.
2019-10-26 20:33:47 +02:00
Jan Nieuwenhuizen ec8202d101
core: assoc: Prepare for M2-Planet.
* src/mes.c (assoc): Prepare for M2-Planet.
2019-10-26 20:33:47 +02:00
Jan Nieuwenhuizen 814cfab336
core: assq: Prepare for M2-Planet.
* src/mes.c (assq): Prepare for M2-Planet.
2019-10-26 20:33:47 +02:00
Jan Nieuwenhuizen 8dae9b30dd
core: eq_p: Prepare for M2-Planet.
* src/mes.c (eq_p): Prepare for M2-Planet.
2019-10-26 20:33:46 +02:00
Jan Nieuwenhuizen 7c80d9675e
core: assoc_string: Prepare for M2-Planet.
src/mes.c (assoc_string): Prepare for M2-Planet.
2019-10-26 20:33:46 +02:00
Jan Nieuwenhuizen 0fc1096c96
build: Add pointer.sh.
* build-aux/pointer.sh: New script.
2019-10-26 20:33:46 +02:00
Jan Nieuwenhuizen 607b6fae0b
core: Prepare for pointer-based 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-10-26 20:33:46 +02:00
Jan Nieuwenhuizen 647d436048
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-10-26 20:00:18 +02:00
Jan Nieuwenhuizen e5a488cea0
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-10-26 20:00:18 +02:00
Jan Nieuwenhuizen be63c349d6
core: Prepare for conversion to pointer cells.
* src/posix.c (execl_): Prepare for conversion to pointer cells.
2019-10-26 20:00:18 +02:00
Jan Nieuwenhuizen 3c9a097237
core: Remove dead macros.
* include/mes/macros.h (CSTRING_STRUCT, START, LEN): Remove.
2019-10-26 20:00:18 +02:00
Jan Nieuwenhuizen 29aa040be2
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-10-26 20:00:18 +02:00
Jan Nieuwenhuizen e0b1ab3114
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-10-26 20:00:18 +02:00
Jan Nieuwenhuizen ea748c5d11
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-10-26 20:00:17 +02:00
Jan Nieuwenhuizen 40efa21cb9
core: Refactor display. 2019-10-26 20:00:17 +02:00
Jan Nieuwenhuizen 3e4fae3039
core: Upcase register names.
* include/mes/mes.h (R0, R1, R2, R3, M0): Rename from lower case.
Update users.
2019-10-26 20:00:17 +02:00
Jan Nieuwenhuizen 02ef80a19a
core: Split-out symbols.c.
* src/mes.c (init_symbol, mes_symbols): Move to ..
* src/symbols.c: New file.
* simple.make: Add it.
* src/eval.c (assert_defined): Likewise.
* include/mes/mes.h: Declare init_symbols.
2019-10-26 20:00:17 +02:00
Jan Nieuwenhuizen 8ece7dca3c
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-10-26 20:00:17 +02:00
Jan Nieuwenhuizen b24327dab1
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-10-26 20:00:17 +02:00
Jan Nieuwenhuizen 5b0511dd73
build: Update mes-snarf.
* build-aux/snarf.sh: Support C-style annotations.
2019-10-26 20:00:17 +02:00
Jan Nieuwenhuizen 6a400a4d8d
mescc: Mes C Library: Prepare for M2-Planet: setenv.
* lib/posix/setenv.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:02 +02:00
Jan Nieuwenhuizen 65e545d589
mescc: Mes C Library: Prepare for M2-Planet: getenv.
* lib/posix/getenv.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:02 +02:00
Jan Nieuwenhuizen b03046b370
mescc: Mes C Library: Prepare for M2-Planet: ntoab.
* lib/mes/ntoab.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen e88f10b067
mescc: Mes C Library: Prepare for M2-Planet: malloc.
* lib/stdlib/malloc.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen b6cd0bd34f
mescc: Mes C Library: Prepare for M2-Planet: fdungetc.
* lib/mes/fdungetc.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen cb1a018f29
mescc: Mes C Library: Prepare for M2-Planet: fdgetc.
* lib/mes/fdgetc.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen dd54e779b6
mescc: Mes C Library: Prepare for M2-Planet: abtol.
* lib/mes/abtol.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen 938c4262f6
mescc: Mes C Library: Prepare for M2-Planet: memcmp.
* lib/string/memcmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen 33f640e005
mescc: Mes C Library: Prepare for M2-Planet: memcpy.
* lib/string/memcpy.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen 6d55e94b6a
mescc: Mes C Library: Prepare for M2-Planet: memchr.
* lib/string/memchr.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:01 +02:00
Jan Nieuwenhuizen d62f5ac1b4
mescc: Mes C Library: Prepare for M2-Planet: strncmp.
* lib/string/strncmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen 3d0411ac25
mescc: Mes C Library: Prepare for M2-Planet: strlen.
* lib/string/strlen.c: : Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen 85627f123c
mescc: Mes C Library: Prepare for M2-Planet: strcpy.
* lib/string/strcpy.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen 70028b1928
mescc: Mes C Library: Prepare for M2-Planet: strcmp.
* lib/string/strcmp.c: Rewrite C-constructs not supported by M2-Planet.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen b7ba80a25b
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-10-26 19:41:00 +02:00
Jan Nieuwenhuizen b391ca3894
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-10-26 19:41:00 +02:00
Jan Nieuwenhuizen ad173240c0
mescc: Mes C Library: Add assert_msg.
* lib/mes/assert_msg.c: New file.
2019-10-26 19:41:00 +02:00
Jan Nieuwenhuizen dfa397f886
core: Prepare for M2-Planet: vector.c.
* src/vector.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:59 +02:00
Jan Nieuwenhuizen 08ffdb51bc
core: Prepare for M2-Planet: struct.c.
* src/struct.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:59 +02:00
Jan Nieuwenhuizen 6c6d85b519
core: Prepare for M2-Planet: string.c.
* src/string.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:59 +02:00
Jan Nieuwenhuizen 2d1bde7621
core: Prepare for M2-Planet: reader.c.
* src/reader.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:59 +02:00
Jan Nieuwenhuizen 6ab4e04921
core: Prepare for M2-Planet: posix.c.
* src/posix.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:59 +02:00
Jan Nieuwenhuizen 64a6f23fea
core: Prepare for M2-Planet: module.c.
* src/module.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:59 +02:00
Jan Nieuwenhuizen eb3ce6f639
core: Prepare for M2-Planet: math.c.
* src/math.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:59 +02:00
Jan Nieuwenhuizen 633a795393
core: Prepare for M2-Planet: lib.c.
* src/lib.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:58 +02:00
Jan Nieuwenhuizen deb499a64e
core: Prepare for M2-Planet: hash.c.
* src/hash.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:58 +02:00
Jan Nieuwenhuizen 4cb35018ed
core: Prepare for M2-Planet: gc.c.
* src/gc.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:58 +02:00
Jan Nieuwenhuizen 727065be5e
core: Prepare for M2-Planet: builtins.c.
* src/builtins.c: Rewrite C constructs not supported by M2-Planet.
2019-10-26 19:40:58 +02:00