mes.git
2 years agomescc: Tinycc support: anonymous union.
Jan Nieuwenhuizen [Sat, 22 Jul 2017 18:40:41 +0000 (20:40 +0200)]
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.

2 years agomescc: Tinycc support: declare struct tm.
Jan Nieuwenhuizen [Sat, 22 Jul 2017 07:22:11 +0000 (09:22 +0200)]
mescc: Tinycc support: declare struct tm.

* mlibc/include/time.h (struct tm): New type.

2 years agomescc: Tinycc support: ignore [ULL], UL, LL, L.
Jan Nieuwenhuizen [Fri, 21 Jul 2017 19:43:18 +0000 (21:43 +0200)]
mescc: Tinycc support: ignore [ULL], UL, LL, L.

* module/language/c99/compiler.mes (cstring->number): Drop suffix.

2 years agomescc: Tinycc support: ~, ^=.
Jan Nieuwenhuizen [Fri, 21 Jul 2017 08:39:04 +0000 (10:39 +0200)]
mescc: Tinycc support: ~, ^=.

* module/mes/as-i386.mes (i386:accu-not): New function.
  (i386:accu-negate): Rename from i386:accu-not.
* module/mes/as-i386.scm (mes): Export them.
* module/language/c99/compiler.mes (expr->accu): Support ~, ^=.
* scaffold/tests/60-math.c (test): Test it.
* stage0/x86.M1 (not____%eax): New define.

2 years agomescc: Tinycc support: struct.struct.
Jan Nieuwenhuizen [Tue, 18 Jul 2017 18:22:44 +0000 (20:22 +0200)]
mescc: Tinycc support: struct.struct.

* module/language/c99/compiler.mes (expr->accu): Support &*,
  bar.foo.i, p->foo.i, p->pf->i (*pp)->foo.i, [slightly modified] offsetof.
* scaffold/tests/72-typedef-struct-def.c (test): Test them.

2 years agomescc: Tinycc support: ***parameter.
Jan Nieuwenhuizen [Thu, 20 Jul 2017 23:02:17 +0000 (01:02 +0200)]
mescc: Tinycc support: ***parameter.

* module/language/c99/compiler.mes (.name): Support ***parameter.

2 years agomescc: Tinycc support: bitwise-or initializer.
Jan Nieuwenhuizen [Thu, 20 Jul 2017 22:21:31 +0000 (00:21 +0200)]
mescc: Tinycc support: bitwise-or initializer.

* module/language/c99/compiler.mes (initzer->value): New function.
  (initzer->data): Use it to support bitwise-or initializer.
* scaffold/tests/74-multi-line-string.c (test): Test it.

2 years agomescc: Tinycc support: char*[] in function.
Jan Nieuwenhuizen [Thu, 20 Jul 2017 22:09:18 +0000 (00:09 +0200)]
mescc: Tinycc support: char*[] in function.

* module/language/c99/compiler.mes (c99-input->full-ast): Add NULL.
  (decl->info): Support char* [] in function scope.
* scaffold/tests/71-struct-array.c (test) Test it.

2 years agomescc: Tinycc support: more list initializers.
Jan Nieuwenhuizen [Tue, 18 Jul 2017 06:04:50 +0000 (08:04 +0200)]
mescc: Tinycc support: more list initializers.

* module/language/c99/compiler.mes (init-declr->name): Handle array,
  pointer array.
  (init-declr->pointer): Likewise.
  (decl->info): Generalize list initializers, add pointer variant.
  FIXME: AST-rewriting?

2 years agomescc: Tinycc support: headers.
Jan Nieuwenhuizen [Mon, 17 Jul 2017 20:03:11 +0000 (22:03 +0200)]
mescc: Tinycc support: headers.

* mlibc/include/string.h (ssize_t): New type.
* mlibc/include/unistd.h (ssize_t): New type.

2 years agomescc: Tinycc support: sizeof struct field.
Jan Nieuwenhuizen [Mon, 17 Jul 2017 05:54:48 +0000 (07:54 +0200)]
mescc: Tinycc support: sizeof struct field.

* module/language/c99/compiler.mes (expr->accu): Sizeof struct field.
* scaffold/tests/72-typedef-struct-def.c (test): Test it.

2 years agomescc: Tinycc support: sizeof typename.
Jan Nieuwenhuizen [Mon, 17 Jul 2017 05:37:03 +0000 (07:37 +0200)]
mescc: Tinycc support: sizeof typename.

* module/language/c99/compiler.mes (expr->accu): Sizeof typename.

2 years agomescc: Tinycc support: pre/post-inc/dec more.
Jan Nieuwenhuizen [Mon, 17 Jul 2017 05:33:38 +0000 (07:33 +0200)]
mescc: Tinycc support: pre/post-inc/dec more.

* module/language/c99/compiler.mes (expr-add): New function.
  (expr->pointer): New function.
  (expr->accu): Use it to support broader pre/post-inc/dec..
* scaffold/tests/72-typedef-struct-def.c (test): Test it.

2 years agomescc: Tinycc support: comma operator.
Jan Nieuwenhuizen [Sun, 16 Jul 2017 22:29:18 +0000 (00:29 +0200)]
mescc: Tinycc support: comma operator.

* module/language/c99/compiler.mes (expr->accu): Handle comma operator.
* scaffold/tests/74-multi-line-string.c (test): Test it.

2 years agomescc: Tinycc support: assign pointer to struct field.
Jan Nieuwenhuizen [Sun, 16 Jul 2017 21:39:59 +0000 (23:39 +0200)]
mescc: Tinycc support: assign pointer to struct field.

* module/language/c99/compiler.mes (expr->accu, expr->accu*): Support
  pointer field selection.
* scaffold/tests/72-typedef-struct-def.c (test): Test it.

2 years agomescc: Tinycc support: multi-line strings.
Jan Nieuwenhuizen [Sun, 16 Jul 2017 20:59:07 +0000 (22:59 +0200)]
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.

2 years agomescc: Tinycc support: union.
Jan Nieuwenhuizen [Sun, 16 Jul 2017 18:54:59 +0000 (20:54 +0200)]
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.

2 years agomescc: Tinycc support: struct.
Jan Nieuwenhuizen [Sun, 16 Jul 2017 17:00:01 +0000 (19:00 +0200)]
mescc: Tinycc support: struct.

* scaffold/tests/72-typedef-struct-def.c: New file.
* module/language/c99/compiler.mes (decl->info): Struct support for tinycc.

2 years agomescc: Refactor decl.
Jan Nieuwenhuizen [Thu, 20 Jul 2017 08:05:48 +0000 (10:05 +0200)]
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.

2 years agomescc: Use records for Guile: <local>.
Jan Nieuwenhuizen [Sat, 15 Jul 2017 09:46:13 +0000 (11:46 +0200)]
mescc: Use records for Guile: <local>.

* module/language/c99/info.scm (<local>): New record.
* module/language/c99/compiler.mes (make-local-entry): Rename from
  make-local.  Update callers.
  (local-var?): Rename from local?. Update callers.
* module/language/c99/info.mes (make-local, local:type, local:pointer,
  local:id): Move from compiler.mes.

2 years agomescc: Use records for Guile: <global>.
Jan Nieuwenhuizen [Sat, 15 Jul 2017 09:24:14 +0000 (11:24 +0200)]
mescc: Use records for Guile: <global>.

* module/language/c99/info.scm (<global>): New record.
* module/language/c99/compiler.mes (make-global-entry): Rename from
  make-global.  Update callers.
* module/language/c99/info.mes (make-global, global:type,
  global:pointer, global:value): Move from compiler.mes.

2 years agomescc: Use records for Guile: <type>.
Jan Nieuwenhuizen [Sat, 15 Jul 2017 08:40:31 +0000 (10:40 +0200)]
mescc: Use records for Guile: <type>.

* module/language/c99/info.scm (<type>): New record.
* module/language/c99/compiler.mes (make-type-entry): Rename from
  make-type.  Update-callers.
* module/language/c99/info.mes (make-type, type:type, type:size,
  type:pointer, type:description): Move from compiler.mes.

2 years agomescc: Use records for Guile: <info>.
Jan Nieuwenhuizen [Fri, 14 Jul 2017 19:26:35 +0000 (21:26 +0200)]
mescc: Use records for Guile: <info>.

* module/language/c99/info.scm (<info>): Make immutable record.
  Update users.

2 years agomescc: Use records for Guile: preparation.
Jan Nieuwenhuizen [Fri, 14 Jul 2017 18:42:26 +0000 (20:42 +0200)]
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.

2 years agomescc: Refactor decl.
Jan Nieuwenhuizen [Wed, 12 Jul 2017 04:55:05 +0000 (06:55 +0200)]
mescc: Refactor decl.

* module/language/c99/compiler.mes (decl->info, ptr-declr->pointer):
  New function.
  (ast->info): Use decl->info.

2 years agoguix: Update build.
Jan Nieuwenhuizen [Thu, 20 Jul 2017 21:17:54 +0000 (23:17 +0200)]
guix: Update build.

* guix.scm (mes): Do not strip.  Fixes mes binary.

2 years agobuild: support Guix.
Jan Nieuwenhuizen [Thu, 20 Jul 2017 06:16:54 +0000 (08:16 +0200)]
build: support Guix.

* guile/guix/make.scm (link-or-cp): New function.
  (assert-link, store): Use it.

2 years agobuild: Add make install.
Jan Nieuwenhuizen [Wed, 19 Jul 2017 21:47:23 +0000 (23:47 +0200)]
build: Add make install.

* guile/guix/make.scm (method-cp, install, install-target?): New functions.
* make.scm: Use them.

2 years agobuild: Add target list.
Jan Nieuwenhuizen [Wed, 19 Jul 2017 17:53:21 +0000 (19:53 +0200)]
build: Add target list.

* GNUmakefile (%): Handle all targets.
* make.scm (main): Show and implement target list.

2 years agobuild: Ignore some files.
Jan Nieuwenhuizen [Wed, 19 Jul 2017 17:31:48 +0000 (19:31 +0200)]
build: Ignore some files.

.gitignore: Update for make.scm.

2 years agobuild: Bugfix for store.
Jan Nieuwenhuizen [Wed, 19 Jul 2017 17:11:26 +0000 (19:11 +0200)]
build: Bugfix for store.

* guile/guix/make.scm (store): Add each store file only once.

2 years agobuild: Resurrect guile-2.0. Thanks rain1!
Jan Nieuwenhuizen [Fri, 21 Jul 2017 22:29:57 +0000 (00:29 +0200)]
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.

2 years agobuild: Non-Guix build robustifications. Thanks, rain1!
Jan Nieuwenhuizen [Wed, 19 Jul 2017 12:12:29 +0000 (14:12 +0200)]
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.

2 years agobuild: Fix snarf dependencies.
Jan Nieuwenhuizen [Sat, 15 Jul 2017 12:56:19 +0000 (14:56 +0200)]
build: Fix snarf dependencies.

* guile/guix/make.scm (compile.gcc compile.mescc bin.mescc m1-asm):
  Accept and forward dependencies.
* make.scm (gcc-snarf-targets): Remove explicit defaults.

2 years agobuild: Use released M0 intead of M1.
Jan Nieuwenhuizen [Wed, 12 Jul 2017 17:41:31 +0000 (19:41 +0200)]
build: Use released M0 intead of M1.

2 years agomescc: Import tinycc test suite.
Jan Nieuwenhuizen [Sun, 9 Jul 2017 16:33:56 +0000 (18:33 +0200)]
mescc: Import tinycc test suite.

* make.scm (check-scaffold-tinycc): New target.
* guile/guix/make.scm (<target>): Add baseline field.
  (method-check): Handle baseline.
* scaffold/tinycc/00_assignment.c: New file.
* scaffold/tinycc/00_assignment.expect: New file.
* scaffold/tinycc/01_comment.c: New file.
* scaffold/tinycc/01_comment.expect: New file.
* scaffold/tinycc/02_printf.c: New file.
* scaffold/tinycc/02_printf.expect: New file.
* scaffold/tinycc/03_struct.c: New file.
* scaffold/tinycc/03_struct.expect: New file.
* scaffold/tinycc/04_for.c: New file.
* scaffold/tinycc/04_for.expect: New file.
* scaffold/tinycc/05_array.c: New file.
* scaffold/tinycc/05_array.expect: New file.
* scaffold/tinycc/06_case.c: New file.
* scaffold/tinycc/06_case.expect: New file.
* scaffold/tinycc/07_function.c: New file.
* scaffold/tinycc/07_function.expect: New file.
* scaffold/tinycc/08_while.c: New file.
* scaffold/tinycc/08_while.expect: New file.
* scaffold/tinycc/09_do_while.c: New file.
* scaffold/tinycc/09_do_while.expect: New file.
* scaffold/tinycc/10_pointer.c: New file.
* scaffold/tinycc/10_pointer.expect: New file.
* scaffold/tinycc/11_precedence.c: New file.
* scaffold/tinycc/11_precedence.expect: New file.
* scaffold/tinycc/12_hashdefine.c: New file.
* scaffold/tinycc/12_hashdefine.expect: New file.
* scaffold/tinycc/13_integer_literals.c: New file.
* scaffold/tinycc/13_integer_literals.expect: New file.
* scaffold/tinycc/14_if.c: New file.
* scaffold/tinycc/14_if.expect: New file.
* scaffold/tinycc/15_recursion.c: New file.
* scaffold/tinycc/15_recursion.expect: New file.
* scaffold/tinycc/16_nesting.c: New file.
* scaffold/tinycc/16_nesting.expect: New file.
* scaffold/tinycc/17_enum.c: New file.
* scaffold/tinycc/17_enum.expect: New file.
* scaffold/tinycc/18_include.h: New file.
* scaffold/tinycc/18_include.c: New file.
* scaffold/tinycc/18_include.expect: New file.
* scaffold/tinycc/19_pointer_arithmetic.c: New file.
* scaffold/tinycc/19_pointer_arithmetic.expect: New file.
* scaffold/tinycc/20_pointer_comparison.c: New file.
* scaffold/tinycc/20_pointer_comparison.expect: New file.
* scaffold/tinycc/21_char_array.c: New file.
* scaffold/tinycc/21_char_array.expect: New file.
* scaffold/tinycc/22_floating_point.c: New file.
* scaffold/tinycc/22_floating_point.expect: New file.
* scaffold/tinycc/23_type_coercion.c: New file.
* scaffold/tinycc/23_type_coercion.expect: New file.
* scaffold/tinycc/24_math_library.c: New file.
* scaffold/tinycc/24_math_library.expect: New file.
* scaffold/tinycc/25_quicksort.c: New file.
* scaffold/tinycc/25_quicksort.expect: New file.
* scaffold/tinycc/26_character_constants.c: New file.
* scaffold/tinycc/26_character_constants.expect: New file.
* scaffold/tinycc/27_sizeof.c: New file.
* scaffold/tinycc/27_sizeof.expect: New file.
* scaffold/tinycc/28_strings.c: New file.
* scaffold/tinycc/28_strings.expect: New file.
* scaffold/tinycc/29_array_address.c: New file.
* scaffold/tinycc/29_array_address.expect: New file.
* scaffold/tinycc/30_hanoi.c: New file.
* scaffold/tinycc/30_hanoi.expect: New file.
* scaffold/tinycc/31_args.c: New file.
* scaffold/tinycc/31_args.expect: New file.
* scaffold/tinycc/32_led.c: New file.
* scaffold/tinycc/32_led.expect: New file.
* scaffold/tinycc/33_ternary_op.c: New file.
* scaffold/tinycc/33_ternary_op.expect: New file.
* scaffold/tinycc/34_array_assignment.c: New file.
* scaffold/tinycc/34_array_assignment.expect: New file.
* scaffold/tinycc/35_sizeof.c: New file.
* scaffold/tinycc/35_sizeof.expect: New file.
* scaffold/tinycc/36_array_initialisers.c: New file.
* scaffold/tinycc/36_array_initialisers.expect: New file.
* scaffold/tinycc/37_sprintf.c: New file.
* scaffold/tinycc/37_sprintf.expect: New file.
* scaffold/tinycc/38_multiple_array_index.c: New file.
* scaffold/tinycc/38_multiple_array_index.expect: New file.
* scaffold/tinycc/39_typedef.c: New file.
* scaffold/tinycc/39_typedef.expect: New file.
* scaffold/tinycc/40_stdio.c: New file.
* scaffold/tinycc/40_stdio.expect: New file.
* scaffold/tinycc/41_hashif.c: New file.
* scaffold/tinycc/41_hashif.expect: New file.
* scaffold/tinycc/42_function_pointer.c: New file.
* scaffold/tinycc/42_function_pointer.expect: New file.
* scaffold/tinycc/43_void_param.c: New file.
* scaffold/tinycc/43_void_param.expect: New file.
* scaffold/tinycc/44_scoped_declarations.c: New file.
* scaffold/tinycc/44_scoped_declarations.expect: New file.
* scaffold/tinycc/45_empty_for.c: New file.
* scaffold/tinycc/45_empty_for.expect: New file.
* scaffold/tinycc/46_grep.c: New file.
* scaffold/tinycc/46_grep.expect: New file.
* scaffold/tinycc/47_switch_return.c: New file.
* scaffold/tinycc/47_switch_return.expect: New file.
* scaffold/tinycc/48_nested_break.c: New file.
* scaffold/tinycc/48_nested_break.expect: New file.
* scaffold/tinycc/49_bracket_evaluation.c: New file.
* scaffold/tinycc/49_bracket_evaluation.expect: New file.
* scaffold/tinycc/50_logical_second_arg.c: New file.
* scaffold/tinycc/50_logical_second_arg.expect: New file.
* scaffold/tinycc/51_static.c: New file.
* scaffold/tinycc/51_static.expect: New file.
* scaffold/tinycc/52_unnamed_enum.c: New file.
* scaffold/tinycc/52_unnamed_enum.expect: New file.
* scaffold/tinycc/54_goto.c: New file.
* scaffold/tinycc/54_goto.expect: New file.
* scaffold/tinycc/55_lshift_type.c: New file.
* scaffold/tinycc/55_lshift_type.expect: New file.
* scaffold/tinycc/56_btype_excess-1.c: New file.
* scaffold/tinycc/56_btype_excess-1.expect: New file.
* scaffold/tinycc/57_btype_excess-2.c: New file.
* scaffold/tinycc/57_btype_excess-2.expect: New file.
* scaffold/tinycc/58_function_redefinition.c: New file.
* scaffold/tinycc/58_function_redefinition.expect: New file.
* scaffold/tinycc/59_function_array.c: New file.
* scaffold/tinycc/59_function_array.expect: New file.
* scaffold/tinycc/60_enum_redefinition.c: New file.
* scaffold/tinycc/60_enum_redefinition.expect: New file.
* scaffold/tinycc/61_undefined_enum.c: New file.
* scaffold/tinycc/61_undefined_enum.expect: New file.
* scaffold/tinycc/62_enumerator_redefinition.c: New file.
* scaffold/tinycc/62_enumerator_redefinition.expect: New file.
* scaffold/tinycc/63_local_enumerator_redefinition.c: New file.
* scaffold/tinycc/63_local_enumerator_redefinition.expect: New file.
* scaffold/tinycc/64_macro_nesting.c: New file.
* scaffold/tinycc/64_macro_nesting.expect: New file.
* scaffold/tinycc/67_macro_concat.c: New file.
* scaffold/tinycc/67_macro_concat.expect: New file.
* scaffold/tinycc/70_floating_point_literals.c: New file.
* scaffold/tinycc/70_floating_point_literals.expect: New file.
* scaffold/tinycc/71_macro_empty_arg.c: New file.
* scaffold/tinycc/71_macro_empty_arg.expect: New file.
* scaffold/tinycc/72_long_long_constant.c: New file.
* scaffold/tinycc/72_long_long_constant.expect: New file.
* scaffold/tinycc/73_arm64.c: New file.
* scaffold/tinycc/73_arm64.expect: New file.
* scaffold/tinycc/74_nocode_wanted.c: New file.
* scaffold/tinycc/74_nocode_wanted.expect: New file.
* scaffold/tinycc/75_array_in_struct_init.c: New file.
* scaffold/tinycc/75_array_in_struct_init.expect: New file.
* scaffold/tinycc/76_dollars_in_identifiers.c: New file.
* scaffold/tinycc/76_dollars_in_identifiers.expect: New file.
* scaffold/tinycc/77_push_pop_macro.c: New file.
* scaffold/tinycc/77_push_pop_macro.expect: New file.
* scaffold/tinycc/78_vla_label.c: New file.
* scaffold/tinycc/78_vla_label.expect: New file.
* scaffold/tinycc/79_vla_continue.c: New file.
* scaffold/tinycc/79_vla_continue.expect: New file.
* scaffold/tinycc/80_flexarray.c: New file.
* scaffold/tinycc/80_flexarray.expect: New file.
* scaffold/tinycc/81_types.c: New file.
* scaffold/tinycc/81_types.expect: New file.
* scaffold/tinycc/82_attribs_position.c: New file.
* scaffold/tinycc/82_attribs_position.expect: New file.
* scaffold/tinycc/83_utf8_in_identifiers.c: New file.
* scaffold/tinycc/83_utf8_in_identifiers.expect: New file.
* scaffold/tinycc/84_hex-float.c: New file.
* scaffold/tinycc/84_hex-float.expect: New file.
* scaffold/tinycc/85_asm-outside-function.c: New file.
* scaffold/tinycc/85_asm-outside-function.expect: New file.
* scaffold/tinycc/86_memory-model.c: New file.
* scaffold/tinycc/86_memory-model.expect: New file.
* scaffold/tinycc/87_dead_code.c: New file.
* scaffold/tinycc/87_dead_code.expect: New file.
* scaffold/tinycc/88_codeopt.c: New file.
* scaffold/tinycc/88_codeopt.expect: New file.
* scaffold/tinycc/89_nocode_wanted.c: New file.
* scaffold/tinycc/89_nocode_wanted.expect: New file.
* scaffold/tinycc/90_struct-init.c: New file.
* scaffold/tinycc/90_struct-init.expect: New file.
* scaffold/tinycc/91_ptr_longlong_arith32.c: New file.
* scaffold/tinycc/91_ptr_longlong_arith32.expect: New file.
* scaffold/tinycc/92_enum_bitfield.c: New file.
* scaffold/tinycc/92_enum_bitfield.expect: New file.
* scaffold/tinycc/93_integer_promotion.c: New file.
* scaffold/tinycc/93_integer_promotion.expect: New file.
* scaffold/tinycc/COPYING: New file.
* scaffold/tinycc/LICENSE: New file.

include

2 years agotest: Split-up Mescc scaffold test.
Jan Nieuwenhuizen [Sun, 9 Jul 2017 07:24:07 +0000 (09:24 +0200)]
test: Split-up Mescc scaffold test.

* make.scm (check-scaffold, check-scaffold-tests): New targets.
* mlibc/include/00-test.i: New file.
* mlibc/include/30-test.i: New file.
* mlibc/mini-libc-mes.c (puts): New function.
* scaffold/tests/00-exit-0.c: : New file.
* scaffold/tests/01-return-0.c: : New file.
* scaffold/tests/02-return-1.c: : New file.
* scaffold/tests/03-call.c: : New file.
* scaffold/tests/04-call-0.c: : New file.
* scaffold/tests/05-call-1.c: : New file.
* scaffold/tests/06-call-!1.c: : New file.
* scaffold/tests/10-if-0.c: : New file.
* scaffold/tests/11-if-1.c: : New file.
* scaffold/tests/12-if-==.c: : New file.
* scaffold/tests/13-if-!=.c: : New file.
* scaffold/tests/14-if-goto.c: : New file.
* scaffold/tests/15-if-!f.c: : New file.
* scaffold/tests/16-if-t.c: : New file.
* scaffold/tests/20-while.c: : New file.
* scaffold/tests/21-char[].c: : New file.
* scaffold/tests/22-while-char[].c: : New file.
* scaffold/tests/30-strlen.c: : New file.
* scaffold/tests/31-eputs.c: : New file.
* scaffold/tests/32-compare.c: : New file.
* scaffold/tests/33-and-or.c: : New file.
* scaffold/tests/34-pre-post.c: : New file.
* scaffold/tests/35-compare-char.c: : New file.
* scaffold/tests/36-compare-arithmetic.c: : New file.
* scaffold/tests/37-compare-assign.c: : New file.
* scaffold/tests/38-compare-call.c: : New file.
* scaffold/tests/40-if-else.c: : New file.
* scaffold/tests/41-?.c: : New file.
* scaffold/tests/42-goto-label.c: : New file.
* scaffold/tests/43-for-do-while.c: : New file.
* scaffold/tests/44-switch.c: : New file.
* scaffold/tests/45-void-call.c: : New file.
* scaffold/tests/50-assert.c: : New file.
* scaffold/tests/51-strcmp.c: : New file.
* scaffold/tests/52-itoa.c: : New file.
* scaffold/tests/53-strcpy.c: : New file.
* scaffold/tests/54-argv.c: : New file.
* scaffold/tests/60-math.c: : New file.
* scaffold/tests/61-array.c: : New file.
* scaffold/tests/63-struct-cell.c: : New file.
* scaffold/tests/64-make-cell.c: : New file.
* scaffold/tests/65-read.c: : New file.
* scaffold/tests/66-struct-array.c: : New file.
* scaffold/t.c: Remove.
* scaffold/t-tcc.c: Remove.

2 years agomescc: Avoid warnings in recursve functions.
Jan Nieuwenhuizen [Sun, 9 Jul 2017 09:01:30 +0000 (11:01 +0200)]
mescc: Avoid warnings in recursve functions.

* module/language/c99/compiler.mes (expr->accu): Avoid warnings in recursve functions.

2 years agomescc: undefine __GNUC__.
Jan Nieuwenhuizen [Sun, 9 Jul 2017 07:26:04 +0000 (09:26 +0200)]
mescc: undefine __GNUC__.

* module/language/c99/compiler.mes (c99-input->full-ast): Remove
  __GNUC__=0.  Should help compiling pcc, libguile/eval.c.

2 years agomescc: Support stdarg.
Jan Nieuwenhuizen [Wed, 5 Jul 2017 16:48:08 +0000 (18:48 +0200)]
mescc: Support stdarg.

* mlibc/include/stdarg.h (va_list): New type.
  (va_start, va_arg, va_end, va_copy): New macro.
  (vprintf): New declaration.
* mlibc/libc-mes.c (vprintf): New function.
  (printf): Rewrite using vprintf.
* module/language/c99/compiler.mes (expr->accu, expr->accu*): Handle
  any array.  Limitation: element size must be 4/sizeof (expression).
  (make-type): Add value pointer to type.
  (type:type, type:size, type:pointer, type:description): New functions.
  (ast->info): Handle typedef with pointer.

2 years agobuild: Remove make.
Jan Nieuwenhuizen [Sun, 2 Jul 2017 10:03:29 +0000 (12:03 +0200)]
build: Remove make.

* GNUmakefile: trivial convenience-frontend to ./make.scm
* make/*.make: Remove.
* */*.make: Remove.

2 years agomescc: Produce M1 output instead of hex2.
Jan Nieuwenhuizen [Sun, 2 Jul 2017 14:25:14 +0000 (16:25 +0200)]
mescc: Produce M1 output instead of hex2.

Use: ./make.scm [TARGET]
     ./make.scm check

* stage0/x86.M1: New file.
* mlibc/mini-libc-mes.c (exit, write): Use M1 instead of .byte.
* mlibc/libc-mes.c (_start, exit, read, write, open, access, brk,
  fsync, printf): Use M1 instead of .byte.
* module/mes/as-i386.mes: Use M1.
* module/mes/make.scm: New file.
* make.scm: New file.
* guile/guix/records.scm: New File.
* guile/guix/shell-utils.scm: New file.
* module/mes/M1.mes: Rename from hex2.mes.
* module/mes/M1.scm: Rename from hex2.scm.
* scripts/mescc.mes: Update callers.
* guile/mescc.scm: Update callers.

2 years agomescc: Add headers for guile:eval.c.
Jan Nieuwenhuizen [Sun, 18 Jun 2017 15:54:33 +0000 (17:54 +0200)]
mescc: Add headers for guile:eval.c.

* mlibc/include/alloca.h: New file.
* mlibc/include/stdint.h: New file.
* mlibc/include/inttypes.h: Remove definitionss, include stdint.h.

2 years agomescc: Add headers for 8cc.
Jan Nieuwenhuizen [Sun, 18 Jun 2017 14:12:15 +0000 (16:12 +0200)]
mescc: Add headers for 8cc.

* mlibc/include/libgen.h: New file.
* mlibc/include/locale.hh: New file.
* mlibc/include/stdbool.h: New file.
* mlibc/include/stdnoreturn.h: New file.
* mlibc/include/time.h: Add time_t.

2 years agoguix: Add missing module.
Jan Nieuwenhuizen [Tue, 27 Jun 2017 05:53:29 +0000 (07:53 +0200)]
guix: Add missing module.

* guix.scm: Use (guix download).  Fixes compilation with mescc-tools included.

2 years agoguix: Add mescc-tools.
Jan Nieuwenhuizen [Mon, 26 Jun 2017 18:29:14 +0000 (20:29 +0200)]
guix: Add mescc-tools.

* guix.scm (mescc-tools): New variable.  Fixes using guix.scm.  Thanks paroneayea!

2 years agoRelease 0.8. v0.8
Jan Nieuwenhuizen [Sun, 25 Jun 2017 16:36:25 +0000 (18:36 +0200)]
Release 0.8.

* configure (VERSION): Bump.

2 years agobuild: Release update.
Jan Nieuwenhuizen [Sun, 25 Jun 2017 15:40:38 +0000 (17:40 +0200)]
build: Release update.

* configure (main): Make hex2 required.
* guix.scm (mes): Add mescc-tools to propagated-inputs.  Update commit, hash.

2 years agodoc: Release update.
Jan Nieuwenhuizen [Thu, 8 Jun 2017 18:39:24 +0000 (20:39 +0200)]
doc: Release update.

* NEWS: Update.
* INSTALL: Update.
* HACKING: Update.
* doc/ANNOUNCE-0.8: New file.

2 years agomescc: Remove ELF creation, handled by hex2 now.
Jan Nieuwenhuizen [Sun, 25 Jun 2017 07:26:25 +0000 (09:26 +0200)]
mescc: Remove ELF creation, handled by hex2 now.

* module/language/c99/compiler.scm (make-global, global:type,
  global:pointer, global:value): Move from elf-util.mes
* module/mes/as.mes: New file.
* module/mes/as-i386.mes: Use it.
* module/mes/as-i386.scm: Use it.
* module/mes/elf-util.mes: Remove.
* module/mes/elf.mes (elf32-addr, elf32-half, elf32-off, elf32-word,
  make-elf, write-any, object->elf): Remove
  (hex2->elf): New function with dummy implementation.
* module/mes/elf.scm: Update exports.
* module/mes/hex2.mes (object->elf): New function.
* module/mes/hex2.scm: Export it.

2 years agomescc: Produce object files in hex2 format, remove hex3.
Jan Nieuwenhuizen [Sun, 25 Jun 2017 07:33:55 +0000 (09:33 +0200)]
mescc: Produce object files in hex2 format, remove hex3.

* GNUmakefile (HEX2_FLAGS): New variable.
* make/mescc-guile.make ($(OUT)/$(TARGET)): Use HEX2 for linking.
* make/mescc-mes.make ($(OUT)/$(TARGET)): Likewise.
* guile/mescc.scm (main): Remove hex3 support.
* scripts/mescc.mes (main): Likewise.
* stage0/elf32-0header.hex2: New file, merging of elf32.hex and elf32-header.hex2.
* stage0/elf-0footer.hex2: New file.
* stage0/elf32-header.hex2: Rename from elf32-header-exit-42.hex2,
  repurpose as generic debug heder.
* stage0/elf32-footer-single-main.hex2: Rename from elf32-footer-exit-42.hex2,
  repurpose as generic debug footer for single-main source.
* stage0/exit-42.c: New file.
* stage0/stage0.make ($(OUT)/0exit-42): Test 0header, 0footer.
  ($(OUT)/exit-42.guile): Test generic debug header, footer.
* stage0/elf32.hex2: Remove.

2 years agobuild: Add stage0 hex2 test.
Jan Nieuwenhuizen [Fri, 23 Jun 2017 18:18:09 +0000 (20:18 +0200)]
build: Add stage0 hex2 test.

* configure (HEX2): Check for hex2 from MESCC_tools.
* INSTALL: Mention it.
* GNUmakefile (SUBDIRS): Add stage0.
* make/check-cc.make: New file.
* make/check.make: Remove CC-not-empty guard.
* scaffold/scaffold.make: Update CC check targets.

2 years agostage0: Move to-be-generated part of body to footer.
Jan Nieuwenhuizen [Wed, 21 Jun 2017 05:05:26 +0000 (07:05 +0200)]
stage0: Move to-be-generated part of body to footer.

* stage0/elf32-footer-exit-42.hex2: Add ELF_str, ELF_sym from body.
* stage0/elf32-body-exit-42.hex2: Remove ELF_str, ELF_sym.

2 years agostage0: Leverage label>base in stage0 gdb header.
Jan Nieuwenhuizen [Mon, 19 Jun 2017 20:45:51 +0000 (22:45 +0200)]
stage0: Leverage label>base in stage0 gdb header.

* stage0/elf32-header-exit-42.hex2: Replace calculated addresses with label>base.
* stage0/elf32-body-exit-42.hex2: Likewise.

2 years agostage0: Move stage0's section-headers before text.
Jan Nieuwenhuizen [Mon, 19 Jun 2017 07:52:27 +0000 (09:52 +0200)]
stage0: Move stage0's section-headers before text.

* stage0/elf32-header-exit-42.hex2: Add section-headers.
* stage0/elf32-body-exit-42.hex2: Update.
* stage0/elf32-footer-exit-42.hex2: Remove section-headers.

2 years agostage0: Add stage0 hex2 gdb header and footer example.
Jan Nieuwenhuizen [Sun, 18 Jun 2017 19:06:27 +0000 (21:06 +0200)]
stage0: Add stage0 hex2 gdb header and footer example.

* stage0/elf32-header-exit-42.hex2: New file.
* stage0/elf32-footer-exit-42.hex2: New file.

2 years agomescc: Remove jump calculation, use labels: rename jumps.
Jan Nieuwenhuizen [Tue, 13 Jun 2017 18:31:03 +0000 (20:31 +0200)]
mescc: Remove jump calculation, use labels: rename jumps.

* module/mes/as-i386.mes (i386:jump, i386:jump-byte-z, i386:jump-g,
  i386:jump-ge, i386:jump-nc, i386:jump-ncz, i386:jump-nz,
  i386:jump-z): Rename from i386:jump-label*.
* module/mes/as-i386.scm (mes): Update exports.
* module/language/c99/compiler.mes (ast->info): Update callers.

2 years agomescc: Remove jump calculation, use labels: remove offset-jumps.
Jan Nieuwenhuizen [Tue, 13 Jun 2017 18:27:40 +0000 (20:27 +0200)]
mescc: Remove jump calculation, use labels: remove offset-jumps.

* module/mes/as-i386.mes (i386:XXjump, i386:Xjump, i386:Xjump-c,
  i386:Xjump-cz, i386:Xjump-g, i386:Xjump-ge, i386:Xjump-l,
  i386:Xjump-le, i386:Xjump-nc, i386:Xjump-ncz, i386:Xjump-ncz",
  i386:Xjump-nz, i386:Xjump-z, i386:jump, i386:jump-byte-nz,
  i386:jump-byte-z, i386:jump-c, i386:jump-cz, i386:jump-le,
  i386:jump-nc, i386:jump-ncz, i386:jump-nz, i386:jump-z,
  i386:test-jump-z): Remove.
* module/mes/as-i386.scm: Remove export.

2 years agomescc: Remove jump calculation, use labels: cleanup.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 18:58:49 +0000 (20:58 +0200)]
mescc: Remove jump calculation, use labels: cleanup.

* module/language/c99/compiler.mes (test->jump->info): Remove.

2 years agomescc: Remove jump calculation, use labels: switch.
Jan Nieuwenhuizen [Tue, 13 Jun 2017 18:20:38 +0000 (20:20 +0200)]
mescc: Remove jump calculation, use labels: switch.

* module/language/c99/compiler.mes (expr->accu): Refactor (switch ...).
  (clause->info): Refactor.

2 years agomescc: Remove jump calculation, use labels: and, or.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 20:11:19 +0000 (22:11 +0200)]
mescc: Remove jump calculation, use labels: and, or.

* module/language/c99/compiler.mes (expr->accu): Refactor (and
  ...), (or ...).

2 years agomescc: Remove jump calculation, use labels: if.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 18:11:37 +0000 (20:11 +0200)]
mescc: Remove jump calculation, use labels: if.

* module/language/c99/compiler.mes (ast->info): Refactor (if ...)
  using test-jump-label->info.

2 years agomescc: Remove jump calculation, use labels: for.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 17:46:35 +0000 (19:46 +0200)]
mescc: Remove jump calculation, use labels: for.

* module/language/c99/compiler.mes (ast->info): Refactor (for ...)
  using test-jump-label->info.

2 years agomescc: Remove jump calculation, use labels: do while.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 17:00:24 +0000 (19:00 +0200)]
mescc: Remove jump calculation, use labels: do while.

* module/language/c99/compiler.mes (ast->info): Refactor (do-while
  ...)  using test-jump-label->info.

2 years agomescc: Remove jump calculation, use labels: ?.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 16:43:25 +0000 (18:43 +0200)]
mescc: Remove jump calculation, use labels: ?.

* module/language/c99/compiler.mes (ast->info): Refactor (cond-expr
  ...)  using test-jump-label->info.

2 years agomescc: Support continue in while.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 15:10:29 +0000 (17:10 +0200)]
mescc: Support continue in while.

* module/language/c99/compiler.mes (make): Add continue field.
  (.continue): New function.
  (clone): Support continue field.
  (ast->info): Support continue.
* scaffold/t.c (test): Test it.

2 years agomescc: Remove jump calculation, use labels: while.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 19:06:12 +0000 (21:06 +0200)]
mescc: Remove jump calculation, use labels: while.

* module/language/c99/compiler.mes (ast->info): Refactor (while ...)
  using test-jump-label->info.

2 years agomescc: Remove jump calculation, use labels: prepare.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 19:00:50 +0000 (21:00 +0200)]
mescc: Remove jump calculation, use labels: prepare.

* module/language/c99/compiler.mes (test-jump-label->info): New
  function.
* module/mes/as-i386.mes (i386:jump-label-z,i386:jump-label-byte-z,
  i386:jump-label-g, i386:jump-label-ge,i386:jump-label-nz): New
  functions.
* module/mes/as-i386.scm: Export them.

2 years agomescc: Remove duplication of string globals.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 08:49:31 +0000 (10:49 +0200)]
mescc: Remove duplication of string globals.

* module/language/c99/compiler.mes (expr->global): Curry-in globals.
  Update callers.
  (initzer->global): Likewise.

2 years agomescc: Unify labels.
Jan Nieuwenhuizen [Sun, 11 Jun 2017 16:05:56 +0000 (18:05 +0200)]
mescc: Unify labels.

* module/language/c99/compiler.mes: Use (#:address label) (#local
  label) (#:relative label) thoughout.
* module/mes/elf-util.mes (add-s:-prefix, drop-s:-prefix): Remove.
  (function->text): Update.
* module/mes/hex2.mes (write-hex2): Update.

2 years agomescc: Write object files in hex2 or hex3 format.
Jan Nieuwenhuizen [Sun, 11 Jun 2017 11:11:40 +0000 (13:11 +0200)]
mescc: Write object files in hex2 or hex3 format.

* stage0/elf32.hex2: New file.
* module/mes/hex2.mes: New file.
* module/mes/hex2.scm: New file.
* module/language/c99/compiler.mes: Eradicate object lamdas.
  (current-eval, dec-xhex, function:-object->text, object->elf,
  object->objects, merge-objects, alist-add): Remove.
* module/mes/elf.mes (object->elf): New function, move from compiler.mes.
* module/mes/elf.scm: Export it.
* guile/mescc.scm (parse-opts): Add -g.
  (main): Use it.
* scripts/mescc.mes: Likewise.
* scripts/mescc-guile.make (MESCC.scm, MESLD.scm): Add -g flag.
* scripts/mescc-mes.make (MESCC.mes, MESLD.mes): Likewise.
* scaffold/m.c: Add proper includes.
* scaffold/argv.c: New file.
* scaffold/hello.c: Simplify.
* scaffold/micro-mes.c: Add proper includes.
* scaffold/t.c: Add proper includes.

2 years agocore: %moduledir ends with /.
Jan Nieuwenhuizen [Mon, 12 Jun 2017 15:18:31 +0000 (17:18 +0200)]
core: %moduledir ends with /.

* make/install.make (MODULEDIR): Append /.
  (install): Remove /.
* src/mes.c (load_env, bload_env): Update.

2 years agomescc: Put _start at top of mlibc.
Jan Nieuwenhuizen [Sun, 11 Jun 2017 11:01:46 +0000 (13:01 +0200)]
mescc: Put _start at top of mlibc.

* mlibc/libc-mes.c (_start): Move to top.
* mlibc/mini-libc-mes.c (_start): Likewise.
* module/mes/elf-util.mes (function-prefix): Update for _start == 0.
  (function-offset): Likewise.

2 years agomes: Add list-index.
Jan Nieuwenhuizen [Sun, 11 Jun 2017 12:45:01 +0000 (14:45 +0200)]
mes: Add list-index.

* module/srfi/srfi-1.scm (list-index): New function.

2 years agobuild: Bugfix add prepocess dependency on snarfing mes.
Jan Nieuwenhuizen [Thu, 8 Jun 2017 04:57:24 +0000 (06:57 +0200)]
build: Bugfix add prepocess dependency on snarfing mes.

* src/src.make ($(OUT)/$(DIR)/mes.guile-E, $(OUT)/$(DIR)/mes.mes-E):
  Depend on mes snarfing.

2 years agotest: Support for non-Guix[SD]: cater for missing CC/CC32 compilers.
Jan Nieuwenhuizen [Tue, 20 Jun 2017 17:07:31 +0000 (19:07 +0200)]
test: Support for non-Guix[SD]: cater for missing CC/CC32 compilers.

* make/check.make: Skip if CC is not set.
* make/check-mlibc.make: New file.
* scaffold/scaffold.make: Use it for mlibc targets.
* tinycc/tinycc.make: Skip mlibc targets if CC32 not set.

2 years agomescc: Support for non-Guix[SD] builds.
Jan Nieuwenhuizen [Tue, 20 Jun 2017 17:06:19 +0000 (19:06 +0200)]
mescc: Support for non-Guix[SD] builds.

* module/language/c99/compiler.mes (c99-input->full-ast): Cater for
  C_INCLUDE_PATH not set.  Fixes non-Guix[SD] builds.

2 years agobuild: Support for non-Guix[SD]: make CC/CC32 optional in configure too.
Jan Nieuwenhuizen [Mon, 19 Jun 2017 10:01:19 +0000 (12:01 +0200)]
build: Support for non-Guix[SD]: make CC/CC32 optional in configure too.

* configure (optional): New global.
  (BUILD_TRIPLET): Use Guile value.
  (check-version): Add keyword argument #:optional.
  (main): Make CC optional (--with-courage).  Only check for stdio.h,
  limits.h if CC is found.
  Make CC32 check optional.
* scripts/scripts.make: Skip if CC is not set.

3 years agomescc: Bugfix for merging objects.
Jan Nieuwenhuizen [Sun, 4 Jun 2017 20:44:21 +0000 (22:44 +0200)]
mescc: Bugfix for merging objects.

* mlibc/libc-mes.c (main): Declare.
* mlibc/mini-libc-mes.c (g_stdin): Define.
  (main): Declare.
* module/language/c99/compiler.mes (alist-add): Thinko.  Fixes merging
  objects when first declares function of next.

3 years agoguix hash: 0fvzr1ai2rmi46zdi5b2bdjb6s8ip78mkmsk02yxl46rajmp2pb1
Jan Nieuwenhuizen [Sat, 3 Jun 2017 19:53:56 +0000 (21:53 +0200)]
guix hash: 0fvzr1ai2rmi46zdi5b2bdjb6s8ip78mkmsk02yxl46rajmp2pb1

3 years agoRelease 0.7. v0.7
Jan Nieuwenhuizen [Sat, 3 Jun 2017 10:00:08 +0000 (12:00 +0200)]
Release 0.7.

* configure (VERSION): Bump.

3 years agodoc: Release update.
Jan Nieuwenhuizen [Mon, 22 May 2017 21:35:39 +0000 (23:35 +0200)]
doc: Release update.

* AUTHORS: Remove module/nyacc.
* HACKING: Release uppdate.
* NEWS: Release uppdate.
* doc/ANNOUNCE-0.7: New file.

3 years agoguix: mes.git: Add git hash to version.
Jan Nieuwenhuizen [Sat, 3 Jun 2017 19:18:53 +0000 (21:18 +0200)]
guix: mes.git: Add git hash to version.

* guix.scm (mes.git): Add git hash to version.

3 years agomescc: move include into share/mlibc, allows installing alongside gcc.
Jan Nieuwenhuizen [Sat, 3 Jun 2017 10:11:57 +0000 (12:11 +0200)]
mescc: move include into share/mlibc, allows installing alongside gcc.

* mlibc: Rename from libc.
* HACKING: Update for name change.
* make/bin.make: Likewise.
* make/mescc-guile.make: Likewise.
* make/mescc-mes.make: Likewise.
* scaffold/scaffold.make: Likewise.
* make/install.make: Likewise.
  (install): Install mlibc into share/mlibc.

3 years agomescc: Handle any const, by ignoring.
Jan Nieuwenhuizen [Fri, 2 Jun 2017 11:12:56 +0000 (13:12 +0200)]
mescc: Handle any const, by ignoring.

* module/language/c99/compiler.mes (ast-strip-const): New function.
  (c99-input->ast): Use it.
  (type->size, type->description, ast->info): Remove const handling.

3 years agomescc: Support array in struct.
Jan Nieuwenhuizen [Wed, 31 May 2017 18:52:48 +0000 (20:52 +0200)]
mescc: Support array in struct.

* module/language/c99/compiler.mes: (field:size, field-offset): New
  functions.  Update callers, use them throughout.
  (ast->info): Support declaration of struct and typedef'ed struct
  variable with array fields.
  (expr->accu, expr->accu*): Support foo.bar[baz], foo->bar[baz].
* scaffold/t-tcc.c: Test it.

3 years agobuild: Skip gcc, mlibc, guile or mes builds using CC=, CC32=, GUILE= or MES=.
Jan Nieuwenhuizen [Sun, 28 May 2017 16:32:53 +0000 (18:32 +0200)]
build: Skip gcc, mlibc, guile or mes builds using CC=, CC32=, GUILE= or MES=.

* GNUmakefile (build-scripts): New target
  (HELP_TOP): Mention it.
* configure (main): Write GUILE_FOR_BUILD.
* make/bin-mlibc.make: Skip if CC32 is not set.
* make/bin.make: Skip if CC is not set.
* make/install.make (install): Only install $(OUT)/mes.mes if
  MES_BOOTSTRAP is set.
* make/mescc-guile.make: Skip if GUILE is not set.
* make/mescc-mes.make: Skip if MES is not set.
* HACKING: write something about

3 years agocore: Always include reader.c, drop binary read-0-32.mo dependency.
Jan Nieuwenhuizen [Sun, 28 May 2017 14:03:45 +0000 (16:03 +0200)]
core: Always include reader.c, drop binary read-0-32.mo dependency.

* module/language/c99/compiler.mes (c99-input->full-ast): Remove
  obsolete __NYACC__ and MES_FULL defines.
* src/mes.c [!MES_FULL]: Include reader-mes.h.
  (mes_builtins) [!MES_FULL]: Include reader.mes.i, reader.me.environment.i.
  [!MES_FULL]: Include reader.c.
  (main) [!MES_FULL]: By default call load_env, only call bload_env
  when --load is supplied.  WAS: Always bload read-0-32.mo.
* src/reader.c (__end_of__mes_): Remove.
  (dump): Remove option of dumping tiny test program.
* make/mescc-mes.make ($(OUT)/$(TARGET), mescc.mes-ccompile,
  mescc.mes.c-compile-E): Depend on $(OUT)/mes, scripts/mes.
* src/src.make (mes.guile): Remove module/mes/read-32-0 dependency.
  Do not build $(OUT)/mes.mes.
* module/module.make (module/mes/read-0.mo, module/mes/read-0-32.mo,
  module/mes/tiny-0-32.mo): Remove targets.
  (CLEAN): Do not add them.  Neither install $(OUT)/mes.mes.
* .gitignore: Remove exceptions for them.
* make/install.make (install): Do not install them.
* HACKING: Update info about creating module/mes/read-32-0.mo.
* scaffold/mini-mes.c: Remove.
* scaffold/tiny-mes.c: Remove.
* scaffold/cons-mes.c: Remove.
* scaffold/scaffold.make (tiny-mes.libc, tiny-mes.guile, tiny-mes.mes,
  mini-mes.libc, mini-mes.guile, mini-mes.mes): Reemove targets.

3 years agomescc: Add missing builtins.
Jan Nieuwenhuizen [Sat, 27 May 2017 07:28:08 +0000 (09:28 +0200)]
mescc: Add missing builtins.

* module/language/c99/compiler.mes (i386:type-alist): Add missing
  builtins.  TODO: identify and handle unsigned.

3 years agomescc: Support typedef and many TCC declaration variants.
Jan Nieuwenhuizen [Thu, 25 May 2017 05:32:29 +0000 (07:32 +0200)]
mescc: Support typedef and many TCC declaration variants.

* module/language/c99/compiler.mes (ast->info): Register typedefs in types.
  (enum-def-list->constants): Support addition and substraction in
  enum field values.
  (get-type): New function.  Use throughout.

3 years agomescc: Handle comments anywhere.
Jan Nieuwenhuizen [Thu, 25 May 2017 17:48:26 +0000 (19:48 +0200)]
mescc: Handle comments anywhere.

* module/language/c99/compiler.mes (c99-input->full-ast): Rename from c99-input->full-ast.
  (ast-strip-comment, c99-input->ast): New functions.
  (ast->info): Remove comment exceptions.

3 years agomescc: Support anonymous enums.
Jan Nieuwenhuizen [Thu, 25 May 2017 05:57:26 +0000 (07:57 +0200)]
mescc: Support anonymous enums.

* module/language/c99/compiler.mes (enum-def-list->constants): New function.
  (ast->info): Support anonymous enum.

3 years agomescc: C99 header files and declaraions.
Jan Nieuwenhuizen [Tue, 23 May 2017 05:16:08 +0000 (07:16 +0200)]
mescc: C99 header files and declaraions.

* libc/include/assert.h (assert_fail):
* libc/include/stdio.h:
+int eputs (char const* s);
+int fputs (char const* s);
+int puts (char const* s);
+int putchar (int c);
+int fputc (int c, int fd);
+int getchar ();
* libc/include/stdlib.h:
+char* getenv (char const* s)
+int atoi (char const *s);
+int *malloc (size_t);
+int *realloc (int *p, int size);
* libc/include/unistd.h (access):
* src/lib.c (display_helper):
* src/mes.c (read_input_file_env):
* src/posix.c: Include unistd.h.

3 years agoguix: Update from Guix.
Jan Nieuwenhuizen [Tue, 23 May 2017 18:11:51 +0000 (20:11 +0200)]
guix: Update from Guix.

* guix.scm (mes): Update from Guix.

3 years agobuild: Use separate preprocessing stage for mescc.
Jan Nieuwenhuizen [Mon, 22 May 2017 19:15:58 +0000 (21:15 +0200)]
build: Use separate preprocessing stage for mescc.

* make/mescc-guile.make (mescc.scm-c-preprocess, (mescc.scm-compile-E):
  New defines.
  [!MESC_DIRECT]Compile .o via separate preprocessed .E stage.

3 years agomescc: support -E.
Jan Nieuwenhuizen [Mon, 22 May 2017 17:22:18 +0000 (19:22 +0200)]
mescc: support -E.

* guile/mescc.scm (parse-opts): Add -E.
  (source->ast): New function.
  (main): Use it.
* scripts/mescc.mes (parse-opts): Add -E.
  (source->ast): New function.
  (main): Use it.

3 years agomescc: Refactor mlibc compilation.
Jan Nieuwenhuizen [Sun, 21 May 2017 20:25:02 +0000 (22:25 +0200)]
mescc: Refactor mlibc compilation.

* libc/libc-mes.c: New file.  Contents from module/mes/libc.mes, module/mes/libc-i386.mes.
* libc/libc-gcc.c: Rename from libc/mlibc.c, include libc/mstart.c
* libc/mstart.c: Remove.
* module/mes/libc-i386.mes: Remove.
* module/mes/libc-i386.scm: Remove.
* module/mes/libc.mes: Remove.
* module/mes/libc.scm: Remove.
* GNUmakefile (CFLAGS): Include libc-gcc.c (WAS: mlibc.c).
* make/bin-mlibc.make (C_FLAGS): Remove start.c include.
* make/mescc-guile.make: Rewrite using compile, link.
* make/mescc-mes.make: Likewise.
* scaffold/m.c: Update.

3 years agomescc: support -c, -o.
Jan Nieuwenhuizen [Wed, 17 May 2017 11:56:25 +0000 (13:56 +0200)]
mescc: support -c, -o.

* module/language/c99/compiler.mes: Throughout: quote lambda's.
  (current-eval): New function.
  Thanks Andy!
  (object->list): New function.  Update callers.
  (c99-input->info): Dump a.o.
  (initzer->non-const, function:object->list): New functions.
  (info:object->list): New function.
  (c99-input->elf): Call it.
* module/mes/as-i386: Throughout: quote lambda's.
* scripts/mescc.mes (main): Rewrite.
* guile/mescc.scm (main): Likewise.

3 years agomes: Bugifx for number->string radix > 10.
Jan Nieuwenhuizen [Tue, 23 May 2017 04:28:37 +0000 (06:28 +0200)]
mes: Bugifx for number->string radix > 10.

* module/mes/scm.mes (number->string): Bugfix for `10' -> hex/radix > 10.

3 years agomes: Simplify read-string.
Jan Nieuwenhuizen [Sun, 21 May 2017 10:21:07 +0000 (12:21 +0200)]
mes: Simplify read-string.

* module/mes/guile.mes (read-string): Simplify, probably fix even.