X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=code.c;h=932bb9ab5d8766c3a43f508a43b5add5b27825ab;hb=8628def3891660a2ebfce358dc65cf6b0f0a92d1;hp=4a84d18c7dcc3e2af57a07431b3f4003f4a28cff;hpb=fe58a4c2ebb3d4ff4649e58f67324214d7f6f863;p=umpf.git diff --git a/code.c b/code.c index 4a84d18..932bb9a 100644 --- a/code.c +++ b/code.c @@ -32,22 +32,36 @@ get_bucket_number(char* name) return n; } -/* if not found, variable with value "" is created */ +/* return var struct or NULL if not found */ +struct variable* +get_var_struct(char* name, enum var_type type, struct list* hash) +{ + int n; + struct variable *p; + + n = get_bucket_number(name); + LIST_FOREACH(p, hash + n) + if (!strcasecmp(p->name, name) && p->type == type) + return p; + + return NULL; +} + int -find_var(char* name, struct list* hash) +find_var(char* name, enum var_type type, struct list* hash) { int n; struct variable *p; n = get_bucket_number(name); - int nocase = isupper(*name); LIST_FOREACH(p, hash + n) - if (!(nocase ? strcasecmp : strcmp)(p->name,name)) + if (!strcasecmp(p->name, name) && p->type == type) return p->varcode; p = xmalloc(sizeof(struct variable)); p->name = xstrdup(name); p->varcode = current_varcode++; + p->type = type; list_add_last(hash+n, &p->car); return p->varcode; @@ -298,6 +312,9 @@ do_arrow(struct tree* t, struct list* where) case K_DISCARD: ins.opcode = OPC_DISCARD; break; + case K_FILTER: + ins.opcode = OPC_FILTER; + break; default: die("do_arrow: This cannot happen ;-)"); } @@ -429,6 +446,9 @@ print_code(void) case OPC_PIPE: printf("PIPE %d %d\n", p->u.arrow.what, p->u.arrow.copy); break; + case OPC_FILTER: + printf("FILTER %d %d\n", p->u.arrow.what, p->u.arrow.copy); + break; case OPC_DELIVER: printf("DELIVER %d %d\n", p->u.arrow.what, p->u.arrow.copy); break;