1
1
mirror of https://github.com/github/semantic.git synced 2024-12-27 17:05:33 +03:00

Assign using assignCell.

This commit is contained in:
Rob Rix 2018-08-09 15:23:18 -04:00
parent ad67e7af23
commit c4aac9c9be
2 changed files with 8 additions and 5 deletions

View File

@ -36,7 +36,6 @@ import Data.Abstract.Heap
import Data.Abstract.Live
import Data.Abstract.Module (ModuleInfo)
import Data.Abstract.Name
import Data.Semigroup.Reducer
import Data.Span (Span)
import Prologue
@ -169,15 +168,19 @@ data Deref address value (m :: * -> *) return where
runAllocator :: ( Allocatable address effects
, Foldable (Cell address)
, Member (State (Heap address (Cell address) value)) effects
, Monoid (Cell address value)
, Ord value
, PureEffects effects
, Reducer value (Cell address value)
, ValueRoots address value
)
=> Evaluator address value (Allocator address value ': effects) a
-> Evaluator address value effects a
runAllocator = interpret $ \ eff -> case eff of
Alloc name -> allocCell name
Assign addr value -> modifyHeap (heapInsert addr value)
Assign addr value -> do
heap <- getHeap
cell <- assignCell addr value (fromMaybe mempty (heapLookup addr heap))
putHeap (heapInit addr cell heap)
GC roots -> modifyHeap (heapRestrict <*> reachable roots)
runDeref :: ( Derefable address effects

View File

@ -40,7 +40,6 @@ import Data.Language
import Data.Scientific (Scientific)
import Data.Semigroup.App
import Data.Semigroup.Foldable
import Data.Semigroup.Reducer hiding (unit)
import Data.Sum
import Data.Term
import Prologue
@ -96,8 +95,9 @@ evaluate :: ( AbstractValue address value valueEffects
, Member (Resumable (BaseError (UnspecializedError value))) effects
, Member (State (Heap address (Cell address) value)) effects
, Member Trace effects
, Monoid (Cell address value)
, Ord value
, Recursive term
, Reducer value (Cell address value)
, ValueRoots address value
, moduleEffects ~ (Exc (LoopControl address) ': Exc (Return address) ': Env address ': Deref address value ': Allocator address value ': Reader ModuleInfo ': effects)
, valueEffects ~ (Function address value ': moduleEffects)