+/* cont_elem is used for continuing information in cfront.
+ It saves information about which types need to be fixed up and
+ completed after all the stabs are read. */
+struct cont_elem
+ {
+ /* sym and stabsstring for continuing information in cfront */
+ struct symbol *sym;
+ char *stabs;
+ /* state dependancies (statics that must be preserved) */
+ int sym_idx;
+ int sym_end;
+ int symnum;
+ int (*func) PARAMS ((struct objfile *, struct symbol *, char *));
+ /* other state dependancies include:
+ (assumption is that these will not change since process_now FIXME!!)
+ stringtab_global
+ n_stabs
+ objfile
+ symfile_bfd */
+ };
+
+static struct cont_elem *cont_list = 0;
+static int cont_limit = 0;
+static int cont_count = 0;
+
+/* Arrange for function F to be called with arguments SYM and P later
+ in the stabs reading process. */
+void
+process_later (sym, p, f)
+ struct symbol *sym;
+ char *p;
+ int (*f) PARAMS ((struct objfile *, struct symbol *, char *));
+{
+
+ /* Allocate more space for the deferred list. */
+ if (cont_count >= cont_limit - 1)
+ {
+ cont_limit += 32; /* chunk size */
+
+ cont_list
+ = (struct cont_elem *) xrealloc (cont_list,
+ (cont_limit
+ * sizeof (struct cont_elem)));
+ if (!cont_list)
+ error ("Virtual memory exhausted\n");
+ }
+
+ /* Save state variables so we can process these stabs later. */
+ cont_list[cont_count].sym_idx = symbuf_idx;
+ cont_list[cont_count].sym_end = symbuf_end;
+ cont_list[cont_count].symnum = symnum;
+ cont_list[cont_count].sym = sym;
+ cont_list[cont_count].stabs = p;
+ cont_list[cont_count].func = f;
+ cont_count++;
+}
+
+/* Call deferred funtions in CONT_LIST. */
+
+static void
+process_now (objfile)
+ struct objfile *objfile;
+{
+ int i;
+ int save_symbuf_idx;
+ int save_symbuf_end;
+ int save_symnum;
+ struct symbol *sym;
+ char *stabs;
+ int err;
+ int (*func) PARAMS ((struct objfile *, struct symbol *, char *));
+
+ /* Save the state of our caller, we'll want to restore it before
+ returning. */
+ save_symbuf_idx = symbuf_idx;
+ save_symbuf_end = symbuf_end;
+ save_symnum = symnum;
+
+ /* Iterate over all the deferred stabs. */
+ for (i = 0; i < cont_count; i++)
+ {
+ /* Restore the state for this deferred stab. */
+ symbuf_idx = cont_list[i].sym_idx;
+ symbuf_end = cont_list[i].sym_end;
+ symnum = cont_list[i].symnum;
+ sym = cont_list[i].sym;
+ stabs = cont_list[i].stabs;
+ func = cont_list[i].func;
+
+ /* Call the function to handle this deferrd stab. */
+ err = (*func) (objfile, sym, stabs);
+ if (err)
+ error ("Internal error: unable to resolve stab.\n");
+ }
+
+ /* Restore our caller's state. */
+ symbuf_idx = save_symbuf_idx;
+ symbuf_end = save_symbuf_end;
+ symnum = save_symnum;
+ cont_count = 0;
+}
+
+