mirror of
https://github.com/github/semantic.git
synced 2024-11-28 10:15:55 +03:00
Rename Allocator to Store.
This commit is contained in:
parent
9f1e73cd07
commit
42540a1e20
@ -78,7 +78,7 @@ cachingTerms recur term = do
|
|||||||
|
|
||||||
convergingModules :: ( AbstractValue address value effects
|
convergingModules :: ( AbstractValue address value effects
|
||||||
, Cacheable term address (Cell address) value
|
, Cacheable term address (Cell address) value
|
||||||
, Member (Allocator address value) effects
|
, Member (Store address value) effects
|
||||||
, Member Fresh effects
|
, Member Fresh effects
|
||||||
, Member NonDet effects
|
, Member NonDet effects
|
||||||
, Member (Reader (Cache term address (Cell address) value)) effects
|
, Member (Reader (Cache term address (Cell address) value)) effects
|
||||||
|
@ -12,8 +12,8 @@ module Control.Abstract.Heap
|
|||||||
, letrec'
|
, letrec'
|
||||||
, variable
|
, variable
|
||||||
-- * Effects
|
-- * Effects
|
||||||
, Allocator(..)
|
, Store(..)
|
||||||
, runAllocator
|
, runStore
|
||||||
, AddressError(..)
|
, AddressError(..)
|
||||||
, runAddressError
|
, runAddressError
|
||||||
, runAddressErrorWith
|
, runAddressErrorWith
|
||||||
@ -41,11 +41,11 @@ modifyHeap :: Member (State (Heap address (Cell address) value)) effects => (Hea
|
|||||||
modifyHeap = modify'
|
modifyHeap = modify'
|
||||||
|
|
||||||
|
|
||||||
alloc :: forall address value effects . Member (Allocator address value) effects => Name -> Evaluator address value effects address
|
alloc :: forall address value effects . Member (Store address value) effects => Name -> Evaluator address value effects address
|
||||||
alloc = send . Alloc @address @value
|
alloc = send . Alloc @address @value
|
||||||
|
|
||||||
-- | Dereference the given address in the heap, or fail if the address is uninitialized.
|
-- | Dereference the given address in the heap, or fail if the address is uninitialized.
|
||||||
deref :: Member (Allocator address value) effects => address -> Evaluator address value effects value
|
deref :: Member (Store address value) effects => address -> Evaluator address value effects value
|
||||||
deref = send . Deref
|
deref = send . Deref
|
||||||
|
|
||||||
|
|
||||||
@ -61,7 +61,7 @@ assign address = modifyHeap . heapInsert address
|
|||||||
|
|
||||||
|
|
||||||
-- | Look up or allocate an address for a 'Name'.
|
-- | Look up or allocate an address for a 'Name'.
|
||||||
lookupOrAlloc :: ( Member (Allocator address value) effects
|
lookupOrAlloc :: ( Member (Store address value) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
)
|
)
|
||||||
=> Name
|
=> Name
|
||||||
@ -69,7 +69,7 @@ lookupOrAlloc :: ( Member (Allocator address value) effects
|
|||||||
lookupOrAlloc name = lookupEnv name >>= maybeM (alloc name)
|
lookupOrAlloc name = lookupEnv name >>= maybeM (alloc name)
|
||||||
|
|
||||||
|
|
||||||
letrec :: ( Member (Allocator address value) effects
|
letrec :: ( Member (Store address value) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
, Member (State (Heap address (Cell address) value)) effects
|
, Member (State (Heap address (Cell address) value)) effects
|
||||||
, Ord address
|
, Ord address
|
||||||
@ -85,7 +85,7 @@ letrec name body = do
|
|||||||
pure (v, addr)
|
pure (v, addr)
|
||||||
|
|
||||||
-- Lookup/alloc a name passing the address to a body evaluated in a new local environment.
|
-- Lookup/alloc a name passing the address to a body evaluated in a new local environment.
|
||||||
letrec' :: ( Member (Allocator address value) effects
|
letrec' :: ( Member (Store address value) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
)
|
)
|
||||||
=> Name
|
=> Name
|
||||||
@ -98,7 +98,7 @@ letrec' name body = do
|
|||||||
|
|
||||||
|
|
||||||
-- | Look up and dereference the given 'Name', throwing an exception for free variables.
|
-- | Look up and dereference the given 'Name', throwing an exception for free variables.
|
||||||
variable :: ( Member (Allocator address value) effects
|
variable :: ( Member (Store address value) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
, Member (Resumable (EnvironmentError address)) effects
|
, Member (Resumable (EnvironmentError address)) effects
|
||||||
)
|
)
|
||||||
@ -109,12 +109,12 @@ variable name = lookupEnv name >>= maybeM (freeVariableError name) >>= deref
|
|||||||
|
|
||||||
-- Effects
|
-- Effects
|
||||||
|
|
||||||
data Allocator address value return where
|
data Store address value return where
|
||||||
Alloc :: Name -> Allocator address value address
|
Alloc :: Name -> Store address value address
|
||||||
Deref :: address -> Allocator address value value
|
Deref :: address -> Store address value value
|
||||||
|
|
||||||
runAllocator :: (Addressable address effects, Effectful (m address value), Member (Resumable (AddressError address value)) effects, Member (State (Heap address (Cell address) value)) effects) => m address value (Allocator address value ': effects) a -> m address value effects a
|
runStore :: (Addressable address effects, Effectful (m address value), Member (Resumable (AddressError address value)) effects, Member (State (Heap address (Cell address) value)) effects) => m address value (Store address value ': effects) a -> m address value effects a
|
||||||
runAllocator = raiseHandler (interpret (\ eff -> case eff of
|
runStore = raiseHandler (interpret (\ eff -> case eff of
|
||||||
Alloc name -> lowerEff $ allocCell name
|
Alloc name -> lowerEff $ allocCell name
|
||||||
Deref addr -> lowerEff $ heapLookup addr <$> get >>= maybeM (throwResumable (UnallocatedAddress addr)) >>= derefCell addr >>= maybeM (throwResumable (UninitializedAddress addr))))
|
Deref addr -> lowerEff $ heapLookup addr <$> get >>= maybeM (throwResumable (UnallocatedAddress addr)) >>= derefCell addr >>= maybeM (throwResumable (UninitializedAddress addr))))
|
||||||
|
|
||||||
|
@ -13,7 +13,7 @@ import Data.Semilattice.Lower
|
|||||||
import Prologue
|
import Prologue
|
||||||
|
|
||||||
builtin :: ( HasCallStack
|
builtin :: ( HasCallStack
|
||||||
, Member (Allocator address value) effects
|
, Member (Store address value) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
, Member (Reader ModuleInfo) effects
|
, Member (Reader ModuleInfo) effects
|
||||||
, Member (Reader Span) effects
|
, Member (Reader Span) effects
|
||||||
@ -39,7 +39,7 @@ lambda body = do
|
|||||||
|
|
||||||
defineBuiltins :: ( AbstractValue address value effects
|
defineBuiltins :: ( AbstractValue address value effects
|
||||||
, HasCallStack
|
, HasCallStack
|
||||||
, Member (Allocator address value) effects
|
, Member (Store address value) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
, Member Fresh effects
|
, Member Fresh effects
|
||||||
, Member (Reader ModuleInfo) effects
|
, Member (Reader ModuleInfo) effects
|
||||||
|
@ -218,7 +218,7 @@ evaluateInScopedEnv scopedEnvTerm term = do
|
|||||||
|
|
||||||
-- | Evaluates a 'Value' returning the referenced value
|
-- | Evaluates a 'Value' returning the referenced value
|
||||||
value :: ( AbstractValue address value effects
|
value :: ( AbstractValue address value effects
|
||||||
, Member (Allocator address value) effects
|
, Member (Store address value) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
, Member (Resumable (EnvironmentError address)) effects
|
, Member (Resumable (EnvironmentError address)) effects
|
||||||
)
|
)
|
||||||
@ -230,7 +230,7 @@ value (Rval val) = pure val
|
|||||||
|
|
||||||
-- | Evaluates a 'Subterm' to its rval
|
-- | Evaluates a 'Subterm' to its rval
|
||||||
subtermValue :: ( AbstractValue address value effects
|
subtermValue :: ( AbstractValue address value effects
|
||||||
, Member (Allocator address value) effects
|
, Member (Store address value) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
, Member (Resumable (EnvironmentError address)) effects
|
, Member (Resumable (EnvironmentError address)) effects
|
||||||
)
|
)
|
||||||
|
@ -52,7 +52,7 @@ type EvaluatableConstraints address term value effects =
|
|||||||
( AbstractValue address value effects
|
( AbstractValue address value effects
|
||||||
, Declarations term
|
, Declarations term
|
||||||
, FreeVariables term
|
, FreeVariables term
|
||||||
, Member (Allocator address value) effects
|
, Member (Store address value) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
, Member (LoopControl value) effects
|
, Member (LoopControl value) effects
|
||||||
, Member (Modules address value) effects
|
, Member (Modules address value) effects
|
||||||
@ -85,7 +85,7 @@ evaluatePackageWith :: forall address term value inner inner' inner'' outer
|
|||||||
, Member (State (ModuleTable (Maybe (value, Environment address)))) outer
|
, Member (State (ModuleTable (Maybe (value, Environment address)))) outer
|
||||||
, Member Trace outer
|
, Member Trace outer
|
||||||
, Recursive term
|
, Recursive term
|
||||||
, inner ~ (LoopControl value ': Return value ': Env address ': Allocator address value ': inner')
|
, inner ~ (LoopControl value ': Return value ': Env address ': Store address value ': inner')
|
||||||
, inner' ~ (Reader ModuleInfo ': inner'')
|
, inner' ~ (Reader ModuleInfo ': inner'')
|
||||||
, inner'' ~ (Modules address value ': Reader Span ': Reader PackageInfo ': outer)
|
, inner'' ~ (Modules address value ': Reader Span ': Reader PackageInfo ': outer)
|
||||||
)
|
)
|
||||||
@ -111,7 +111,7 @@ evaluatePackageWith analyzeModule analyzeTerm package
|
|||||||
|
|
||||||
runInModule preludeEnv info
|
runInModule preludeEnv info
|
||||||
= runReader info
|
= runReader info
|
||||||
. raiseHandler runAllocator
|
. raiseHandler runStore
|
||||||
. raiseHandler (runEnv preludeEnv)
|
. raiseHandler (runEnv preludeEnv)
|
||||||
. raiseHandler runReturn
|
. raiseHandler runReturn
|
||||||
. raiseHandler runLoopControl
|
. raiseHandler runLoopControl
|
||||||
|
@ -116,7 +116,7 @@ instance AbstractIntro Type where
|
|||||||
null = Null
|
null = Null
|
||||||
|
|
||||||
|
|
||||||
instance ( Member (Allocator address Type) effects
|
instance ( Member (Store address Type) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
, Member Fresh effects
|
, Member Fresh effects
|
||||||
, Member (Resumable TypeError) effects
|
, Member (Resumable TypeError) effects
|
||||||
@ -145,7 +145,7 @@ instance ( Member (Allocator address Type) effects
|
|||||||
|
|
||||||
|
|
||||||
-- | Discard the value arguments (if any), constructing a 'Type' instead.
|
-- | Discard the value arguments (if any), constructing a 'Type' instead.
|
||||||
instance ( Member (Allocator address Type) effects
|
instance ( Member (Store address Type) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
, Member Fresh effects
|
, Member Fresh effects
|
||||||
, Member NonDet effects
|
, Member NonDet effects
|
||||||
|
@ -55,7 +55,7 @@ instance AbstractHole (Value address body) where
|
|||||||
hole = Hole
|
hole = Hole
|
||||||
|
|
||||||
instance ( Coercible body (Eff effects)
|
instance ( Coercible body (Eff effects)
|
||||||
, Member (Allocator address (Value address body)) effects
|
, Member (Store address (Value address body)) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
, Member Fresh effects
|
, Member Fresh effects
|
||||||
, Member (Reader ModuleInfo) effects
|
, Member (Reader ModuleInfo) effects
|
||||||
@ -108,7 +108,7 @@ instance Show address => AbstractIntro (Value address body) where
|
|||||||
|
|
||||||
-- | Construct a 'Value' wrapping the value arguments (if any).
|
-- | Construct a 'Value' wrapping the value arguments (if any).
|
||||||
instance ( Coercible body (Eff effects)
|
instance ( Coercible body (Eff effects)
|
||||||
, Member (Allocator address (Value address body)) effects
|
, Member (Store address (Value address body)) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
, Member Fresh effects
|
, Member Fresh effects
|
||||||
, Member (LoopControl (Value address body)) effects
|
, Member (LoopControl (Value address body)) effects
|
||||||
|
@ -53,7 +53,7 @@ resolvePHPName n = do
|
|||||||
toName = BC.unpack . dropRelativePrefix . stripQuotes
|
toName = BC.unpack . dropRelativePrefix . stripQuotes
|
||||||
|
|
||||||
include :: ( AbstractValue address value effects
|
include :: ( AbstractValue address value effects
|
||||||
, Member (Allocator address value) effects
|
, Member (Store address value) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
, Member (Modules address value) effects
|
, Member (Modules address value) effects
|
||||||
, Member (Resumable ResolutionError) effects
|
, Member (Resumable ResolutionError) effects
|
||||||
|
@ -128,7 +128,7 @@ instance Evaluatable Import where
|
|||||||
|
|
||||||
-- Evaluate a qualified import
|
-- Evaluate a qualified import
|
||||||
evalQualifiedImport :: ( AbstractValue address value effects
|
evalQualifiedImport :: ( AbstractValue address value effects
|
||||||
, Member (Allocator address value) effects
|
, Member (Store address value) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
, Member (Modules address value) effects
|
, Member (Modules address value) effects
|
||||||
, Member (State (Heap address (Cell address) value)) effects
|
, Member (State (Heap address (Cell address) value)) effects
|
||||||
|
@ -134,7 +134,7 @@ javascriptExtensions :: [String]
|
|||||||
javascriptExtensions = ["js"]
|
javascriptExtensions = ["js"]
|
||||||
|
|
||||||
evalRequire :: ( AbstractValue address value effects
|
evalRequire :: ( AbstractValue address value effects
|
||||||
, Member (Allocator address value) effects
|
, Member (Store address value) effects
|
||||||
, Member (Env address) effects
|
, Member (Env address) effects
|
||||||
, Member (Modules address value) effects
|
, Member (Modules address value) effects
|
||||||
, Member (State (Heap address (Cell address) value)) effects
|
, Member (State (Heap address (Cell address) value)) effects
|
||||||
|
@ -37,7 +37,7 @@ evaluate
|
|||||||
. runValueError
|
. runValueError
|
||||||
. runEnvironmentError
|
. runEnvironmentError
|
||||||
. runAddressError
|
. runAddressError
|
||||||
. runAllocator
|
. runStore
|
||||||
. runEnv lowerBound
|
. runEnv lowerBound
|
||||||
. runReturn
|
. runReturn
|
||||||
. runLoopControl
|
. runLoopControl
|
||||||
|
Loading…
Reference in New Issue
Block a user