* module/language/c99/compiler.mes (struct-field): Add struct tag to
struct/union types.
(field-type, field-size, field-offset, field-field, ast-type->type):
Ascertain struct tag with type.
* (expr->accu*): Do not add struct tag.
* scaffold/tests/75-struct-union.c: Test it.
* scaffold/tests/71-struct-array.c: Update.
* module/language/c99/compiler.mes (init-declr->pointer): Use -1 for array.
(expr->accu): Implement foo[i].bar.baz.
* scaffold/tests/72-typedef-struct-def.c (test): Test it.
* 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.
* 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.
* 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.
* 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.
* 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.
* module/language/c99/compiler.mes (expr->accu, expr->accu*): Support
pointer field selection.
* scaffold/tests/72-typedef-struct-def.c (test): Test it.
* 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.
* 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.
* 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.
* 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.
* 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.
* module/language/c99/compiler.mes (ast-strip-const): New function.
(c99-input->ast): Use it.
(type->size, type->description, ast->info): Remove const handling.
* 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.
* 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.
* 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.
* libc/include/string.h (strcpy): Declare.
* libc/mlibc.c (strcpy): New function.
* module/mes/libc.mes (strcpy): New function.
(libc): Add it.
* scaffold/t.c (string_test): Test it.
* module/language/c99/compiler.mes (push-ident): Cater for local arrays.
(expr->accu): Avoid post-inc/post-dec twice on rhs of assignment.
Fix size lookup for local char arrayns.
* module/mes/as-i386.scm: Export them.
* module/language/c99/compiler.mes (expr->accu): Set accu to 0/1 for eq, ne.
* module/mes/as-i386.mes (i386:nz->accu, i386:z->accu,
i386:accu<->stack): New functions.
* scaffold/t.c (math_test): Test it.
* module/language/c99/compiler.mes (expr->accu): Support
&struct.field, struct->field.
(ast->info): Support struct *foo = &bar;
* scaffold/t.c (struct_test): Test it.
* module/language/c99/compiler.mes (function->info): Add return if
missing. Fixes calling void functions (and functions where return
is missing).
* scaffold/t.c (void_func): Test it.
* module/language/c99/compiler.mes (clause->jump-info): Rename from
case->jump-info.
(statements->clauses): New function.
(ast->info): Use it. Fixes switch statement with break in a case
outside of a compound.
* scaffold/t.c (swits): Test it.
* module/language/c99/compiler.mes (p-expr->type): Handle array-ref
with any index.
(ast->info): Support plain array declerations.
(expr->accu): For size == 4, assume value in accu. Fixes int/pointer arrays.
* scaffold/t.c: Test it.
* module/language/c99/compiler.mes (expr->accu): Remove struct scm
hardcoding.
(p-expr->type): New function.
(ast->info): Support struct variable declaration without
initializer. Set struct type for all struct declarations.
* module/mes/libc-i386.mes (i386:va-arg): New function.
* module/mes/libc-i386.scm (mes): Export it.
* module/mes/libc.mes (printf): New function.
(libc): Add it.
* libc/include/stdio.h: New file.
* module/language/c99/compiler.mes (c99-input->ast): Add libc/include
to include path.
(ast-info): Handle (skip) ellipsis in function declaration.
* module/language/c99/compiler.mes (globals:add-string): New function.
(expr->arg): Use it to avoid globals duplication.
(expr->accu): Do not pre-add globals.
* module/mes/libc-i386.mes (i386:_start): Push environment pointer.
* module/mes/libc.mes (g_environment): New global.
(_env): New function.
(_start): Use it to set g_environment.
(getenv): New function.
* lib/mlibc.c (strncmp): New function.
(getenv): Implement.
* lib/mstart.c (_start): Set g_environment.
* module/mes/libc.mes (strncmp): New function.
(libc): Add it.
* scaffold/t.c: (array_ref): Test it.
* 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.
* module/language/c99/compiler.mes (make): Add break field.
(.break): New function.
(clone): Support break field.
(ast->info): Support break.
* scaffold/t.c (test): Test it.
* scaffold/mini-mes.c (lookup_symbol_): Use it; remove goto workaround.
* module/language/c99/compiler.mes (case->jump-info): Refactor.
Support multiple case statements.
* scaffold/t.c (swits): Test it.
* lib.c (display_helper)[__NYACC__]: Remove branch.
* module/language/c99/compiler.mes (binop->accu): Rename from
compare->accu. Update callers.
(expr->accu): Use it for binary operators.
* scaffold/t.c (math_test): Test it.
* module/language/c99/compiler.mes (compare->accu, append-text, wrap):
New functions.
(expr->accu): Use them to implement construct like 1 == inc (0).
* scaffold/t.c (math_test): Test them.
* guix.scm (%source-dir): New variable.
(git-file?): New function.
(mes): Use them to simplify building/installing from git.
* make/install.make (READMES): Add INSTALL, README.
* (install): Install mescc.scm and read-0-32.mo.
* module/language/c99/compiler.mes (expr->accu): Fix by value
assignment from array-of struct entry.
* scaffold/t.c (struct_test): Test it.
* vector.c (make_vector, list_to_vector, vector_to_list): Use it;
remove workarounds.
* gc.c (gc_copy): Likewise.
* module/mes/as-i386.mes (i386:accu>>base): New function.
* module/mes/as-i386.scm (mes): Export it.
* module/language/c99/compiler.mes (expr->accu): Support rshift.
* scaffold/t.c (math_test): Test it.
* scaffold/mini-mes.c (ash): Use it.
* module/mes/as-i386.mes (i386:accu<<base): New function.
* module/mes/as-i386.scm: Export it.
* module/language/c99/compiler.mes (expr->accu): Use it.
* scaffold/t.c (math_test): Test it.
* module/language/c99/compiler.mes (expr->accu, ast->info): Some
push/pop fixes, fixes struct field comparisons.
* doc/examples/t.c (struct_test): Test it.
* module/language/c99/compiler.mes (expr->accu): Handle assignment -> accu.
* doc/examples/t.c (test): Test it.
* doc/examples/mini-mes.c (eval_apply): Use it.
* module/language/c99/compiler.mes (ast->info): Support generic
declaration using initializer. Supports struct field initializer.
* doc/examples/t.c (struct_test): Test it.
* doc/examples/mini-mes.c (call_lambda, eval_apply, write_byte,
display_): Use it. (call_lambda): (eval_apply,
list_of_char_equal_p): Use it.
* module/language/c99/compiler.mes (ident->accu, ident->base):
Use local:ptr, type->size to remove hard coding of functionx, c1.
(expr->accu): Use type->size to remove hard coding of size byte.
(decl->type): Also handle typename, bail out if type not found.
(type->size): Print identifier and and bail out if type not found.
(formal:ptr): New function.
(formals->locals): Use it to set pointer value of parameter. WAS: 0.
(ast->info): Remove functionx hardcoding.
(getchar): Rename c1 to c.
* doc/examples/t.c: Test it.
* module/language/c99/compiler.mes (ast->info): Save base while
computing accu. Fix comparison using d-sel in second argument.
* doc/examples/t.c: Test it.
* doc/examples/mini-mes.c (assq): Use it.
* module/language/c99/compiler.mes (expr->arg, expr->accu, ast->info):
Use type size to calculate index.
* doc/examples/t.c: Test it.
* doc/examples/mini-mes.c (cstring_to_list): Simplify.
Mini-mes, compiled with either gcc or mescc, now runs a memory dump of
this mini-0.mes program
(begin
(write-byte (make-cell 0 0 65))
(write-byte (make-cell 0 0 66))
(write-byte (make-cell 0 0 67))
(write-byte (make-cell 0 0 10))
#f)
when read and dumped by (gcc-compiled) mes-32.
* build-aux/mes-snarf.scm: FIXES ..collapse?
* module/language/c99/compiler.mes (ast->info): Bail out on unhandled
declarations. Was: verbosely skip.
* module/mes/libc-i386.mes (i386:accu%base): New function.
* module/mes/libc-i386.scm: Export it.
* module/language/c99/compiler.mes (expr->accu): Use it to support mod.
* doc/examples/t.c (itoa): New function.
(test): Test it.
* doc/examples/mini-mes.c (itoa)[!__GNUC__]: New function.
* module/language/c99/compiler.mes (expr->arg): Also push parameter,
always return info.
(ast->info): Loop over args. Fixes using function calls in arguments.
* module/mes/libc-i386.mes (i386:push-arg): Remove.
(i386:call, i386:call-accu): Remove arguments parameter.
* doc/examples/t.c: Test it.
* module/mes/libc-i386.mes (XXjump): New function.
* module/mes/libc-i386.scm: Export it.
* module/language/c99/compiler.mes (case->jump-info, ast->info): Use it.
* scaffold/t.c: Test it.
* GNUmakefile (cons-mes): New target.
* scaffold/cons-mes.c: New file.
* scaffold/mini-mes.c:
* module/mes/libc-i386.mes (i386:Xjump-z, i386:Xjump-c,
i386:Xjump-nc): New functions.
* module/mes/libc-i386.scm: Export them.
* module/language/c99/compiler.mes (case->jump-info, test-jump->info,
ast->info): Use them.
* doc/examples/t.c: Test it.
* doc/examples/mini-mes.c: Run it.