Import Upstream version 20180207
[hcoop/debian/mlton.git] / mlton / atoms / profile-exp.fun
1 (* Copyright (C) 2004-2005 Henry Cejtin, Matthew Fluet, Suresh
2 * Jagannathan, and Stephen Weeks.
3 *
4 * MLton is released under a BSD-style license.
5 * See the file MLton-LICENSE for details.
6 *)
7
8 functor ProfileExp (S: PROFILE_EXP_STRUCTS): PROFILE_EXP =
9 struct
10
11 open S
12
13 datatype t =
14 Enter of SourceInfo.t
15 | Leave of SourceInfo.t
16
17 val toString =
18 fn Enter si => concat ["Enter ", SourceInfo.toString si]
19 | Leave si => concat ["Leave " , SourceInfo.toString si]
20
21 val layout = Layout.str o toString
22
23 val equals =
24 fn (Enter si, Enter si') => SourceInfo.equals (si, si')
25 | (Leave si, Leave si') => SourceInfo.equals (si, si')
26 | _ => false
27
28 local
29 val newHash = Random.word
30 val enter = newHash ()
31 val leave = newHash ()
32 in
33 val hash =
34 fn Enter si => Word.xorb (enter, SourceInfo.hash si)
35 | Leave si => Word.xorb (leave, SourceInfo.hash si)
36 end
37
38 end