12 |
type policy = Policy.policy |
type policy = Policy.policy |
13 |
|
|
14 |
type fileoffset = AbsPath.t * int |
type fileoffset = AbsPath.t * int |
15 |
type stableinfo = { skeleton: Skeleton.decl, binary: fileoffset } |
|
16 |
|
val resync : unit -> unit |
17 |
|
|
18 |
val info : policy -> |
val info : policy -> |
19 |
{ sourcepath: AbsPath.t, |
{ sourcepath: AbsPath.t, |
20 |
group: AbsPath.t, |
group: AbsPath.t, |
21 |
error: string -> unit, |
error: string -> (PrettyPrint.ppstream -> unit) -> unit, |
22 |
history: string list, |
history: string list, |
23 |
share: bool option, |
share: bool option } |
|
stableinfo: stableinfo option } |
|
24 |
-> info |
-> info |
25 |
|
|
26 |
|
val sourcepath : info -> AbsPath.t |
27 |
|
val error : info -> string -> (PrettyPrint.ppstream -> unit) -> unit |
28 |
|
|
29 |
val exports : info -> SymbolSet.set |
val exports : info -> SymbolSet.set |
30 |
val describe : info -> string |
val describe : info -> string |
31 |
end |
end |
46 |
INFO of { |
INFO of { |
47 |
sourcepath: AbsPath.t, |
sourcepath: AbsPath.t, |
48 |
group: AbsPath.t, |
group: AbsPath.t, |
49 |
error: string -> unit, (* reports wrt. group description *) |
error: string -> (PrettyPrint.ppstream -> unit) -> unit, |
50 |
lastseen: TStamp.t ref, |
lastseen: TStamp.t ref, |
51 |
parsetree: { tree: parsetree, source: source } option ref, |
parsetree: { tree: parsetree, source: source } option ref, |
52 |
skelpath: AbsPath.t, |
skelpath: AbsPath.t, |
57 |
type fileoffset = AbsPath.t * int |
type fileoffset = AbsPath.t * int |
58 |
type stableinfo = { skeleton: Skeleton.decl, binary: fileoffset } |
type stableinfo = { skeleton: Skeleton.decl, binary: fileoffset } |
59 |
|
|
60 |
fun info policy { sourcepath, group, error, history, share, stableinfo } = |
fun sourcepath (INFO { sourcepath = sp, ... }) = sp |
61 |
case stableinfo of |
fun error (INFO { error = e, ... }) = e |
62 |
NONE => INFO { |
|
63 |
|
(* If files change their file ids, then CM will be seriously |
64 |
|
* disturbed because the ordering relation will change. |
65 |
|
* We'll asume that this won't happen in general. However, we provide |
66 |
|
* a "resync" function that -- at the very least -- should be run |
67 |
|
* at startup time. *) |
68 |
|
val knownInfo : info AbsPathMap.map ref = ref AbsPathMap.empty |
69 |
|
|
70 |
|
fun resync () = let |
71 |
|
val l = AbsPathMap.listItemsi (!knownInfo) |
72 |
|
in |
73 |
|
AbsPath.newEra (); (* force recalculation of file ids *) |
74 |
|
knownInfo := foldl AbsPathMap.insert' AbsPathMap.empty l |
75 |
|
end |
76 |
|
|
77 |
|
fun info policy { sourcepath, group, error, history, share } = |
78 |
|
case AbsPathMap.find (!knownInfo, sourcepath) of |
79 |
|
SOME (i as INFO { group = g, error = e, ... }) => |
80 |
|
(if AbsPath.compare (group, g) <> EQUAL then |
81 |
|
let val n = AbsPath.name sourcepath |
82 |
|
in |
83 |
|
error (concat ["ML source file ", n, |
84 |
|
" appears in more than one group"]) |
85 |
|
EM.nullErrorBody; |
86 |
|
e (concat ["(previous occurence of ", n, ")"]) |
87 |
|
EM.nullErrorBody |
88 |
|
end |
89 |
|
else (); |
90 |
|
i) |
91 |
|
| NONE => let |
92 |
|
val i = INFO { |
93 |
sourcepath = sourcepath, |
sourcepath = sourcepath, |
94 |
group = group, |
group = group, |
95 |
error = error, |
error = error, |
98 |
skelpath = Policy.mkSkelPath policy sourcepath, |
skelpath = Policy.mkSkelPath policy sourcepath, |
99 |
skeleton = ref NONE |
skeleton = ref NONE |
100 |
} |
} |
101 |
| SOME si => Dummy.f () |
in |
102 |
|
knownInfo := AbsPathMap.insert (!knownInfo, sourcepath, i); |
103 |
|
i |
104 |
|
end |
105 |
|
|
106 |
(* check timestamp and throw away any invalid cache *) |
(* check timestamp and throw away any invalid cache *) |
107 |
fun validate (INFO ir) = let |
fun validate (INFO ir) = let |
141 |
in |
in |
142 |
SOME { tree = tree, source = source } |
SOME { tree = tree, source = source } |
143 |
end handle SF.Compile msg => (TextIO.closeIn stream; |
end handle SF.Compile msg => (TextIO.closeIn stream; |
144 |
error msg; |
error msg EM.nullErrorBody; |
145 |
NONE) |
NONE) |
146 |
| exn => (TextIO.closeIn stream; raise exn) |
| exn => (TextIO.closeIn stream; raise exn) |
147 |
in |
in |
148 |
TextIO.closeIn stream; |
TextIO.closeIn stream; |
149 |
parsetree := pto; |
parsetree := pto; |
150 |
pto |
pto |
151 |
end handle exn as IO.Io _ => (error (General.exnMessage exn); |
end handle exn as IO.Io _ => (error (General.exnMessage exn) |
152 |
|
EM.nullErrorBody; |
153 |
NONE) |
NONE) |
154 |
end |
end |
155 |
|
|