From 98d46a95ee04d0e7de9b24041b8fb6bfefeb9a91 Mon Sep 17 00:00:00 2001 From: Anicka Bernathova Date: Wed, 15 Jul 2009 15:25:51 +0200 Subject: [PATCH] fix arrow --- code.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/code.c b/code.c index 7c22968..04b41b3 100644 --- a/code.c +++ b/code.c @@ -231,8 +231,6 @@ do_arrow(struct tree* t, struct list* where) int v; struct code ins; - v = evaluate(t->pt.arrow.s, -1, where); - ins.u.arrow.what = v; if (t->pt.arrow.left == K_COPY) ins.u.arrow.copy = 1; @@ -248,9 +246,18 @@ do_arrow(struct tree* t, struct list* where) case K_MAIL: ins.opcode = MAIL; break; + case K_DISCARD: + ins.opcode = DISCARD; + break; default: die("do_arrow: This cannot happen ;-)"); } + + if (t->pt.arrow.right != K_DISCARD) { + v = evaluate(t->pt.arrow.s, -1, where); + ins.u.arrow.what = v; + } + new_instr(ins, where); } @@ -291,8 +298,9 @@ compile(struct tree* t, struct list* where) eval_cond(t, -1, where); // warn? case ST_ARROW: do_arrow(t, where); + break; default: - die("compile: got to default"); + die("compile: got to default, type: %d", t->st); } } @@ -325,6 +333,18 @@ print_code(void) case NOP: puts("NOP"); break; + case PIPE: + printf("PIPE %d %d\n", p->u.arrow.what, p->u.arrow.copy); + break; + case STORE: + printf("STORE %d %d\n", p->u.arrow.what, p->u.arrow.copy); + break; + case MAIL: + printf("MAIL %d %d\n", p->u.arrow.what, p->u.arrow.copy); + break; + case DISCARD: + puts("DISCARD"); + break; default: printf("not implemented, opcode: %d\n", p->opcode); -- 2.39.5