1
1
mirror of https://github.com/github/semantic.git synced 2024-12-20 13:21:59 +03:00

Use isolate for imports too

This commit is contained in:
Timothy Clem 2018-03-15 10:50:32 -07:00
parent 395b0306ad
commit ff2cc72549
2 changed files with 5 additions and 4 deletions

View File

@ -50,7 +50,7 @@ class Monad m => MonadEnvironment value m | m -> value where
getExports :: m (ExportsFor value)
-- | Set the global export state.
putExports :: ExportsFor value -> m ()
-- | Sets the exports the lifetime of the given action.
-- | Sets the global export state for the lifetime of the given action.
withExports :: ExportsFor value -> m a -> m a
-- | Retrieve the local environment.
@ -64,6 +64,7 @@ modifyGlobalEnv f = do
env <- getGlobalEnv
putGlobalEnv $! f env
-- | Update the global export state.
modifyExports :: MonadEnvironment value m => (ExportsFor value -> ExportsFor value) -> m ()
modifyExports f = do
exports <- getExports

View File

@ -273,7 +273,7 @@ instance Show1 QualifiedImport where liftShowsPrec = genericLiftShowsPrec
instance Evaluatable QualifiedImport where
eval (QualifiedImport from alias xs) = do
let moduleName = freeVariable (subterm from)
importedEnv <- withGlobalEnv mempty (require moduleName)
importedEnv <- isolate (require moduleName)
modifyGlobalEnv (flip (Map.foldrWithKey copy) (unEnvironment importedEnv))
unit
where
@ -297,7 +297,7 @@ instance Show1 Import where liftShowsPrec = genericLiftShowsPrec
instance Evaluatable Import where
eval (Import from xs _) = do
let moduleName = freeVariable (subterm from)
importedEnv <- withGlobalEnv mempty (require moduleName)
importedEnv <- isolate (require moduleName)
modifyGlobalEnv (flip (Map.foldrWithKey copy) (unEnvironment importedEnv))
unit
where
@ -316,7 +316,7 @@ instance Show1 SideEffectImport where liftShowsPrec = genericLiftShowsPrec
instance Evaluatable SideEffectImport where
eval (SideEffectImport from _) = do
let moduleName = freeVariable (subterm from)
void $ withGlobalEnv mempty (require moduleName)
void $ isolate (require moduleName)
unit