Commit Graph

35 Commits

Author SHA1 Message Date
Jan (janneke) Nieuwenhuizen 7932d4bad7
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.
2020-05-18 00:40:50 +02:00
Jan (janneke) Nieuwenhuizen f746db72c5
core: Upcase register names.
* include/mes/mes.h (R0, R1, R2, R3, M0): Rename from lower case.
Update users.
2020-05-17 22:32:53 +02:00
Jan (janneke) Nieuwenhuizen 6a96134eba
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.
2020-05-17 16:07:04 +02:00
Jan (janneke) Nieuwenhuizen 948c6ef91d
core: Prepare for M2-Planet: gc.c.
* src/gc.c: Rewrite C constructs not supported by M2-Planet.
2020-04-19 13:23:47 +02:00
Jan (janneke) Nieuwenhuizen 348e070bac
build: Run indent for M2.
* src/gc.c: Indented.
* src/string.c: Likewise.
2020-04-19 11:36:18 +02:00
Jan Nieuwenhuizen 5dc245e739
build: Simplify.
core: Make mes src/ c files separate compilation units.

* include/mes/constants.h: New file.
* include/mes/macros.h: New file.
* include/mes/mes.h: New file.
* src/gc.c: Update.
* src/hash.c: Update.
* src/lib.c: Update.
* src/math.c: Update.
* src/mes.c: Update.
* src/module.c: Update.
* src/posix.c: Update.
* src/reader.c: Update.
* src/string.c: Update.
* src/struct.c: Update.
* src/vector.c: Update.

    mes: Update datadir.

* src/mes.c (g_datadir): New global.
(open_boot): Rename from read_boot.
(read_boot): New function.
* mes/module/mes/boot-0.scm: Move from boot-0.scm.in
* configure: Update.
* configure.sh: Update.

    mescc: Create libraries from separate files.

* .gitignore: Update.
* build-aux/bootstrap-mes.sh: Remove.
* build-aux/bootstrap.sh.in: Remove.
* build-aux/build-guile.sh: Update.
* build-aux/build-mes.sh: Update.
* build-aux/build-scaffold.sh: New file.
* build-aux/build.sh.in: Update.
* build-aux/cc.sh: Update.
* build-aux/check-tcc.sh: Remove.
* build-aux/config.sh.in: New file.
* build-aux/config.sh: Remove.
* build-aux/install.sh.in: Update.
* build-aux/test-boot.sh: New file.
* build-aux/test-c.sh: New file.
* build-aux/test-driver: New file.
* build-aux/test-suite.sh: New file.
* build-aux/trace.sh: Update.
* build-aux/uninstall.sh.in: Update.
* configure: Update.
* configure.sh: Update.
* lib/linux/x86-mes-mescc/crt1.c: Move from lib/linux/x86-mes.
* lib/linux/x86-mes-mescc/mini.c: Likewise.
* lib/linux/x86_64-mes-mescc/crt1.c: Move from lib/linux/x86_64-mes.
* lib/linux/x86_64-mes-mescc/mini.c: Likewise.
* lib/linux/x86-mes-gcc/syscall.c: Rename from mes.c.
* lib/linux/x86-mes-mescc/syscall.c: Likewise.
* lib/linux/x86_64-mes-gcc/syscall.c: Likewise.
* lib/linux/x86_64-mes-mescc/syscall.c: Likewise.
* lib/mes/mes_open.c: Include config.h.
* lib/tests/stdio/70-printf-hello.c: Likewise.
* lib/tests/stdio/70-printf-simple.c: Likewise.
* scaffold/gc-test.sh: New file.
* simple.sh: Update.
2019-06-08 15:36:22 +02:00
Jan Nieuwenhuizen 952b92dfec
mes: Make debug levels 4 and 5 usable.
* HACKING: Update debug policy.
* lib/linux/read.c (read): Print read in level 5.
* src/mes.c (eval_apply): Print module in level 6.
(main): Likewise.  Remove redundant module printing.
* src/gc.c (gc): Print symbols in level 6.
2019-05-27 21:30:48 +02:00
Jan Nieuwenhuizen c33d6d00bc
mes: Run build-aux/indent.sh.
* src/mes.c: Re-indent.
* src: Likewise.
* include: Likewise.
* lib: Likewise.
* scaffold: Likewise.
2019-05-18 13:27:42 +02:00
Jan Nieuwenhuizen 99ac7b59c4
core: Remove struct definitions for builtins, drop snarfing.
After making a change to the list of builtin functions, run

    cat src/*.i

and move the into

    src/mes.c:mes_builtins ()

and, or also after changing the list of fixed symbols in src/mes.c:mes_symbols (), do

    cat src/*.h > src/builtins.h

* build-aux/build.sh.in: Remove snarfing.
* build-aux/bootstrap.sh.in: Likewise.
* mes/module/mes/display.mes (display):
* mes/module/mes/type-0.mes (cell:type-alist): Remove <cell:function>.
(function?, builtin?): Remove.
* src/builtins.h: New file.
* src/mes.c (TFUNCTION): Remove.
(struct function): Remove.
(apply_builtin): Rewrite from call.
(mes_builtins): Rewrite.
(init_builtin, make_builtin_type, make_builtin, builtin_name,
builtin_arity, builtin, builtin_p, builtin_printer): New function.
2019-01-04 09:55:16 +01:00
Jan Nieuwenhuizen 149f2a3e51
core: String as array of bytes.
* src/strings.c: New file.
* src/mes.c: Use it.  Update users.
2018-11-11 16:25:36 +01:00
Jan Nieuwenhuizen c2c361bf1a
core: Implement stack and frame.
* src/lib.c (frame_printer make_frame_type, make_frame,
make_stack_type, make_stack, stack_length, stack_ref): New function.
2018-10-20 18:23:20 +02:00
Jan Nieuwenhuizen 4e0e4c83d8
Revert "core: Add gc-debug for stack array."
This reverts commit f35084d1dbea889d107824e7596da1701c6b90ad.
2018-10-20 10:58:56 +02:00
Jan Nieuwenhuizen e032f6c70f
core: Add gc-debug for stack array.
* src/gc.c (gc_debug): New function.
2018-10-19 21:23:17 +02:00
Jan Nieuwenhuizen d73df09ab6
core: Use array-based stack.
* src/mes.c (STACK_SIZE)[MES_ARRAY_STACK]: New variable.
(g_stack_array): New variable.
(g_stack): Change type to SCM*.
(gc_push_frame)[MES_ARRAY_STACK]: Use g_stack_array, g_stack.
(gc_peek_frame): Likewise.
(gc_pop_frame): Likewise.
* src/gc.c (gc_check): Likewise.
(gc): Likewise.
2017-12-14 07:05:53 +01:00
Jan Nieuwenhuizen 0068fe533d
core: Add struct type.
* src/struct.c: New file.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.
2018-10-13 17:34:27 +02:00
Jan Nieuwenhuizen 5a6d8c21e0
mescc: Mes C Library: Add x86_64 libc support.
* include/linux/x86_64/syscall.h: New file.
* include/linux/x86/syscall.h: New file.
* lib/linux/x86_64-mes-gcc/mes.c: New file.
* lib/linux/x86-mes/mes.c: Rename from lib/linux/mes.c.
* lib/linux/x86-mes-gcc/mes.c: Rename from lib/linux/gcc.c.
* lib/linux/libc.c: Update includes.
(waitpid)[__x86_64__]: Use wait4.
* build-aux/build-cc.sh: Build libc too.
* lib/x86-mes/x86.M1 (mov____0x8(%ebp),%esi): New macro.
2018-08-11 11:42:30 +02:00
Jan Nieuwenhuizen 72cb975213
GNU Mes.
Throughout, make these changes

   Copyright headers: GNU Mes
   First mention of name: GNU Mes
   Website: https://www.gnu.org/software/mes
   Git:     git://git.savannah.gnu.org/mes.git
2018-07-22 14:24:36 +02:00
Jan Nieuwenhuizen dc24a7f76f
core: Add string ports.
* src/mes.c (type_t): Add TPORT.
  (scm_type_port): New symbol.
  (PORT): New macro.
  (MAKE_STRING_PORT): New macro.
  (eval_apply): Handle string ports in primitive-load.
  (mes_symbols): Add scm_type_port.
* src/posix.c (peekchar): Handle string ports.
  (readchar): New function.  Replace all getchar callers.
  (unreadchar): Likewise.
* module/mes/type-0 (port?): New function.
* module/mes/guile.mes (with-input-from-file): Rewrite.
  (open-input-string): Remove.
* module/mes/guile.scm (guile): Update cell types.
* src/gc.c (gc_loop): Support TPORT.
* src/lib.c (display_helper): Support TPORT.
* module/mes/display.mes (display): Support TPORT.
2018-04-29 17:48:38 +02:00
Jan Nieuwenhuizen a56d5e3efe
core: Fix gc_up_arena for x86_64.
* src/gc.c (gc_): Fix gc_up_arena for x86_64.
2018-04-29 12:04:18 +02:00
Jan Nieuwenhuizen 865e72ae8a
core: Fix compile warnings.
* src/posix.c: Include sys/stat.h.
  (chmod): Return cell_unspecified.
* include/stdlib.h: Typo.
2018-04-29 12:02:23 +02:00
Jan Nieuwenhuizen e3b929aa87
core: jam-scaper/garbage-collector: Use only one arena.
* src/mes.c (ARENA_SIZE): Lower to 200000.
  (MES_MAX_ARENA): Bump to 300000000.
  (JAM_SIZE): New global.
  (make_cell__): Remove ARENA assert.
  (gc_init_cells): Alloc ARENA_SIZE + JAM_SIZE.
  (mes_symbols): Do not init news.
  (gc_init_news): Remove.
  (main): Initialize JAM_SIZE, consider MES_JAM environment variable.
* src/gc.c (gc_init_news): Move from mes.c.  Start at g_free.
  (gc_flip): Do not flip to g_news, instead copy g_news to cells.
  (gc_up_arena): Realloc to ARENA_SIZE + JAM_SIZE.
  (gc_): Init news.  Only up arena if g_news is safe.
2018-04-25 08:35:05 +02:00
Jan Nieuwenhuizen 833fe991cb
core: Fixes for garbage collector/jam scraper.
* src/gc.c (gc_loop): Do not relocate car of TCLOSURE, TCONTINUATION.
  Check for TBROKEN_HEART.
* src/mes.c (make_closure_): Set car to 0.
  (check_apply): Check for TBROKEN_HEART.  Fixes reporting artificial
  out-of-memory error.
  (eval_apply): Likewise.
* src/vector.c (vector_entry): Only copy TCHAR and TNUMBER.
2018-04-21 13:31:12 +02:00
Jan Nieuwenhuizen 0be441446e
core: drop global_p from variable.
* src/mes (struct scm): Remove field global_p.
 (VARIABLE_GLOBAL_P): Remove.
 (make_variable_): Remove global_p parameter.  Update callers.
* src/lib.c (display_helper): Drop VARIABLE_GLOBAL_P support.
2018-04-21 13:19:54 +02:00
Jan Nieuwenhuizen ac0baf84d4
core: Cleanup make_cell, remove tmp cells.
* src/mes.c (make_cell__): New function.
  (make_cell_): Use it.
  (length__): New function.
  (tmp, tmp_num, tmp_num2, tmp_num_, tmp_num2_, make_tmps): Remove.
  Update callers to use make_cell__ directly.
 * src/vector.c (make_vector__): New function.
  (make_vector_): Use it.
2018-04-14 08:15:49 +02:00
Jan Nieuwenhuizen 3dc72ce20d
core: Remove local variables from gc.
* src/gc.c (gl_loop): Remove local variables.
2018-04-12 21:33:38 +02:00
Jan Nieuwenhuizen b65e57be31
core: Tune debug printing.
* src/mes.c: Tune debug printing.
* src/gc.c: Likewise.
* module/mes/guile.mes: Likewise.
* HACKING: Describe it.
2018-04-09 07:12:38 +02:00
Jan Nieuwenhuizen ad135d3752 doc: Release udpate.
* HACKING: Update.
* INSTALL: Update.
* NEWS: Update.
* README: Update.
* doc/ANNOUNCE-0.12: New file.
* throughout: (janneke) coming out.
2017-11-21 19:22:26 +01:00
Jan Nieuwenhuizen 35bb5869f9 mes: Cleanup formatting. 2018-04-05 21:35:31 +02:00
Jan Nieuwenhuizen 9fc27ee25a mes: Single environment lookup for variables, SICP chapter 3.
* src/mes.c (t): Add TVARIABLE.
  (scm_vm_eval_deref): New vm special.
  (make_vref_): New internal function.
  (eval_apply): WIP: replace symbols with their variable reference.
* src/gc.c (gc_loop): Handle TVARIABLE.
* src/lib.c (display_helper): Handle TVARIABLE.
* module/mes/type-0.mes (<cell:variable>): New variable.
  (cell:type-alist): Add it.
  (variable?): New function.
* module/mes/display.mes (display): Handle <variable>.
2017-12-09 08:33:50 +01:00
Jan Nieuwenhuizen 562d91466c Revert "mes: use array-based stack. WIP: will not survice gc."
This reverts commit 7fb653f68c2dbf8bc83cce4bd138439c600b538f.
2017-12-17 07:42:49 +01:00
Jan Nieuwenhuizen da20d92c77 mes: use array-based stack. WIP: will not survice gc.
* src/mes.c (STACK_SIZE)[MES_ARRAY_STACK]: New variable.
  (g_stack_array): New variable.
  (g_stack): Change type to SCM*.
* (gc_push_frame)[MES_ARRAY_STACK]: Use g_stack_array, g_stack.
  (gc_peek_frame): Likewise.
  (gc_pop_frame): Likewise.
* src/gc.c (gc_check): Likewise.
  (gc): Likewise.
2017-12-14 07:05:53 +01:00
Jan Nieuwenhuizen fe727301c5 mescc: Support regular C99 compile, headers + mlibc.
* libc/include/assert.h: New file.
* libc/include/ctype.h: New file.
* libc/include/errno.h: New file.
* libc/include/fcntl.h: New file.
* libc/include/limits.h: New file.
* libc/include/mlibc.h: New file.
* libc/include/stdio.h: New file.
* libc/include/stdlib: New file.
* libc/include/string.h: New file.
* libc/include/unistd.h: New file.
* libc/mlibc.c: Remove declarations.
* make/bin.make (INCLUDES): Factor out standard includes.
* make/bin-mlibc.make: New file.
* scaffold/scaffold.make: Use it.
* src/src.make: Use it.
* module/language/c99/compiler.mes (ast-info): Handle more function declarations.
* scaffold/cons-mes.c: Remove mlibc definitionsa and mlibc.c include.
  Instead include <mlibc.h>.
* scaffold/hello.c: Likewise.
* scaffold/m.c: Likewise.
* scaffold/malloc.c: Likewise.
* scaffold/micro-mes.c: Likewise.
* scaffold/mini-mes.c: Likewise.
* scaffold/t.c: Likewise.
* scaffold/tiny-mes.c: Likewise.
* src/gc.c: Likewise.
* src/lib.c: Likewise.
* src/math.c: Likewise.
* src/mes.c: Likewise.
* src/posix.c: Likewise.
* src/reader.c: Likewise.
2017-05-02 23:30:46 +02:00
Jan Nieuwenhuizen d9e5e2d21f doc: Release update.
* AUTHORS: Mention Nyacc and GuixSD.
* NEWS: Update.
* README: Update.
* doc/ANNOUNCE-0.5 New file.
* HACKING: Add pointers, update TODO/DONE.
2017-04-27 12:08:16 +02:00
Jan Nieuwenhuizen e0a0a3798a core: Move some debugging to MES_DEBUG=2.
* module/mes/base-0.mes (load): Add ;;;.
* src/gc.c (gc_flip): Test on g_debug > 1.
  (gc): Likewise.
* src/mes.c (mes_builtins): Likewise.
  (main): Likewise.
* src/reader.c (dump): Likewise.
2017-04-17 23:32:02 +02:00
Jan Nieuwenhuizen 38d30a3e42 build: Refactor.
* GNUmakefile (OUT,QUIET,SUBDIRS): New variables.
  include make/common.make
* .gitignore: Remove toplevel targets.
* build-aux/compile-all.scm: Import from GNU Guix.
* configure (gulp-pipe): Check exit status.  Actually test for CC,
  CC32.
* make/bin.make: New file.
* make/check.make: New file.
* make/clean.make: New file.
* make/common.make: New file.
* make/compile.make: New file.
* make/guile.make: New file.
* make/mescc-guile.make: New file.
* make/mescc-mes.make: New file.
* make/reset.make: New file.
* lib/mlibc.c: Rename from top.
* lib/start.c: Rename from top.
* module/module.make: New file.
* scaffold/scaffold.make: New file.
* scripts/scripts.make: New file.
* src/mes.c: Rename from top.
* src/src.make: New file.
* src/mes.c: Rename from top.
* src/gc..c: Rename from top.
* src/lib.c: Rename from top.
* src/posix.c: Rename from top.
* src/reader.c: Rename from top.
* src/vector.c: Rename from top.
* tests/tests.make: New file.
2017-04-12 21:27:59 +02:00