39 |
val system_values = ref emptydyn |
val system_values = ref emptydyn |
40 |
|
|
41 |
structure Compile = |
structure Compile = |
42 |
CompileFn (structure MachDepVC = HostMachDepVC) |
CompileFn (structure MachDepVC = HostMachDepVC |
43 |
|
val compile_there = Servers.compile) |
44 |
|
|
45 |
structure Link = |
structure Link = |
46 |
LinkFn (structure MachDepVC = HostMachDepVC |
LinkFn (structure MachDepVC = HostMachDepVC |
205 |
fun run sflag f s = let |
fun run sflag f s = let |
206 |
val c = SrcPath.cwdContext () |
val c = SrcPath.cwdContext () |
207 |
val p = SrcPath.standard pcmode { context = c, spec = s } |
val p = SrcPath.standard pcmode { context = c, spec = s } |
208 |
|
val _ = Servers.start (c, p) |
209 |
in |
in |
210 |
case Parse.parse NONE (param ()) sflag p of |
case Parse.parse NONE (param ()) sflag p of |
211 |
NONE => false |
NONE => false |
212 |
| SOME (g, gp) => f gp g |
| SOME (g, gp) => f gp g |
213 |
end |
end |
214 |
|
|
215 |
|
fun slave () = let |
216 |
|
fun shutdown () = OS.Process.exit OS.Process.success |
217 |
|
fun say_ok () = Say.say ["SLAVE: ok\n"] |
218 |
|
fun say_error () = Say.say ["SLAVE: error\n"] |
219 |
|
|
220 |
|
fun waitForStart () = let |
221 |
|
val line = TextIO.inputLine TextIO.stdIn |
222 |
|
in |
223 |
|
if line = "" then shutdown () |
224 |
|
else case String.tokens Char.isSpace line of |
225 |
|
["cm", d, f] => start (d, f) |
226 |
|
| ["shutdown"] => shutdown () |
227 |
|
| _ => (say_error (); waitForStart ()) |
228 |
|
end handle _ => (say_error (); waitForStart ()) |
229 |
|
|
230 |
|
and start (d, f) = let |
231 |
|
val _ = OS.FileSys.chDir d |
232 |
|
val c = SrcPath.cwdContext () |
233 |
|
val p = SrcPath.native { context = c, spec = f } |
234 |
|
in |
235 |
|
case Parse.parse NONE (param ()) NONE p of |
236 |
|
NONE => (say_error (); waitForStart ()) |
237 |
|
| SOME x => (say_ok (); workLoop (x, c)) |
238 |
|
end handle _ => (say_error (); waitForStart ()) |
239 |
|
|
240 |
|
and workLoop ((g, gp), c) = let |
241 |
|
val index = Reachable.snodeMap g |
242 |
|
val trav = Compile.newSbnodeTraversal () |
243 |
|
fun loop () = let |
244 |
|
val line = TextIO.inputLine TextIO.stdIn |
245 |
|
in |
246 |
|
if line = "" then shutdown () |
247 |
|
else case String.tokens Char.isSpace line of |
248 |
|
["compile", f] => let |
249 |
|
val p = SrcPath.native { context = c, spec = f } |
250 |
|
in |
251 |
|
case SrcPathMap.find (index, p) of |
252 |
|
NONE => (say_error (); loop ()) |
253 |
|
| SOME sn => let |
254 |
|
val sbn = DependencyGraph.SB_SNODE sn |
255 |
|
in |
256 |
|
case trav gp sbn of |
257 |
|
NONE => (say_error (); loop ()) |
258 |
|
| SOME _ => (say_ok (); loop ()) |
259 |
|
end |
260 |
|
end |
261 |
|
| ["cm", d, f] => start (d, f) |
262 |
|
| ["finish"] => (say_ok (); waitForStart ()) |
263 |
|
| ["shutdown"] => shutdown () |
264 |
|
| _ => (say_error (); loop ()) |
265 |
|
end handle _ => (say_error (); loop ()) |
266 |
|
in |
267 |
|
loop () |
268 |
|
end |
269 |
|
in |
270 |
|
say_ok (); (* announce readiness *) |
271 |
|
waitForStart () |
272 |
|
end |
273 |
|
|
274 |
val listLibs = Parse.listLibs |
val listLibs = Parse.listLibs |
275 |
fun dismissLib l = let |
fun dismissLib l = let |
276 |
val c = SrcPath.cwdContext () |
val c = SrcPath.cwdContext () |
426 |
showPending = showPending, |
showPending = showPending, |
427 |
listLibs = listLibs, |
listLibs = listLibs, |
428 |
dismissLib = dismissLib, |
dismissLib = dismissLib, |
429 |
symval = SSV.symval }) |
symval = SSV.symval, |
430 |
|
server = Servers.add }) |
431 |
|
|
432 |
end |
end |
433 |
end |
end |
437 |
(system_values := de; |
(system_values := de; |
438 |
initTheValues (bootdir, er); |
initTheValues (bootdir, er); |
439 |
Cleanup.install initPaths) |
Cleanup.install initPaths) |
440 |
|
|
441 |
|
fun procCmdLine () = let |
442 |
|
fun p (f, "sml") = HostMachDepVC.Interact.useFile f |
443 |
|
| p (f, "sig") = HostMachDepVC.Interact.useFile f |
444 |
|
| p (f, "cm") = ignore (make f) |
445 |
|
| p (f, e) = |
446 |
|
(print (concat ["!* unable to process `", f, |
447 |
|
"' (unknown extension `", e, "')\n"])) |
448 |
|
fun c f = (f, String.map Char.toLower |
449 |
|
(getOpt (OS.Path.ext f, "<none>"))) |
450 |
|
in |
451 |
|
case SMLofNJ.getArgs () of |
452 |
|
["@CMslave"] => slave () |
453 |
|
| l => app (p o c) l |
454 |
|
end |
455 |
end |
end |
456 |
end |
end |