mescc: Support assignment with comparison.

* module/language/c99/compiler.mes (expr->accu): Handle assignment -> accu.
* doc/examples/t.c (test): Test it.
* doc/examples/mini-mes.c (eval_apply): Use it.
This commit is contained in:
Jan Nieuwenhuizen 2017-03-18 08:25:15 +01:00
parent 4c59078002
commit a14c3d937a
3 changed files with 12 additions and 5 deletions

View file

@ -798,6 +798,11 @@ _)))))
((cast ,cast ,o)
((expr->accu info) o))
((assn-expr (p-expr (ident ,name)) ,op ,expr)
(let ((info ((ast->info info) o)))
(clone info #:text (append (.text info)
((ident->accu info) name)))))
(_
(format (current-error-port) "SKIP: expr->accu=~s\n" o)
barf

View file

@ -913,10 +913,8 @@ eval_apply ()
SCM macro;
SCM expanders;
macro_expand:
#if __GNUC__
//FIXME
if (TYPE (r1) == TPAIR
&& (macro = lookup_macro (car (r1), r0)) != cell_f) // FIXME GNUC
&& (macro = lookup_macro (car (r1), r0)) != cell_f)
{
r1 = cons (macro, CDR (r1));
goto apply;
@ -933,7 +931,6 @@ eval_apply ()
goto apply;
}
}
#endif
goto vm_return;
begin:
x = cell_unspecified;
@ -1341,7 +1338,6 @@ bload_env (SCM a) ///((internal))
g_stdin = STDIN;
r0 = mes_builtins (r0);
#if 1
//__GNUC__
puts ("symbols: ");
SCM s = g_symbols;
while (s && s != cell_nil) {

View file

@ -534,6 +534,12 @@ test (char *p)
puts ("t: if (!(t = 1)) ?\n");
if (!(t = 1)) return 1;
puts ("t: if ((f = 0) != 0) ?\n");
if ((f = 0) != 0) return 1;
puts ("t: if ((t = 1) != 1) ?\n");
if ((t = 1) != 1) return 1;
puts ("t: (one == 1) ?\n");
(one == 1) ? 1 : exit (1);