mescc: Fix d-sel comparisons.
* module/language/c99/compiler.mes (ast->info): Save base while computing accu. Fix comparison using d-sel in second argument. * doc/examples/t.c: Test it. * doc/examples/mini-mes.c (assq): Use it.
This commit is contained in:
parent
d039b00349
commit
a2f180ba4a
|
@ -1522,7 +1522,10 @@ _)))))
|
||||||
(clone info #:text
|
(clone info #:text
|
||||||
(append text
|
(append text
|
||||||
(.text base)
|
(.text base)
|
||||||
|
(list (lambda (f g ta t d)
|
||||||
|
(i386:push-base)))
|
||||||
(.text accu)
|
(.text accu)
|
||||||
|
(i386:pop-accu)
|
||||||
(list (lambda (f g ta t d)
|
(list (lambda (f g ta t d)
|
||||||
(i386:sub-base)))))))
|
(i386:sub-base)))))))
|
||||||
|
|
||||||
|
@ -1533,7 +1536,11 @@ _)))))
|
||||||
(clone info #:text
|
(clone info #:text
|
||||||
(append text
|
(append text
|
||||||
(.text base)
|
(.text base)
|
||||||
|
(list (lambda (f g ta t d)
|
||||||
|
(i386:push-base)))
|
||||||
(.text accu)
|
(.text accu)
|
||||||
|
(list (lambda (f g ta t d)
|
||||||
|
(i386:pop-base)))
|
||||||
(list (lambda (f g ta t d)
|
(list (lambda (f g ta t d)
|
||||||
(i386:sub-base)))))))
|
(i386:sub-base)))))))
|
||||||
|
|
||||||
|
@ -1544,7 +1551,11 @@ _)))))
|
||||||
(clone info #:text
|
(clone info #:text
|
||||||
(append text
|
(append text
|
||||||
(.text base)
|
(.text base)
|
||||||
|
(list (lambda (f g ta t d)
|
||||||
|
(i386:push-base)))
|
||||||
(.text accu)
|
(.text accu)
|
||||||
|
(list (lambda (f g ta t d)
|
||||||
|
(i386:pop-base)))
|
||||||
(list (lambda (f g ta t d)
|
(list (lambda (f g ta t d)
|
||||||
(append
|
(append
|
||||||
(i386:sub-base)
|
(i386:sub-base)
|
||||||
|
@ -1557,6 +1568,8 @@ _)))))
|
||||||
(clone info #:text
|
(clone info #:text
|
||||||
(append text
|
(append text
|
||||||
(.text base)
|
(.text base)
|
||||||
|
(list (lambda (f g ta t d)
|
||||||
|
(i386:push-base)))
|
||||||
(.text accu)
|
(.text accu)
|
||||||
(list (lambda (f g ta t d)
|
(list (lambda (f g ta t d)
|
||||||
(i386:base-sub)))))))
|
(i386:base-sub)))))))
|
||||||
|
@ -1569,7 +1582,11 @@ _)))))
|
||||||
(clone info #:text
|
(clone info #:text
|
||||||
(append text
|
(append text
|
||||||
(.text base)
|
(.text base)
|
||||||
|
(list (lambda (f g ta t d)
|
||||||
|
(i386:push-base)))
|
||||||
(.text accu)
|
(.text accu)
|
||||||
|
(list (lambda (f g ta t d)
|
||||||
|
(i386:pop-base)))
|
||||||
(list (lambda (f g ta t d)
|
(list (lambda (f g ta t d)
|
||||||
(i386:base-sub)))))))
|
(i386:base-sub)))))))
|
||||||
|
|
||||||
|
|
|
@ -616,51 +616,9 @@ call (SCM fn, SCM x)
|
||||||
SCM
|
SCM
|
||||||
assq (SCM x, SCM a)
|
assq (SCM x, SCM a)
|
||||||
{
|
{
|
||||||
|
//FIXME: todo eq_p
|
||||||
//while (a != cell_nil && eq_p (x, CAAR (a)) == cell_f) a = CDR (a);
|
//while (a != cell_nil && eq_p (x, CAAR (a)) == cell_f) a = CDR (a);
|
||||||
//while (a != cell_nil && x != CAAR (a)) a = CDR (a);
|
while (a != cell_nil && x != CAAR (a)) a = CDR (a);
|
||||||
|
|
||||||
#if BDEBUG
|
|
||||||
puts ("assq: ");
|
|
||||||
display_ (x);
|
|
||||||
puts (" [");
|
|
||||||
puts (itoa (x));
|
|
||||||
puts ("]\n");
|
|
||||||
#endif
|
|
||||||
int i;
|
|
||||||
while (a != cell_nil) // && x != CAR (CAR (a)))
|
|
||||||
{
|
|
||||||
a = CDR (a);
|
|
||||||
// FIXME
|
|
||||||
i = CAR (CAR (a));
|
|
||||||
#if 1
|
|
||||||
//!__GNUC__
|
|
||||||
// puts (" ");
|
|
||||||
// puts (itoa (i));
|
|
||||||
// if (x == i) puts ("***FOUND*** ");
|
|
||||||
if (x == i) goto found;
|
|
||||||
// puts (" ");
|
|
||||||
// display_ (CAAR (a));
|
|
||||||
// puts ("[");
|
|
||||||
// puts (itoa (CAAR (a)));
|
|
||||||
// puts ("]\n");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
found:
|
|
||||||
#if BDEBUG
|
|
||||||
//!__GNUC__
|
|
||||||
//puts ("assq: ");
|
|
||||||
puts (" ");
|
|
||||||
puts (" [");
|
|
||||||
puts (itoa (x));
|
|
||||||
puts ("]");
|
|
||||||
display_ (x);
|
|
||||||
puts (" => ");
|
|
||||||
if (a == cell_nil) display_ (cell_f);
|
|
||||||
else display_ (CAR (a));
|
|
||||||
puts ("[");
|
|
||||||
puts (itoa (CDR (CDR (CAR (a)))));
|
|
||||||
puts ("]\n");
|
|
||||||
#endif
|
|
||||||
return a != cell_nil ? car (a) : cell_f;
|
return a != cell_nil ? car (a) : cell_f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
17
scaffold/t.c
17
scaffold/t.c
|
@ -129,6 +129,8 @@ int ARENA_SIZE = 200;
|
||||||
#define CDR(x) g_cells[x].cdr
|
#define CDR(x) g_cells[x].cdr
|
||||||
#define VALUE(x) g_cells[x].cdr
|
#define VALUE(x) g_cells[x].cdr
|
||||||
|
|
||||||
|
#define CAAR(x) CAR (CAR (x))
|
||||||
|
|
||||||
struct scm scm_fun = {TFUNCTION,0,0};
|
struct scm scm_fun = {TFUNCTION,0,0};
|
||||||
SCM cell_fun;
|
SCM cell_fun;
|
||||||
|
|
||||||
|
@ -321,6 +323,15 @@ make_tmps_test (struct scm* cells)
|
||||||
int
|
int
|
||||||
struct_test ()
|
struct_test ()
|
||||||
{
|
{
|
||||||
|
g_cells[0].car = 1;
|
||||||
|
g_cells[1].car = 2;
|
||||||
|
|
||||||
|
puts ("t: CAAR (0) != 2\n");
|
||||||
|
if (CAAR (0) != 2) return 1;
|
||||||
|
|
||||||
|
puts ("t: 2 != CAAR (0)\n");
|
||||||
|
if (2 != CAAR (0)) return 1;
|
||||||
|
|
||||||
g_cells[3].type = 0x64;
|
g_cells[3].type = 0x64;
|
||||||
if (g_cells[3].type != 0x64)
|
if (g_cells[3].type != 0x64)
|
||||||
return g_cells[3].type;
|
return g_cells[3].type;
|
||||||
|
@ -460,6 +471,12 @@ test (char *p)
|
||||||
puts ("t: if (f)\n");
|
puts ("t: if (f)\n");
|
||||||
if (f) return 1;
|
if (f) return 1;
|
||||||
|
|
||||||
|
puts ("t: if (one != 1)\n");
|
||||||
|
if (one != 1) return 1;
|
||||||
|
|
||||||
|
puts ("t: if (1 != one)\n");
|
||||||
|
if (1 != one) return 1;
|
||||||
|
|
||||||
puts ("t: if (one > 1)\n");
|
puts ("t: if (one > 1)\n");
|
||||||
if (one > 1) return 1;
|
if (one > 1) return 1;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue