From: Anicka Bernathova Date: Tue, 14 Jul 2009 16:54:41 +0000 (+0200) Subject: add nice conditions X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=60fdc8abb225a39e83391cc7efe6517e8c204aba;p=umpf.git add nice conditions --- diff --git a/cond.y b/cond.y index b5e4bf6..f46afe5 100644 --- a/cond.y +++ b/cond.y @@ -128,6 +128,11 @@ cond: '!' cond { $$->pt.cond.op = $2; $$->pt.cond.type = OP_REL; } + | ass_right { + $$ = tree_malloc(ST_COND); + $$->pt.cond.left = $1; + $$->pt.cond.type = JUST_BOOL; + } ; rop: '>' diff --git a/umpf.h b/umpf.h index 2da7f00..179229f 100644 --- a/umpf.h +++ b/umpf.h @@ -23,11 +23,12 @@ struct tree { } tif; struct { - int op; enum { OP_REL, - OP_BOOL + OP_BOOL, + JUST_BOOL /* value only in left */ } type; + int op; struct tree* left; struct tree* right; } cond; /* binary operator */ @@ -115,7 +116,7 @@ int open_mailbox(char* path, int is_default_mailbox); char* cat(char* l, char* r); /* code.c */ -#define BUFSIZE 1024 +#define BUFSIZE 4096 struct code { struct node car; enum { @@ -130,17 +131,26 @@ struct code { } opcode; union { + struct { + struct code* target; + } jump; + struct { + struct code* target; + int cond; + } jump_if; + struct { + struct code* target; + int cond; + } jump_unless; struct { int l; int r; } set; - struct { int l; int r; int res; /* result */ } cat; - struct { } nop; } u;