static void dump_args(funcargs *fa, dump *ctx) { decl **di; for(di = fa->arglist; di && *di; di++) dump_decl(*di, ctx, "argument"); }
static void dump_sue(dump *ctx, type *ty) { struct_union_enum_st *sue = type_is_s_or_u_or_e(ty); sue_member **mi; if(!sue) return; dump_inc(ctx); for(mi = sue->members; mi && *mi; mi++){ if(sue->primitive == type_enum){ enum_member *emem = (*mi)->enum_member; dump_desc(ctx, emem->spel, emem, &emem->where); if(emem->val && emem->val != (expr *)-1){ dump_inc(ctx); dump_expr(emem->val, ctx); dump_dec(ctx); } dump_attributes(emem->attr, ctx); }else{ decl *d = (*mi)->struct_member; dump_decl(d, ctx, "member"); dump_sue(ctx, d->ref); } } dump_dec(ctx); }
void dump_flow(stmt_flow *flow, dump *ctx) { decl **di; if(!flow) return; for(di = flow->for_init_symtab->decls; di && *di; di++) dump_decl(*di, ctx, NULL); }
void gen_dump(symtable_global *globs) { dump dump = { 0 }; symtable_gasm **iasm = globs->gasms; decl **diter; dump.fout = stdout; for(diter = symtab_decls(&globs->stab); diter && *diter; diter++){ decl *d = *diter; while(iasm && d == (*iasm)->before){ dump_gasm(*iasm, &dump); if(!*++iasm) iasm = NULL; } dump_decl(d, &dump, NULL); } }
//Recusively dumping SCOPE trees. void dump_scope(SCOPE * s, UINT flag) { if (g_tfile == NULL) return; static CHAR buf[8192]; buf[0] = 0; note("\nSCOPE(id:%d, level:%d)", SCOPE_id(s), SCOPE_level(s)); g_indent++; //symbols SYM_LIST * sym_list = SCOPE_sym_tab_list(s); if (sym_list != NULL) { note("\nSYMBAL:"); g_indent++; note("\n"); while (sym_list != NULL) { note("%s\n", SYM_name(SYM_LIST_sym(sym_list))); sym_list = SYM_LIST_next(sym_list); } g_indent--; } //all of defined customer label in code LABEL_INFO * li = SCOPE_label_list(s).get_head(); if (li != NULL) { note("\nDEFINED LABEL:"); g_indent++; note("\n"); for (; li != NULL; li = SCOPE_label_list(s).get_next()) { IS_TRUE0(map_lab2lineno(li) != 0); note("%s (def in line:%d)\n", SYM_name(LABEL_INFO_name(li)), map_lab2lineno(li)); } g_indent--; } //refered customer label in code li = SCOPE_ref_label_list(s).get_head(); if (li != NULL) { note("\nREFED LABEL:"); g_indent++; note("\n"); for (; li != NULL; li = SCOPE_ref_label_list(s).get_next()) { note("%s (use in line:%d)\n", SYM_name(LABEL_INFO_name(li)), map_lab2lineno(li)); } g_indent--; } //enums ENUM_LIST * el = SCOPE_enum_list(s); if (el != NULL) { note("\nENUM LIST:"); g_indent++; note("\n"); while (el != NULL) { buf[0] = 0; format_enum_complete(buf, ENUM_LIST_enum(el)); note("%s\n", buf); el = ENUM_LIST_next(el); } g_indent--; } //user defined type, by 'typedef' USER_TYPE_LIST * utl = SCOPE_user_type_list(s); if (utl != NULL) { note("\nUSER TYPE:"); g_indent++; note("\n"); while (utl != NULL) { buf[0] = 0; format_user_type_spec(buf, USER_TYPE_LIST_utype(utl)); note("%s\n", buf); utl = USER_TYPE_LIST_next(utl); } g_indent--; } //structs STRUCT * st = SCOPE_struct_list(s); if (st != NULL) { note("\nSTRUCT:"); g_indent++; note("\n"); while (st != NULL) { buf[0] = 0; format_struct_complete(buf, st); note("%s\n", buf); st = USER_TYPE_LIST_next(st); } g_indent--; } //unions UNION * un = SCOPE_union_list(s); if (un != NULL) { note("\nUNION:"); g_indent++; note("\n"); while (un != NULL) { buf[0] = 0; format_union_complete(buf, un); note("%s\n", buf); un = USER_TYPE_LIST_next(un); } g_indent--; } //declarations DECL * dcl = SCOPE_decl_list(s); if (dcl != NULL) { note("\nDECLARATIONS:"); note("\n"); g_indent++; while (dcl != NULL) { buf[0] = 0; format_declaration(buf, dcl); note("%s", buf); dump_decl(dcl); //Dump function body if (DECL_is_fun_def(dcl) && HAVE_FLAG(flag, DUMP_SCOPE_FUNC_BODY)) { g_indent += 2; dump_scope(DECL_fun_body(dcl), flag); g_indent -= 2; } //Dump initializing value/expression. if (DECL_is_init(DECL_decl_list(dcl))) { note("= "); g_indent += 2; dump_tree(DECL_init_tree(DECL_decl_list(dcl))); g_indent -= 2; } note("\n"); dcl = DECL_next(dcl); } g_indent--; } fflush(g_tfile); if (HAVE_FLAG(flag, DUMP_SCOPE_STMT_TREE)) { TREE * t = SCOPE_stmt_list(s); if (t != NULL) { note("\nSTATEMENT:"); g_indent++; note("\n"); dump_trees(t); g_indent--; } } g_indent--; }