remove-unused

Stephen Weeks MLton@sourcelight.com
Fri, 26 Oct 2001 13:45:57 -0700


I rewrote the translation of Call statements in removeUnused to the
following.  Hopefully this is cleaner.  I'll but back in the
translation to nontail into tail calls once I understand it.

	    of Call {func, args, return}
	     => let
		   val return =
		      case return of 
			 NONE => NONE
		       | SOME {cont, handler} =>
			    let
			       val cont =
				  if doesTerminateFunc func
				     then getContWrapperLabel (cont,
							       returnsFunc func)
				  else getBugContFunc (f, returnsFunc func)
			       val handler =
				  if doesFailFunc func
				     then Handler.map (handler,
						       getHandlerWrapperLabel)
				  else Handler.None
			    in SOME {cont = cont,
				     handler = handler}
			    end
		   val args =
		      Vector.keepAllMap2 (args, argsFunc func, fn (x, (y, t)) =>
					  if isUsedVar y
					     then SOME x
					  else NONE)
		in
		   Call {func = func,
			 args = args,
			 return = return}
		end