Debian Codegraph @

basis-library/primitive/prim2.sml

raw
1 (* Copyright (C) 2019 Matthew Fluet.
2 * Copyright (C) 1999-2006, 2008 Henry Cejtin, Matthew Fluet, Suresh
3 * Jagannathan, and Stephen Weeks.
4 * Copyright (C) 1997-2000 NEC Research Institute.
5 *
6 * MLton is released under a HPND-style license.
7 * See the file MLton-LICENSE for details.
8 *)
9
10 structure Primitive =
11 struct
12 open Primitive
13
14 val dontInline: (unit -> 'a) -> 'a =
15 fn f =>
16 let
17 val rec recur: Int32.int -> 'a =
18 fn i =>
19 if i = 0
20 then f ()
21 else let
22 val _ = recur (Int32.- (i, 1))
23 in
24 recur (Int32.- (i, 2))
25 end
26 in
27 recur 0
28 end
29 end
30
31 (* Install an emergency exception handler. *)
32 local
33 structure P = Primitive
34 structure PFFI = PrimitiveFFI
35 val _ =
36 P.TopLevel.setHandler
37 (fn exn =>
38 (PFFI.Stdio.print "unhandled exception: "
39 ; case exn of
40 P.Exn.Fail8 msg => (PFFI.Stdio.print "Fail "
41 ; PFFI.Stdio.print msg)
42 | _ => PFFI.Stdio.print (P.Exn.name exn)
43 ; PFFI.Stdio.print "\n"
44 ; P.MLton.bug ("unhandled exception in Basis Library")))
45 in
46 end
47
48 (* Install an emergency suffix. *)
49 local
50 structure P = Primitive
51 val _ =
52 P.TopLevel.setSuffix
53 (fn () =>
54 P.MLton.bug ("missing suffix in Basis Library"))
55 in
56 end