1
1
mirror of https://github.com/github/semantic.git synced 2024-12-30 10:27:45 +03:00

Change scopedEnvironment to return the address of an Object

This commit is contained in:
joshvera 2018-11-15 20:24:06 -05:00
parent 994fd861c5
commit 3de1cbce5b
4 changed files with 6 additions and 4 deletions

View File

@ -297,7 +297,7 @@ class AbstractIntro value => AbstractValue term address value carrier where
-> Evaluator term address value carrier value
-- | Extract the environment from any scoped object (e.g. classes, namespaces, etc).
scopedEnvironment :: address -> Evaluator term address value carrier (Maybe (Environment address))
scopedEnvironment :: value -> Evaluator term address value carrier (Maybe address)
-- TODO rethink whether this function is necessary.

View File

@ -114,7 +114,7 @@ instance AbstractValue term address Abstract m where
klass _ _ _ = pure Abstract
namespace _ _ _ = pure Abstract
scopedEnvironment _ = pure lowerBound
scopedEnvironment _ = pure Nothing
asString _ = pure ""
asPair _ = pure (Abstract, Abstract)

View File

@ -272,7 +272,9 @@ instance ( Member (Allocator address) sig
-- | Namespace _ _ binds' <- v = pure binds'
-- | otherwise = throwValueError $ NamespaceError ("expected " <> show v <> " to be a namespace")
-- scopedEnvironment = deref >=> materializeEnvironment
scopedEnvironment v
| Object address <- v = pure (Just address)
| otherwise = pure Nothing
asString v
| String n <- v = pure n

View File

@ -359,7 +359,7 @@ instance ( Member Fresh sig
klass _ _ _ = pure Object
namespace _ _ _ = pure Unit
scopedEnvironment _ = pure (Just lowerBound)
scopedEnvironment _ = pure Nothing
asString t = unify t String $> ""
asPair t = do