mirror of
https://github.com/github/semantic.git
synced 2024-12-15 01:51:39 +03:00
Add AbstractHole instances for Path, Scope, Address
Co-Authored-By: Rick Winfrey <rick.winfrey@gmail.com>
This commit is contained in:
parent
eebcc9c9ee
commit
244109310a
@ -24,6 +24,7 @@ module Data.Abstract.ScopeGraph
|
||||
, scopeOfRef
|
||||
) where
|
||||
|
||||
import Control.Abstract.Hole
|
||||
import Data.Abstract.Name
|
||||
import qualified Data.Map.Strict as Map
|
||||
import Data.Span
|
||||
@ -41,6 +42,15 @@ data Scope scopeAddress = Scope {
|
||||
, declarations :: Seq (Declaration, (Span, Maybe scopeAddress))
|
||||
} deriving (Eq, Show, Ord, Generic, NFData)
|
||||
|
||||
instance Lower (Scope scopeAddress) where
|
||||
lowerBound = Scope mempty mempty mempty
|
||||
|
||||
instance AbstractHole (Scope scopeAddress) where
|
||||
hole = lowerBound
|
||||
|
||||
instance AbstractHole address => AbstractHole (Address address) where
|
||||
hole = Address hole (Position 0)
|
||||
|
||||
newtype Position = Position { unPosition :: Int }
|
||||
deriving (Eq, Show, Ord, Generic, NFData)
|
||||
|
||||
@ -57,10 +67,14 @@ deriving instance NFData scope => NFData (ScopeGraph scope)
|
||||
|
||||
data Path scope where
|
||||
-- | Construct a direct path to a declaration.
|
||||
Hole :: Path scope
|
||||
DPath :: Declaration -> Position -> Path scope
|
||||
-- | Construct an edge from a scope to another declaration path.
|
||||
EPath :: EdgeLabel -> scope -> Path scope -> Path scope
|
||||
|
||||
instance AbstractHole (Path scope) where
|
||||
hole = Hole
|
||||
|
||||
deriving instance Eq scope => Eq (Path scope)
|
||||
deriving instance Show scope => Show (Path scope)
|
||||
deriving instance Ord scope => Ord (Path scope)
|
||||
|
@ -422,17 +422,20 @@ resumingHeapError = runHeapErrorWith (\ baseError -> traceError "ScopeError" bas
|
||||
|
||||
resumingScopeError :: ( Carrier sig m
|
||||
, Member Trace sig
|
||||
, AbstractHole (Address address)
|
||||
, AbstractHole (Scope address)
|
||||
, AbstractHole (Path address)
|
||||
, AbstractHole address
|
||||
, Show address
|
||||
, Ord address
|
||||
)
|
||||
=> Evaluator term address value (ResumableWithC (BaseError (ScopeError address)) (Eff m)) a
|
||||
-> Evaluator term address value m a
|
||||
resumingScopeError = runScopeErrorWith (\ baseError -> traceError "ScopeError" baseError *> case baseErrorException baseError of
|
||||
ex -> undefined)
|
||||
-- LookupError :: address -> HeapError address address
|
||||
-- LookupLinksError :: address -> HeapError address (Map EdgeLabel (Map address address))
|
||||
-- LookupPathError :: Path address -> HeapError address address
|
||||
|
||||
ScopeError decl span -> pure hole
|
||||
LookupScopeError -> pure hole
|
||||
LookupPathError decl -> pure hole
|
||||
CurrentScopeError -> pure hole)
|
||||
|
||||
resumingTypeError :: ( Carrier sig m
|
||||
, Member NonDet sig
|
||||
|
Loading…
Reference in New Issue
Block a user