home *** CD-ROM | disk | FTP | other *** search
/ ftp.cs.arizona.edu / ftp.cs.arizona.edu.tar / ftp.cs.arizona.edu / icon / historic / v941.tgz / icon.v941src.tar / icon.v941src / ipl / progs / fnctab.icn < prev    next >
Text File  |  2000-07-29  |  2KB  |  68 lines

  1. ############################################################################
  2. #
  3. #    File:     fnctab.icn
  4. #
  5. #    Subject:  Program to list function usage
  6. #
  7. #    Author:   Ralph E. Griswold
  8. #
  9. #    Date:     June 18, 1994
  10. #
  11. ############################################################################
  12. #
  13. #   This file is in the public domain.
  14. #
  15. ############################################################################
  16. #
  17. #  This program processes an MVT token file and tabulates the usage
  18. #  of functions.
  19. #
  20. #  Since function usage cannot be determined completely from static
  21. #  analysis, the results should be viewed with this limitation in mind.
  22. #
  23. ############################################################################
  24.  
  25. procedure main()
  26.    local fncset, fnctab, line, count, name, total
  27.  
  28.    fncset := set()            # set for the names of all functions
  29.    fnctab := table(0)            # table to tabulate function count
  30.  
  31.    total := 0
  32.  
  33.    every insert(fncset, function())
  34.    delete(fncset, "args")        # ad hoc -- usual not used as functions
  35.    delete(fncset, "name")
  36.  
  37.    while line := read() | stop("*** didn't find variable references") do {
  38.       line ? {
  39.          if ="Variable references:" then break
  40.          }
  41.       }
  42.  
  43.  
  44.    while line := trim(read()) do {
  45.       line ? {
  46.          if tab(upto(&digits)) then {
  47.             count := tab(many(&digits))
  48.             tab(upto(&letters))
  49.             name := tab(0)
  50.             if name == "" then break
  51.             if member(fncset, name) then {
  52.                fnctab[name] +:= count
  53.                total +:= count
  54.                }
  55.             }
  56.          }
  57.       }
  58.  
  59.    fnctab := sort(fnctab, 4)
  60.  
  61.    while count := pull(fnctab) do
  62.       write(left(pull(fnctab), 14), right(count, 8))
  63.  
  64.    write()
  65.    write("total         ", right(total, 8))
  66.  
  67. end
  68.