Permalink
Browse files

More simplification. Move definition of PureState into splitter

  • Loading branch information...
1 parent 429670d commit 0218e0e98f3d59d5c025b816e65f585d73e46f96 @batterseapower committed Jul 8, 2010
Showing with 9 additions and 9 deletions.
  1. +2 −5 Evaluator/FreeVars.hs
  2. +1 −2 Evaluator/Syntax.hs
  3. +6 −2 Supercompile/Split.hs
View
7 Evaluator/FreeVars.hs
@@ -3,7 +3,7 @@ module Evaluator.FreeVars (
inFreeVars,
pureHeapFreeVars, pureHeapOpenFreeVars,
stackFreeVars, stackFrameFreeVars,
- stateFreeVars, pureStateFreeVars
+ stateFreeVars
) where
import Evaluator.Syntax
@@ -42,7 +42,4 @@ stackFrameFreeVars kf = case kf of
Update x' -> (S.singleton x', S.empty)
stateFreeVars :: State -> FreeVars
-stateFreeVars (Heap h _, k, in_e) = pureStateFreeVars (h, k, in_e)
-
-pureStateFreeVars :: PureState -> FreeVars
-pureStateFreeVars (h, k, in_e) = pureHeapFreeVars h (stackFreeVars k (inFreeVars taggedTermFreeVars in_e))
+stateFreeVars (Heap h _, k, in_e) = pureHeapFreeVars h (stackFreeVars k (inFreeVars taggedTermFreeVars in_e))
View
3 Evaluator/Syntax.hs
@@ -8,8 +8,7 @@ import Utilities
import qualified Data.Map as M
-type PureState = (PureHeap, Stack, In TaggedTerm)
-type State = (Heap, Stack, In TaggedTerm)
+type State = (Heap, Stack, In TaggedTerm)
type PureHeap = M.Map (Out Var) (In TaggedTerm)
data Heap = Heap PureHeap IdSupply
View
8 Supercompile/Split.hs
@@ -172,7 +172,7 @@ data Bracketed a = Bracketed {
rebuild :: [Out Term] -> Out Term, -- Rebuild the full output term given outputs to plug into each hole
extra_fvs :: FreeVars, -- Maximum free variables added by the residual wrapped around the holes
transfer :: [FreeVars] -> FreeVars, -- Strips any variables bound by the residual out of the hole FVs
- fillers :: [a] -- Hole-fillers themselves. Can be In TaggedTerm, State or DrivePureState
+ fillers :: [a] -- Hole-fillers themselves. Can be State or PureState
}
instance Functor Bracketed where
@@ -194,7 +194,7 @@ transitiveInline h_inlineable h_output fvs
fvs' = M.fold (\in_e fvs -> fvs `S.union` inFreeVars taggedTermFreeVars in_e) S.empty h_inline
transitiveInline' :: PureHeap -> State -> State
-transitiveInline' h_inlineable state@(Heap h ids, k, in_e) = (Heap (transitiveInline (h_inlineable `M.union` h) M.empty (stateFreeVars state)) ids, k, in_e)
+transitiveInline' h_inlineable (Heap h ids, k, in_e) = (Heap (transitiveInline (h_inlineable `M.union` h) M.empty (stateFreeVars (Heap M.empty ids, k, in_e))) ids, k, in_e)
optimiseSplit :: Monad m
=> (State -> m (FreeVars, Out Term))
@@ -234,6 +234,10 @@ type EnteredManyEnv = M.Map (Out Var) Bool
toEnteredManyEnv :: EnteredEnv -> EnteredManyEnv
toEnteredManyEnv = M.map (not . isOnce)
+-- State with no Ids yet. Used only to delay filling in the Ids until we inline the inlineable parts of the Heap.
+-- TODO: remove the use of this type entirely.
+type PureState = (PureHeap, Stack, In TaggedTerm)
+
split'
:: Heap
-> Stack

0 comments on commit 0218e0e

Please sign in to comment.