Skip to content

Commit

Permalink
More simplification. Move definition of PureState into splitter
Browse files Browse the repository at this point in the history
  • Loading branch information
batterseapower committed Jul 8, 2010
1 parent 429670d commit 0218e0e
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
7 changes: 2 additions & 5 deletions Evaluator/FreeVars.hs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Evaluator.FreeVars (
inFreeVars,
pureHeapFreeVars, pureHeapOpenFreeVars,
stackFreeVars, stackFrameFreeVars,
stateFreeVars, pureStateFreeVars
stateFreeVars
) where

import Evaluator.Syntax
Expand Down Expand Up @@ -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))
3 changes: 1 addition & 2 deletions Evaluator/Syntax.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions Supercompile/Split.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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))
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0218e0e

Please sign in to comment.