SCM Repository
[smlnj] Diff of /sml/trunk/src/cm/smlfile/smlinfo.sml
Diff of /sml/trunk/src/cm/smlfile/smlinfo.sml
Parent Directory
|
Revision Log
|
Patch
103 |
|
|
104 |
val knownInfo = ref (SrcPathMap.empty: persinfo SrcPathMap.map) |
val knownInfo = ref (SrcPathMap.empty: persinfo SrcPathMap.map) |
105 |
|
|
106 |
|
fun countParseTrees () = let |
107 |
|
fun one (PERS { parsetree = ref (SOME _), ... }, i) = i + 1 |
108 |
|
| one (_, i) = i |
109 |
|
in |
110 |
|
SrcPathMap.foldl one 0 (!knownInfo) |
111 |
|
end |
112 |
|
|
113 |
fun forgetParsetree (INFO { persinfo = PERS { parsetree, ... }, ... }) = |
fun forgetParsetree (INFO { persinfo = PERS { parsetree, ... }, ... }) = |
114 |
parsetree := NONE |
parsetree := NONE |
115 |
|
|
206 |
closeIt = TextIO.closeIn, |
closeIt = TextIO.closeIn, |
207 |
work = work, |
work = work, |
208 |
cleanup = fn () => () }) |
cleanup = fn () => () }) |
209 |
in |
(* Counting the trees explicitly may be a bit slow, |
210 |
parsetree := pto; |
* but maintaining an accurate count is difficult, so |
211 |
|
* this method should be robust. (I don't think that |
212 |
|
* the overhead of counting will make a noticeable |
213 |
|
* difference.) *) |
214 |
|
val ntrees = countParseTrees () |
215 |
|
val treelimit = EnvConfig.getSet StdConfig.parse_caching NONE |
216 |
|
in |
217 |
|
if ntrees < treelimit then |
218 |
|
parsetree := pto |
219 |
|
else (); |
220 |
pto |
pto |
221 |
end handle exn as IO.Io _ => (err (General.exnMessage exn); NONE) |
end handle exn as IO.Io _ => (err (General.exnMessage exn); NONE) |
222 |
| SF.Compile msg => (err msg; NONE) |
| SF.Compile msg => (err msg; NONE) |
|
Legend:
Removed from v.364 |
|
changed lines |
|
Added in v.365 |
|
|