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/cm/paths/srcpath.sml
ViewVC logotype

Annotation of /sml/trunk/src/cm/paths/srcpath.sml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 364 - (view) (download)

1 : blume 354 (*
2 :     * Operations over abstract path names.
3 :     * This is the "surface" abstraction that the client actually gets to
4 :     * see. It is built on top of the "AbsPath" abstraction, but its
5 :     * important improvement over AbsPath is that the ordering relation
6 :     * is stable: once you have created two "SrcPath"s, they will always
7 :     * compare the same way -- even if files are moved about, file_ids
8 :     * change, etc.
9 :     *
10 :     * Copyright (c) 1999 by Lucent Technologies, Bell Laboratories
11 :     *
12 :     * Author: Matthias Blume (blume@cs.princeton.edu)
13 :     *)
14 :     signature SRCPATH = sig
15 :     type context
16 :     type t
17 :     type ord_key = t
18 :    
19 :     val compare : ord_key * ord_key -> order
20 :    
21 :     (* This rebuilds the internal table in a manner consistent with
22 :     * the current state of the file system: *)
23 :     val sync : unit -> unit
24 :    
25 :     (* This erases all persistent state: *)
26 :     val clear : unit -> unit
27 :    
28 :     (* This should be called at the beginning of every main operation
29 :     * to make sure CM knows what the current working directory is: *)
30 :     val revalidateCwd : unit -> unit
31 :    
32 :     val osstring : t -> string
33 :     val descr : t -> string
34 :     val reAnchoredName : t * string -> string option
35 :     val contextOf : t -> context
36 :     val specOf : t -> string
37 :     val contextName : context -> string
38 :     val sameDirContext : t -> context
39 :     val cwdContext : unit -> context
40 :    
41 :     val native : { context: context, spec: string } -> t
42 :     val standard : PathConfig.mode -> { context: context, spec: string } -> t
43 :    
44 :     val pickle : (bool -> unit) -> t * t -> string list
45 :     val unpickle : PathConfig.mode -> string list * t -> t option
46 :    
47 :     val tstamp : t -> TStamp.t
48 :     end
49 :    
50 :     structure SrcPath :> SRCPATH = struct
51 :    
52 :     type context = AbsPath.context
53 :     type t = AbsPath.t * int
54 :     type ord_key = t
55 :    
56 :     fun compare ((_, i), (_, i')) = Int.compare (i, i')
57 :    
58 :     val knownPaths = ref (AbsPathMap.empty: int AbsPathMap.map)
59 :     val nextId = ref 0
60 :    
61 :     fun sync () =
62 :     (AbsPath.newEra ();
63 :     knownPaths := foldl AbsPathMap.insert' AbsPathMap.empty
64 :     (AbsPathMap.listItemsi (!knownPaths)))
65 :    
66 :     fun clear () = knownPaths := AbsPathMap.empty
67 :    
68 :     val revalidateCwd = AbsPath.revalidateCwd
69 :    
70 :     fun intern ap =
71 :     case AbsPathMap.find (!knownPaths, ap) of
72 :     SOME i => (ap, i)
73 :     | NONE => let
74 :     val i = !nextId
75 :     in
76 :     nextId := i + 1;
77 :     knownPaths := AbsPathMap.insert (!knownPaths, ap, i);
78 :     (ap, i)
79 :     end
80 :    
81 :     val native = intern o AbsPath.native
82 :     fun standard m = intern o AbsPath.standard m
83 :    
84 :     val contextName = AbsPath.contextName
85 :     fun contextOf (ap, _) = AbsPath.contextOf ap
86 :     fun specOf (ap, _) = AbsPath.specOf ap
87 :     fun osstring (ap, _) = AbsPath.osstring ap
88 :     fun descr (ap, _) = AbsPath.descr ap
89 :     fun reAnchoredName ((ap, _), root) = AbsPath.reAnchoredName (ap, root)
90 :     fun tstamp (ap, _) = AbsPath.tstamp ap
91 :     fun sameDirContext (ap, _) = AbsPath.sameDirContext ap
92 :     val cwdContext = AbsPath.cwdContext
93 :    
94 :     fun pickle warn ((ap, _), (cap, _)) = AbsPath.pickle warn (ap, cap)
95 :     fun unpickle m (l, (cap, _)) =
96 :     Option.map intern (AbsPath.unpickle m (l, cap))
97 :     end

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