Home My Page Projects Code Snippets Project Openings diderot
Summary Activity Tracker Tasks SCM

SCM Repository

[diderot] Diff of /trunk/src/compiler/driver/main.sml
ViewVC logotype

Diff of /trunk/src/compiler/driver/main.sml

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 428, Mon Oct 18 19:48:43 2010 UTC revision 429, Mon Oct 18 19:59:04 2010 UTC
# Line 19  Line 19 
19      fun err1 c =  TextIO.output1 (TextIO.stdErr, c)      fun err1 c =  TextIO.output1 (TextIO.stdErr, c)
20      fun errnl s = (err s; err1 #"\n")      fun errnl s = (err s; err1 #"\n")
21    
22      fun quitWithError () = raise Fail "error"      exception ERROR
23    
24        fun quitWithError srcFile = raise Fail("Error in compiling " ^ srcFile)
25    
26    (* check for errors and report them if there are any *)    (* check for errors and report them if there are any *)
27      fun checkForErrors errStrm = (      fun checkForErrors errStrm = (
28            Error.report (TextIO.stdErr, errStrm);            Error.report (TextIO.stdErr, errStrm);
29            if Error.anyErrors errStrm            if Error.anyErrors errStrm
30              then quitWithError ()              then quitWithError (Error.sourceFile errStrm)
31              else ())              else ())
32    
33      fun doFile filename = let      fun doFile filename = let
# Line 34  Line 36 
36            val checkTypes = Typechecker.check errStrm            val checkTypes = Typechecker.check errStrm
37            in            in
38              case Parser.parseFile (errStrm, inS)              case Parser.parseFile (errStrm, inS)
39               of NONE => (checkForErrors errStrm; quitWithError ())               of NONE => (checkForErrors errStrm; quitWithError filename)
40                | SOME pt => let                | SOME pt => let
41                    val _ = checkForErrors errStrm                    val _ = checkForErrors errStrm
42                    val ast = (checkTypes pt) handle Typechecker.Error => AST.Program[]                    val ast = (checkTypes pt) handle Typechecker.Error => AST.Program[]
# Line 46  Line 48 
48                    val _ = ( (* DEBUG *)                    val _ = ( (* DEBUG *)
49                          HighPP.output (Log.logFile(), "HighIL after translation", highIL);                          HighPP.output (Log.logFile(), "HighIL after translation", highIL);
50                          if CheckHighIL.check ("after translation", highIL)                          if CheckHighIL.check ("after translation", highIL)
51                            then raise Fail "ERROR"                            then quitWithError filename
52                            else ())                            else ())
53                    val highIL = HighOptimizer.optimize highIL                    val highIL = HighOptimizer.optimize highIL
54                    val _ = ( (* DEBUG *)                    val _ = ( (* DEBUG *)
55                          HighPP.output (Log.logFile(), "HighIL after optimization", highIL);                          HighPP.output (Log.logFile(), "HighIL after optimization", highIL);
56                          if CheckHighIL.check ("after optimization", highIL)                          if CheckHighIL.check ("after optimization", highIL)
57                            then raise Fail "ERROR"                            then quitWithError filename
58                            else ())                            else ())
59                    val midIL = HighToMid.translate highIL                    val midIL = HighToMid.translate highIL
60                    val _ = ( (* DEBUG *)                    val _ = ( (* DEBUG *)
61                          MidPP.output (Log.logFile(), "MidIL after translation", midIL);                          MidPP.output (Log.logFile(), "MidIL after translation", midIL);
62                          if CheckMidIL.check ("after translation", midIL)                          if CheckMidIL.check ("after translation", midIL)
63                            then raise Fail "ERROR"                            then quitWithError filename
64                            else ())                            else ())
                   val _ = MidPP.output (Log.logFile(), "MidIL after translation", midIL) (* DEBUG *)  
65                    in                    in
66                      ()                      ()
67                    end                    end
# Line 78  Line 79 
79                    then (defs := opt :: !defs; doOpts r)                    then (defs := opt :: !defs; doOpts r)
80                    else (                    else (
81                      err(concat["invalid command-line input \"", opt, "\"\n"]);                      err(concat["invalid command-line input \"", opt, "\"\n"]);
82                      quitWithError())                      raise ERROR)
83            in            in
84              doOpts args              doOpts args
85            end            end
# Line 94  Line 95 
95                        "uncaught exception ", General.exnName exn, " [", General.exnMessage exn, "]\n"]);                        "uncaught exception ", General.exnName exn, " [", General.exnMessage exn, "]\n"]);
96                        List.app (fn s => err (concat ["  raised at ", s, "\n"]))                        List.app (fn s => err (concat ["  raised at ", s, "\n"]))
97                          (SMLofNJ.exnHistory exn);                          (SMLofNJ.exnHistory exn);
98                        quitWithError())                        OS.Process.failure)
99                else (err "invalid command-line inputs\n"; quitWithError())                else (err "invalid command-line inputs\n"; OS.Process.failure)
100            end            end
101                handle ERROR => OS.Process.failure
102    
103      fun test file = (main ("", [file]); print "** Success!!\n")      fun test file = (main ("", [file]); print "** Success!!\n")
104    

Legend:
Removed from v.428  
changed lines
  Added in v.429

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0