mescc: Support assignment test.
* module/language/c99/compiler.mes (test->jump->info): Handle assignment. * doc/examples/t.c (test): Test it.
This commit is contained in:
parent
b22eee36df
commit
4c59078002
|
@ -1014,7 +1014,7 @@ _)))))
|
||||||
)))
|
)))
|
||||||
|
|
||||||
(define (test->jump->info info)
|
(define (test->jump->info info)
|
||||||
(define (jump type)
|
(define (jump type . test)
|
||||||
(lambda (o)
|
(lambda (o)
|
||||||
(let* ((text (.text info))
|
(let* ((text (.text info))
|
||||||
(info (clone info #:text '()))
|
(info (clone info #:text '()))
|
||||||
|
@ -1025,6 +1025,7 @@ _)))))
|
||||||
(clone info #:text
|
(clone info #:text
|
||||||
(append text
|
(append text
|
||||||
(.text info)
|
(.text info)
|
||||||
|
(if (null? test) '() (car test))
|
||||||
(jump-text body-length)))))))
|
(jump-text body-length)))))))
|
||||||
(lambda (o)
|
(lambda (o)
|
||||||
(pmatch o
|
(pmatch o
|
||||||
|
@ -1074,18 +1075,19 @@ _)))))
|
||||||
jump-text
|
jump-text
|
||||||
(.text (b-jump body-length)))))))
|
(.text (b-jump body-length)))))))
|
||||||
|
|
||||||
((array-ref . _) ((jump (lambda (n)
|
((array-ref . _) ((jump i386:jump-byte-z
|
||||||
(append
|
(list (lambda (f g ta t d) (i386:accu-zero?)))) o))
|
||||||
(i386:accu-zero?)
|
|
||||||
(i386:jump-byte-z n)))) o))
|
((de-ref _) ((jump i386:jump-byte-z
|
||||||
((de-ref _) ((jump (lambda (n)
|
(list (lambda (f g ta t d) (i386:accu-zero?)))) o))
|
||||||
(append
|
|
||||||
(i386:accu-zero?)
|
((assn-expr (p-expr (ident ,name)) ,op ,expr)
|
||||||
(i386:jump-byte-z n)))) o))
|
((jump i386:Xjump-z
|
||||||
(_ ((jump (lambda (n)
|
(append
|
||||||
(append
|
((ident->accu info) name)
|
||||||
(i386:accu-zero?)
|
(list (lambda (f g ta t d) (i386:accu-zero?))))) o))
|
||||||
(i386:Xjump-z n)))) o)))))
|
|
||||||
|
(_ ((jump i386:Xjump-z (list (lambda (f g ta t d) (i386:accu-zero?)))) o)))))
|
||||||
|
|
||||||
(define (cstring->number s)
|
(define (cstring->number s)
|
||||||
(cond ((string-prefix? "0x" s) (string->number (string-drop s 2) 16))
|
(cond ((string-prefix? "0x" s) (string->number (string-drop s 2) 16))
|
||||||
|
|
17
scaffold/t.c
17
scaffold/t.c
|
@ -528,6 +528,12 @@ test (char *p)
|
||||||
i -= 2;
|
i -= 2;
|
||||||
if (i != 0) return 1;
|
if (i != 0) return 1;
|
||||||
|
|
||||||
|
puts ("t: if (f = 0) ?\n");
|
||||||
|
if (f = 0) return 1;
|
||||||
|
|
||||||
|
puts ("t: if (!(t = 1)) ?\n");
|
||||||
|
if (!(t = 1)) return 1;
|
||||||
|
|
||||||
puts ("t: (one == 1) ?\n");
|
puts ("t: (one == 1) ?\n");
|
||||||
(one == 1) ? 1 : exit (1);
|
(one == 1) ? 1 : exit (1);
|
||||||
|
|
||||||
|
@ -728,17 +734,6 @@ test (char *p)
|
||||||
}
|
}
|
||||||
#endif
|
#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
|
int
|
||||||
main (int argc, char *argv[])
|
main (int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue