mirror of
https://github.com/github/semantic.git
synced 2024-11-24 17:04:47 +03:00
Move Located into Data.Abstract.Address.
This commit is contained in:
parent
a6eb856631
commit
db185d5e47
@ -56,7 +56,6 @@ library
|
||||
, Data.Abstract.FreeVariables
|
||||
, Data.Abstract.Heap
|
||||
, Data.Abstract.Live
|
||||
, Data.Abstract.Located
|
||||
, Data.Abstract.Module
|
||||
, Data.Abstract.ModuleTable
|
||||
, Data.Abstract.Number
|
||||
|
@ -22,7 +22,6 @@ import Control.Abstract
|
||||
import Data.Abstract.Address
|
||||
import Data.Abstract.Evaluatable (LoadError (..))
|
||||
import Data.Abstract.FreeVariables
|
||||
import Data.Abstract.Located
|
||||
import Data.Abstract.Module (Module(moduleInfo), ModuleInfo(..))
|
||||
import Data.Abstract.Package (PackageInfo(..))
|
||||
import Data.Aeson hiding (Result)
|
||||
|
@ -1,6 +1,7 @@
|
||||
{-# LANGUAGE GADTs, RankNTypes, TypeOperators, UndecidableInstances #-}
|
||||
module Control.Abstract.Addressable where
|
||||
|
||||
import Control.Abstract.Context
|
||||
import Control.Abstract.Environment
|
||||
import Control.Abstract.Evaluator
|
||||
import Control.Abstract.Heap
|
||||
@ -71,6 +72,15 @@ variable :: ( Addressable location effects
|
||||
-> Evaluator location value effects value
|
||||
variable name = lookupEnv name >>= maybe (freeVariableError name) deref
|
||||
|
||||
instance ( Addressable (location cell) effects
|
||||
, Members '[ Reader ModuleInfo
|
||||
, Reader PackageInfo
|
||||
] effects
|
||||
)
|
||||
=> Addressable (Located location cell) effects where
|
||||
derefCell (Address (Located loc _ _)) = raiseEff . lowerEff . derefCell (Address loc)
|
||||
|
||||
allocLoc name = raiseEff (lowerEff (Located <$> allocLoc name <*> currentPackage <*> currentModule))
|
||||
|
||||
-- Instances
|
||||
|
||||
|
@ -2,6 +2,8 @@
|
||||
module Data.Abstract.Address where
|
||||
|
||||
import Data.Abstract.FreeVariables
|
||||
import Data.Abstract.Module (ModuleInfo)
|
||||
import Data.Abstract.Package (PackageInfo)
|
||||
import Data.Semigroup.Reducer
|
||||
import Data.Semilattice.Lower
|
||||
import Prologue
|
||||
@ -44,6 +46,17 @@ instance Location (Monovariant cell) where
|
||||
type Cell (Monovariant cell) = cell
|
||||
|
||||
|
||||
data Located location (cell :: * -> *) = Located
|
||||
{ location :: location cell
|
||||
, locationPackage :: {-# UNPACK #-} !PackageInfo
|
||||
, locationModule :: !ModuleInfo
|
||||
}
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
instance Location (Located location cell) where
|
||||
type Cell (Located location cell) = Cell (location cell)
|
||||
|
||||
|
||||
-- | A cell holding a single value. Writes will replace any prior value.
|
||||
-- This is isomorphic to 'Last' from Data.Monoid, but is more convenient
|
||||
-- because it has a 'Reducer' instance.
|
||||
|
@ -1,27 +0,0 @@
|
||||
{-# LANGUAGE TypeFamilies, UndecidableInstances #-}
|
||||
module Data.Abstract.Located where
|
||||
|
||||
import Control.Abstract
|
||||
import Data.Abstract.Address
|
||||
import Data.Abstract.Module (ModuleInfo)
|
||||
import Data.Abstract.Package (PackageInfo)
|
||||
|
||||
data Located location (cell :: * -> *) = Located
|
||||
{ location :: location cell
|
||||
, locationPackage :: {-# UNPACK #-} !PackageInfo
|
||||
, locationModule :: !ModuleInfo
|
||||
}
|
||||
deriving (Eq, Ord, Show)
|
||||
|
||||
instance Location (Located location cell) where
|
||||
type Cell (Located location cell) = Cell (location cell)
|
||||
|
||||
instance ( Addressable (location cell) effects
|
||||
, Members '[ Reader ModuleInfo
|
||||
, Reader PackageInfo
|
||||
] effects
|
||||
)
|
||||
=> Addressable (Located location cell) effects where
|
||||
derefCell (Address (Located loc _ _)) = raiseEff . lowerEff . derefCell (Address loc)
|
||||
|
||||
allocLoc name = raiseEff (lowerEff (Located <$> allocLoc name <*> currentPackage <*> currentModule))
|
@ -8,7 +8,6 @@ import qualified Control.Exception as Exc
|
||||
import Control.Monad.Effect (reinterpret)
|
||||
import Data.Abstract.Address
|
||||
import Data.Abstract.Evaluatable
|
||||
import Data.Abstract.Located
|
||||
import Data.Abstract.Module
|
||||
import Data.Abstract.Package as Package
|
||||
import Data.Abstract.Value (Value, ValueError(..), runValueErrorWith)
|
||||
|
Loading…
Reference in New Issue
Block a user