Changeset 170
- Timestamp:
- 05/12/07 19:33:47 (1 year ago)
- Files:
-
- trunk/gcc/gcc/algol60/a60_symtab.c (modified) (1 diff)
- trunk/gcc/gcc/algol60/a60_symtab.h (modified) (1 diff)
- trunk/gcc/gcc/algol60/expression.c (modified) (3 diffs)
- trunk/gcc/gcc/algol60/slist.c (modified) (3 diffs)
- trunk/gcc/gcc/algol60/slist.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/gcc/gcc/algol60/a60_symtab.c
r169 r170 218 218 } 219 219 delete_slist_it (it); 220 }221 222 int223 a60_symtab_second_resolve_symbols (a60_symtab_t * self, slist_t * ret_list,224 a60_symtab_t * context_tab,225 logger_t * log, cursor_t * cursor)226 {227 int ret = 1;228 slist_it_t * it = slist_iter (self->table);229 for (; slist_it_has (it); slist_it_next (it))230 {231 symbol_t * sym = slist_it_get (it);232 label_t const * label = symbol_label (sym);233 234 // Skip symbols that are not implied parameters.235 if (!type_is_implicit (symbol_type (sym)))236 continue;237 238 symbol_t * found =239 a60_symtab_find_name_rec (context_tab, label, type_any ());240 if (found == NULL)241 {242 /*243 int was_there = a60_symtab_add_symbol (context_tab, new_symbol_var (label),244 sek_ordinary);245 assert (!was_there);246 found = a60_symtab_find_name (self, label, type_any ());247 symbol_set_type (found, type_unknown ());248 */249 250 log_printfc (log, ll_error, a60_as_cursor (symbol_extra (sym)),251 "implicit parameter `%s'",252 estr_cstr (label_id (label)));253 log_printfc (log, ll_error, cursor,254 "cannot be resolved at this point in file.");255 256 ret = 0;257 }258 else259 slist_pushback (ret_list, sym /*found*/);260 }261 262 slist_it_reset (it, ret_list);263 for (; slist_it_has (it); slist_it_next (it))264 a60_symtab_erase_symbol (self, a60_as_symbol (slist_it_get (it)));265 266 delete_slist_it (it);267 268 return ret;269 220 } 270 221 trunk/gcc/gcc/algol60/a60_symtab.h
r169 r170 93 93 ATTRIBUTE_NONNULL(1); 94 94 95 /// For resolution of implicit function parameters. This takes each96 /// symbol in the symbol table, and adds into list `ret_list` a97 /// symbols found by recursive lookup in `context_tab`. The symbtab98 /// `self` will be function's symbol table with implicit and explicit99 /// parameters; `context_tab` will be symtab of call site.100 ///101 /// Only the symbols in `self` that are of type `implicit' are looked102 /// up this way.103 ///104 /// The function returns 1 if all symbols were resolved, or 0 if there105 /// were resolution errors.106 int a60_symtab_second_resolve_symbols (a60_symtab_t * self, slist_t * ret_list, a60_symtab_t * context_tab, logger_t * log, cursor_t * cursor)107 ATTRIBUTE_NONNULL(1)108 ATTRIBUTE_NONNULL(2)109 ATTRIBUTE_NONNULL(3);110 111 95 typedef symbol_t * (* a60_symtab_missing_handler_t) (a60_symtab_t * self, label_t const * lbl, type_t const * atype, logger_t * log, cursor_t * cursor, void * data); 112 96 trunk/gcc/gcc/algol60/expression.c
r169 r170 714 714 } 715 715 716 typedef struct { 717 a60_symtab_t * context_tab; 718 logger_t * log; 719 cursor_t * cursor; 720 slist_t * resolved; 721 int status; 722 } 723 private_resolve_context_t; 724 725 static void * 726 private_resolve_implicit_callback (symbol_t * sym, void * data) 727 { 728 private_resolve_context_t * ctx = data; 729 label_t const * label = symbol_label (sym); 730 731 // Skip symbols that are not implied parameters. 732 if (!type_is_implicit (symbol_type (sym))) 733 return NULL; 734 735 symbol_t * found = 736 a60_symtab_find_name_rec (ctx->context_tab, label, type_any ()); 737 738 if (found != NULL) 739 slist_pushback (ctx->resolved, sym); 740 else 741 { 742 log_printfc (ctx->log, ll_error, a60_as_cursor (symbol_extra (sym)), 743 "implicit parameter `%s'", 744 estr_cstr (label_id (label))); 745 log_printfc (ctx->log, ll_error, ctx->cursor, 746 "cannot be resolved at this point in file."); 747 748 ctx->status = 0; 749 } 750 751 return NULL; 752 } 753 716 754 static void 717 755 private_resolve_symbols_call (expression_t * self, … … 771 809 container_t * f_container = a60_as_container (f_stmt); 772 810 a60_symtab_t * f_implicit = container_symtab (f_container); 773 slist_t * resolved = new_slist ();774 811 int e_messages = log_count_messages (log, ll_error); 775 812 int w_messages = log_count_messages (log, ll_warning); 776 if (a60_symtab_second_resolve_symbols (f_implicit, resolved, symtab, 777 log, expr_cursor (self))) 813 814 private_resolve_context_t ctx 815 = {symtab, log, expr_cursor (self), new_slist (), 1}; 816 a60_symtab_each 817 (f_implicit, a60_symbol_callback (private_resolve_implicit_callback), &ctx); 818 slist_it_t * it = slist_iter (ctx.resolved); 819 for (; slist_it_has (it); slist_it_next (it)) 820 a60_symtab_erase_symbol (f_implicit, a60_as_symbol (slist_it_get (it))); 821 delete_slist_it (it); 822 delete_slist (ctx.resolved); 823 824 if (ctx.status) 778 825 { 779 826 assert (container_parent (f_container) == NULL); … … 789 836 log_printfc (log, level, self->cursor, "at this point in file."); 790 837 } 791 delete_slist (resolved);792 838 } 793 839 } trunk/gcc/gcc/algol60/slist.c
r161 r170 402 402 slist_each ( 403 403 slist_t * list, 404 void (*fn)( slist_t *,void *, void *),404 void (*fn)(void *, void *), 405 405 void * userdata) 406 406 { … … 412 412 { 413 413 void * obj = node->object; 414 (*fn) ( list,obj, userdata);414 (*fn) (obj, userdata); 415 415 } 416 416 } … … 565 565 566 566 void 567 incctr ( slist_t * list, void * obj, void * pctr)568 { 569 (*(int*) pctr)++;567 incctr (void * obj, void * userdata) 568 { 569 (*(int*)userdata)++; 570 570 } 571 571 572 572 int 573 odd ( slist_t * list,void * obj, void * userdata)573 odd (void * obj, void * userdata) 574 574 { 575 575 return (int)obj % 2; trunk/gcc/gcc/algol60/slist.h
r160 r170 113 113 /// Apply the function `fn' to each element of the list `list'. The 114 114 /// argument `userdata' will be passed over to fn verbatim. The 115 /// arguments of `fn' are, respectively, the list that is iterated 116 /// over, the object that is currently under the cursor, and the 117 /// userdata passed to slist_map. 115 /// arguments of `fn' are, respectively, the object that is currently 116 /// under the cursor, and the userdata passed to slist_map. 118 117 void slist_each ( 119 118 slist_t * list, 120 void (*fn)( slist_t * /*list*/,void * /*object*/, void * /*userdata*/),119 void (*fn)(void * /*object*/, void * /*userdata*/), 121 120 void * userdata) 122 121 ATTRIBUTE_NONNULL(1)
