From c9502add3f614d388aa476255547f79c1c80509c Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Fri, 20 Jul 2018 09:34:18 -0700 Subject: [PATCH] Store Name and Span in Located --- src/Control/Abstract/Addressable.hs | 6 +++--- src/Data/Abstract/Address.hs | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Control/Abstract/Addressable.hs b/src/Control/Abstract/Addressable.hs index 6dcc4eae6..862dc24fe 100644 --- a/src/Control/Abstract/Addressable.hs +++ b/src/Control/Abstract/Addressable.hs @@ -34,11 +34,11 @@ instance Member NonDet effects => Addressable Monovariant effects where derefCell _ = traverse (foldMapA pure) . nonEmpty . toList -- | 'Located' addresses allocate & dereference using the underlying address, contextualizing addresses with the current 'PackageInfo' & 'ModuleInfo'. -instance (Addressable address effects, Member (Reader ModuleInfo) effects, Member (Reader PackageInfo) effects) => Addressable (Located address) effects where +instance (Addressable address effects, Member (Reader ModuleInfo) effects, Member (Reader PackageInfo) effects, Member (Reader Span) effects) => Addressable (Located address) effects where type Cell (Located address) = Cell address - allocCell name = relocate (Located <$> allocCell name <*> currentPackage <*> currentModule) - derefCell (Located loc _ _) = relocate . derefCell loc + allocCell name = relocate (Located <$> allocCell name <*> currentPackage <*> currentModule <*> pure name <*> ask) + derefCell (Located loc _ _ _ _) = relocate . derefCell loc instance (Addressable address effects, Ord context, Show context) => Addressable (Hole context address) effects where type Cell (Hole context address) = Cell address diff --git a/src/Data/Abstract/Address.hs b/src/Data/Abstract/Address.hs index b9205a51a..63dfd0892 100644 --- a/src/Data/Abstract/Address.hs +++ b/src/Data/Abstract/Address.hs @@ -12,6 +12,7 @@ import Data.Abstract.Name import Data.Abstract.Package (PackageInfo) import Data.Monoid (Last(..)) import Data.Semigroup.Reducer +import Data.Span import Data.Set as Set import Prologue @@ -35,6 +36,8 @@ data Located address = Located { address :: address , addressPackage :: {-# UNPACK #-} !PackageInfo , addressModule :: !ModuleInfo + , addressName :: Name + , addressSpan :: Span } deriving (Eq, Ord, Show)