]> mj.ucw.cz Git - umpf.git/commitdiff
fix if-else bug
authorAnicka Bernathova <anicka@anicka.net>
Tue, 21 Jul 2009 17:36:22 +0000 (19:36 +0200)
committerAnicka Bernathova <anicka@anicka.net>
Tue, 21 Jul 2009 17:36:22 +0000 (19:36 +0200)
code.c
int.c

diff --git a/code.c b/code.c
index 170fd3a9f686afcbde584880f83004cd69929aa4..dfb47a6b0d7ee297149e7c49f12a30a7e8517117 100644 (file)
--- a/code.c
+++ b/code.c
@@ -271,7 +271,7 @@ do_if(struct tree *t, struct list* where)
        c = eval_cond(t->pt.tif.c, -1, where);
 
        compile(t->pt.tif.i, if_branch);        
-       compile(t->pt.tif.i, else_branch);      
+       compile(t->pt.tif.e, else_branch);      
        new_instr(nop, else_branch);
        jmp.u.jump.target = list_last(else_branch);
        new_instr(jmp, if_branch);
diff --git a/int.c b/int.c
index 60c40d502356c74e94a0080dda1ba1a46c3c42f5..bf3f2d97f0d49f35632050361e90dfd7c4a54d2e 100644 (file)
--- a/int.c
+++ b/int.c
@@ -690,7 +690,8 @@ interp(struct list* ins, struct list* hash)
        char* result;
        int v;
 
-       LIST_FOREACH(p, ins) {
+       p = (void*) ins->head.next; 
+       while ((struct node*) p != &ins->head) {
        switch (p->opcode) {
                case OPC_SET:
                        result = get_var(p->u.set.r);
@@ -699,20 +700,20 @@ interp(struct list* ins, struct list* hash)
                        break;  
                case OPC_JUMP:
                        p = p->u.jump.target;
-                       continue;
-                       break;
+                       continue;       
                case OPC_JUMP_IF:
-                       if (eval_cond(p->u.jump_if.cond))
+                       if (eval_cond(p->u.jump_if.cond)) {
                                p = p->u.jump_if.target;
-                       continue;
+                               continue;       
+                       }
                        break;
                case OPC_JUMP_UNLESS:
-                       if (!eval_cond(p->u.jump_unless.cond))
+                       if (!eval_cond(p->u.jump_unless.cond)) {
                                p = p->u.jump_unless.target;
-                       continue;
+                               continue;       
+                       }
                        break;
                case OPC_NOP:
-                       continue;
                        break;
                case OPC_GT:
                case OPC_LT:
@@ -758,7 +759,9 @@ interp(struct list* ins, struct list* hash)
                case OPC_DISCARD:
                        bye(0, NULL);
                        break;
-       }}
+       }
+               p = (void*) ((struct node*) p)->next;
+       }
        deliver(default_mailbox, 0, hash);
 }