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 (jump type)
|
||||
(define (jump type . test)
|
||||
(lambda (o)
|
||||
(let* ((text (.text info))
|
||||
(info (clone info #:text '()))
|
||||
|
@ -1025,6 +1025,7 @@ _)))))
|
|||
(clone info #:text
|
||||
(append text
|
||||
(.text info)
|
||||
(if (null? test) '() (car test))
|
||||
(jump-text body-length)))))))
|
||||
(lambda (o)
|
||||
(pmatch o
|
||||
|
@ -1074,18 +1075,19 @@ _)))))
|
|||
jump-text
|
||||
(.text (b-jump body-length)))))))
|
||||
|
||||
((array-ref . _) ((jump (lambda (n)
|
||||
((array-ref . _) ((jump i386:jump-byte-z
|
||||
(list (lambda (f g ta t d) (i386:accu-zero?)))) o))
|
||||
|
||||
((de-ref _) ((jump i386:jump-byte-z
|
||||
(list (lambda (f g ta t d) (i386:accu-zero?)))) o))
|
||||
|
||||
((assn-expr (p-expr (ident ,name)) ,op ,expr)
|
||||
((jump i386:Xjump-z
|
||||
(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)))))
|
||||
((ident->accu info) name)
|
||||
(list (lambda (f g ta t d) (i386:accu-zero?))))) o))
|
||||
|
||||
(_ ((jump i386:Xjump-z (list (lambda (f g ta t d) (i386:accu-zero?)))) o)))))
|
||||
|
||||
(define (cstring->number s)
|
||||
(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;
|
||||
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");
|
||||
(one == 1) ? 1 : exit (1);
|
||||
|
||||
|
@ -728,17 +734,6 @@ 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[])
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue