comparison src/mono_reduce.sml @ 1845:c1e3805e604e

Make Scriptcheck catch more script/message-passing uses, and move the phase earlier in compilation
author Adam Chlipala <adam@chlipala.net>
date Fri, 15 Mar 2013 16:09:55 -0400
parents 216e92b39fc1
children e15234fbb163
comparison
equal deleted inserted replaced
1844:2c5e6f78560c 1845:c1e3805e604e
306 bind = fn (n, b) => 306 bind = fn (n, b) =>
307 case b of 307 case b of
308 U.Exp.RelE _ => n + 1 308 U.Exp.RelE _ => n + 1
309 | _ => n} 0 309 | _ => n} 0
310 310
311 fun reduce file = 311 fun reduce (file : file) =
312 let 312 let
313 val (timpures, impures, absCounts) = 313 val (timpures, impures, absCounts) =
314 foldl (fn ((d, _), (timpures, impures, absCounts)) => 314 foldl (fn ((d, _), (timpures, impures, absCounts)) =>
315 let 315 let
316 fun countAbs env e = 316 fun countAbs env e =
364 foldl (fn ((x, n, _, e, _), absCounts) => 364 foldl (fn ((x, n, _, e, _), absCounts) =>
365 IM.insert (absCounts, n, countAbs E.empty e)) 365 IM.insert (absCounts, n, countAbs E.empty e))
366 absCounts vis) 366 absCounts vis)
367 | _ => (timpures, impures, absCounts) 367 | _ => (timpures, impures, absCounts)
368 end) 368 end)
369 (IS.empty, IS.empty, IM.empty) file 369 (IS.empty, IS.empty, IM.empty) (#1 file)
370 370
371 val uses = U.File.fold {typ = fn (_, m) => m, 371 val uses = U.File.fold {typ = fn (_, m) => m,
372 exp = fn (e, m) => 372 exp = fn (e, m) =>
373 case e of 373 case e of
374 ENamed n => IM.insert (m, n, 1 + Option.getOpt (IM.find (m, n), 0)) 374 ENamed n => IM.insert (m, n, 1 + Option.getOpt (IM.find (m, n), 0))