| 1 |
(* Copyright (C) 1999-2006, 2008 Henry Cejtin, Matthew Fluet, Suresh |
| 2 |
* Jagannathan, and Stephen Weeks. |
| 3 |
* Copyright (C) 1997-2000 NEC Research Institute. |
| 4 |
* |
| 5 |
* MLton is released under a HPND-style license. |
| 6 |
* See the file MLton-LICENSE for details. |
| 7 |
*) |
| 8 |
|
| 9 |
structure SMLofNJ: SML_OF_NJ = |
| 10 |
struct |
| 11 |
structure Cont = |
| 12 |
struct |
| 13 |
structure C = MLton.Cont |
| 14 |
|
| 15 |
type 'a cont = 'a C.t |
| 16 |
val callcc = C.callcc |
| 17 |
val isolate = C.isolate |
| 18 |
fun throw k v = C.throw (k, v) |
| 19 |
end |
| 20 |
|
| 21 |
structure SysInfo = |
| 22 |
struct |
| 23 |
exception UNKNOWN |
| 24 |
datatype os_kind = BEOS | MACOS | OS2 | UNIX | WIN32 |
| 25 |
|
| 26 |
fun getHostArch () = |
| 27 |
MLton.Platform.Arch.toString MLton.Platform.Arch.host |
| 28 |
|
| 29 |
fun getOSKind () = |
| 30 |
let |
| 31 |
open MLton.Platform.OS |
| 32 |
in |
| 33 |
case host of |
| 34 |
AIX => UNIX |
| 35 |
| Cygwin => UNIX |
| 36 |
| Darwin => MACOS |
| 37 |
| FreeBSD => UNIX |
| 38 |
| Hurd => UNIX |
| 39 |
| HPUX => UNIX |
| 40 |
| Linux => UNIX |
| 41 |
| MinGW => WIN32 |
| 42 |
| NetBSD => UNIX |
| 43 |
| OpenBSD => UNIX |
| 44 |
| Solaris => UNIX |
| 45 |
| WASI => UNIX |
| 46 |
end |
| 47 |
|
| 48 |
fun getOSName () = MLton.Platform.OS.toString MLton.Platform.OS.host |
| 49 |
end |
| 50 |
|
| 51 |
val getCmdName = CommandLine.name |
| 52 |
val getArgs = CommandLine.arguments |
| 53 |
|
| 54 |
fun getAllArgs () = getCmdName () :: getArgs () |
| 55 |
|
| 56 |
val exnHistory = MLton.Exn.history |
| 57 |
|
| 58 |
fun exportFn (file: string, f) = |
| 59 |
let |
| 60 |
open MLton.World OS.Process |
| 61 |
in |
| 62 |
case save (file ^ ".mlton") of |
| 63 |
Original => exit success |
| 64 |
| Clone => exit (f (getCmdName (), getArgs ()) handle _ => failure) |
| 65 |
end |
| 66 |
|
| 67 |
fun exportML (f: string): bool = |
| 68 |
let |
| 69 |
open MLton.World |
| 70 |
in |
| 71 |
case save (f ^ ".mlton") of |
| 72 |
Clone => true |
| 73 |
| Original => false |
| 74 |
end |
| 75 |
end |