extern data list_member( arg_s *parg, /* arg entry causing call */ callinfo_s *pinfo, /* info we need to pass around */ long *plength) /* for varying length fields */ { long is_arglist; /* set if we're building an arglist */ plength; if (list_stack == 0) { fatal("unexpected list end without list start\n"); } /* if */ is_arglist = pinfo->psym->st == stParam; emit_tag(list_stack, (unsigned short)(is_arglist ? LF_ARGLIST:LF_FIELDLIST)); list_stack->count++; VERBOSE_POP_INDENT(); VERBOSE_PUSH_INDENT(TYPE_INDENT); VERBOSE_PRINTF("LIST 0x%x field %d:\n", type_get_index(list_stack->type), list_stack->count); VERBOSE_POP_INDENT(); VERBOSE_PUSH_INDENT(TYPE_INDENT); pinfo->buf = list_stack->type->buf; /* subversion */ switch (parg->id) { case MEMB: return LF_MEMBER; case ENUM: return LF_ENUMERATE; default: return 0xbadbad; } /* switch */ } /* list_member */
static int cu__emit_tags(struct cu *cu) { uint32_t i; struct tag *tag; puts("/* Types: */\n"); cu__for_each_type(cu, i, tag) emit_tag(tag, i, cu); puts("/* Functions: */\n"); conf.no_semicolon = true; struct function *function; cu__for_each_function(cu, i, function) { tag__fprintf(function__tag(function), cu, &conf, stdout); putchar('\n'); lexblock__fprintf(&function->lexblock, cu, function, 0, &conf, stdout); printf(" /* size: %zd */\n\n", tag__size(function__tag(function), cu)); }
extern void list_end( arg_s *parg, /* arg entry causing call */ callinfo_s *pinfo, /* info we need to pass around */ long *plength) /* for varying length fields */ { pSYMR psymbegin; list_s *list; unsigned short *pcount; unsigned short *ptype_index; parg; plength; if (list_stack == 0) { fatal("unexpected list end without list start\n"); } /* if */ list = list_stack; VERBOSE_PUSH_INDENT(TYPE_INDENT); /* no entries, emit tag*/ if (pinfo->psym->st != stEnd) emit_tag(list, LF_ARGLIST); else emit_tag(list, LF_FIELDLIST); if (pinfo->psym->st == stEnd) { if (pinfo->psym->index == indexNil) { fatal("list end doesn't point to list begin symbol (%d)\n", pinfo->psym->index); } /* if */ psymbegin = isym_to_psym(pinfo, pinfo->psym->index); if (psymbegin != list->psym) { fatal("list end doesn't point to list begin symbol (%d)\n", pinfo->psym->index); } /* if */ } /* if */ /* stash the count in stEnd iss field, and the type in stEnd value field */ if (pinfo->psym->sc == scForward) { /* referenced the count and type information already and the pointers * to where they go are in the respective fields we intend * to stash them in. */ pcount = (unsigned short *)pinfo->psym->iss; ptype_index = (unsigned short *)pinfo->psym->value; *pcount = (unsigned short)list->count; *ptype_index = (unsigned short)type_get_index(list->type); VERBOSE_PRINTF("Fill forward ref count (%d) & type index (0x%x)\n", *pcount, *ptype_index); } /* if */ pinfo->psym->iss = list->count; pinfo->psym->value = type_get_index(list->type); pinfo->psym->sc = scProcessed; /* mark that we've done it */ if (list->cv_leaf_type == LF_ARGLIST) { /* fix count field */ VERBOSE_PRINTF("Fix ARGLIST count field = %d\n", list->count); *list->pcount = (unsigned short)list->count; if (pinfo->psym->st == stEnd) { /* prottype appears before typedef using prototype, so set * st so we know it was a prototype. */ pinfo->psym->st = stProto; } else if (pinfo->psym->st == stEndParam) { if (list->pproccount) { /* proc definition appears before arglist, so we need to back * fill LF_PROCEDURE arg count */ VERBOSE_PRINTF("Fix LF_PROCEDURE count field = %d\n", list->count); *list->pproccount = (unsigned short)list->count; } /* if */ } /* if */ } /* if */ /* pop the list stack and free list structure, types will dump buffer * later. */ list_stack = list->next; VERBOSE_PRINTF("LIST 0x%x count = %d\n", pinfo->psym->value, list->count); VERBOSE_POP_INDENT(); free(list); } /* list_end */