Commit Graph

14 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 536cf7c075
drop number based cells 2019-11-03 10:34:13 +01:00
Jan Nieuwenhuizen 906b878a18
core: eval-apply: Prepare for M2-Planet.
* src/eval-apply.c (apply_builtin): Split M2-Planet specific and CC
specifi part off to ..
* src/cc.c: New file, and
* src/m2.c: New file.
2019-11-03 10:02:15 +01:00
Jan Nieuwenhuizen 1c1b99d19b
core: gc: Prepare for pointer cells, M2-Planet.
* include/mes/mes.h (cell_zero): Declare.
* src/gc.c (gc_init): Initialize it.
(gc_init_news): Likewise.
2019-11-03 09:57:16 +01:00
Jan Nieuwenhuizen 9b6ef58b10
test: Test-gc.
* src/test/gc.c (main): New unit test.
* simple.make (test-gcc, test-m2): New target to build it.
* build-aux/pointer.sh: Add it.
2019-11-02 21:32:46 +01:00
Jan Nieuwenhuizen f9d2fc1252
mescc: Mes C Library: Add M2-Planet support.
Mes can now be built with M2-Planet by running

    kaem --verbose --strict

* include/linux/x86/syscall.h (SYS_getcwd, SYS_dup, SYS_dup2,
SYS_unlilnk, SYS_gettimeofday, SYS_clock_gettime, SYS_time): Move to
libc section.  Add M2-Planet constants.
* include/m2/lib.h (struct timezone, struct timespec): struct timeval):
Define.  Add M2-Planet flavor prototypes for mes libc.
* include/mes/m2.h: Remove macros.
* include/mes/mes.h (g_start_time, __gettimeofday_time,
__get_internal_run_time_ts): Declare.
* src/mes.c (init): Initialize them.
* src/posix.c: Use them.
* simple.make: Use them.  Remove macro preprocessing for M2-Planet.
* kaem.run: New file.
2019-11-02 21:32:44 +01:00
Jan Nieuwenhuizen 91277b44c9
core: Split-out stack.c
* src/lib.c (exit_, frame_printer, make_frame_type, make_frame,
make_stack_type, make_stack, stack_length, stack_ref_): Move to ..
* src/posix.c (exit_): Here and to ..
* src/core.c: New file.
* build-aux/build-mes.sh (mes_sources): Add it.
* simple.make (LIBMES_SOURCES): Likewise.
2019-11-02 21:27:35 +01:00
Jan Nieuwenhuizen 68c09f880c
core: Split-off core.c.
* src/mes.c (assoc_string, car, cdr, list, null_p, eq_p, values, acons,
length__, length, error, append2, append_reverse, reverse_x_, assq,
assoc): Move to ...
* src/core.c: New file.
* build-aux/build-mes.sh (mes_sources): Likewise.
* simple.make (MES_SOURCES): Add it..
2019-11-02 21:27:35 +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 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 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 28edf91357
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/build-mes.sh (mes_sources): Add it.
* build-aux/snarf.sh: Likewise.
* 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-02 13:53:24 +01:00
Jan Nieuwenhuizen 26243d5373
build: simple.make.
* simple.make: New file.
2019-11-02 13:53:23 +01:00