X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=codea%2Fsymtable.c;h=47762405fad1f69f1da306b6ec9a37da155452f7;hb=7f1d29c581324003e8c378069b94eafef62fbab0;hp=5476ae8243fb71637f0ae3f6e73b70cafecdcc1f;hpb=8f8ed7aa1e635e7bcc50823b943654c9a82a1c9b;p=uebersetzerbau-ss10.git diff --git a/codea/symtable.c b/codea/symtable.c old mode 100755 new mode 100644 index 5476ae8..4776240 --- a/codea/symtable.c +++ b/codea/symtable.c @@ -21,21 +21,26 @@ struct symbol *tab_clone(struct symbol *tab) #endif while(elm != SYMNULL) { - ntab = tab_add_symbol(ntab, elm->ident, elm->type, 0, elm->param_index ? elm->param_index : 0); + ntab = tab_add_symbol(ntab, elm->ident, elm->type, 0, elm->param_index, elm->soffset); elm = elm->next; } return ntab; } -struct symbol *tab_add_symbol(struct symbol *tab, char *ident, short type, short check, int param_index) +struct symbol *tab_add_symbol(struct symbol *tab, char *ident, short type, short check, int param_index, int soffset) { struct symbol *elm = tab; struct symbol *new_elm; #ifdef DD - fprintf(stderr, "tab_add_symbol: tab(%08X), ident(%s), type(%i), check(%i), param_index(%i)\n", tab, ident, type, check, param_index); + fprintf(stderr, "tab_add_symbol: tab(%08X), ident(%s), type(%i), check(%i), param_index(%i), soffset(%i)\n", tab, ident, type, check, param_index, soffset); #endif - if(tab_lookup(tab, ident, type) != SYMNULL) { + if(param_index >= 6) { + fprintf(stderr, "eine methode hat zu viele parameter (max. 6 inkl. this erlaubt)\n"); + exit(4); + } + + if(tab_lookup(tab, ident, type) != SYMNULL || (type == S_VAR && tab_lookup(tab, ident, S_PARM) != SYMNULL)) { if(check) { fprintf(stderr, "Identifier doppelt vorhanden: \"%s\"\n", ident); exit(3); @@ -48,13 +53,10 @@ struct symbol *tab_add_symbol(struct symbol *tab, char *ident, short type, short new_elm->next = SYMNULL; new_elm->ident = strdup(ident); new_elm->type = type; - if(type == S_PARM) { - new_elm->param_index = param_index; - } + new_elm->param_index = param_index; + new_elm->soffset = soffset; - if(tab == SYMNULL) { - return new_elm; - } + if(tab == SYMNULL) return new_elm; while(elm->next != SYMNULL) { elm = elm->next; @@ -68,9 +70,7 @@ struct symbol *tab_lookup(struct symbol *tab, char *ident, short type) { struct symbol *elm = tab; - if(tab == SYMNULL) { - return SYMNULL; - } + if(tab == SYMNULL) return SYMNULL; do { if((elm->type & type) && (strcmp(elm->ident, ident) == 0)) { @@ -91,7 +91,7 @@ struct symbol *tab_merge(struct symbol *tab, struct symbol *to_add, short check) #endif while(elm != SYMNULL) { - ntab = tab_add_symbol(ntab, elm->ident, elm->type, check, elm->param_index ? elm->param_index : 0); + ntab = tab_add_symbol(ntab, elm->ident, elm->type, check, elm->param_index, elm->soffset); elm = elm->next; }