############################################################################ # # Name: redconv.icn # # Title: Spot redundant conversions # # Author: Clint Jeffery, from code by Ralph E. Griswold # # Date: Aug 29, 1992 # ############################################################################ # # The tool-specific options are: # # -H i height of panel, default 300 # -W i width of panel, default 300 # -x i number of columns, default 30 # -y i number of rows, default 30 # -s i number of sectors, default 240 # -v s view to use, default "pinwheel" # ############################################################################ # # Links: typesyms, typecode, views, visprocs # ############################################################################ # # Requires: MT Icon # ############################################################################ $include "evdefs.icn" link typesyms link typecode link options link optwindw link evinit global EventMask, Width, Height, Sectors, Gc, Rows, Cols, Clear, Binding, Value global Blue, Red, lastconv, last_to, red_rows, red_counts, top_row, nonred_counts global Opts, Visualization procedure main(args) local name, descrip, specs, defaults, p, plist name := "conversion" descrip := "display type conversion" Opts := options(args, winoptions()) EvInit(args) | stop("no event monitoring") lastconv := table() red_rows := table() red_counts := table(0) nonred_counts := table(0) top_row := 1 xopen() # temporary patch # EventMask := cset(E_Sconv || E_Tconv || E_Loc) EventMask := cset(E_Sconv || E_Tconv) Height := Opts["H"] Width := Opts["W"] Rows := Opts["y"] Cols := Opts["x"] Sectors := Opts["s"] NextEvent() EvTerm(&window) end procedure NextEvent() local intype, outtype static typemap initial { typemap := typesyms() } repeat { EvGet(EventMask) | { Eov := 1 fail } case &eventcode of { # E_Loc: { # curline := iand(&eventvalue,65535) # } E_Tconv: { last_to := type(&eventvalue) } E_Sconv: { curline := keyword("line", Monitored) on := if lastconv[curline] === &eventvalue then 1 else &null lastconv[curline] := &eventvalue this_guy := image(&eventvalue)||" to "||last_to|| " line "||curline||" file "||keyword("file",Monitored) if \on then { red_counts[this_guy] +:= 1 if red_counts[this_guy] > 9 then { if /red_rows[this_guy] := top_row then top_row +:= 1 if WAttrib("lines") < top_row then WAttrib("lines="||top_row) GotoRC(red_rows[this_guy]) writes(&window,this_guy,": ",red_counts[this_guy], "/",nonred_counts[this_guy]) } } else { nonred_counts[this_guy] +:= 1 } } } } end procedure xopen() &window := Visualization := optwindow ( Opts ) Red := Clone(Visualization, "fg=red") Blue := Clone(Visualization, "fg=blue") end