mescc: Cleanup mini-mes build and test.
* GNUmakefile (guile-cons-mes guile-m guile-main guile-micro-mes guile-mini-mes guile-t guile-tiny-mes): New targets. (clean): Clean them. * .gitignore: Ignore them. * HACKING: Update. * scaffold/tiny-mes.c (bload_env): Read module/mes/tiny-0-32.mo. * scaffold/cons-mes.c (simple_bload_env): Likewise. * lib.c (dump)[MES_TINY]: Write crafted dump: module/mes/tiny-0-32.mo. (load_env): Read module/mes/mini-0.mes. (bload_env): Read module/mes/read-0-32.mo. * module/mes/mini-0.mes: New file. * module/mes/tiny-0.mes : New file.
This commit is contained in:
parent
4e12e14b85
commit
240f2814f4
21
.gitignore
vendored
21
.gitignore
vendored
|
@ -13,11 +13,28 @@
|
||||||
/ChangeLog
|
/ChangeLog
|
||||||
/a.out
|
/a.out
|
||||||
/mes
|
/mes
|
||||||
|
/mes-32
|
||||||
|
|
||||||
|
/cons-mes
|
||||||
|
/m
|
||||||
|
/main
|
||||||
/micro-mes
|
/micro-mes
|
||||||
/mini-mes
|
/mini-mes
|
||||||
|
/t
|
||||||
/tiny-mes
|
/tiny-mes
|
||||||
/module/mes/hack-32.mo
|
|
||||||
/module/mes/read-0-32.mo
|
/guile-cons-mes
|
||||||
|
/guile-m
|
||||||
|
/guile-main
|
||||||
|
/guile-micro-mes
|
||||||
|
/guile-mini-mes
|
||||||
|
/guile-t
|
||||||
|
/guile-tiny-mes
|
||||||
|
|
||||||
|
/module/mes/tiny-0-32.mo
|
||||||
|
#keep this: bootstrap
|
||||||
|
#/module/mes/read-0-32.mo
|
||||||
|
/module/mes/mini-0.mo
|
||||||
/module/mes/read-0.mo
|
/module/mes/read-0.mo
|
||||||
/out
|
/out
|
||||||
?
|
?
|
||||||
|
|
56
GNUmakefile
56
GNUmakefile
|
@ -15,6 +15,7 @@ CFLAGS:=-std=c99 -O3 -finline-functions
|
||||||
include .config.make
|
include .config.make
|
||||||
include make/install.make
|
include make/install.make
|
||||||
|
|
||||||
|
CPPFLAGS+=-I.
|
||||||
CPPFLAGS+=-DPREFIX='"$(PREFIX)"'
|
CPPFLAGS+=-DPREFIX='"$(PREFIX)"'
|
||||||
CPPFLAGS+=-DVERSION='"$(VERSION)"'
|
CPPFLAGS+=-DVERSION='"$(VERSION)"'
|
||||||
|
|
||||||
|
@ -37,6 +38,10 @@ mes.o: reader.c reader.h reader.i reader.environment.i
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
rm -f mes *.o *.environment.i *.symbols.i *.environment.h *.cat a.out
|
rm -f mes *.o *.environment.i *.symbols.i *.environment.h *.cat a.out
|
||||||
|
rm -f mes-32
|
||||||
|
rm -f cons-mes m main micro-mes mini-mes t tiny-mes
|
||||||
|
rm -f guile-cons-mes guile-m guile-main guile-micro-mes guile-mini-mes guile-t guile-tiny-mes
|
||||||
|
rm -f module/mes/*.mo
|
||||||
|
|
||||||
distclean: clean
|
distclean: clean
|
||||||
rm -f .config.make
|
rm -f .config.make
|
||||||
|
@ -90,13 +95,16 @@ module/mes/read-0.mo: module/mes/read-0.mes mes
|
||||||
|
|
||||||
dump: module/mes/read-0.mo
|
dump: module/mes/read-0.mo
|
||||||
|
|
||||||
mes-32:
|
mes-32: mes.c lib.c
|
||||||
rm -f mes mes.o
|
rm -f mes mes.o
|
||||||
guix environment --system=i686-linux --ad-hoc gcc-toolchain -- bash -c 'make mes CC=i686-unknown-linux-gnu-gcc LIBRARY_PATH=$${PATH%%/bin:*}/lib'
|
guix environment --system=i686-linux --ad-hoc gcc-toolchain -- bash -c 'make mes CC=i686-unknown-linux-gnu-gcc LIBRARY_PATH=$${PATH%%/bin:*}/lib'
|
||||||
mv mes mes-32
|
mv mes mes-32
|
||||||
|
|
||||||
module/mes/hack-32.mo: mes-32
|
module/mes/read-0-32.mo: module/mes/mini-0.mes mes-32
|
||||||
MES_HACK=1 ./mes-32 --dump < module/mes/read-0.mes > module/mes/hack-32.mo
|
MES_MINI=1 ./mes-32 --dump < $< > $@
|
||||||
|
|
||||||
|
module/mes/tiny-0-32.mo: module/mes/tiny-0.mes mes-32
|
||||||
|
MES_TINY=1 ./mes-32 --dump < $< > $@
|
||||||
|
|
||||||
guile-check:
|
guile-check:
|
||||||
set -e; for i in $(TESTS); do\
|
set -e; for i in $(TESTS); do\
|
||||||
|
@ -117,43 +125,81 @@ mescc-check: t-check
|
||||||
build-aux/mes-snarf.scm $<
|
build-aux/mes-snarf.scm $<
|
||||||
|
|
||||||
mini-mes: mini-mes.h mini-mes.i mini-mes.environment.i mini-mes.symbols.i
|
mini-mes: mini-mes.h mini-mes.i mini-mes.environment.i mini-mes.symbols.i
|
||||||
|
mini-mes: mlibc.c mstart.c
|
||||||
mini-mes: GNUmakefile
|
mini-mes: GNUmakefile
|
||||||
mini-mes: doc/examples/mini-mes.c
|
mini-mes: module/mes/read-0-32.mo
|
||||||
|
mini-mes: scaffold/mini-mes.c
|
||||||
rm -f $@
|
rm -f $@
|
||||||
gcc -nostdlib -I. --std=gnu99 -m32 -g -I. -o $@ '-DVERSION="0.4"' $<
|
# gcc -nostdlib --std=gnu99 -m32 -g -o $@ '-DPREFIX=' '-DVERSION='"$(VERSION)"' $<
|
||||||
|
gcc -nostdlib -I. --std=gnu99 -m32 -g -I. -o $@ $(CPPFLAGS) $<
|
||||||
chmod +x $@
|
chmod +x $@
|
||||||
|
|
||||||
|
guile-mini-mes: mini-mes.h mini-mes.i mini-mes.environment.i mini-mes.symbols.i
|
||||||
|
guile-mini-mes: module/mes/read-0-32.mo
|
||||||
|
guile-mini-mes: scaffold/mini-mes.c
|
||||||
|
guile/mescc.scm $< > $@ || rm -f $@
|
||||||
|
chmod +x $@
|
||||||
|
|
||||||
|
cons-mes: module/mes/tiny-0-32.mo
|
||||||
cons-mes: scaffold/cons-mes.c GNUmakefile
|
cons-mes: scaffold/cons-mes.c GNUmakefile
|
||||||
rm -f $@
|
rm -f $@
|
||||||
gcc -nostdlib -I. --std=gnu99 -m32 -g -o $@ '-DVERSION="0.4"' $<
|
gcc -nostdlib -I. --std=gnu99 -m32 -g -o $@ '-DVERSION="0.4"' $<
|
||||||
chmod +x $@
|
chmod +x $@
|
||||||
|
|
||||||
|
guile-cons-mes: module/mes/tiny-0-32.mo
|
||||||
|
guile-cons-mes: scaffold/cons-mes.c
|
||||||
|
guile/mescc.scm $< > $@ || rm -f $@
|
||||||
|
chmod +x $@
|
||||||
|
|
||||||
|
tiny-mes: module/mes/tiny-0-32.mo
|
||||||
tiny-mes: scaffold/tiny-mes.c GNUmakefile
|
tiny-mes: scaffold/tiny-mes.c GNUmakefile
|
||||||
rm -f $@
|
rm -f $@
|
||||||
gcc -nostdlib -I. --std=gnu99 -m32 -g -o $@ '-DVERSION="0.4"' $<
|
gcc -nostdlib -I. --std=gnu99 -m32 -g -o $@ '-DVERSION="0.4"' $<
|
||||||
chmod +x $@
|
chmod +x $@
|
||||||
|
|
||||||
|
guile-tiny-mes: module/mes/tiny-0-32.mo
|
||||||
|
guile-tiny-mes: scaffold/tiny-mes.c
|
||||||
|
guile/mescc.scm $< > $@ || rm -f $@
|
||||||
|
chmod +x $@
|
||||||
|
|
||||||
m: scaffold/m.c GNUmakefile
|
m: scaffold/m.c GNUmakefile
|
||||||
rm -f $@
|
rm -f $@
|
||||||
gcc -nostdlib -I. --std=gnu99 -m32 -g -o $@ '-DVERSION="0.4"' $<
|
gcc -nostdlib -I. --std=gnu99 -m32 -g -o $@ '-DVERSION="0.4"' $<
|
||||||
# gcc --std=gnu99 -g -o $@ '-DVERSION="0.4"' $<
|
# gcc --std=gnu99 -g -o $@ '-DVERSION="0.4"' $<
|
||||||
chmod +x $@
|
chmod +x $@
|
||||||
|
|
||||||
|
guile-m: scaffold/m.c
|
||||||
|
guile/mescc.scm $< > $@ || rm -f $@
|
||||||
|
chmod +x $@
|
||||||
|
|
||||||
micro-mes: scaffold/micro-mes.c GNUmakefile
|
micro-mes: scaffold/micro-mes.c GNUmakefile
|
||||||
rm -f $@
|
rm -f $@
|
||||||
gcc -nostdlib -I. --std=gnu99 -m32 -o $@ '-DVERSION="0.4"' $<
|
gcc -nostdlib -I. --std=gnu99 -m32 -o $@ '-DVERSION="0.4"' $<
|
||||||
chmod +x $@
|
chmod +x $@
|
||||||
|
|
||||||
|
guile-micro-mes: scaffold/micro-mes.c
|
||||||
|
guile/mescc.scm $< > $@ || rm -f $@
|
||||||
|
chmod +x $@
|
||||||
|
|
||||||
main: doc/examples/main.c GNUmakefile
|
main: doc/examples/main.c GNUmakefile
|
||||||
rm -f $@
|
rm -f $@
|
||||||
gcc -nostdlib -I. --std=gnu99 -m32 -o $@ '-DVERSION="0.4"' $<
|
gcc -nostdlib -I. --std=gnu99 -m32 -o $@ '-DVERSION="0.4"' $<
|
||||||
chmod +x $@
|
chmod +x $@
|
||||||
|
|
||||||
|
guile-main: doc/examples/main.c
|
||||||
|
guile/mescc.scm $< > $@ || rm -f $@
|
||||||
|
chmod +x $@
|
||||||
|
|
||||||
|
t: mlibc.c
|
||||||
t: scaffold/t.c GNUmakefile
|
t: scaffold/t.c GNUmakefile
|
||||||
rm -f $@
|
rm -f $@
|
||||||
gcc -nostdlib -I. --std=gnu99 -m32 -g -o $@ '-DVERSION="0.4"' $<
|
gcc -nostdlib -I. --std=gnu99 -m32 -g -o $@ '-DVERSION="0.4"' $<
|
||||||
chmod +x $@
|
chmod +x $@
|
||||||
|
|
||||||
|
guile-t: scaffold/t.c
|
||||||
|
guile/mescc.scm $< > $@ || rm -f $@
|
||||||
|
chmod +x $@
|
||||||
|
|
||||||
MAIN_C:=doc/examples/main.c
|
MAIN_C:=doc/examples/main.c
|
||||||
mescc: all $(MAIN_C)
|
mescc: all $(MAIN_C)
|
||||||
rm -f a.out
|
rm -f a.out
|
||||||
|
|
4
HACKING
4
HACKING
|
@ -82,7 +82,9 @@ gdb-display-disassembly-buffer
|
||||||
b *0x804a79d
|
b *0x804a79d
|
||||||
** Create memory dump with 32 bit Gcc compiled Mes
|
** Create memory dump with 32 bit Gcc compiled Mes
|
||||||
guix environment --ad-hoc --system=i686-linux gcc-toolchain -- bash -c 'make mes CC=i686-unknown-linux-gnu-gcc LIBRARY_PATH=${PATH%%/bin:*}/lib'
|
guix environment --ad-hoc --system=i686-linux gcc-toolchain -- bash -c 'make mes CC=i686-unknown-linux-gnu-gcc LIBRARY_PATH=${PATH%%/bin:*}/lib'
|
||||||
MES_HACK=1 ./mes-32 --dump < module/mes/read-0.mes > module/mes/read-0-32.mo
|
mv mes mes-32
|
||||||
|
MES_TINY=1 ./mes-32 --dump < module/mes/tiny-0.mes > module/mes/tiny-0-32.mo
|
||||||
|
./mes-32 --dump < module/mes/read-0.mes > module/mes/read-0-32.mo
|
||||||
** C parser/compiler
|
** C parser/compiler
|
||||||
*** [[https://savannah.gnu.org/projects/nyacc][nyacc]]
|
*** [[https://savannah.gnu.org/projects/nyacc][nyacc]]
|
||||||
*** PEG: [[http://piumarta.com/software/peg/][parse C using PEG]]
|
*** PEG: [[http://piumarta.com/software/peg/][parse C using PEG]]
|
||||||
|
|
7
lib.c
7
lib.c
|
@ -172,7 +172,8 @@ dump ()
|
||||||
fputc ('S', stdout);
|
fputc ('S', stdout);
|
||||||
fputc (g_stack >> 8, stdout);
|
fputc (g_stack >> 8, stdout);
|
||||||
fputc (g_stack % 256, stdout);
|
fputc (g_stack % 256, stdout);
|
||||||
if (getenv ("MES_HACK"))
|
// See HACKING, simple crafted dump for tiny-mes.c
|
||||||
|
if (getenv ("MES_TINY"))
|
||||||
{
|
{
|
||||||
TYPE (9) = 0x2d2d2d2d;
|
TYPE (9) = 0x2d2d2d2d;
|
||||||
CAR (9) = 0x2d2d2d2d;
|
CAR (9) = 0x2d2d2d2d;
|
||||||
|
@ -210,7 +211,7 @@ load_env (SCM a) ///((internal))
|
||||||
{
|
{
|
||||||
r0 = a;
|
r0 = a;
|
||||||
if (getenv ("MES_MINI"))
|
if (getenv ("MES_MINI"))
|
||||||
g_stdin = fopen ("mini-0.mes", "r");
|
g_stdin = fopen ("module/mes/mini-0.mes", "r");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
g_stdin = fopen ("module/mes/read-0.mes", "r");
|
g_stdin = fopen ("module/mes/read-0.mes", "r");
|
||||||
|
@ -226,7 +227,7 @@ SCM
|
||||||
bload_env (SCM a) ///((internal))
|
bload_env (SCM a) ///((internal))
|
||||||
{
|
{
|
||||||
#if MES_MINI
|
#if MES_MINI
|
||||||
g_stdin = fopen ("mini-0.mo", "r");
|
g_stdin = fopen ("module/mes/read-0-32.mo", "r");
|
||||||
#else
|
#else
|
||||||
g_stdin = fopen ("module/mes/read-0.mo", "r");
|
g_stdin = fopen ("module/mes/read-0.mo", "r");
|
||||||
g_stdin = g_stdin ? g_stdin : fopen (PREFIX "module/mes/read-0.mo", "r");
|
g_stdin = g_stdin ? g_stdin : fopen (PREFIX "module/mes/read-0.mo", "r");
|
||||||
|
|
7
module/mes/mini-0.mes
Normal file
7
module/mes/mini-0.mes
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
(begin
|
||||||
|
(write-byte (make-cell 0 0 65))
|
||||||
|
(write-byte (make-cell 0 0 66))
|
||||||
|
(write-byte (make-cell 0 0 67))
|
||||||
|
(write-byte (make-cell 0 0 10))
|
||||||
|
#f
|
||||||
|
)
|
1
module/mes/tiny-0.mes
Normal file
1
module/mes/tiny-0.mes
Normal file
|
@ -0,0 +1 @@
|
||||||
|
(cons 0 1)
|
|
@ -844,11 +844,11 @@ SCM
|
||||||
simple_bload_env (SCM a) ///((internal))
|
simple_bload_env (SCM a) ///((internal))
|
||||||
{
|
{
|
||||||
puts ("reading: ");
|
puts ("reading: ");
|
||||||
char *mo = "module/mes/hack-32.mo";
|
char *mo = "module/mes/tiny-0-32.mo";
|
||||||
puts (mo);
|
puts (mo);
|
||||||
puts ("\n");
|
puts ("\n");
|
||||||
g_stdin = open (mo, 0);
|
g_stdin = open (mo, 0);
|
||||||
if (g_stdin < 0) {eputs ("no such file: module/mes/read-0-32.mo\n");return 1;}
|
if (g_stdin < 0) {eputs ("no such file: module/mes/tiny-0-32.mo\n");return 1;}
|
||||||
|
|
||||||
char *p = (char*)g_cells;
|
char *p = (char*)g_cells;
|
||||||
int c;
|
int c;
|
||||||
|
|
|
@ -1117,8 +1117,7 @@ mes_builtins (SCM a) ///((internal))
|
||||||
SCM
|
SCM
|
||||||
bload_env (SCM a) ///((internal))
|
bload_env (SCM a) ///((internal))
|
||||||
{
|
{
|
||||||
char *mo = "mini-0-32.mo";
|
char *mo = "module/mes/read-0-32.mo";
|
||||||
//char *mo = "module/mes/read-0-32.mo";
|
|
||||||
g_stdin = open (mo, 0);
|
g_stdin = open (mo, 0);
|
||||||
if (g_stdin < 0) {eputs ("no such file: ");eputs (mo);eputs ("\n");return 1;}
|
if (g_stdin < 0) {eputs ("no such file: ");eputs (mo);eputs ("\n");return 1;}
|
||||||
assert (getchar () == 'M');
|
assert (getchar () == 'M');
|
||||||
|
|
|
@ -313,11 +313,11 @@ SCM
|
||||||
bload_env (SCM a) ///((internal))
|
bload_env (SCM a) ///((internal))
|
||||||
{
|
{
|
||||||
puts ("reading: ");
|
puts ("reading: ");
|
||||||
char *mo = "module/mes/hack-32.mo";
|
char *mo = "module/mes/tiny-0-32.mo";
|
||||||
puts (mo);
|
puts (mo);
|
||||||
puts ("\n");
|
puts ("\n");
|
||||||
g_stdin = open (mo, 0);
|
g_stdin = open (mo, 0);
|
||||||
if (g_stdin < 0) {eputs ("no such file: module/mes/read-0-32.mo\n");return 1;}
|
if (g_stdin < 0) {eputs ("no such file: module/mes/tiny-0-32.mo\n");return 1;}
|
||||||
|
|
||||||
// BOOM
|
// BOOM
|
||||||
//char *p = arena;
|
//char *p = arena;
|
||||||
|
|
Loading…
Reference in a new issue