Commit | Line | Data |
---|---|---|
7f918cf1 CE |
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 BSD-style license. | |
6 | * See the file MLton-LICENSE for details. | |
7 | *) | |
8 | ||
9 | structure Primitive = | |
10 | struct | |
11 | open Primitive | |
12 | ||
13 | structure MLton = | |
14 | struct | |
15 | open MLton | |
16 | val bug = PrimitiveFFI.MLton.bug | |
17 | end | |
18 | ||
19 | val dontInline: (unit -> 'a) -> 'a = | |
20 | fn f => | |
21 | let | |
22 | val rec recur: Int32.int -> 'a = | |
23 | fn i => | |
24 | if i = 0 | |
25 | then f () | |
26 | else let | |
27 | val _ = recur (Int32.- (i, 1)) | |
28 | in | |
29 | recur (Int32.- (i, 2)) | |
30 | end | |
31 | in | |
32 | recur 0 | |
33 | end | |
34 | end | |
35 | ||
36 | (* Install an emergency exception handler. *) | |
37 | local | |
38 | structure P = Primitive | |
39 | structure PFFI = PrimitiveFFI | |
40 | val _ = | |
41 | P.TopLevel.setHandler | |
42 | (fn exn => | |
43 | (PFFI.Stdio.print "unhandled exception: " | |
44 | ; case exn of | |
45 | P.Exn.Fail8 msg => (PFFI.Stdio.print "Fail " | |
46 | ; PFFI.Stdio.print msg) | |
47 | | _ => PFFI.Stdio.print (P.Exn.name exn) | |
48 | ; PFFI.Stdio.print "\n" | |
49 | ; P.MLton.bug ("unhandled exception in Basis Library"))) | |
50 | in | |
51 | end | |
52 | ||
53 | (* Install an emergency suffix. *) | |
54 | local | |
55 | structure P = Primitive | |
56 | val _ = | |
57 | P.TopLevel.setSuffix | |
58 | (fn () => | |
59 | (P.MLton.halt 0 | |
60 | ; P.MLton.bug ("missing suffix in Basis Library"))) | |
61 | in | |
62 | end |