Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Tracker SCM

SCM Repository

[smlnj] Diff of /sml/trunk/src/compiler/TopLevel/interact/interact.sml
ViewVC logotype

Diff of /sml/trunk/src/compiler/TopLevel/interact/interact.sml

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

revision 904, Mon Aug 20 19:50:05 2001 UTC revision 905, Thu Aug 23 21:53:02 2001 UTC
# Line 5  Line 5 
5  struct  struct
6    exception Interrupt = EvalLoop.Interrupt    exception Interrupt = EvalLoop.Interrupt
7    
  (* This is where CM can install itelf into.  Added for the purpose of  
   * autoloading. (blume)  
   *)  
8    type envref = EnvRef.envref    type envref = EnvRef.envref
9    
10    fun installCompManager m = (#compManagerHook EvalLoop.stdParams) := m    val installCompManager = EvalLoop.installCompManager
11    
12    fun interact() = (    fun interact() = (EvalLoop.interact (); OS.Process.exit OS.Process.success)
         EvalLoop.interact EvalLoop.stdParams;  
         OS.Process.exit OS.Process.success)  
13    
14    fun useFile (fname: string) =    fun useFile fname =
15        (app Control.Print.say ["[opening ",fname,"]\n"];        (app Control.Print.say ["[opening ",fname,"]\n"];
16         EvalLoop.evalStream EvalLoop.stdParams         EvalLoop.evalStream
17                    (fname,(TextIO.openIn fname                    (fname,(TextIO.openIn fname
18                            handle e as IO.Io _ =>                            handle e as IO.Io _ =>
19                                (app Control.Print.say["[use failed: ",                                (app Control.Print.say["[use failed: ",
# Line 26  Line 21 
21                                                       "]\n"];                                                       "]\n"];
22                                 raise ErrorMsg.Error))))                                 raise ErrorMsg.Error))))
23    
24    fun useStream (stream: TextIO.instream) =    fun useStream stream = EvalLoop.evalStream ("<instream>", stream)
     EvalLoop.evalStream EvalLoop.stdParams ("<instream>", stream)  
25    
26    fun evalStream (stream: TextIO.instream, baseEnv: Environment.environment) :    fun evalStream (stream, baseEnv) = let
27        Environment.environment =        val r = ref Environment.emptyEnv
28        let val r = ref Environment.emptyEnv        val base = { set = fn _ => raise Fail "evalStream: #set base",
29            val localEnvRef = {get=(fn()=> !r),set=(fn x=>r:=x)}                     get = fn () => baseEnv }
30            val b = ref baseEnv        val loc = { set = fn e => r := e,
31            val baseEnvRef =                    get = fn () => !r }
32              {get=(fn()=> !b),set=(fn _ => raise Fail "evalStream")}        val props = PropList.newHolder ()
33         in EvalLoop.evalStream        val state = { loc = loc, base = base, props = props }
34              ({compManagerHook = ref NONE,    in
35                (* ????  should CM get its hands into that? *)        EnvRef.locally (state,
36                baseEnvRef = baseEnvRef,                        fn () => (EvalLoop.evalStream ("<instream>", stream);
37                localEnvRef=localEnvRef,                                  !r))
               transform=(fn x => x),  
               instrument=(fn _ => fn x => x),  
               perform=(fn x => x),  
               isolate= #isolate EvalLoop.stdParams,  
               printer= #printer EvalLoop.stdParams})  
             ("<instream>", stream);  
           #get localEnvRef ()  
38        end        end
39    
   (* These mUse functions should really be part of the Open Compiler *)  
   val mUseFile_hiddenList =  
         ref [ [((fn () => (print "--mUseFile not reset!")),"Error!")] ];  
   
   fun mUseFile_reset () = (mUseFile_hiddenList := [])  
   fun mUseFile_add   f  = (mUseFile_hiddenList := (f::(!mUseFile_hiddenList)))  
   fun mUseFile_list  () = (List.rev(!mUseFile_hiddenList))  
   
   fun mUseFile (test) (fname: string) =  
       let fun repeat test n =  
                if (test n) then (useFile fname; repeat test (n+1)) else ()  
       in repeat test 0 end  
   
40  end (* functor Interact *)  end (* functor Interact *)
   

Legend:
Removed from v.904  
changed lines
  Added in v.905

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