1
1
mirror of https://github.com/github/semantic.git synced 2024-12-30 02:14:20 +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) getExports :: m (ExportsFor value)
-- | Set the global export state. -- | Set the global export state.
putExports :: ExportsFor value -> m () 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 withExports :: ExportsFor value -> m a -> m a
-- | Retrieve the local environment. -- | Retrieve the local environment.
@ -64,6 +64,7 @@ modifyGlobalEnv f = do
env <- getGlobalEnv env <- getGlobalEnv
putGlobalEnv $! f env putGlobalEnv $! f env
-- | Update the global export state.
modifyExports :: MonadEnvironment value m => (ExportsFor value -> ExportsFor value) -> m () modifyExports :: MonadEnvironment value m => (ExportsFor value -> ExportsFor value) -> m ()
modifyExports f = do modifyExports f = do
exports <- getExports exports <- getExports

View File

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