X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=codea%2Fsymtable.c;h=dc11f878318a6c4cc56450778a6ad93ca2d62a19;hb=1655012042275ce0a24e5429e3d2a14559849cda;hp=850c1b08388b9252a5dac9f54ee674c0f256bf11;hpb=536ec62d45af2b1893a2ccd617eb4b7604adf5c9;p=uebersetzerbau-ss10.git diff --git a/codea/symtable.c b/codea/symtable.c index 850c1b0..dc11f87 100755 --- a/codea/symtable.c +++ b/codea/symtable.c @@ -3,7 +3,9 @@ #include #include "symtable.h" +#if 0 #define DD +#endif struct symbol *tab_new(void) { @@ -15,24 +17,29 @@ struct symbol *tab_clone(struct symbol *tab) struct symbol *elm = tab; struct symbol *ntab = tab_new(); #ifdef DD - printf("tab_clone: tab(%08X)\n", tab); + fprintf(stderr, "tab_clone: tab(%08X)\n", tab); #endif while(elm != SYMNULL) { - ntab = tab_add_symbol(ntab, elm->ident, elm->type, 0); + ntab = tab_add_symbol(ntab, elm->ident, elm->type, 0, elm->param_index ? elm->param_index : 0); elm = elm->next; } return ntab; } -struct symbol *tab_add_symbol(struct symbol *tab, char *ident, short type, short check) +struct symbol *tab_add_symbol(struct symbol *tab, char *ident, short type, short check, int param_index) { struct symbol *elm = tab; struct symbol *new_elm; #ifdef DD - printf("tab_add_symbol: tab(%08X), ident(%s), type(%i), check(%i)\n", tab, ident, type, check); + fprintf(stderr, "tab_add_symbol: tab(%08X), ident(%s), type(%i), check(%i), param_index(%i)\n", tab, ident, type, check, param_index); #endif + 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) { if(check) { fprintf(stderr, "Identifier doppelt vorhanden: \"%s\"\n", ident); @@ -46,6 +53,9 @@ 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; + } if(tab == SYMNULL) { return new_elm; @@ -68,7 +78,7 @@ struct symbol *tab_lookup(struct symbol *tab, char *ident, short type) } do { - if((elm->type == type) && (strcmp(elm->ident, ident) == 0)) { + if((elm->type & type) && (strcmp(elm->ident, ident) == 0)) { return elm; } elm = elm->next; @@ -82,11 +92,11 @@ struct symbol *tab_merge(struct symbol *tab, struct symbol *to_add, short check) struct symbol *elm = to_add; struct symbol *ntab = tab_clone(tab); #ifdef DD - printf("tab_merge: tab(%08X), to_add(%08X), check(%i), ntab(%08X)\n", tab, to_add, check, ntab); + fprintf(stderr, "tab_merge: tab(%08X), to_add(%08X), check(%i), ntab(%08X)\n", tab, to_add, check, ntab); #endif while(elm != SYMNULL) { - ntab = tab_add_symbol(ntab, elm->ident, elm->type, check); + ntab = tab_add_symbol(ntab, elm->ident, elm->type, check, elm->param_index ? elm->param_index : 0); elm = elm->next; } @@ -120,10 +130,10 @@ void check(struct symbol *tab, char *ident, short type) { struct symbol *elm; #ifdef DD - printf("check: tab(%08X), ident(%s), type(%i), elm(%08X)\n", tab, ident, type, elm); + fprintf(stderr, "check: tab(%08X), ident(%s), type(%i), elm(%08X)\n", tab, ident, type, elm); #endif - if(type == S_VAR) { + if(type & (S_VAR | S_PARM)) { elm = tab_lookup(tab, ident, type); if(elm != SYMNULL) { return;