Commit Graph

54 Commits

Author SHA1 Message Date
Jan Nieuwenhuizen c3fdfedb20 mes: resurrect full reader in C core.
* module/mes/read-0.mes (defined?): New function.
  (eat-whitespace, read-env, read-word, read-block-comment,
  read-line-comment, read-list, read-character, read-hex, read-octal,
  reader:read-string, lookup, read-hash, read-word): Only define if
  not %c-reader.
* module/mes/base-0.mes (defined?): Remove.
* src/mes.c[MES_C_READER]: Set ARENA_SIZE=10000000.
  (scm_symbol_quasiquote scm_symbol_unquote,
  scm_symbol_unquote_splicing, scm_symbol_syntax,
  scm_symbol_quasisyntax, scm_symbol_unsyntax,
  scm_symbol_unsyntax_splicing): New symbol.
  (scm_symbol_c_reader): New symbol.
  (MAKE_KEYWORD)[MES_C_READER]: New define.
  (mes_symbols): Define %c_reader.
* src/reader.c (read_word_)[MES_C_READER]: Extend to full Scheme
  reader.
  (eat_whitespace)[MES_C_READER]: Likewise.
  (read_block_comment, read_hash, read_word, read_character,
  read_octal, read_hex, append_char, read_string)[MES_C_READER]:
  Likewise.
* make.scm (bin.gcc,bin.mescc): Define MES_C_READER=1.
2017-11-29 21:42:50 +01:00
Jan Nieuwenhuizen 74c4197467 mescc: Mescc-tools support: char foo[BAR] = {'a', 'b', 'c'}.
* stage0/x86.M1 (mov____%al,0x8(%ebp), mov____%al,0x32(%ebp),
  mov____%ax,0x8(%ebp), mov____%ax,0x32(%ebp)): New define.
* module/mes/as-i386.mes (i386:accu->local+n,i386:byte-accu->local+n,
  i386:word-accu->local+n): New function.
* module/language/c99/compiler.mes (accu->local+n): New function.
  (initzer->data): Return char as single byte.
  (decl->info): Support char foo[BAR] = {'a', 'b', 'c'}.
* scaffold/tests/66-local-char-array.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-11-27 19:51:18 +01:00
Jan Nieuwenhuizen e8884d83e1 mlibc: GNU Gcc support: setjmp, longjmp.
* stage0/x86.M1 (jmp____*%ebx): New macro.
  (mov____0x8(%ebp),%ebp): New macro.
  (mov____0x8(%ebp),%esp): New macro.
* include/setjmp.h (jmp_buf): Redefine as struct.
* lib/libc-mes+tcc.c (longjmp, setjmp): Implement.
* scaffold/tests/80-setjmp.c: Test it.
* make.scm ("80-setjmp"): Build it.
* .gitignore: Ignore *.tcc-guile.
2017-11-26 13:10:46 +01:00
Jan Nieuwenhuizen 0fa18b338d build: mlib/include to include, move mlib to lib.
* include: Move from mlib/include.
* lib: Move from mlib.
* BOOTSTRAP: Update.
* HACKING: Update.
* guile/guix/make.scm: Update.
* make.scm: Update.
* module/language/c99/compiler.mes: Update.
2017-11-22 16:23:48 +01:00
Jan Nieuwenhuizen 1762efc4b9 mes: Resurrect running mes tests tests/*.test with Guile.
* tests/tests/base.test-guile: New file to resurrect running Mes test with Guile.
* tests/catch.test-guile: Symlink for same purpose.
* tests/closure.test-guile: Likewise.
* tests/cwv.test-guile: Likewise.
* tests/display.test-guile: Likewise.
* tests/fluids.test-guile: Likewise.
* tests/guile.test-guile: Likewise.
* tests/let-syntax.test-guile: Likewise.
* tests/let.test-guile: Likewise.
* tests/match.test-guile: Likewise.
* tests/math.test-guile: Likewise.
* tests/module.test-guile: Likewise.
* tests/optargs.test-guile: Likewise.
* tests/peg.test-guile: Likewise.
* tests/pmatch.test-guile: Likewise.
* tests/psyntax.test-guile: Likewise.
* tests/quasiquote.test-guile: Likewise.
* tests/read.test-guile: Likewise.
* tests/record.test-guile: Likewise.
* tests/scm.test-guile: Likewise.
* tests/srfi-1.test-guile: Likewise.
* tests/srfi-13.test-guile: Likewise.
* tests/srfi-14.test-guile: Likewise.
* tests/vector.test-guile: Likewise.
* make.scm (add-guile-test): New function.  Use it to run running tests/*.test-guile.
2017-11-21 19:13:14 +01:00
Jan Nieuwenhuizen 448b167c09 mes: resurrect running MesCC: update info interface.
* module/language/c99/info.mes (type?, global?, local?): New function.
  (make-global): Remove name parameter.
* module/nyacc/lang/c99/pprint.mes: New file.
2017-11-20 23:17:50 +01:00
Jan Nieuwenhuizen 2965649786 Release 0.11.
* configure (VERSION): Bump to 0.11.
2017-11-18 13:14:20 +01:00
Jan Nieuwenhuizen d111d64e50 build: fix for 07-include, thanks rain1!
* make.scm (add-scaffold-test): New keyword parameter: includes.
  ("07-include"): Use it.
2017-11-18 15:02:21 +01:00
Jan Nieuwenhuizen ada6ac99dd mescc: Tinycc support: test #include.
* scaffold/tests/exit-42.i: New file.
* scaffold/tests/07-include.c: New file.
* make.scm ("07-include"): Build it.
2017-11-18 11:55:47 +01:00
Jan Nieuwenhuizen 02e70486a1 mescc: Tinycc support: struct struct array.
Support

  struct foo
  {
    struct bar baz[N];
    struct bar bla*[M];
  };

* module/language/c99/compiler.mes (expr->accu):
* scaffold/tests/7n-struct-struct-array.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-11-17 15:24:45 +01:00
Jan Nieuwenhuizen 67afa2a397 mescc: Tinycc support: empty for.
* module/language/c99/compiler.mes (test-jump-label->info): Handle
  empty expression.
* make.scm (add-tcc-test "45_empty_for"): Test it.
2017-11-16 05:52:47 +01:00
Jan Nieuwenhuizen dc65de59ce mescc: refactor expr->accu, expr->accu*, fixes nontrivial struct by value assign.
* module/language/c99/compiler.mes: (pke): New function.
  (expr->number): Rename from p-expr->number.  Update callers.
  (decl->info, init-declr->pointer, struct-field): Several pointeryness fixes.
  (expr->accu*, expr->accu): Remove special-casing for foo.bar,
  foo->bar, foo[bar].  Fixes struct by value assign for non-trival
  expressions.
  (accu->ident, ident-address->accu, ident->accu):
  (base->ident-address, ident->base): Remove.
* scaffold/tests/7k-for-each-elem.c (test): Test it.
* scaffold/tests/7c-dynarray.c (test): Test it.
* scaffold/tests/7m-struct-char-array-assign.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-11-11 13:45:53 +01:00
Jan Nieuwenhuizen 5c7ba63729 doc: Release udpate.
* HACKING: Update.
* INSTALL: Update.
* NEWS: Update.
* doc/ANNOUNCE-0.10: New file.
* BOOTSTRAP: New file.
* make.scm: Install them.
2017-09-10 21:53:59 +02:00
Jan Nieuwenhuizen 7e6408534f tinycc: scaffold/main.c: running tcc-compiled binary #3.
* scaffold/main.c (main): Remove asm.
2017-09-03 10:43:02 +02:00
Jan Nieuwenhuizen 9555d90174 mescc: Tinycc support: struct by value assign.
* module/language/c99/compiler.mes (expr->accu): warn for unsupported
  sizes.
* scaffold/tests/7h-struct-assign.c (test): Test it.
2017-09-10 16:59:53 +02:00
Jan Nieuwenhuizen 7619190d5c build: compile crt1.c, libc-mesc.c and <input>.c separately.
* mlibc/crt1.c: New file.
* mlibc/libc-mes.c (_start): Remove.
* mlibc/libc-gcc.c (_start): Remove.
* make.scm (LINK.hex2, bin.mescc): Move from guile/guix/make.scm.
* guile/guix/make.scm (LINK.hex2, bin.mescc): Remove.
2017-09-10 16:59:43 +02:00
Jan Nieuwenhuizen 9aa8d8bd9d tinycc: scaffold/main.c: first running tcc-compiled binary.
* scaffold/main.c (_start): Exit 42 using asm.
2017-08-19 11:35:58 +02:00
Jan Nieuwenhuizen 989bfdbd25 mescc: Tinycc support: array of struct of any size.
* module/language/c99/compiler.mes (accu*value): New function
  (expr->accu*): Use it to support array of struct of any size.
* scaffold/tests/7l-struct-any-size-array.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-08-27 11:23:45 +02:00
Jan Nieuwenhuizen 1e23dbaf17 mescc: Tinycc support: handle pointerness, siziness for cast foo*.
* module/language/c99/compiler.mes (expr->pointer): Support cast foo*.
  (expr->size): Likewise.
* scaffold/tests/7k-for-each-elem.c: Test it
* make.scm (add-scaffold-test): Build it.
2017-08-23 06:55:25 +02:00
Jan Nieuwenhuizen 93714ad0a4 mescc: Tinycc support: strtoull.
* mlibc/include/mlibc.h (_atoi): Declare.
* mlibc/include/ctype.h (isxdigit): Declare.
* mlibc/libc-gcc.c (isxdigit, _atoi): New function.
  (atoi): Use it.
* mlibc/libc-mes.c (isxdigit, _atoi): New function.
  (atoi): Use it.
* scaffold/tests/7j-strtoull.c (test): Test it.
* make.scm (add-scaffold-test): Build it.
2017-08-19 10:51:24 +02:00
Jan Nieuwenhuizen 3392f7241a mescc: Tinycc support: struct.struct.
* module/language/c99/compiler.mes (field:name):
  (field:pointer):
  (field:size):
  (field:type):
  (field-field):
  (field-offset):
  (struct-field): Support struct.struct.
* scaffold/tests/7i-struct-struct.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-08-10 21:36:49 +02:00
Jan Nieuwenhuizen 11d240e756 mescc: Tinycc support: struct assign by value.
* module/language/c99/compiler.mes (base->ident): Remove.
  (accu->ident): Use them to support assign of size >4 by value.
* scaffold/tests/7h-struct-assign.c: Test it.
* make.scm (add-scaffold-test): Build it.
* module/mes/as-i386.mes (i386:base->local): Remove.
  (i386:accu*n->local):
  (i386:accu*n->label): New functions.
* module/mes/as-i386.scm: Export them.
* stage0/x86.M1: (mov____%ebx,0x32):
  (mov____%ebx,0x32(%ebp)):
  (mov____%ebx,0x8(%ebp)):
  (mov____%ebx,0x8(%edx)):
  (mov____%ecx,0x32(%ebp)):
  (mov____%ecx,0x8(%ebp)):
  (mov____0x32(%eax),%ebx):
  (mov____0x32(%eax),%ecx):
  (mov____0x8(%eax),%ebx): New define.
2017-08-06 18:49:19 +02:00
Jan Nieuwenhuizen ba50d4bd25 mescc: Move simple main to scaffold.
* scaffold/main.c (main): Move from doc/examples/main.c
* make.scm: Build it.
* README: Update.
* guile/mescc.scm (main):
* scripts/mescc.mes (main): Remove fallback doc/examples/main.c
2017-08-06 13:14:09 +02:00
Jan Nieuwenhuizen 12b41e0e86 mescc: Tinycc support: byte and word struct fields.
* stage0/x86.M1 (mov____%al,0x8(%edx)):
  (mov____%ax,(%edx)):
  (mov____%ax,0x32(%edx)):
  (mov____%ax,0x8(%edx)):
  (movzbl_0x32(%eax),%eax):
  (movzbl_0x8(%eax),%eax):
  (movzwl_0x32(%eax),%eax):
  (movzwl_0x8(%eax),%eax): New define.
* module/mes/as-i386.mes (i386:word-accu->base-mem):
  (i386:byte-accu->base-mem+n):
  (i386:word-accu->base-mem+n):
  (i386:byte-mem+n->accu):
  (i386:word-mem+n->accu): New function.
* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes (struct-field): Use actual size for
  simple types (WAS: 4).
  (decl->info):
  (expr->accu): Respect byte and word struct field sizes.
* scaffold/tests/7g-struct-byte-word-field.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-08-06 12:27:16 +02:00
Jan Nieuwenhuizen 95f107282d mescc: Tinycc support: fixes for foo->bar[baz].
* module/language/c99/compiler.mes (expr->accu, expr->accu*): fixes
  for foo->bar[baz].
  (expr->pointer): Support i-sel.
  (p-expr->type): Support add, sub, de-ref, ref-to.
* scaffold/tests/7f-struct-pointer-arithmetic.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-08-05 19:10:00 +02:00
Jan Nieuwenhuizen 3f4cc96a7b mescc: Tinycc support: foo[index]->bar for array bar.
* module/language/c99/compiler.mes (expr->accu*): foo[index]->bar for array bar.
* scaffold/tests/7e-struct-array-access.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-08-04 21:45:29 +02:00
Jan Nieuwenhuizen 949e320622 mescc: Tinycc support: ((unsigned char*)str)[0].
* module/language/c99/compiler.mes (expr->accu): Consider size of
  expr array deref.
* stage0/x86.M1 (movzbl_0x32(%ebp),%eax): New define.
* scaffold/tests/7d-cast-char.c: Test it.
2017-08-04 11:34:01 +02:00
Jan Nieuwenhuizen 0b60a58809 mescc: Tinycc support: support foo.bar[baz], foo->bar[baz] for struct bar.
* module/language/c99/compiler.mes (struct-field): Use negative
  pointer for struct array fields.
  (expr->accu): support: support foo.bar[baz], foo->bar[baz] for struct bar.
* scaffold/tests/7c-dynarray.c: Test it.
2017-08-01 11:26:00 +02:00
Jan Nieuwenhuizen 1e37c9d9ea mescc: Tinycc support: ((foo*) p) + n.
* module/language/c99/compiler.mes init-declr->pointer, expr->pointer,
  expr->size): support: ((foo*) p) + n.
  (expr->accu*): Consider field size for foo.bar[baz].
* scaffold/tests/7b-struct-int-array.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-07-31 12:19:23 +02:00
Jan Nieuwenhuizen edb6bbcd9c mescc: Tinycc support: field size of foo.bar[baz], foo->bar[baz].
Inspired by a patch from rain1 for foo->bar[baz].

* module/language/c99/compiler.mes (expr->accu):
  (expr->accu*): Consider field size for foo.bar[baz].
* scaffold/tests/7a-struct-char-array.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-07-30 18:04:25 +02:00
Jan Nieuwenhuizen 9c4519af8d mescc: Tinycc support: int foo[bar] = {baz,...}.
* scaffold/tests/79-int-array.c: Test it.
* make.scm (add-scaffold-test): Build it.
* module/language/c99/compiler.mes (init-declr->count): New function.
  (decl->info): Support int foo[bar] = {baz,...}.
2017-07-30 08:27:05 +02:00
Jan Nieuwenhuizen bd3ab85e98 mescc: Tinycc support: union.struct.
* module/language/c99/compiler.mes (decl->info): Support struct inside union.
* scaffold/tests/78-union-struct.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-07-29 22:50:00 +02:00
Jan Nieuwenhuizen 2e0c1c0aff mescc: Tinycc support: bugfix *(cast)foo = bar.
* module/language/c99/compiler.mes (expr->accu): Thinko for de-ref assign.
* stage0/x86.M1: Fix typos.
* module/mes/as-i386.mes: Update for typos.
* scaffold/tests/77-pointer-assign.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-07-28 15:27:25 +02:00
Jan Nieuwenhuizen c7547dfd52 mescc: Tinycc support: pointer arithmetic.
* module/language/c99/compiler.mes (ident->size, expr->size): New function.
  (expr->accu): Use them for ++,--,add, sub.
  (i386:type-alist): Set void size to 1.
* scaffold/tests/71-struct-array.c (test):
* scaffold/tests/76-pointer-arithmetic.c: Test it.
* make.scm (add-scaffold-test): Build it.
2017-07-28 10:40:30 +02:00
Jan Nieuwenhuizen 397d7a6c43 mlibc: Tinycc support: gcc -nostdinc -nostdlib.
* mlibc/libc-gcc+tcc.c: New file.
* mlibc/include/dlfcn.h:
* mlibc/include/errno.h:
* mlibc/include/signal.h:
* mlibc/include/sys/mman.h:
* mlibc/include/sys/time.h:  Add tcc declarations.
2017-07-27 23:44:22 +02:00
Jan Nieuwenhuizen ba78b78203 build: support libc-mes+tcc. 2017-07-27 18:41:45 +02:00
Jan Nieuwenhuizen e1e8f03735 doc: Release udpate.
* HACKING: Update.
* INSTALL: Update.
* NEWS: Update.
* README: Update.
* doc/ANNOUNCE-0.9: New file.
* make.scm: Install it.
* guix.scm (mescc-tools): Bump to 0.2.
2017-07-26 15:57:38 +02:00
Jan Nieuwenhuizen 4b1de28449 build: Install and installed-run fixes.
* guile/mescc.scm (%datadir,%docdir,%moduledir,%version): Remove.
* scripts/mescc.mes: Likewise.
* module/language/c99/compiler.mes: Likewise.
 (%prefix): Prefer environment setting.
 (c99-input->full-ast): Remove unnecessary includes.
 Remove unnecessary defines.
* make.scm (%scm-files): Add mes/guile.scm.
 (src/mes.gcc, src/mes.mlibc-gcc, src/mes.guile):  Update  MODULEDIR,
 add -I src.
* src/mes.c (load_env): Use temporary variable for MODULEDIR concatenation.
  (bload_env): Likewise.
2017-07-26 15:57:38 +02:00
Jan Nieuwenhuizen ba6edad975 mescc: Tinycc support: close.
* stage0/x86.M1 (SYS_close): New define.
* mlibc/include/unistd.h (close): Declare.
* mlibc/libc-mes+tcc.c: New file.
* make.scm: Build and install it.
2017-07-26 11:36:44 +02:00
Jan Nieuwenhuizen 73726b2e27 mescc: Tinycc support: anonymous union.
* module/language/c99/compiler.mes (field:name): New function.
  (decl->info): Use it.
  (struct-field): Support anonymous union.
  (field:size): Update.
  (field-field): Update.
  (field-offset): Update.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 9b66421ce8 mescc: Tinycc support: multi-line strings.
* module/language/c99/compiler.mes (initzer->data, expr->global):
  Handle multi-line strings.
* scaffold/tests/74-multi-line-string.c: New file.
* make.scm (add-scaffold-test): Build it.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 3ae27f52e4 mescc: Tinycc support: union.
* scaffold/tests/73-union.c: New file.
* module/language/c99/compiler.mes (union->type-entry): New
  function.
  (decl->info): Support unions.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 07ee1fbf4f mescc: Tinycc support: struct.
* scaffold/tests/72-typedef-struct-def.c: New file.
* module/language/c99/compiler.mes (decl->info): Struct support for tinycc.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 94b3c828d3 mescc: Refactor decl.
* module/mes/as-i386.mes (i386:mem->base, i386:nop): New functions.
* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes:
* stage0/x86.M1 (nop,mov____(%edx),%edx,movzbl_(%edx),%edx): New defines.
* scaffold/tests/23-pointer.c: New file.
* scaffold/tests/t.c: New file.
* make.scm: Build them.
* module/language/c99/compiler.mes (init-declr->name): Handle array.
  (init-declr->pointer): Likewise.
  (ident->accu): Simplify.
  (ident->base): Simplify.
  (ident-address->base): Typo.
  (expr->accu): Simplify.
  (decl->info): Simplify.
* mlibc/libc-mes.c (getenv): Remove superfluous statement.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 52b09c5f17 mescc: Use records for Guile: preparation.
* module/language/c99/info.mes: New file.
* module/mes/M1.mes: Use it.
* scripts/mescc.mes: Use it.
* module/language/c99/compiler.mes: Use it.  (<info>, <types>,
  <constants>, <functions>, <globals>, <locals>, <function>, <text>,
  <break>, <continue>, make, info?, .info, .types, .constants,
  .functions, .globals, .locals, .function, .text, .break, .continue):
  Remove.
* module/language/c99/info.scm: New file.
* module/language/c99/compiler.scm: Use it.
* guile/mescc.scm: Use it.
* module/mes/M1.scm: Use it.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 81f3fb0ecf mescc: Refactor decl.
* module/language/c99/compiler.mes (decl->info, ptr-declr->pointer):
  New function.
  (ast->info): Use decl->info.
2017-07-26 11:36:08 +02:00
Jan Nieuwenhuizen 2de207076b build: Add make install.
* guile/guix/make.scm (method-cp, install, install-target?): New functions.
* make.scm: Use them.
2017-07-26 11:36:07 +02:00
Jan Nieuwenhuizen a7b7297ee2 build: Add target list.
* GNUmakefile (%): Handle all targets.
* make.scm (main): Show and implement target list.
2017-07-26 11:36:07 +02:00
Jan Nieuwenhuizen 1bddb52c75 build: Resurrect guile-2.0. Thanks rain1!
* module/mes/guile.scm: New file.
* module/mes/elf.scm: Include it.
* module/mes/bytevectors.scm: : Include it.
* module/mes/as.scm: Include it.
* module/mes/as-i386.scm: Include it.
* module/mes/M1.scm: Include it.
* module/language/c99/compiler.scm: Include it.
* make.scm: Update.
2017-07-26 11:36:07 +02:00
Jan Nieuwenhuizen 822d0df889 build: Non-Guix build robustifications. Thanks, rain1!
Fix typo in configure, gracefully switch between M0 vs M1, skip
CC32/i686-unknown-linux-gnu-gcc targets if not available, esp. for
non-Guix usage.

* configure (M1): Declare missing variable.
* make.scm (main): all-go, clean-go: New targets.
* GNUmakefile (PHONY_TARGETS): Add them.
  (.config.make): New target.
* guile/guix/make.scm (%CC32): Set to #f if not found.
  (bin.gcc): Skip if CC not set.
  (check-target?, add-target): Skip if target is not set.
2017-07-26 11:36:07 +02:00