diff options
-rw-r--r-- | doc/manual.tex | 2 | ||||
-rw-r--r-- | src/compiler.sig | 3 | ||||
-rw-r--r-- | src/compiler.sml | 7 | ||||
-rw-r--r-- | src/main.mlton.sml | 3 |
4 files changed, 15 insertions, 0 deletions
diff --git a/doc/manual.tex b/doc/manual.tex index 0a088436..42ab7f70 100644 --- a/doc/manual.tex +++ b/doc/manual.tex @@ -341,6 +341,8 @@ fastcgi.server = ( \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 --git a/src/compiler.sig b/src/compiler.sig index fdb1311f..fa131cf4 100644 --- a/src/compiler.sig +++ b/src/compiler.sig @@ -202,4 +202,7 @@ signature COMPILER = sig val moduleOf : string -> string + val setStop : string -> unit + (* Stop compilation after this phase. *) + end diff --git a/src/compiler.sml b/src/compiler.sml index 0ffab01c..21ae903f 100644 --- a/src/compiler.sml +++ b/src/compiler.sml @@ -86,6 +86,9 @@ val doIflow = ref false 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 @@ fun transform (ph : ('src, 'dst) phase) name = { (!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 --git a/src/main.mlton.sml b/src/main.mlton.sml index b0c4e03f..6bdc9539 100644 --- a/src/main.mlton.sml +++ b/src/main.mlton.sml @@ -133,6 +133,9 @@ fun oneRun args = | "-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) |