From: Anicka Bernathova Date: Tue, 21 Jul 2009 17:36:22 +0000 (+0200) Subject: fix if-else bug X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=b3adc63e8b78dbcec1547cc8b8ae5d929746bb33;p=umpf.git fix if-else bug --- diff --git a/code.c b/code.c index 170fd3a..dfb47a6 100644 --- 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 60c40d5..bf3f2d9 100644 --- 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); }