mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
/* -*-comment-start: "//";comment-end:""-*-
|
|
|
|
* Mes --- Maxwell Equations of Software
|
|
|
|
* Copyright © 2016,2017 Jan Nieuwenhuizen <janneke@gnu.org>
|
|
|
|
*
|
|
|
|
* This file is part of Mes.
|
|
|
|
*
|
|
|
|
* Mes is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 3 of the License, or (at
|
|
|
|
* your option) any later version.
|
|
|
|
*
|
|
|
|
* Mes is distributed in the hope that it will be useful, but
|
|
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with Mes. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2017-05-02 21:30:46 +00:00
|
|
|
#include <mlibc.h>
|
|
|
|
#include <assert.h>
|
|
|
|
#include <stdlib.h>
|
2017-06-11 11:11:40 +00:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <string.h>
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
struct scm {
|
|
|
|
int type;
|
|
|
|
int car;
|
|
|
|
int cdr;
|
|
|
|
};
|
2017-01-17 18:03:08 +00:00
|
|
|
|
2017-03-17 07:37:45 +00:00
|
|
|
int bla = 1234;
|
2017-03-13 18:38:38 +00:00
|
|
|
char arena[84];
|
2017-04-12 19:27:59 +00:00
|
|
|
#if __MESC__
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
struct scm *g_cells = arena;
|
2017-04-12 19:27:59 +00:00
|
|
|
#else
|
|
|
|
struct scm *g_cells = (struct scm*)arena;
|
|
|
|
#endif
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
char *g_chars = arena;
|
2017-01-17 18:03:08 +00:00
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
int foo () {puts ("t: foo\n"); return 0;};
|
2017-03-02 19:26:13 +00:00
|
|
|
int bar (int i) {puts ("t: bar\n"); return 0;};
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
struct function {
|
|
|
|
int (*function) (void);
|
|
|
|
int arity;
|
2017-03-09 07:14:27 +00:00
|
|
|
char *name;
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
};
|
2017-03-09 07:14:27 +00:00
|
|
|
struct function g_fun = {&exit,1,"fun"};
|
|
|
|
struct function g_foo = {&foo,0,"foo"};
|
|
|
|
struct function g_bar = {&bar,1,"bar"};
|
2017-01-08 16:51:40 +00:00
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
//void *functions[2];
|
|
|
|
int functions[2];
|
2017-01-08 16:51:40 +00:00
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
struct function g_functions[2];
|
|
|
|
int g_function = 0;
|
2017-01-08 16:51:40 +00:00
|
|
|
|
2017-03-12 11:02:12 +00:00
|
|
|
enum type_t {TCHAR, TCLOSURE, TCONTINUATION, TFUNCTION, TKEYWORD, TMACRO, TNUMBER, TPAIR, TREF, TSPECIAL, TSTRING, TSYMBOL, TVALUES, TVECTOR, TBROKEN_HEART};
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
|
|
|
|
typedef int SCM;
|
|
|
|
int g_free = 3;
|
|
|
|
SCM tmp;
|
2017-02-24 12:27:39 +00:00
|
|
|
SCM tmp_num;
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
|
2017-03-02 19:26:13 +00:00
|
|
|
int ARENA_SIZE = 200;
|
2017-07-02 14:25:14 +00:00
|
|
|
#define TYPE(x) g_cells[x].type
|
2017-03-02 19:26:13 +00:00
|
|
|
#define CAR(x) g_cells[x].car
|
|
|
|
#define CDR(x) g_cells[x].cdr
|
|
|
|
#define VALUE(x) g_cells[x].cdr
|
|
|
|
|
2017-03-13 23:15:13 +00:00
|
|
|
#define CAAR(x) CAR (CAR (x))
|
|
|
|
|
2017-03-02 19:26:13 +00:00
|
|
|
struct scm scm_fun = {TFUNCTION,0,0};
|
|
|
|
SCM cell_fun;
|
|
|
|
|
2017-04-17 00:15:11 +00:00
|
|
|
char *env[] = {"foo", "bar", "baz", 0};
|
|
|
|
|
2017-02-27 06:50:33 +00:00
|
|
|
int
|
|
|
|
add (int a, int b)
|
|
|
|
{
|
|
|
|
return a + b;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
inc (int i)
|
|
|
|
{
|
|
|
|
return i + 1;
|
|
|
|
}
|
|
|
|
|
2017-03-13 18:38:38 +00:00
|
|
|
int
|
|
|
|
identity (int i)
|
|
|
|
{
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
2017-06-12 19:00:50 +00:00
|
|
|
#if 1
|
2017-04-02 10:13:04 +00:00
|
|
|
int
|
|
|
|
label (int c)
|
|
|
|
{
|
|
|
|
label:
|
|
|
|
if (c == 0) return c;
|
|
|
|
c--;
|
|
|
|
goto label;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2017-01-17 18:03:08 +00:00
|
|
|
int
|
|
|
|
swits (int c)
|
|
|
|
{
|
|
|
|
int x = -1;
|
2017-02-24 12:27:39 +00:00
|
|
|
|
|
|
|
switch (c)
|
|
|
|
{
|
2017-03-12 11:02:12 +00:00
|
|
|
case TCHAR: {goto next;}
|
2017-02-24 12:27:39 +00:00
|
|
|
case 1: {goto next;}
|
|
|
|
case 2: {goto next;}
|
|
|
|
default: {goto next;}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
next:
|
2017-01-17 18:03:08 +00:00
|
|
|
switch (c)
|
|
|
|
{
|
2017-04-09 04:52:39 +00:00
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
x = 0;
|
|
|
|
c = 34;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case -1:
|
|
|
|
case 1:
|
2017-05-06 06:39:04 +00:00
|
|
|
x = 1;
|
|
|
|
break;
|
2017-04-09 04:52:39 +00:00
|
|
|
default:
|
|
|
|
{
|
|
|
|
x = 2;
|
|
|
|
break;
|
|
|
|
}
|
2017-01-17 18:03:08 +00:00
|
|
|
}
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
int g = 48;
|
|
|
|
int
|
|
|
|
get ()
|
|
|
|
{
|
|
|
|
int i = g;
|
|
|
|
g++;
|
|
|
|
return i;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
read_test ()
|
|
|
|
{
|
|
|
|
char *p = (char*)g_chars;
|
|
|
|
int i = 0;
|
2017-03-23 17:57:06 +00:00
|
|
|
puts ("t: read 0123456789\nt: ");
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
int c = get ();
|
|
|
|
while (i < 10) {
|
|
|
|
*p++ = c;
|
|
|
|
putchar (c);
|
|
|
|
c = get ();
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
puts ("\n");
|
|
|
|
if (strcmp (g_chars, "0123456789")) return 1;
|
2017-03-23 17:57:06 +00:00
|
|
|
|
|
|
|
puts ("t: ungetc ('A') == getchar ()\n");
|
|
|
|
ungetc ('A', STDIN);
|
|
|
|
if (getchar () != 'A') return 1;
|
|
|
|
ungetc (0, STDIN);
|
|
|
|
//ungetc ('\1', STDIN);
|
|
|
|
ungetc (1, STDIN);
|
|
|
|
puts ("t: ungetc ();ungetc ();getchar ();getchar ()\n");
|
|
|
|
if (getchar () != 1) return 1;
|
|
|
|
//if (getchar () != '\0') return 1;
|
|
|
|
if (getchar () != 0) return 1;
|
|
|
|
|
2017-04-17 00:15:11 +00:00
|
|
|
puts ("t: i == 'm'\n");
|
|
|
|
char m = 0x1122336d;
|
|
|
|
i = m;
|
|
|
|
if (i != 'm') return 1;
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2017-04-17 00:15:11 +00:00
|
|
|
int
|
|
|
|
array_test (char **e)
|
|
|
|
{
|
|
|
|
int i = 0;
|
|
|
|
|
2017-05-05 07:24:19 +00:00
|
|
|
puts ("a[i] = i-1\n");
|
|
|
|
int a[3];
|
|
|
|
for (int i=0; i < 3; i++) a[i] = i-1;
|
|
|
|
for (int i=0; i < 3; i++) if (a[i] != i-1) return 1;
|
|
|
|
|
2017-04-17 00:15:11 +00:00
|
|
|
puts ("env [");
|
|
|
|
puts (itoa (env));
|
|
|
|
puts ("]\n");
|
|
|
|
|
|
|
|
puts ("e [");
|
|
|
|
puts (itoa (e));
|
|
|
|
puts ("]\n");
|
|
|
|
|
|
|
|
puts ("env [0] == \"foo\"\n");
|
|
|
|
if (strcmp (env[0], "foo")) return 1;
|
|
|
|
|
|
|
|
puts ("env [1] == \"bar\"\n");
|
|
|
|
if (strcmp (env[1], "bar")) return 1;
|
|
|
|
|
|
|
|
puts ("t: **p in *env[]\n");
|
|
|
|
|
|
|
|
char **pp = env;
|
|
|
|
while (*pp)
|
|
|
|
{
|
|
|
|
puts ("pp [");
|
|
|
|
puts (itoa (pp));
|
|
|
|
puts ("]: ");
|
|
|
|
if (*pp) puts (*pp);
|
|
|
|
puts ("\n");
|
|
|
|
pp++;
|
|
|
|
i++;
|
|
|
|
}
|
|
|
|
if (i != 3) return i;
|
|
|
|
|
|
|
|
pp = env;
|
|
|
|
puts ("t: *pp++ == \"foo\"\n");
|
|
|
|
if (strcmp (*pp++, "foo")) return 1;
|
|
|
|
|
|
|
|
puts ("t: *pp++ == \"bar\"\n");
|
|
|
|
if (strcmp (*pp++, "bar")) return 1;
|
|
|
|
|
|
|
|
char *buf = "hello";
|
|
|
|
puts ("t: buf[0]\n");
|
|
|
|
if (buf[0] != 'h') return 1;
|
|
|
|
|
|
|
|
puts ("t: buf + 1\n");
|
|
|
|
if (*(buf+1) != 'e') return 1;
|
|
|
|
|
|
|
|
char **p = &buf;
|
|
|
|
puts ("t: **p\n");
|
|
|
|
if (**p != 'h') return 1;
|
|
|
|
|
|
|
|
puts ("t: *(p + 1)\n");
|
|
|
|
if (*(*p + 1) != 'e') return 1;
|
|
|
|
|
2017-04-17 00:24:20 +00:00
|
|
|
puts ("t: getenv ()");
|
|
|
|
if (!getenv ("SHELL")) return 1;
|
|
|
|
|
2017-04-17 00:15:11 +00:00
|
|
|
return read_test ();
|
|
|
|
}
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
int
|
|
|
|
math_test ()
|
|
|
|
{
|
2017-04-07 05:06:35 +00:00
|
|
|
int i;
|
|
|
|
|
2017-03-24 20:45:19 +00:00
|
|
|
puts ("t: 0 < 0\n");
|
|
|
|
if (0 < 0) return 1;
|
|
|
|
|
|
|
|
puts ("t: 2 < 1\n");
|
|
|
|
if (2 < 1) return 1;
|
|
|
|
|
|
|
|
puts ("t: -1 < -2\n");
|
|
|
|
if (-1 < -2) return 1;
|
|
|
|
|
|
|
|
puts ("t: 0 < -1\n");
|
|
|
|
if (0 < -1) return 1;
|
|
|
|
|
|
|
|
puts ("t: 0 > 0\n");
|
|
|
|
if (0 > 0) return 1;
|
|
|
|
|
|
|
|
puts ("t: 1 > 2\n");
|
|
|
|
if (1 > 2) return 1;
|
|
|
|
|
|
|
|
puts ("t: -2 > -1\n");
|
|
|
|
if (-2 > -1) return 1;
|
|
|
|
|
|
|
|
puts ("t: -1 > 0\n");
|
|
|
|
if (-1 > 0) return 1;
|
|
|
|
|
2017-04-07 05:06:35 +00:00
|
|
|
puts ("t: 1 == inc (0)\n");
|
|
|
|
if (1 == inc (0)) goto ok0;
|
|
|
|
return 1;
|
|
|
|
ok0:
|
|
|
|
|
|
|
|
puts ("t: 0 < inc (0)\n");
|
|
|
|
if (0 < inc (0)) goto ok1;
|
|
|
|
return 1;
|
|
|
|
ok1:
|
|
|
|
|
2017-04-07 12:31:35 +00:00
|
|
|
puts ("t: inc (0) + 2 != 3\n");
|
|
|
|
if (inc (0) + inc (1) != 3) return 1;
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
puts ("t: 4/2=");
|
|
|
|
i = 4 / 2;
|
|
|
|
if (i!=2) return 1;
|
|
|
|
i += 48;
|
|
|
|
putchar (i);
|
|
|
|
puts ("\n");
|
mescc: Run module/base-0.mes.
* gc.c: New file.
* vector.c: New file.
* mes.c: Remove vector and gc functions, include vector.c, gc.c.
* GNUmakefile (mes.o): Add gc, vector dependencies.
* scaffold/mini-mes.c (eval_apply): Support primitive-load through
read_input_file.
(getenv_, open_input_file, current_input_port,
set_current_input_port force_output, exit_, values, arity_, xassq,
is_p, minus, plus, divide, modulo multiply, logior, ash): New function.
(mes_symbols): Add symbols %gnuc, %mesc.
* scaffold/mini-mes.c (): New functions.
* scaffold/b-0.mes: New file.
* scaffold/t-0.mes: New file.
2017-03-26 19:13:01 +00:00
|
|
|
|
2017-04-08 04:31:12 +00:00
|
|
|
puts ("t: 3*4=\n");
|
mescc: Run module/base-0.mes.
* gc.c: New file.
* vector.c: New file.
* mes.c: Remove vector and gc functions, include vector.c, gc.c.
* GNUmakefile (mes.o): Add gc, vector dependencies.
* scaffold/mini-mes.c (eval_apply): Support primitive-load through
read_input_file.
(getenv_, open_input_file, current_input_port,
set_current_input_port force_output, exit_, values, arity_, xassq,
is_p, minus, plus, divide, modulo multiply, logior, ash): New function.
(mes_symbols): Add symbols %gnuc, %mesc.
* scaffold/mini-mes.c (): New functions.
* scaffold/b-0.mes: New file.
* scaffold/t-0.mes: New file.
2017-03-26 19:13:01 +00:00
|
|
|
i = 3 * 4;
|
|
|
|
if (i!=12) return 1;
|
2017-03-24 21:32:02 +00:00
|
|
|
|
2017-04-08 04:31:12 +00:00
|
|
|
puts ("t: i /= 4\n");
|
|
|
|
i /= 4;
|
|
|
|
if (i!=3) return 1;
|
|
|
|
|
|
|
|
puts ("t: i *= 4\n");
|
|
|
|
i *= 4;
|
|
|
|
if (i!=12) return 1;
|
|
|
|
|
2017-03-24 21:32:02 +00:00
|
|
|
puts ("t: 1 << 3\n");
|
|
|
|
if (1 << 3 != 8) return 1 << 3;
|
|
|
|
|
|
|
|
puts ("t: 3 << 4\n");
|
|
|
|
if (3 << 4 != 48) return 3 << 4;
|
|
|
|
|
2017-03-25 17:48:40 +00:00
|
|
|
puts ("t: 48 >> 3\n");
|
|
|
|
if (48 >> 4 != 3) return 48 >> 4;
|
|
|
|
|
|
|
|
puts ("t: 10 >> 1\n");
|
|
|
|
if (10 >> 1 != 5) return 10 >> 1;
|
|
|
|
|
2017-03-24 22:15:01 +00:00
|
|
|
puts ("t: 1 | 4\n");
|
|
|
|
if ((1 | 4) != 5) return 1 | 4;
|
|
|
|
|
2017-03-25 17:48:40 +00:00
|
|
|
i = -3;
|
|
|
|
puts ("t: -i\n");
|
2017-03-25 18:03:03 +00:00
|
|
|
if (-i != 3) return 1;
|
2017-03-25 17:48:40 +00:00
|
|
|
|
|
|
|
puts ("t: -1 + 2\n");
|
2017-03-25 18:03:03 +00:00
|
|
|
if (-1 + 2 != 1) return 1;
|
2017-03-25 17:48:40 +00:00
|
|
|
|
2017-05-06 12:57:39 +00:00
|
|
|
puts ("t: 1 & 3\n");
|
|
|
|
if ((1 & 3) != 1) return 1;
|
|
|
|
|
|
|
|
puts ("t: 1 | 3\n");
|
|
|
|
if ((1 | 2) != 3) return 1;
|
|
|
|
|
|
|
|
puts ("t: ^ 1 \n");
|
|
|
|
if ((1 ^ 3) != 2) return 1;
|
|
|
|
|
2017-05-06 15:30:14 +00:00
|
|
|
puts ("t: 3 == 3\n");
|
|
|
|
if ((3 == 3) != 1) return 1;
|
|
|
|
|
|
|
|
puts ("t: 3 != 3\n");
|
|
|
|
if ((3 != 3) != 0) return 1;
|
|
|
|
|
2017-05-06 16:16:24 +00:00
|
|
|
puts ("t: 011 == 15\n");
|
|
|
|
if (011 != 9) return 1;
|
|
|
|
|
|
|
|
puts ("t: 0b11 == 3\n");
|
|
|
|
if (0b11 != 3) return 1;
|
|
|
|
|
|
|
|
puts ("t: 0x11 == 3\n");
|
|
|
|
if (0x11 != 17) return 1;
|
|
|
|
|
2017-04-17 00:15:11 +00:00
|
|
|
return array_test (env);
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
}
|
|
|
|
|
2017-02-24 12:27:39 +00:00
|
|
|
SCM
|
|
|
|
alloc (int n)
|
|
|
|
{
|
|
|
|
SCM x = g_free;
|
|
|
|
g_free += n;
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
SCM
|
|
|
|
make_cell (SCM type, SCM car, SCM cdr)
|
|
|
|
{
|
|
|
|
SCM x = alloc (1);
|
|
|
|
TYPE (x) = VALUE (type);
|
2017-03-12 11:02:12 +00:00
|
|
|
if (VALUE (type) == TCHAR || VALUE (type) == TNUMBER) {
|
2017-02-24 12:27:39 +00:00
|
|
|
if (car) CAR (x) = CAR (car);
|
|
|
|
if (cdr) CDR(x) = CDR(cdr);
|
|
|
|
}
|
|
|
|
else if (VALUE (type) == TFUNCTION) {
|
|
|
|
if (car) CAR (x) = car;
|
|
|
|
if (cdr) CDR(x) = CDR(cdr);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
CAR (x) = car;
|
|
|
|
CDR(x) = cdr;
|
|
|
|
}
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
|
|
|
|
SCM
|
|
|
|
make_cell_test ()
|
|
|
|
{
|
2017-03-12 11:02:12 +00:00
|
|
|
VALUE (tmp_num) = TPAIR;
|
2017-02-24 12:27:39 +00:00
|
|
|
make_cell (tmp_num, 0, 1);
|
|
|
|
return math_test ();
|
|
|
|
}
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
SCM
|
|
|
|
make_tmps_test (struct scm* cells)
|
|
|
|
{
|
|
|
|
puts ("t: tmp = g_free++\n");
|
|
|
|
tmp = g_free++;
|
|
|
|
puts ("t: cells[tmp].type = CHAR\n");
|
2017-03-12 11:02:12 +00:00
|
|
|
cells[tmp].type = TCHAR;
|
2017-02-24 12:27:39 +00:00
|
|
|
tmp_num = g_free++;
|
2017-03-12 11:02:12 +00:00
|
|
|
cells[tmp_num].type = TNUMBER;
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
|
2017-02-24 12:27:39 +00:00
|
|
|
return make_cell_test();
|
|
|
|
}
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
struct_test ()
|
|
|
|
{
|
2017-04-01 21:12:37 +00:00
|
|
|
puts ("t: g_cells[0] = g_cells[1]\n");
|
|
|
|
TYPE (1) = 1;
|
|
|
|
CAR (1) = 2;
|
|
|
|
CDR (1) = 3;
|
2017-04-06 21:05:44 +00:00
|
|
|
g_cells[0] = g_cells[1];
|
2017-04-01 21:12:37 +00:00
|
|
|
if (TYPE (0) != 1) return 1;
|
|
|
|
if (CAR (0) != 2) return 2;
|
|
|
|
if (CDR (0) != 3) return 3;
|
|
|
|
|
|
|
|
puts ("t: g_cells[i] = g_cells[j]\n");
|
|
|
|
int i = 0;
|
|
|
|
int j = 1;
|
|
|
|
TYPE (1) = 4;
|
|
|
|
CAR (1) = 5;
|
|
|
|
CDR (1) = 6;
|
|
|
|
g_cells[i] = g_cells[j];
|
|
|
|
if (TYPE (0) != 4) return 1;
|
|
|
|
if (CAR (0) != 5) return 2;
|
|
|
|
if (CDR (0) != 6) return 3;
|
|
|
|
|
2017-04-06 21:05:44 +00:00
|
|
|
puts ("t: g_cells[0+add(0,0] = g_cells[0+inc(0)]\n");
|
|
|
|
TYPE (1) = 1;
|
|
|
|
CAR (1) = 2;
|
|
|
|
CDR (1) = 3;
|
|
|
|
g_cells[0+add(0, 0)] = g_cells[0+inc(0)];
|
|
|
|
if (TYPE (0) != 1) return 1;
|
|
|
|
if (CAR (0) != 2) return 2;
|
|
|
|
if (CDR (0) != 3) return 3;
|
|
|
|
|
2017-03-22 06:10:54 +00:00
|
|
|
g_cells[0].type = TNUMBER;
|
2017-04-01 21:12:37 +00:00
|
|
|
g_cells[0].car = 0;
|
|
|
|
g_cells[0].cdr = 0;
|
2017-03-22 06:10:54 +00:00
|
|
|
g_cells[1].type = TNUMBER;
|
2017-04-01 21:12:37 +00:00
|
|
|
g_cells[1].car = 0;
|
|
|
|
g_cells[1].cdr = 0;
|
|
|
|
|
2017-03-22 06:10:54 +00:00
|
|
|
puts ("t: TYPE (0) != TYPE (1)\n");
|
|
|
|
if (TYPE (0) == TYPE (1)) goto ok;
|
|
|
|
return 1;
|
|
|
|
ok:
|
|
|
|
|
2017-03-13 23:15:13 +00:00
|
|
|
g_cells[0].car = 1;
|
|
|
|
g_cells[1].car = 2;
|
|
|
|
|
2017-03-17 16:54:37 +00:00
|
|
|
puts ("t: int c = VALUE (0)\n");
|
|
|
|
int c = CAR (0);
|
|
|
|
if (c != 1) return 1;
|
|
|
|
|
2017-03-13 23:15:13 +00:00
|
|
|
puts ("t: CAAR (0) != 2\n");
|
|
|
|
if (CAAR (0) != 2) return 1;
|
|
|
|
|
|
|
|
puts ("t: 2 != CAAR (0)\n");
|
|
|
|
if (2 != CAAR (0)) return 1;
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
g_cells[3].type = 0x64;
|
|
|
|
if (g_cells[3].type != 0x64)
|
|
|
|
return g_cells[3].type;
|
|
|
|
|
|
|
|
TYPE (4) = 4;
|
|
|
|
if (TYPE (4) != 4)
|
|
|
|
return 4;
|
|
|
|
|
|
|
|
CDR (3) = 0x22;
|
|
|
|
CDR (4) = 0x23;
|
|
|
|
if (CDR (3) != 0x22)
|
|
|
|
return CDR (3);
|
|
|
|
|
|
|
|
puts ("t: g_fun.arity != 1;\n");
|
|
|
|
if (g_fun.arity != 1) return 1;
|
|
|
|
|
|
|
|
puts ("t: g_fun.function != exit;\n");
|
|
|
|
if (g_fun.function != &exit) return 1;
|
|
|
|
|
2017-03-09 07:14:27 +00:00
|
|
|
puts ("t: struct fun = {&exit,1,\"exit\"};\n");
|
|
|
|
struct function fun = {&exit,1,"exit"};
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
puts ("t: fun.arity != 1;\n");
|
|
|
|
if (fun.arity != 1) return 1;
|
|
|
|
|
|
|
|
puts ("t: fun.function != exit;\n");
|
|
|
|
if (fun.function != &exit) return 1;
|
|
|
|
|
2017-03-09 07:14:27 +00:00
|
|
|
puts ("t: puts (fun.name)\n");
|
|
|
|
if (strcmp (fun.name, "exit")) return 1;
|
|
|
|
|
|
|
|
puts ("t: puts (g_fun.name)\n");
|
|
|
|
if (strcmp (g_fun.name, "fun")) return 1;
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
puts ("t: g_functions[g_function++] = g_foo;\n");
|
|
|
|
g_functions[g_function++] = g_foo;
|
|
|
|
|
2017-05-06 09:01:58 +00:00
|
|
|
puts ("t: pbar->arity == 1\n");
|
|
|
|
struct function* barp = &g_bar;
|
|
|
|
if (barp->arity != 1) return 1;
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
int fn = 0;
|
|
|
|
puts ("t: g_functions[g_cells[fn].cdr].arity\n");
|
2017-03-02 19:26:13 +00:00
|
|
|
if (g_functions[g_cells[fn].cdr].arity) return 1;
|
|
|
|
if (g_functions[g_cells[fn].cdr].arity != 0) return 1;
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
|
|
|
|
int (*functionx) (void) = 0;
|
|
|
|
functionx = g_functions[0].function;
|
2017-03-09 07:14:27 +00:00
|
|
|
puts ("t: functionx == foo\n");
|
2017-03-02 19:26:13 +00:00
|
|
|
if (functionx != foo) return 11;
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
|
2017-03-09 07:14:27 +00:00
|
|
|
puts ("t: g_functions[0].name\n");
|
|
|
|
if (strcmp (g_functions[0].name, "foo")) return 1;
|
|
|
|
|
|
|
|
puts ("t: (functionx) () == foo\n");
|
2017-03-02 19:26:13 +00:00
|
|
|
if ((functionx) () != 0) return 12;
|
|
|
|
|
|
|
|
puts ("t: g_functions[<foo>].arity\n");
|
|
|
|
if (g_functions[0].arity != 0) return 17;
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
|
|
|
|
fn++;
|
2017-03-02 19:26:13 +00:00
|
|
|
g_functions[fn] = g_bar;
|
|
|
|
g_cells[fn].cdr = fn;
|
|
|
|
if (g_cells[fn].cdr != fn) return 13;
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
puts ("t: g_functions[g_cells[fn].cdr].function\n");
|
|
|
|
functionx = g_functions[g_cells[fn].cdr].function;
|
2017-03-02 19:26:13 +00:00
|
|
|
|
2017-03-09 07:14:27 +00:00
|
|
|
puts ("t: g_functions[1].name\n");
|
|
|
|
if (strcmp (g_functions[1].name, "bar")) return 1;
|
|
|
|
|
2017-03-02 19:26:13 +00:00
|
|
|
puts ("t: functionx == bar\n");
|
|
|
|
if (functionx != bar) return 15;
|
|
|
|
|
2017-03-09 07:14:27 +00:00
|
|
|
puts ("t: (functiony) (1) == bar\n");
|
2017-03-02 19:26:13 +00:00
|
|
|
int (*functiony) (int) = 0;
|
|
|
|
functiony = g_functions[g_cells[fn].cdr].function;
|
|
|
|
if ((functiony) (1) != 0) return 16;
|
|
|
|
|
2017-03-22 06:13:34 +00:00
|
|
|
puts ("t: g_functions[<bar>].arity\n");
|
2017-03-02 19:26:13 +00:00
|
|
|
if (g_functions[fn].arity != 1) return 18;
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
|
2017-03-22 06:13:34 +00:00
|
|
|
// fake name
|
|
|
|
scm_fun.car = 33;
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
scm_fun.cdr = g_function;
|
2017-03-22 06:13:34 +00:00
|
|
|
//g_functions[g_function++] = g_fun;
|
|
|
|
g_functions[g_function] = g_fun;
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
cell_fun = g_free++;
|
|
|
|
g_cells[cell_fun] = scm_fun;
|
|
|
|
|
2017-03-22 06:13:34 +00:00
|
|
|
puts ("t: TYPE (cell_fun)\n");
|
|
|
|
if (TYPE (cell_fun) != TFUNCTION) return 1;
|
|
|
|
|
|
|
|
puts ("t: CAR (cell_fun)\n");
|
|
|
|
if (CAR (cell_fun) != 33) return 1;
|
|
|
|
|
|
|
|
puts ("t: CDR (cell_fun)\n");
|
|
|
|
if (CDR (cell_fun) != g_function) return 1;
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
return make_tmps_test (g_cells);
|
|
|
|
}
|
|
|
|
|
2017-05-08 19:15:53 +00:00
|
|
|
int
|
|
|
|
string_test ()
|
|
|
|
{
|
|
|
|
puts ("t: strcpy (buf, \"hallo\")\n");
|
|
|
|
char buf[10];
|
|
|
|
strcpy (buf, "hallo");
|
|
|
|
if (strcmp (buf, "hallo")) return 1;
|
|
|
|
|
|
|
|
return struct_test ();
|
|
|
|
}
|
|
|
|
|
2017-05-06 07:11:42 +00:00
|
|
|
void
|
|
|
|
void_func ()
|
|
|
|
{
|
|
|
|
}
|
2017-06-12 19:00:50 +00:00
|
|
|
#endif
|
2017-05-06 07:11:42 +00:00
|
|
|
|
2017-06-12 19:00:50 +00:00
|
|
|
#if 1
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
int
|
2017-01-08 16:51:40 +00:00
|
|
|
test (char *p)
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
{
|
|
|
|
int f = 0;
|
|
|
|
int t = 1;
|
|
|
|
int one = 1;
|
2017-01-10 19:05:47 +00:00
|
|
|
char c = 'C';
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
int i=0;
|
|
|
|
|
|
|
|
char *x = arena;
|
|
|
|
char *y = g_chars;
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
|
2017-03-12 10:05:00 +00:00
|
|
|
puts ("t: for (i=1; i<5; ++i)\n");
|
|
|
|
for (i=1; i<5; ++i);
|
|
|
|
if (i != 5) return i;
|
|
|
|
|
|
|
|
puts ("t: while (i<3) i++\n");
|
|
|
|
i = 1;
|
|
|
|
while (i<3) i++;
|
|
|
|
if (i != 3) return i;
|
|
|
|
|
|
|
|
puts ("t: do i-- while (i>0)\n");
|
|
|
|
do i--; while (i>0);
|
|
|
|
if (i != 0) return 1;
|
|
|
|
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
puts ("t: if (0)\n");
|
|
|
|
if (0) return 1;
|
|
|
|
|
2017-02-24 12:27:39 +00:00
|
|
|
if (i)
|
|
|
|
return 1;
|
|
|
|
else
|
|
|
|
puts ("t: else 1\n");
|
|
|
|
|
|
|
|
if (i)
|
|
|
|
puts ("0");
|
|
|
|
else if (i == 1)
|
|
|
|
puts ("1");
|
|
|
|
else
|
|
|
|
puts ("t: else if 2\n");
|
|
|
|
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
puts ("t: if (f)\n");
|
|
|
|
if (f) return 1;
|
|
|
|
|
2017-03-13 23:15:13 +00:00
|
|
|
puts ("t: if (one != 1)\n");
|
|
|
|
if (one != 1) return 1;
|
|
|
|
|
|
|
|
puts ("t: if (1 != one)\n");
|
|
|
|
if (1 != one) return 1;
|
|
|
|
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
puts ("t: if (one > 1)\n");
|
|
|
|
if (one > 1) return 1;
|
|
|
|
|
|
|
|
puts ("t: if (one < 0)\n");
|
|
|
|
if (one < 0) return 1;
|
|
|
|
|
mescc: Mini-mes (gcc-compiled) runs read-0.mes.
* module/language/c99/compiler.mes (expr->accu): Add mul.
(test->jump->info): Add le, ge.
(ast->info): Support int and char* initialization at top level.
* module/mes/as-i386.mes (i386:accu*base, i386:Xjump-cz,
i386:Xjump-ncz): New function.
* module/mes/as-i386.scm: Export them.
* doc/examples/t.c (test): Test them.
* module/mes/libc.mes (ungetc): New function.
(getchar): Support it.
(assert_fail, isdigit): New functions.
(libc): Export them.
* module/mes/mini-0.mes: Load full reader.
* mlibc.c (ungetc): New function.
(getchar): Support it.
(assert_fail, isdigit): New functions.
* mes.c (list length error lookup_ getchar ungetchar peekchar
peek_byte read_byte unread_byte greater_p less_p): Move functions
needed to run read-0.mes into core.
* doc/examples/mini-mes.c: Likewise.
* lib.c (length, error): Comment-out.
* math.c (greater_p, less_p): Comment-out.
* posix.c: (getchar, ungetchar, peekchar, peek_byte, read_byte,
unread_byte): Comment-out.
* reader.c (lookup_): Comment-out.
2017-03-22 05:39:24 +00:00
|
|
|
puts ("t: if (one <= 0)\n");
|
|
|
|
if (one <= 0) return 1;
|
|
|
|
|
|
|
|
puts ("t: if (one >= 2)\n");
|
|
|
|
if (one >= 2) return 1;
|
|
|
|
|
2017-01-08 16:51:40 +00:00
|
|
|
puts ("t: if (strlen (\"\"))\n");
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
if (strlen ("")) return 1;
|
|
|
|
|
2017-01-08 16:51:40 +00:00
|
|
|
puts ("t: if (strlen (p) != 4)\n");
|
|
|
|
if (strlen (p) != 4) return 1;
|
|
|
|
|
|
|
|
puts ("t: if (!strlen (\".\"))\n");
|
|
|
|
if (!strlen (".")) return 1;
|
|
|
|
|
|
|
|
puts ("t: if (strcmp (p, \"foo\"))\n");
|
|
|
|
if (!strcmp (p, "foo")) return 1;
|
|
|
|
|
|
|
|
puts ("t: if (strcmp (p, \"t.c\\n\"))\n");
|
|
|
|
if (strcmp (p, "t.c\n")) return 1;
|
|
|
|
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
puts ("t: if (!1)\n");
|
|
|
|
if (!1) return 1;
|
|
|
|
|
|
|
|
puts ("t: if (one == 0)\n");
|
|
|
|
if (one == 0) return 1;
|
|
|
|
|
|
|
|
puts ("t: if (f != 0)\n");
|
|
|
|
if (one != 1) return 1;
|
|
|
|
|
|
|
|
puts ("t: if (1 && 0)\n");
|
|
|
|
if (1 && 0) return 1;
|
|
|
|
|
2017-01-08 16:51:40 +00:00
|
|
|
puts ("t: if (!t && f)\n");
|
|
|
|
if (!t && f) return 1;
|
|
|
|
|
|
|
|
puts ("t: if (t && !one)\n");
|
|
|
|
if (t && !one) return 1;
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
puts ("t: if (f || !t)\n");
|
|
|
|
if (f || !t) return 1;
|
|
|
|
|
2017-01-07 20:53:12 +00:00
|
|
|
puts ("t: if (i++)\n");
|
|
|
|
if (i++) return 1;
|
|
|
|
|
|
|
|
puts ("t: if (--i)\n");
|
|
|
|
if (--i) return 1;
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
puts ("t: i += 2\n");
|
|
|
|
i += 2;
|
|
|
|
if (i != 2) return 1;
|
|
|
|
|
|
|
|
puts ("t: i -= 2\n");
|
|
|
|
i -= 2;
|
|
|
|
if (i != 0) return 1;
|
|
|
|
|
2017-03-18 07:17:18 +00:00
|
|
|
puts ("t: if (f = 0) ?\n");
|
|
|
|
if (f = 0) return 1;
|
|
|
|
|
|
|
|
puts ("t: if (!(t = 1)) ?\n");
|
|
|
|
if (!(t = 1)) return 1;
|
|
|
|
|
2017-03-18 07:25:15 +00:00
|
|
|
puts ("t: if ((f = 0) != 0) ?\n");
|
|
|
|
if ((f = 0) != 0) return 1;
|
|
|
|
|
|
|
|
puts ("t: if ((t = 1) != 1) ?\n");
|
|
|
|
if ((t = 1) != 1) return 1;
|
|
|
|
|
2017-01-17 18:03:08 +00:00
|
|
|
puts ("t: (one == 1) ?\n");
|
2017-01-10 19:27:44 +00:00
|
|
|
(one == 1) ? 1 : exit (1);
|
|
|
|
|
2017-01-17 18:03:08 +00:00
|
|
|
puts ("t: (f) ?\n");
|
2017-01-10 19:27:44 +00:00
|
|
|
(f) ? exit (1) : 1;
|
|
|
|
|
2017-04-02 10:29:09 +00:00
|
|
|
puts ("t: assert (1) ?\n");
|
|
|
|
assert (1);
|
|
|
|
|
|
|
|
puts ("t: assert (f==0) ?\n");
|
|
|
|
assert (f==0);
|
|
|
|
|
2017-03-13 18:38:38 +00:00
|
|
|
puts ("t: p[0] != 't'\n");
|
|
|
|
if (p[0] != 't') return p[0];
|
|
|
|
|
|
|
|
puts ("t: p[i] != 't'\n");
|
|
|
|
if (p[i] != 't') return p[i];
|
|
|
|
|
|
|
|
puts ("t: identity (p[i]) != 't'\n");
|
|
|
|
if (identity (p[i]) != 't') return identity (p[i]);
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
puts ("t: *g_chars != 'A'\n");
|
2017-01-10 19:05:47 +00:00
|
|
|
arena[0] = 'A';
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
if (*g_chars != 'A') return 1;
|
2017-01-10 19:05:47 +00:00
|
|
|
|
|
|
|
puts ("t: *x != 'A'\n");
|
|
|
|
if (*x != 'A') return 1;
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
puts ("t: *y != 'A'\n");
|
|
|
|
if (*y != 'A') return 1;
|
|
|
|
|
2017-01-17 18:03:08 +00:00
|
|
|
puts ("t: *x != 'Q'\n");
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
g_chars[0] = 'Q';
|
2017-01-17 18:03:08 +00:00
|
|
|
if (*x != 'Q') return 1;
|
|
|
|
|
2017-01-10 19:05:47 +00:00
|
|
|
puts ("t: *x++ != 'C'\n");
|
|
|
|
*x++ = c;
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
if (*g_chars != 'C') return 1;
|
2017-01-10 19:05:47 +00:00
|
|
|
|
2017-03-02 19:19:53 +00:00
|
|
|
puts ("t: 1 + 2\n");
|
|
|
|
if (1 + 2 != 3) return 1;
|
|
|
|
|
|
|
|
puts ("t: 2 - 1\n");
|
|
|
|
if (2 - 1 != 1) return 1;
|
|
|
|
|
|
|
|
puts ("t: 1 << 3\n");
|
|
|
|
if (1 << 3 != 8) return 1;
|
|
|
|
|
2017-03-25 17:48:40 +00:00
|
|
|
puts ("t: 8 >> 3\n");
|
|
|
|
if (8 >> 3 != 1) return 1;
|
|
|
|
|
2017-03-02 19:19:53 +00:00
|
|
|
puts ("t: 8 / 4\n");
|
|
|
|
if (8 / 4 != 2) return 1;
|
|
|
|
|
2017-02-27 06:50:33 +00:00
|
|
|
puts ("t: inc (0)\n");
|
|
|
|
if (inc (0) != 1) return 1;
|
|
|
|
|
|
|
|
puts ("t: inc (inc (0))\n");
|
|
|
|
if (inc (inc (0)) != 2) return 1;
|
|
|
|
|
|
|
|
puts ("t: inc (inc (inc (0)))\n");
|
|
|
|
if (inc (inc (inc (0))) != 3) return 1;
|
|
|
|
|
|
|
|
puts ("t: add (1, 2)\n");
|
|
|
|
if (add (1, 2) != 3) return 1;
|
|
|
|
|
|
|
|
puts ("t: add (inc (0), inc (1))\n");
|
|
|
|
if (add (inc (0), inc (1)) != 3) return 1;
|
|
|
|
|
2017-03-17 07:37:45 +00:00
|
|
|
puts ("t: add (TSTRING, 3)\n");
|
|
|
|
if (add (TSTRING, 3) != 13) return 1;
|
|
|
|
|
2017-02-27 06:50:33 +00:00
|
|
|
puts ("t: add (inc (inc (0)), inc (inc (1)))\n");
|
|
|
|
if (add (inc (inc (0)), inc (inc (1))) != 5) return 1;
|
|
|
|
|
2017-04-02 10:13:04 +00:00
|
|
|
puts ("t: goto label\n");
|
|
|
|
if (label (1) != 0) return 1;
|
|
|
|
|
2017-01-17 18:03:08 +00:00
|
|
|
puts ("t: switch 0\n");
|
|
|
|
if (swits (0) != 0) return swits (0);
|
|
|
|
|
|
|
|
puts ("t: switch 1\n");
|
|
|
|
if (swits (1) != 1) return 1;
|
|
|
|
|
|
|
|
puts ("t: switch -1\n");
|
2017-04-09 04:52:39 +00:00
|
|
|
if (swits (-1) != 1) return 1;
|
|
|
|
|
|
|
|
puts ("t: switch -1\n");
|
|
|
|
if (swits (-2) != 2) return 1;
|
2017-01-17 18:03:08 +00:00
|
|
|
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
puts ("t: if (1)\n");
|
|
|
|
if (1) goto ok0;
|
|
|
|
return 1;
|
|
|
|
ok0:
|
|
|
|
|
2017-04-10 04:59:50 +00:00
|
|
|
puts ("t: while (1) break;\n");
|
|
|
|
while (1) break;
|
|
|
|
|
|
|
|
puts ("t: while (1) ... break;\n");
|
|
|
|
while (1) {f=0;break;}
|
|
|
|
|
2017-06-12 19:00:50 +00:00
|
|
|
puts ("t: while (1) {while (1) break;break;}\n");
|
2017-04-10 04:59:50 +00:00
|
|
|
while (1) {while (1) break;break;}
|
|
|
|
|
2017-06-12 15:10:29 +00:00
|
|
|
puts ("t: while () {continue;...}\n");
|
|
|
|
while (one--) {continue;one=1;}
|
|
|
|
one += 2;
|
|
|
|
|
2017-03-10 06:01:51 +00:00
|
|
|
puts ("t: while (1) { goto label; };\n");
|
|
|
|
while (1) {
|
|
|
|
goto ok00;
|
|
|
|
}
|
|
|
|
ok00:
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
puts ("t: if (0); return 1; else;\n");
|
|
|
|
if (0) return 1; else goto ok01;
|
|
|
|
ok01:
|
|
|
|
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
puts ("t: if (t)\n");
|
|
|
|
if (t) goto ok1;
|
|
|
|
return 1;
|
|
|
|
ok1:
|
|
|
|
|
|
|
|
puts ("t: if (one > 0)\n");
|
|
|
|
if (one > 0) goto ok2;
|
|
|
|
return 1;
|
|
|
|
ok2:
|
|
|
|
|
|
|
|
puts ("t: if (one < 2)\n");
|
mescc: Mini-mes (gcc-compiled) runs read-0.mes.
* module/language/c99/compiler.mes (expr->accu): Add mul.
(test->jump->info): Add le, ge.
(ast->info): Support int and char* initialization at top level.
* module/mes/as-i386.mes (i386:accu*base, i386:Xjump-cz,
i386:Xjump-ncz): New function.
* module/mes/as-i386.scm: Export them.
* doc/examples/t.c (test): Test them.
* module/mes/libc.mes (ungetc): New function.
(getchar): Support it.
(assert_fail, isdigit): New functions.
(libc): Export them.
* module/mes/mini-0.mes: Load full reader.
* mlibc.c (ungetc): New function.
(getchar): Support it.
(assert_fail, isdigit): New functions.
* mes.c (list length error lookup_ getchar ungetchar peekchar
peek_byte read_byte unread_byte greater_p less_p): Move functions
needed to run read-0.mes into core.
* doc/examples/mini-mes.c: Likewise.
* lib.c (length, error): Comment-out.
* math.c (greater_p, less_p): Comment-out.
* posix.c: (getchar, ungetchar, peekchar, peek_byte, read_byte,
unread_byte): Comment-out.
* reader.c (lookup_): Comment-out.
2017-03-22 05:39:24 +00:00
|
|
|
if (one < 2) goto ok3;
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
return 1;
|
|
|
|
ok3:
|
|
|
|
|
mescc: Mini-mes (gcc-compiled) runs read-0.mes.
* module/language/c99/compiler.mes (expr->accu): Add mul.
(test->jump->info): Add le, ge.
(ast->info): Support int and char* initialization at top level.
* module/mes/as-i386.mes (i386:accu*base, i386:Xjump-cz,
i386:Xjump-ncz): New function.
* module/mes/as-i386.scm: Export them.
* doc/examples/t.c (test): Test them.
* module/mes/libc.mes (ungetc): New function.
(getchar): Support it.
(assert_fail, isdigit): New functions.
(libc): Export them.
* module/mes/mini-0.mes: Load full reader.
* mlibc.c (ungetc): New function.
(getchar): Support it.
(assert_fail, isdigit): New functions.
* mes.c (list length error lookup_ getchar ungetchar peekchar
peek_byte read_byte unread_byte greater_p less_p): Move functions
needed to run read-0.mes into core.
* doc/examples/mini-mes.c: Likewise.
* lib.c (length, error): Comment-out.
* math.c (greater_p, less_p): Comment-out.
* posix.c: (getchar, ungetchar, peekchar, peek_byte, read_byte,
unread_byte): Comment-out.
* reader.c (lookup_): Comment-out.
2017-03-22 05:39:24 +00:00
|
|
|
puts ("t: if (one >= 0)\n");
|
|
|
|
if (one >= 0) goto ok30;
|
|
|
|
return 1;
|
|
|
|
ok30:
|
|
|
|
|
|
|
|
puts ("t: if (one >= 1)\n");
|
|
|
|
if (one >= 0) goto ok31;
|
|
|
|
return 1;
|
|
|
|
ok31:
|
|
|
|
|
|
|
|
puts ("t: if (one <= 2)\n");
|
|
|
|
if (one <= 2) goto ok32;
|
|
|
|
return 1;
|
|
|
|
ok32:
|
|
|
|
|
|
|
|
puts ("t: if (one <= 1)\n");
|
|
|
|
if (one <= 1) goto ok33;
|
|
|
|
return 1;
|
|
|
|
ok33:
|
|
|
|
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
puts ("t: if (strlen (\".\"))\n");
|
|
|
|
if (strlen (".")) goto ok4;
|
|
|
|
return 1;
|
|
|
|
ok4:
|
|
|
|
|
2017-01-08 16:51:40 +00:00
|
|
|
puts ("t: if (strlen (p) == 4)\n");
|
|
|
|
if (strlen (p) == 4) goto ok40;
|
|
|
|
ok40:
|
|
|
|
|
|
|
|
puts ("t: if (!strcmp (p, \"t.c\\n\"))\n");
|
|
|
|
if (!strcmp (p, "t.c\n")) goto ok41;
|
|
|
|
return 1;
|
|
|
|
ok41:
|
|
|
|
|
|
|
|
puts ("t: if (strcmp (p, \"foo\"))\n");
|
|
|
|
if (strcmp (p, "foo")) goto ok42;
|
|
|
|
return 1;
|
|
|
|
ok42:
|
|
|
|
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
puts ("t: if (!0)\n");
|
|
|
|
if (!0) goto ok5;
|
|
|
|
return 1;
|
|
|
|
ok5:
|
|
|
|
|
|
|
|
puts ("t: if (one == 1)\n");
|
|
|
|
if (one == 1) goto ok6;
|
|
|
|
return 1;
|
|
|
|
ok6:
|
|
|
|
|
|
|
|
puts ("t: if (one != 0)\n");
|
|
|
|
if (one != 0) goto ok7;
|
|
|
|
return 1;
|
|
|
|
ok7:
|
|
|
|
|
|
|
|
puts ("t: if (1 && !0)\n");
|
|
|
|
if (1 && !0) goto ok8;
|
|
|
|
return 1;
|
|
|
|
ok8:
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
puts ("t: if (f || t)\n");
|
|
|
|
if (f || t) goto ok80;
|
|
|
|
return 1;
|
|
|
|
ok80:
|
|
|
|
|
2017-01-07 20:53:12 +00:00
|
|
|
puts ("t: if (++i)\n");
|
|
|
|
if (++i) goto ok9;
|
2017-01-10 19:05:47 +00:00
|
|
|
return 1;
|
2017-01-07 20:53:12 +00:00
|
|
|
ok9:
|
|
|
|
|
|
|
|
puts ("t: if (i--)\n");
|
|
|
|
if (i--) goto ok10;
|
2017-01-10 19:05:47 +00:00
|
|
|
return 1;
|
2017-01-07 20:53:12 +00:00
|
|
|
ok10:
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
puts ("t: *g_chars == 'B'\n");
|
2017-01-10 19:05:47 +00:00
|
|
|
arena[0] = 'B';
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
if (*g_chars == 'B') goto ok11;
|
2017-01-10 19:05:47 +00:00
|
|
|
return 1;
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
ok11:
|
2017-01-10 19:05:47 +00:00
|
|
|
|
|
|
|
puts ("t: *x == 'B'\n");
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
x = arena;
|
2017-01-10 19:05:47 +00:00
|
|
|
if (*x == 'B') goto ok12;
|
|
|
|
return 1;
|
|
|
|
ok12:
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
puts ("t: *y == 'B'\n");
|
|
|
|
y = g_chars;
|
|
|
|
if (*y == 'B') goto ok13;
|
2017-01-10 19:05:47 +00:00
|
|
|
return 1;
|
|
|
|
ok13:
|
|
|
|
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
puts ("t: *x == 'R'\n");
|
|
|
|
g_chars[0] = 'R';
|
|
|
|
if (*x == 'R') goto ok14;
|
|
|
|
return 1;
|
|
|
|
ok14:
|
|
|
|
|
2017-01-10 19:05:47 +00:00
|
|
|
puts ("t: *x++ == 'C'\n");
|
|
|
|
*x++ = c;
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
if (*g_chars == 'C') goto ok15;
|
2017-01-10 19:05:47 +00:00
|
|
|
return 1;
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
ok15:
|
2017-01-10 19:05:47 +00:00
|
|
|
|
2017-03-12 10:05:20 +00:00
|
|
|
puts ("t: itoa (33) == \"33\"\n");
|
|
|
|
if (strcmp (itoa (33), "33")) return 1;
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
|
2017-05-03 21:01:49 +00:00
|
|
|
puts ("strcmp (itoa (-1), \"-1\")\n");
|
|
|
|
if (strcmp (itoa (-1), "-1")) return 1;
|
|
|
|
|
|
|
|
puts ("strcmp (itoa (0), \"0\")\n");
|
|
|
|
if (strcmp (itoa (0), "0")) return 1;
|
|
|
|
|
|
|
|
puts ("strcmp (itoa (1), \"1\")\n");
|
|
|
|
if (strcmp (itoa (1), "1")) return 1;
|
|
|
|
|
2017-05-06 07:11:42 +00:00
|
|
|
puts ("void_func ()\n");
|
|
|
|
void_func ();
|
|
|
|
|
2017-05-08 19:15:53 +00:00
|
|
|
return string_test ();
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
int
|
|
|
|
main (int argc, char *argv[])
|
|
|
|
{
|
|
|
|
char *p = "t.c\n";
|
|
|
|
puts ("t.c\n");
|
|
|
|
|
2017-07-02 14:25:14 +00:00
|
|
|
puts ("t: argv[0] == \"scaffold/t....\"\n");
|
|
|
|
if (strncmp (argv[0], "scaffold/t", 5)) return 1;
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
|
2017-04-17 00:15:11 +00:00
|
|
|
puts ("t: *argv\"\n");
|
|
|
|
puts (*argv);
|
|
|
|
puts ("\n");
|
|
|
|
|
|
|
|
puts ("t: if (argc > 1 && !strcmp (argv[1], \"--help\")\n");
|
|
|
|
if (argc > 1 && !strcmp (argv[1], "--help")) return 1;
|
mescc: Run mini-mes.
* .gitignore: Ignore tiny-mes and tiny .mo's.
* doc/examples/tiny-mes.c: Simplify.
* doc/examples/mini-mes.c: Use simplifications from tiny-mes.
* doc/examples/t.c (read_test, struct_test): New functions.
(test): Add tests for arena, g_cells globals.
* module/mes/elf-util.mes (dec->hex): New function.
(lambda/label->list): Add text-address parameter. Update callers.
* module/language/c99/compiler.mes (make, info, clone): Add init field.
(.init): New function.
(ident->accu): Add exceptions for globals.
* module/mes/elf-util.scm: Export it.
* module/mes/libc-i386.mes (i386:accu->base-ref,
i386:byte-accu->base-ref, i386:accu->base-ref+n,
i386:accu->global-ref, i386:global-ref->accu, i386:global-ref->base,
i386:global-add, i386:global->accu):, i386:local-ref->accu,
i386:local-ptr->accu, i386:local-ptr->base): New functions.
* module/mes/libc-i386.scm: Export them.
2017-01-29 14:22:39 +00:00
|
|
|
|
|
|
|
return test (p);
|
|
|
|
|
|
|
|
return 22;
|
mescc: Beginning of expression and test template.
* scaffold/t.c: New file.
* GNUmakefile (mescc-check, t-check): New targets.
* module/language/c99/compiler.mes (write-any): Catch weirdness.
(make): Add <function> slot.
(.function): New accessor.
(clone): Handle it.
(function->info): Set it.
(ast->info): Make tests generic in if, for, while. Add goto, label,
!, ==, !=, -, &&.
* module/mes/elf-util.mes (lambda/label->list): New function.
(text->list): Use it.
(functions->text, function-prefix): New function.
(function-offset): Use it.
(label-offset): New function.
* module/mes/elf-util.scm (mes): Export them.
* module/mes/elf.mes (make-elf): Use text->list.
* module/mes/libc-i386.mes (eputs, puts): Remove.
(i386:byte-base-sub): Rename from sub-byte-base.
(i386:byte-jump-z): Rename from i386:Xjump-byte-z.
(i386:byte-mem->accu): Rename from i386:Xmem-byte->accu.
(i386:byte-mem->base): Rename from i386:Xmem-byte->base.
(i386:accu->local, i386:accu-non-zero?, i386:accu-zero?,
i386:base-sub, i386:byte-sub-base, i386:jump-c, i386:jump-cz,
i386:jump-nc, i386:jump-ncz, i386:byte-mem->base, i386:sub-base,
i386:test-accu, i386:test-base, i386:test-jump-z, i386:value->base,
i386:xor-zf): New functions.
2017-04-02 10:23:00 +00:00
|
|
|
}
|