]> mj.ucw.cz Git - umpf.git/commitdiff
fix arrow
authorAnicka Bernathova <anicka@anicka.net>
Wed, 15 Jul 2009 13:25:51 +0000 (15:25 +0200)
committerAnicka Bernathova <anicka@anicka.net>
Wed, 15 Jul 2009 13:25:51 +0000 (15:25 +0200)
code.c

diff --git a/code.c b/code.c
index 7c2296829c80268d092fb0cdc0dcfa47fa008c41..04b41b3acfb3fb9310ada0627933f46e6342c7ac 100644 (file)
--- 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);