# HG changeset patch # User Adam Chlipala # Date 1246113051 14400 # Node ID 3d2f6cb6d54af691c4760a9731f8cd572d5279e7 # Parent 86ec89baee0117a18f5195499dce7c19f138612f -debug from the command line diff -r 86ec89baee01 -r 3d2f6cb6d54a src/compiler.sml --- a/src/compiler.sml Tue Jun 23 17:59:23 2009 -0400 +++ b/src/compiler.sml Sat Jun 27 10:30:51 2009 -0400 @@ -333,7 +333,7 @@ val database = ref NONE val exe = ref NONE val sql = ref NONE - val debug = ref false + val debug = ref (Settings.getDebug ()) val profile = ref false val timeout = ref NONE val ffi = ref [] diff -r 86ec89baee01 -r 3d2f6cb6d54a src/main.mlton.sml --- a/src/main.mlton.sml Tue Jun 23 17:59:23 2009 -0400 +++ b/src/main.mlton.sml Sat Jun 27 10:30:51 2009 -0400 @@ -25,42 +25,48 @@ * POSSIBILITY OF SUCH DAMAGE. *) -fun doArgs (args, (timing, demo, sources)) = +val timing = ref false +val sources = ref ([] : string list) +val demo = ref (NONE : (string * bool) option) + +fun doArgs args = case args of - [] => (timing, demo, rev sources) + [] => () | "-demo" :: prefix :: rest => - doArgs (rest, (timing, SOME (prefix, false), sources)) + (demo := SOME (prefix, false); + doArgs rest) | "-guided-demo" :: prefix :: rest => - doArgs (rest, (timing, SOME (prefix, true), sources)) + (demo := SOME (prefix, true); + doArgs rest) | "-protocol" :: name :: rest => (Settings.setProtocol name; - doArgs (rest, (timing, demo, sources))) + doArgs rest) + | "-debug" :: rest => + (Settings.setDebug true; + doArgs rest) + | "-timing" :: rest => + (timing := true; + doArgs rest) | arg :: rest => - let - val acc = - if size arg > 0 andalso String.sub (arg, 0) = #"-" then - case arg of - "-timing" => (true, demo, sources) - | _ => raise Fail ("Unknown option " ^ arg) - else - (timing, demo, arg :: sources) - in - doArgs (rest, acc) - end + (if size arg > 0 andalso String.sub (arg, 0) = #"-" then + raise Fail ("Unknown flag " ^ arg) + else + sources := arg :: !sources; + doArgs rest) -val (timing, demo, sources) = doArgs (CommandLine.arguments (), (false, NONE, [])) +val () = doArgs (CommandLine.arguments ()) val job = - case sources of + case !sources of [file] => file | _ => raise Fail "Zero or multiple job files specified" val () = - case demo of + case !demo of SOME (prefix, guided) => Demo.make {prefix = prefix, dirname = job, guided = guided} | NONE => - if timing then + if !timing then Compiler.time Compiler.toCjrize job else Compiler.compile job diff -r 86ec89baee01 -r 3d2f6cb6d54a src/settings.sig --- a/src/settings.sig Tue Jun 23 17:59:23 2009 -0400 +++ b/src/settings.sig Sat Jun 27 10:30:51 2009 -0400 @@ -96,4 +96,7 @@ val setProtocol : string -> unit val currentProtocol : unit -> protocol + val setDebug : bool -> unit + val getDebug : unit -> bool + end diff -r 86ec89baee01 -r 3d2f6cb6d54a src/settings.sml --- a/src/settings.sml Tue Jun 23 17:59:23 2009 -0400 +++ b/src/settings.sml Sat Jun 27 10:30:51 2009 -0400 @@ -277,4 +277,8 @@ | SOME p => curProto := p fun currentProtocol () = !curProto +val debug = ref false +fun setDebug b = debug := b +fun getDebug () = !debug + end