Commit Graph

284 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen b9f40e2653
core: Switch to pointer cells.
Run

   build-aux/pointer.sh

* src/*.c: Update.
* include/mes/*.h: Update.
2019-11-03 10:34:32 +01:00
Jan Nieuwenhuizen 536cf7c075
drop number based cells 2019-11-03 10:34:13 +01:00
Jan Nieuwenhuizen b2d7a0140b
drop flip 2019-11-03 10:24:40 +01:00
Jan Nieuwenhuizen 225862cf84
flip: broken heart. 2019-11-03 10:02:17 +01:00
Jan Nieuwenhuizen b1cdcd2930
gc: flip twice and dump. 2019-11-03 10:02:17 +01:00
Jan Nieuwenhuizen 2dd537314c
gc_dump_arena
* src/gc.c (gc_dump_arena): New function.
2019-11-03 10:02:17 +01:00
Jan Nieuwenhuizen b08dab15ac
core: Pointer Cells: copy back. WIPPERDEWIP
* src/gc.c (gc_init)[POINTER_CELLS]: Do not use double sized arena.
(gc_cellcpy): New function.
* src/gc.c (gc_flip): Use it, do not flip.
2019-11-03 10:02:17 +01:00
Jan Nieuwenhuizen 41b6cc0368
test 2019-11-03 10:02:16 +01:00
Jan Nieuwenhuizen 4e9ebf508b
test: struct.
* src/test/gc.c (test_struct): New function.
(main): Call it.
2019-11-03 10:02:16 +01:00
Jan Nieuwenhuizen 47f797031f
test: vector.
* src/test/gc.c (test_vector): New function.
(main): Call it.
(print_arena): New function.
(test_gc): Call it.
2019-11-03 10:02:16 +01:00
Jan Nieuwenhuizen 3bb4b05666
test: string.
* src/test/gc.c (test_string): New function.
(main): Call it.
2019-11-03 10:02:16 +01:00
Jan Nieuwenhuizen 3a67dc36a5
test: setenv. 2019-11-03 10:02:16 +01:00
Jan Nieuwenhuizen cda1c54517
test: list. 2019-11-03 10:02:16 +01:00
Jan Nieuwenhuizen 0d147dcddd
test: cons. 2019-11-03 10:02:16 +01:00
Jan Nieuwenhuizen 7198116ff0
test: number.
* src/test/gc.c (test_number): New function.
(main): Call it.
2019-11-03 10:02:15 +01:00
Jan Nieuwenhuizen e8a2075c01
test: empty.
* src/test/gc.c (test_empty): New function.
2019-11-03 10:02:15 +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 5d7192ac05
core: display: Prepare for pointer cells, M2-Planet.
* src/display.c (display_helper): Use cell_ref, return. etc
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 fc61fc199d
core: Remove cell_call_with_current_continuation special.
* include/mes/symbols.h (cell_call_with_current_continuation): Remove.
* src/eval-apply.c (eval_apply): Update to use
cell_symbol_call_with_current_continuation.
* src/symbol.c (init_symbols_): Remove inititialization.
2019-11-02 21:32:47 +01:00
Jan Nieuwenhuizen 6307376d8a
core: Remove cell_begin special.
* include/mes/symbols.h (cell_begin): Remove.
* src/eval-apply.c (eval_apply): Update to use cell_symbol_begin.
* src/symbol.c (init_symbols_): Remove initialization.
2019-11-02 21:32:47 +01:00
Jan Nieuwenhuizen 3efb50cf95
core: Remove unused symbols.
* include/mes/symbols.h (cell_symbol_dot, cell_symbol_read_input_file,
cell_symbol_write, cell_symbol_display): Remove
* src/symbol.c (init_symbols_): Remove initializations.
2019-11-02 21:32:47 +01:00
Jan Nieuwenhuizen 34826aaab6
core: builtins: MES_MINI.
* include/mes/mes.h (g_mini): New global.
* src/mes.c (init): Initialize it with environment variable MES_MINI.
* src/builtins.c (mes_builtins): Register a minimal set of builtins
when g_mini.
2019-11-02 21:32:47 +01:00
Jan Nieuwenhuizen b0b53c98e7
boot: Add gc test.
* scaffold/boot/gc.test: New file.
* build-aux/check-boot.sh (TESTS): Add it.
* include/mes/symbols.h (cell_symbol_program): New symbol.
* src/symbol.c (init_symbols_): Initialize it.
* src/mes.c (main): Add it to environment.
2019-11-02 21:32:46 +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 746919dcd5
core: make_struct: Nicer gc layout.
* src/struct.c (make_struct): Use STRUCT TYPE PRINTER FIELD0 ... FIELDN.
2019-11-02 21:32:46 +01:00
Jan Nieuwenhuizen 803b679d15
core: make-vector: Move to core.
* src/vector.c (make_vector_): Rename from make_vector__.  Add
parameter.  Fix double allocation.
(make_vector): Rename from make_vector_.  Use arity n.  Update users.
2019-11-02 21:32:46 +01:00
Jan Nieuwenhuizen 74f95a3b67
core: posix: Prepare for M2-Planet.
* src/posix.c (access_p): Prepare for M2-Planet.
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 403c173c36
core: Prepare for M2-Planet: if (foo).
Rewrite C-constructs not supported by M2-Planet

    if (foo)              -> if (foo != 0)

* src/posix.c: Rewrite C-constructs not supported by M2-Planet.
(current_input_port): Likewise.
* src/display.c (display_helper): : Likewise.
* src/eval-apply.c (expand_variable_): : Likewise.
(eval_apply): : Likewise.
* src/mes.c (open_boot): : Likewise.
* src/reader.c (reader_read_identifier_or_number): : Likewise.
* src/symbols.c (init_symbol): : Likewise.
2019-11-02 19:13:15 +01:00
Jan Nieuwenhuizen a0971af6ab
core: Outline hashq_get_handle, hash_set_x_.
* src/hash.c (hashq_ref): Use hashq_get_handle.
(hashq_set_x_): Enable.
(hash_set_x): Use it.
2019-11-02 19:13:15 +01:00
Jan Nieuwenhuizen 4ae116d7ff
core: Prepare for M2-Planet: continue.
Rewrite C-constructs not supported by M2-Planet

    continue              -> goto LABEL

* src/eval-apply.c (eval_apply): Add label: begin_expand_while.  Use it
instead of continue.
2019-11-02 19:13:15 +01:00
Jan Nieuwenhuizen 5e445ce773
core: Prepare for M2-Planet: VALUE/TYPE indirections.
Rewrite C-constructs not supported by M2-Planet

    VALUE (CAR (foo))           -> SCM a = CAR (foo); VALUE (a)
    TYPE (CAR (foo))            -> SCM t = CAR (foo); TYPE (a)

* src/builtins.c (builtin_function): Use VALUE indirections.
(builtin_printer): Likewise.
* src/eval-apply.c (apply_builtin): Likewise.
(get_macro): Likewise.
(expand_variable_): Likewise.
(eval_apply): Likewise.
* src/hash.c (hashq_get_handle): Likewise.
(hashq_ref): Likewise.
(hash_ref): Likewise.
(hash_set_x): Likewise.
(hash_table_printer): Likewise.
* src/math.c (greater_p): Likewise.
(less_p): Likewise.
(is_p): Likewise.
(minus): Likewise.
(plus): Likewise.
(divide): Likewise.
(multiply): Likewise.
(logand): Likewise.
(logior): Likewise.
(logxor): Likewise.
* src/posix.c (current_input_port): Likewise.
(set_current_output_port): Likewise.
* src/reader.c (reader_read_list): Likewise.
(reader_read_character): Likewise.
(reader_read_string): Likewise.
* src/string.c (list_to_cstring): Likewise.
(read_string): Likewise.
2019-11-02 19:13:15 +01:00
Jan Nieuwenhuizen 9f80a7c566
core: Prepare for M2-Planet: M2_CELL_SIZE.
* src/gc.c (M2_CELL_SIZE): Hack for missing pointer arithmetic in
M2-Planet.
(gc_init, alloc, make_cell, gc_up_arena, gc_copy, gc_loop, gc_): Use it.
2019-11-02 19:13:15 +01:00
Jan Nieuwenhuizen 481a7fa17a
core: Use unique assert_msg.
* src/mes.c (error): Use unique assert_msg.
2019-11-02 19:13:14 +01:00
Jan Nieuwenhuizen d2cf928890
core: read_string: Prepare for M2-Planet.
* src/string.c (read_string): Prepare for M2-Planet.
2019-11-02 19:13:14 +01:00
Jan Nieuwenhuizen beec989d66
core: string_equal_p: Prepare for M2-Planet.
* src/string.c (string_equal_p): Prepare for M2-Planet.
2019-11-02 19:13:14 +01:00
Jan Nieuwenhuizen 03accfc7ac
core: reader_read_block_comment: Prepare for M2-Planet.
* src/reader.c (reader_read_block_comment): Prepare for M2-Planet.
2019-11-02 19:13:14 +01:00
Jan Nieuwenhuizen 3fdfad333e
core: reader_eat_whitespace: Prepare for M2-Planet.
* src/reader.c (reader_eat_whitespace): Prepare for M2-Planet.
2019-11-02 19:13:14 +01:00
Jan Nieuwenhuizen 4e123d5133
core: reader_read_sexp_: Prepare for M2-Planet.
* src/reader.c (reader_read_sexp_): Prepare for M2-Planet.
2019-11-02 19:13:14 +01:00
Jan Nieuwenhuizen ecc1db6b88
core: reader_read_identifier_or_number: Prepare for M2-Planet.
* src/reader.c (reader_read_identifier_or_number): Prepare for M2-Planet.
2019-11-02 19:13:14 +01:00
Jan Nieuwenhuizen 1fedea5db6
core: open_output_file: Prepare for M2-Planet.
* src/posix.c (open_output_file): Prepare for M2-Planet.
2019-11-02 19:13:13 +01:00
Jan Nieuwenhuizen a48c4eabbd
core: current_input_port: Prepare for M2-Planet.
* src/posix.c (current_input_port): Prepare for M2-Planet.
2019-11-02 19:13:13 +01:00
Jan Nieuwenhuizen abe12e1929
core: write_byte: Prepare for M2-Planet.
* src/posix.c (write_byte): Prepare for M2-Planet.
2019-11-02 19:13:13 +01:00
Jan Nieuwenhuizen 57b2686a91
core: read_char: Prepare for M2-Planet.
* src/posix.c (read_char): Prepare for M2-Planet.
2019-11-02 19:13:13 +01:00
Jan Nieuwenhuizen 242a26e0db
core: last_pair: Prepare for M2-Planet.
* src/lib.c (last_pair): Prepare for M2-Planet.
2019-11-02 19:13:13 +01:00
Jan Nieuwenhuizen facc3a2af6
core: memq: Prepare for M2-Planet.
* src/lib.c (memq): Prepare for M2-Planet.
2019-11-02 19:13:13 +01:00
Jan Nieuwenhuizen 1cb7e13d42
core: xassq: Prepare for M2-Planet.
* src/lib.c (xassq): Prepare for M2-Planet.
2019-11-02 19:13:13 +01:00