File: mlton.sml

package info (click to toggle)
mlton 20210117%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 58,464 kB
  • sloc: ansic: 27,682; sh: 4,455; asm: 3,569; lisp: 2,879; makefile: 2,347; perl: 1,169; python: 191; pascal: 68; javascript: 7
file content (61 lines) | stat: -rw-r--r-- 2,061 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
(* Copyright (C) 2009,2019 Matthew Fluet.
 * Copyright (C) 2004-2005 Henry Cejtin, Matthew Fluet, Suresh
 *    Jagannathan, and Stephen Weeks.
 *
 * MLton is released under a HPND-style license.
 * See the file MLton-LICENSE for details.
 *)

structure MLton =
   struct
      val isMLton = false
      structure Exn =
         struct
            val history : exn -> string list = fn _ => []
         end
      structure GC =
         struct
            fun collect () = PolyML.fullGC ()
            fun setMessages (b : bool) = ()
            fun pack () = collect ()
         end
      structure Platform =
         struct
            local
               fun mkHost cmd =
                  let
                     fun findCmd dir =
                        let
                           val cmd = dir ^ "/bin/" ^ cmd
                           val upDir = OS.FileSys.realPath (dir ^ "/..")
                        in
                           if OS.FileSys.access (cmd, [OS.FileSys.A_EXEC])
                              then SOME cmd
                           else if dir <> upDir
                              then findCmd upDir
                           else NONE
                        end
                     val proc = Unix.execute (valOf (findCmd "."), [])
                     val ins = Unix.textInstreamOf proc
                     val hostString = TextIO.inputAll ins
                     val status = Unix.reap proc
                  in
                     String.extract
                     (hostString, 0, SOME (String.size hostString - 1))
                  end
            in
               structure Arch =
                  struct
                     type t = string
                     val toString = fn s => s
                     val host = mkHost "host-arch"
                  end
               structure OS =
                  struct
                     type t = string
                     val toString = fn s => s
                     val host = mkHost "host-os"
                  end
            end
         end
   end