virtual Stmt funccall_x ( const std::string& p, const std::list<std::string>& args, const std::list<std::string>& x) { std::cout << stmtIndex << ":" << "("; outputlist(x); std::cout << ") =" << p << "("; outputlist( args); std::cout << ");\n"; return (void*)stmtIndex++; }
virtual Stmt funcdef_x(const std::string& x, const std::list<std::string>& params, const std::list<std::string>& results) { std::cout << stmtIndex << ":" << "func " << x; std::cout << "("; outputlist( params); std::cout << ") => ("; outputlist( results); std::cout << ");\n"; return (void*)stmtIndex++; }
/* main(). */ int main(int argc, char *argv[]) { textline *lines = NULL; char **arg; int ret = 0; int count, i; readoptions(argc, argv); if (optind == argc) { err("nothing to do."); exit(EXIT_FAILURE); } for (arg = argv + optind ; (thefilename = *arg) != NULL ; ++arg) { if (!(thefile = fopen(thefilename, "rb"))) { perror(thefilename); ++ret; continue; } if (!readelfhdr() || !readproghdrs() || !readsecthdrs()) { fclose(thefile); ++ret; continue; } describeehdr(stdout); if (ldepls && proghdrs) { if ((count = getlibraries(&lines))) { outputlist(stdout, lines, count, "Dependencies: "); free(lines); } } if (srcfls && secthdrs) { if ((count = getsrcfiles(&lines))) { qsort(lines, count, sizeof *lines, linesorter); outputlist(stdout, lines, count, "Source files: "); free(lines); } } makenumberfmts(); if (phdrls && proghdrs) { printf("Program header table entries: %d", elffhdr.e_phnum); if (dooffs) printf(" (%lX - %lX)", (unsigned long)elffhdr.e_phoff, (unsigned long)elffhdr.e_phoff + elffhdr.e_phnum * elffhdr.e_phentsize); putchar('\n'); lines = gettextlines(elffhdr.e_phnum); for (i = 0 ; i < elffhdr.e_phnum ; ++i) { append(lines + i, "%2d ", i); describephdr(lines + i, proghdr + i); } formatlist(stdout, lines, elffhdr.e_phnum); free(lines); } if (shdrls && secthdrs) { printf("Section header table entries: %d", elffhdr.e_shnum); if (dooffs) printf(" (%lX - %lX)", (unsigned long)elffhdr.e_shoff, (unsigned long)elffhdr.e_shoff + elffhdr.e_shnum * elffhdr.e_shentsize); putchar('\n'); lines = gettextlines(elffhdr.e_shnum); for (i = 0 ; i < elffhdr.e_shnum ; ++i) { append(lines + i, "%2d ", i); describeshdr(lines + i, secthdr + i); } formatlist(stdout, lines, elffhdr.e_shnum); free(lines); } fclose(thefile); free(proghdr); free(secthdr); free(sectstr); } return ret; }