245 |
|
|
246 |
val touch = HostMachDepVC.Interact.useStream o TextIO.openString |
val touch = HostMachDepVC.Interact.useStream o TextIO.openString |
247 |
|
|
248 |
|
val home = |
249 |
|
case OS.Process.getEnv "HOME" of |
250 |
|
SOME h => (fn d => OS.Path.mkAbsolute { path = d, |
251 |
|
relativeTo = h }) |
252 |
|
| NONE => (fn d => |
253 |
|
(Say.say ["HOME not set!\n"]; |
254 |
|
raise Fail "HOME not set")) |
255 |
|
|
256 |
|
fun chDir d0 = |
257 |
|
OS.FileSys.chDir (if OS.Path.isAbsolute d0 then d0 |
258 |
|
else home d0) |
259 |
|
|
260 |
|
fun path (s, pcmode) = SrcPath.fromDescr pcmode s |
261 |
|
|
262 |
fun waitForStart () = let |
fun waitForStart () = let |
263 |
val line = TextIO.inputLine TextIO.stdIn |
val line = TextIO.inputLine TextIO.stdIn |
264 |
in |
in |
275 |
end handle _ => (say_error (); waitForStart ()) |
end handle _ => (say_error (); waitForStart ()) |
276 |
|
|
277 |
and do_cmb (archos, d, f) = let |
and do_cmb (archos, d, f) = let |
278 |
val _ = OS.FileSys.chDir d |
val _ = chDir d |
|
val c = SrcPath.cwdContext () |
|
279 |
val slave = CMBSlave.slave { load = autoload, touch = touch } |
val slave = CMBSlave.slave { load = autoload, touch = touch } |
280 |
in |
in |
281 |
case slave archos (!dbr, f) of |
case slave archos (!dbr, f) of |
282 |
NONE => (say_error (); waitForStart ()) |
NONE => (say_error (); waitForStart ()) |
283 |
| SOME (g, trav) => let |
| SOME (g, trav, cmb_pcmode) => let |
284 |
val _ = say_ok () |
val _ = say_ok () |
285 |
val index = Reachable.snodeMap g |
val index = Reachable.snodeMap g |
286 |
in |
in |
287 |
workLoop (index, trav, c) |
workLoop (index, trav, cmb_pcmode) |
288 |
end |
end |
289 |
end handle _ => (say_error (); waitForStart ()) |
end handle _ => (say_error (); waitForStart ()) |
290 |
|
|
291 |
and do_cm (d, f) = let |
and do_cm (d, f) = let |
292 |
val _ = OS.FileSys.chDir d |
val _ = chDir d |
293 |
val c = SrcPath.cwdContext () |
val p = path (f, pcmode) |
|
val p = SrcPath.native { context = c, spec = f } |
|
294 |
in |
in |
295 |
case Parse.parse NONE (param ()) NONE p of |
case Parse.parse NONE (param ()) NONE p of |
296 |
NONE => (say_error (); waitForStart ()) |
NONE => (say_error (); waitForStart ()) |
300 |
val trav = Compile.newSbnodeTraversal () gp |
val trav = Compile.newSbnodeTraversal () gp |
301 |
fun trav' sbn = isSome (trav sbn) |
fun trav' sbn = isSome (trav sbn) |
302 |
in |
in |
303 |
workLoop (index, trav', c) |
workLoop (index, trav', pcmode) |
304 |
end |
end |
305 |
end handle _ => (say_error (); waitForStart ()) |
end handle _ => (say_error (); waitForStart ()) |
306 |
|
|
307 |
and workLoop (index, trav, c) = let |
and workLoop (index, trav, pcmode) = let |
|
fun f2sn f = |
|
|
SrcPathMap.find (index, |
|
|
SrcPath.native { context = c, |
|
|
spec = f }) |
|
308 |
fun loop () = let |
fun loop () = let |
309 |
val line = TextIO.inputLine TextIO.stdIn |
val line = TextIO.inputLine TextIO.stdIn |
310 |
in |
in |
311 |
if line = "" then shutdown () |
if line = "" then shutdown () |
312 |
else case String.tokens Char.isSpace line of |
else case String.tokens Char.isSpace line of |
313 |
["compile", f] => let |
["compile", f] => let |
314 |
val p = SrcPath.native { context = c, spec = f } |
val p = path (f, pcmode) |
315 |
in |
in |
316 |
case SrcPathMap.find (index, p) of |
case SrcPathMap.find (index, p) of |
317 |
NONE => (say_error (); loop ()) |
NONE => (say_error (); loop ()) |