# HG changeset patch # User Adam Chlipala # Date 1390154881 18000 # Node ID 0652f295e0faf99a928cb0c12a94bba6e3e2b3cb # Parent 93f3e35a79672f5d8ffc56ba3f96459cc485cbed New compiler option: -stop diff -r 93f3e35a7967 -r 0652f295e0fa doc/manual.tex --- a/doc/manual.tex Sat Jan 18 08:34:19 2014 -0500 +++ b/doc/manual.tex Sun Jan 19 13:08:01 2014 -0500 @@ -341,6 +341,8 @@ \item \texttt{-sql FILENAME}: Set where a database set-up SQL script is written. \item \texttt{-static}: Link the runtime system statically. The default is to link against dynamic libraries. + +\item \texttt{-stop PHASE}: Stop compilation after the named phase, printing the intermediate program to stderr. This flag is mainly useful for debugging the Ur/Web compiler itself. \end{itemize} There is an additional convenience method for invoking \texttt{urweb}. If the main argument is \texttt{FOO}, and \texttt{FOO.ur} exists but \texttt{FOO.urp} doesn't, then the invocation is interpreted as if called on a \texttt{.urp} file containing \texttt{FOO} as its only main entry, with an additional \texttt{rewrite all FOO/*} directive. diff -r 93f3e35a7967 -r 0652f295e0fa src/compiler.sig --- a/src/compiler.sig Sat Jan 18 08:34:19 2014 -0500 +++ b/src/compiler.sig Sun Jan 19 13:08:01 2014 -0500 @@ -202,4 +202,7 @@ val moduleOf : string -> string + val setStop : string -> unit + (* Stop compilation after this phase. *) + end diff -r 93f3e35a7967 -r 0652f295e0fa src/compiler.sml --- a/src/compiler.sml Sat Jan 18 08:34:19 2014 -0500 +++ b/src/compiler.sml Sun Jan 19 13:08:01 2014 -0500 @@ -86,6 +86,9 @@ val doDumpSource = ref (fn () => ()) +val stop = ref (NONE : string option) +fun setStop s = stop := SOME s + fun transform (ph : ('src, 'dst) phase) name = { func = fn input => let val () = if !debug then @@ -102,6 +105,10 @@ (!doDumpSource (); doDumpSource := (fn () => ()); NONE) + else if !stop = SOME name then + (Print.eprint (#print ph v); + ErrorMsg.error ("Stopped compilation after phase " ^ name); + NONE) else (if !dumpSource then doDumpSource := (fn () => Print.eprint (#print ph v)) diff -r 93f3e35a7967 -r 0652f295e0fa src/main.mlton.sml --- a/src/main.mlton.sml Sat Jan 18 08:34:19 2014 -0500 +++ b/src/main.mlton.sml Sun Jan 19 13:08:01 2014 -0500 @@ -133,6 +133,9 @@ | "-static" :: rest => (Settings.setStaticLinking true; doArgs rest) + | "-stop" :: phase :: rest => + (Compiler.setStop phase; + doArgs rest) | "-path" :: name :: path :: rest => (Compiler.addPath (name, path); doArgs rest)