From b22eee36df3fd6a8803e604e7bf2198eaabbaf30 Mon Sep 17 00:00:00 2001 From: Jan Nieuwenhuizen Date: Fri, 17 Mar 2017 23:49:29 +0100 Subject: [PATCH] mescc: Fix simple value tests. * module/language/c99/compiler.mes (test->jump->info): Test accu before jumping. Fixes simple value tests. --- module/language/c99/compiler.mes | 16 +++++++++++++--- scaffold/mini-mes.c | 11 ----------- scaffold/t.c | 14 +++++++++++--- 3 files changed, 24 insertions(+), 17 deletions(-) diff --git a/module/language/c99/compiler.mes b/module/language/c99/compiler.mes index 381f6f61..d66e1d41 100644 --- a/module/language/c99/compiler.mes +++ b/module/language/c99/compiler.mes @@ -1073,9 +1073,19 @@ _))))) (.text (a-jump jump-length)) jump-text (.text (b-jump body-length))))))) - ((array-ref . _) ((jump i386:jump-byte-z) o)) - ((de-ref _) ((jump i386:jump-byte-z) o)) - (_ ((jump i386:Xjump-z) o))))) + + ((array-ref . _) ((jump (lambda (n) + (append + (i386:accu-zero?) + (i386:jump-byte-z n)))) o)) + ((de-ref _) ((jump (lambda (n) + (append + (i386:accu-zero?) + (i386:jump-byte-z n)))) o)) + (_ ((jump (lambda (n) + (append + (i386:accu-zero?) + (i386:Xjump-z n)))) o))))) (define (cstring->number s) (cond ((string-prefix? "0x" s) (string->number (string-drop s 2) 16)) diff --git a/scaffold/mini-mes.c b/scaffold/mini-mes.c index b79ef163..9b14d42c 100644 --- a/scaffold/mini-mes.c +++ b/scaffold/mini-mes.c @@ -1100,19 +1100,8 @@ make_symbol (SCM s) return make_symbol_ (s); #else SCM x = lookup_symbol_ (s); - // FIXME: does not work with mescc?! - // return x != 0 ? x : make_symbol_ (s); return x ? x : make_symbol_ (s); #endif -// FIXME -// #if MES_MINI -// SCM x = 0; -// #else -// SCM x = lookup_symbol_ (s); -// #endif -// //FIXME -// //return x ? x : make_symbol_ (s); -// return x != 0 ? x : make_symbol_ (s); } SCM diff --git a/scaffold/t.c b/scaffold/t.c index f19d2933..82165c41 100644 --- a/scaffold/t.c +++ b/scaffold/t.c @@ -376,10 +376,7 @@ struct_test () int fn = 0; puts ("t: g_functions[g_cells[fn].cdr].arity\n"); -#if __GNUC__ - //FIXME if (g_functions[g_cells[fn].cdr].arity) return 1; -#endif if (g_functions[g_cells[fn].cdr].arity != 0) return 1; int (*functionx) (void) = 0; @@ -731,6 +728,17 @@ test (char *p) } #endif +int +init () +{ + // g_cells[0].cdr = 0; + // g_cells[1].cdr = 1; + g_functions[0] = g_foo; + g_functions[1] = g_bar; + + return 0; +} + int main (int argc, char *argv[]) {