Commit Graph

167 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen 1425127012
core: struct_set_: Oops typo.
* src/struct.c (struct_set_x_): Oops, remove indirection.
2018-11-15 21:01:13 +01:00
Jan Nieuwenhuizen b85db01e9b
core: read_string: Allow for gc.
* src/posix.c (read_char): Add optional port parameter.
(read_string): Allow for gc.
2018-11-15 18:08:49 +01:00
Jan Nieuwenhuizen 280b763ae8
core: Add delete_file.
* src/posix.c (delete_file): New function.
2018-11-15 18:08:49 +01:00
Jan Nieuwenhuizen 4568b8434b
core: Add dup, dup2.
* src/posix.c (dup_, dup2_): New function.
2018-11-15 18:08:49 +01:00
Jan Nieuwenhuizen cf04774209
core: Add getcwd.
* src/posix.c (getcwd_): New function.
2018-11-15 18:08:49 +01:00
Jan Nieuwenhuizen 059fb2e27f
core: Support redirection of stderr.
* include/libmes-mini.h (g_stderr): New global.
* lib/mes/eputc.c (eputc): Use it.
* lib/mes/eputs.c (eputs): Likewise.
* lib/mes/oputc.c (oputc): Likewise.
* lib/mes/oputs.c (oputs): Likewise.
* src/lib.c (display_error_, write_error_): Likewise.
* src/posix.c (write_byte): Likewise.
* src/mes.c (mes_builtins): Likewise.
(main): Iniitalize g_stderr.
* src/posix.c (current_error_port, set_current_error_port): New
function.
* mes/module/mes/boot-0.scm.in (current-output-port,
current-error-port): Remove.
2018-11-15 18:08:49 +01:00
Jan Nieuwenhuizen 216936e085
core: Assert g_free in alloc.
* src/mes.c (alloc): Assert g_free.
2018-11-15 18:08:49 +01:00
Jan Nieuwenhuizen bb6cdb6b54
mes: read-string: Take optional port argument.
* src/posix.c (read_string): Take optional port argument.
* mes/module/mes/guile.mes (read-string): Remove.
2018-11-11 12:10:41 +01:00
Jan Nieuwenhuizen 4a31bcb06a
core: eval_apply: Order gotos according to frequency.
* src/mes.c (eval_apply): Order gotos according to frequency.
2018-11-11 12:10:41 +01:00
Jan Nieuwenhuizen 47600095c3
Revert "core: eval_apply profile."
This reverts commit d61e6be0b18459a8e3c262eab448b428dc81937a.
2018-11-11 12:10:41 +01:00
Jan Nieuwenhuizen 3d4dbdef60
core: eval_apply profile.
* src/mes.c: Poor man's eval_apply profile.
2018-11-11 12:10:41 +01:00
Jan Nieuwenhuizen cee0972566
core: Fix displaying of closure.
* src/lib.c (display_helper): Fix displaying of closure.
2018-11-11 12:10:41 +01:00
Jan Nieuwenhuizen b93fd30819
core: Set procedure in stack frame.
* src/mes.c (eval_apply): Set procedure in stack frame.
2018-11-07 22:48:10 +01:00
Jan Nieuwenhuizen 10a0ec8808
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-11-07 22:48:10 +01:00
Jan Nieuwenhuizen 37cba9c93b
core: Support time functions.
* lib/linux/clock_gettime.c: New file, move from gnu.c.
* lib/linux/gettimeofday.c: New file, move from tcc.c.
* lib/linux/time.c: New file, move from tcc.c.
* lib/linux/libc.c: Include them.
* lib/linux/gnu.c (clock_gettime): Remove.
* lib/linux/tcc.c (time, gettimeofday): Remove.
* include/time.h (CLOCK_PROCESS_CPUTIME_ID): New define.
* src/posix.c (init_time, current_time, gettimeofday_,
seconds_and_nanoseconds_to_long, get_internal_run_time): New function.
* src/mes.c (scm_symbol_internal_time_units_per_second): New symbol.
(main): Call init_time.
2018-11-07 22:48:10 +01:00
Jan Nieuwenhuizen 9b32098573
core: Use hash table for symbols.
* src/mes.c (mes_symbols): Use hash table for symbols.  Update users.
2018-11-07 22:48:10 +01:00
Jan Nieuwenhuizen 554d1beeb2
core: Use assert before failure exit.
* src/mes.c (error): Use assert before failure exit.  Helps debugging.
2018-11-07 22:48:10 +01:00
Jan Nieuwenhuizen 42e6f43149
core: Add hashq_get_handle, hash, hash_ref, hash_set_x.
* src/mes.c (scm_symbol_hashq_table, scm_symbol_record_type,
scm_symbol_module, scm_symbol_buckets, scm_symbol_size): New symbols.
Update users.
* src/hash.c (hash_list_of_char): Rename from hashq_.  Respect size,
update callers.
(hashq_, hash_ hash, hashq_get_handle, hash_ref, hash_set_x_,
hash_set_x): New function.
(hashq_ref): Do not return handle.  Update callers.
2018-11-07 22:48:09 +01:00
Jan Nieuwenhuizen d9199b3536
mes: Move pair? to core.
* src/lib.c (pair_p): New function.  Gains 8% performance on MesCC.
2018-11-07 22:48:09 +01:00
Jan Nieuwenhuizen 4e1f494d19
mes: Move assoc to core.
* mes/mes.c (assoc_string, assoc): New function.
* mes/module/mes/scm.mes (assoc): Remove.  Gains 12% performance for
MesCC.
2018-11-07 22:48:09 +01:00
Jan Nieuwenhuizen 5c685ebd22
Revert "core: Add gc-debug for stack array."
This reverts commit f35084d1dbea889d107824e7596da1701c6b90ad.
2018-11-07 22:48:09 +01:00
Jan Nieuwenhuizen 30c67ca3e0
core: Add gc-debug for stack array.
* src/gc.c (gc_debug): New function.
2018-11-07 22:48:09 +01:00
Jan Nieuwenhuizen 79cffa7d79
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.
2018-11-07 22:48:09 +01:00
Jan Nieuwenhuizen d3fa0b4a1a
core: expand_variable: Remove weird exceptions: begin, if.
* src/mes.c (expand_variable_): Remove weird exceptions: begin, if.
2018-11-07 22:48:08 +01:00
Jan Nieuwenhuizen 8044674d00
mes: Switch to srfi-9 based on structs.
* mes/module/srfi/srfi-9.mes: Swap symlink to srfi-9-struct.mes.
* mes/module/srfi/srfi-9/gnu.mes: Swap symlink to gnu-struct.mes.
* src/module.c (make_module_type): Update to match srfi-9-struct
records.  Update users.
* src/hash.c (make_hashq_type): Likewise.
2018-11-07 22:48:08 +01:00
Jan Nieuwenhuizen 08ef31c86b
mes: srfi-9: Add implementation based on struct.
* mes/module/srfi/srfi-9-struct.mes: New file.
* mes/module/srfi/srfi-9-vector.mes: Rename from srfi-9.mes
* mes/module/srfi/srfi-9.mes: Symlink to srfi-9-vector.mes.
* mes/module/srfi/srfi-9/gnu-struct.mes: Add srfi-9-struct
implementation.
* mes/module/srfi/srfi-9/gnu-vector.mes: Rename from gnu.mes.
* mes/module/srfi/srfi-9/gnu.mes: Symlink to gnu-vector.mes.
2018-11-07 22:48:08 +01:00
Jan Nieuwenhuizen 3dcc9879ab
core: hashq-table: Refactor to be a record-like struct.
* src/hash.c (hash_table_printer): New function.
(make_hashq_type): New function.
* src/module.c (module_printer): Use it.
(make_module_type): New function.
(make_initial_module): Use them.
2018-11-07 22:48:08 +01:00
Jan Nieuwenhuizen 99d890e340
core: Use hashq-table for macros.
* src/mes.c (lookup_macro_): Remove.
(macro_ref, get_macro, macro_set_x): New function.  Update callers.
2018-11-07 22:48:08 +01:00
Jan Nieuwenhuizen d9fb66a258
core: Add hashq-table type.
src/hash.c: New file.
src/module.c (char_hash, module_hash): Remove.
* src/module.c (make_initial_module): Use hash primitives.
(module_define_x): Likewise.
(module_variable): Likewise.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.
2018-11-07 22:48:08 +01:00
Jan Nieuwenhuizen 08452c7b26
core: Add boot-module.
* src/mes.c (scm_symbol_boot_module): New symbol.
(eval_apply): Handle it.
(mes_symbols): Initialize it.
2018-11-07 22:48:07 +01:00
Jan Nieuwenhuizen 049066edc7
core: Add module-define!
* src/module.c (module_define_x, module_printer): New function.
(make_initial_module): Use them.
* tests/srfi-0.test: Test it.
* src/mes.c (display_m0): Remove.  Update callers.
* mes/module/mes/fluids.mes (make-fluid): Rewrite.
* tests/macro.test: Test it.
* mes/module/mes/boot-0.scm.in (module-define!): Remove.
* mes/module/mes/boot-02.scm: Likewise.
* module/mes/misc.scm (pk, warn): New function.
* build-aux/check-mes.sh (tests): Run tests.
2018-11-07 22:48:07 +01:00
Jan Nieuwenhuizen f8b70ff62e
core: Add module indirection for variable lookup.
* src/module.c (module_ref, module_variable): New function.
* src/mes.c: Thoughout: Use them.
(assq_ref_env): Remove.
* mes/module/mes/boot-0.scm.in (defined?): Use module-variable.
* mes/module/mes/boot-00.scm (defined?): Likewise.
* mes/module/mes/boot-01.scm (defined?): Likewise.
* mes/module/mes/boot-02.scm (defined?): Likewise.
* scaffold/boot/53-closure-display.scm: Likewise.
2018-10-14 08:30:18 +02:00
Jan Nieuwenhuizen b243af5499
core: Add module type.
* src/module.c: New file.
* build-aux/snarf.sh: Snarf it.
* src/mes.c: Include it.
2018-10-14 08:15:22 +02:00
Jan Nieuwenhuizen 47604479e2
core: Add cstring_to_symbol.
* src/mes.c (make_symbol): Rename from lookup_symbol_.  Update
callers.
(cstring_to_symbol): New function.
* src/reader.c (reader_read_identifier_or_number): Use it.
2018-10-14 07:38:51 +02:00
Jan Nieuwenhuizen c3a1435714
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 18a9e37567
core: core:cdr: Support port type.
* src/mes.c (cdr_): Support port type.
* mes/module/mes/display.mes (display): Add space between fields.
2018-10-15 12:28:02 +02:00
Jan Nieuwenhuizen 183514d103
core: reader: Support 64 bit.
* src/reader.c (reader_read_identifier_or_number): Support 64 bit.
(reader_read_binary): Likewise.
(reader_read_octal): Likewise.
(reader_read_hex): Likewise.
2018-10-07 00:58:31 +02:00
Jan Nieuwenhuizen f7e208dd7b
core: Avoid 64bit zero divide.
* src/math.c (divide): Avoid (64bit) 0 divide.
(modulo): Likewise.
2018-10-07 00:25:33 +02:00
Jan Nieuwenhuizen d0a1cc5096
core: Use proper name for %compiler.
* src/mes.c (mes_symbols, bload_env): : Use proper name for %compiler.
2018-10-06 08:43:26 +02:00
Jan Nieuwenhuizen e4e41a30b4
core: Resurrect MES_MINI for non-POSIX.
src/mes.c[MES_MINI,!POSIX]: Resurrect.
2018-10-06 07:25:39 +02:00
Jan Nieuwenhuizen 133013a3d2
core: Support x86_64.
* src/lib.c: Support x86_64.
* src/math.c: Likewise.
* src/mes.c: Likewise.
* src/reader.c: Likewise.
* src/vector.c Likewise.
2018-10-04 21:43:45 +02:00
Jan Nieuwenhuizen bc094d0e1f
core: mes: Prepare for M2-Planet.
* src/mes.c (cal): Refactor to use if instead of switch.
(eval_apply): Likewise.
2018-08-12 16:53:21 +02:00
Jan Nieuwenhuizen 1e787637d8
core: lib: Prepare for M2-Planet.
* src/lib.c (display_helper): Refactor to use if instead of switch.
(memq): Likewise.
2018-08-12 16:41:07 +02:00
Jan Nieuwenhuizen 03ee240904
core: reader: Prepare for M2-Planet.
* src/reader.c (MAX_STRING): New define.
(read_input_file_env_): Remove dead code.
(reader_read_line_comment): Refactor to remove recursion.
(reader_read_line_sexp_): Refactor to use if instead of switch.
(reader_read_hash): Likewise.
(reader_read_character): Refactor: cache peekchar () value, make
M2-Planet friendly.
(reader_read_binary): Make M2-Planet friendly.
(reader_read_octal): Likewise.
(reader_read_hex): Likewise.
(reader_read_string): Refactor.
(dump): Make M2-Planet friendly.
2018-08-12 14:53:06 +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 46e0641e9c
mescc: Mes C Library: Add x86_64 libc-mini support.
* lib/linux/x86-mes-gcc/mini.c: Rename from lib/linux/mini-gcc.c.
* lib/linux/x86-mes/mini.c: Rename from lib/linux/mini-mes.c.
* lib/linux/x86_64-mes-gcc/crt1.c: Rename from lib/linux/x86_64/crt1.c.
* lib/linux/x86_64-mes-gcc/mini.c: New file.
* build-aux/build-cc.sh: Build libc-mini, scaffold/main, scaffold/hello.
* build-aux/cc64.sh: New file.
2018-08-10 17:05:01 +02:00
Jan Nieuwenhuizen f18e1fea36
build: Make build more autotools-like.
* build-aux/build.sh.in: Move from ./build.sh
* build-aux/check.sh.in: Likewise.
* build-aux/GNUmakefile.in: Likewise.
* build-aux/install.sh.in: Likewise.
* build-aux/uninstall.sh.in: Likewise.
* configure: Substitute them.
* configure.sh: Likewise.
* build-aux/build-cc.sh: Update: use ${srcdest} instead of ${top_builddest}.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-guile.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/cc-mes.sh: Likewise.
* build-aux/cc.sh: Likewise.
* build-aux/cc32-mes.sh: Likewise.
* build-aux/check-boot.sh: Likewise.
* build-aux/check-mes.sh: Likewise.
* build-aux/check-mescc.sh: Likewise.
* build-aux/config.sh: Likewise.
* build-aux/export.make: Likewise.
* build-aux/mes-snarf.scm: Likewise.
* build-aux/pre-inst-env.in: Likewise.
* build-aux/test.sh: Likewise.
* build-aux/trace.sh: Likewise.
* module/mescc/mescc.scm: Likewise.
* scripts/mescc.in: Likewise.
* src/mes.c: Likewise.
* .gitignore: Likewise.
2018-07-25 08:14:13 +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 4203a427d0
build: Support --srcdir build.
* build-aux/config.sh: New file.
* build-aux/trace.sh: New file.
* build-aux/GNUmakefile.in: New file.
* configure: Support srcdir configure.
* GNUmakefile: Support srcdir build.
* build-aux/build-cc.sh: Likewise.
* build-aux/build-cc32.sh: Likewise.
* build-aux/build-guile.sh: Likewise.
* build-aux/build-mes.sh: Likewise.
* build-aux/cc-mes.sh: Likewise.
* build-aux/cc.sh: Likewise.
* build-aux/cc32-mes.sh: Likewise.
* build-aux/check-mes.sh: Likewise.
* build-aux/check-mescc.sh: Likewise.
* build-aux/export.make: Likewise.
* build-aux/mes-snarf.scm: Likewise.
* build-aux/pre-inst-env.in: Likewise.
* build-aux/test.sh: Likewise.
* build.sh: Likewise.
* check.sh: Likewise.
* install.sh: Likewise.
* module/mescc/mescc.scm: Likewise.
* scripts/mescc.in: Likewise.
* src/mes.c: Likewise.
2018-07-22 00:43:39 +02:00
Jan Nieuwenhuizen 87269a16f6
core: Document number->string INT-MIN failure with gcc-x86.
* src/mes.c (scm_symbol_arch, scm_symbol_compiler): New symbol.
  (mes_symbols, bload_env): Add them.
  (scm_symbol_gnuc, scm_symbol_mesc): Remove.
* scaffold/mini-mes.c: Likewise.
* module/mes/mes-0.scm (%arch, %compiler): New public variable.
* tests/srfi-13.test: Expect number->string INT-MIN to fail for
  gcc-x86.
* HACKING (Bugs): Add it.
2018-07-21 15:20:01 +02:00