Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Annotation of /sml/trunk/src/compiler/Semant/basics/persstamps.sml
ViewVC logotype

Annotation of /sml/trunk/src/compiler/Semant/basics/persstamps.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 249 - (view) (download)
Original Path: sml/branches/SMLNJ/src/compiler/Semant/basics/persstamps.sml

1 : monnier 249 (* Copyright 1992 by AT&T Bell Laboratories *)
2 :     (* persstamps.sml *)
3 :    
4 :     (*
5 :     * DBM: was an abstraction, but persstamp needs to be an equality type
6 :     * so that conrep is.
7 :     *)
8 :    
9 :     structure PersStamps : PERSSTAMPS =
10 :     struct
11 :     datatype persstamp = PS of Word8Vector.vector
12 :    
13 :     fun compare (PS v1, PS v2) =
14 :     String.compare(Byte.bytesToString v1, Byte.bytesToString v2)
15 :    
16 :     fun toBytes (PS x) = x
17 :    
18 :     fun fromBytes v =
19 :     if Word8Vector.length v = 16 then PS v
20 :     else ErrorMsg.impossible "PersStamps.stringToStamp"
21 :    
22 :     (* convert the persstamp to a printable representation (hex digits) *)
23 :     fun toHex (PS pid) =
24 :     let fun cvtByte b = StringCvt.padLeft #"0" 2 (Word8.toString b)
25 :     fun f (b, l) = cvtByte b :: l
26 :     in String.concat (Word8Vector.foldr f [] pid)
27 :     end
28 :    
29 :     end (* structure PersStamps *)
30 :    
31 :    
32 :    
33 :     (*
34 :     * $Log$
35 :     *)

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0