1
1
mirror of https://github.com/github/semantic.git synced 2024-12-15 18:13:38 +03:00

Update Python QualifiedImport for scope / frames

Co-Authored-By: Josh Vera <vera@github.com>
This commit is contained in:
Rick Winfrey 2018-11-27 15:42:07 -08:00
parent f74b7810cd
commit 92b5d82cfb

View File

@ -238,34 +238,9 @@ instance Evaluatable QualifiedImport where
insertFrameLink ScopeGraph.Import scopeMap insertFrameLink ScopeGraph.Import scopeMap
go rest) go rest)
mkScopeMap modulePath fun = do mkScopeMap modulePath fun = do
(scopeGraph, (heap, _)) <- require modulePath (moduleScope, (moduleFrame, _)) <- require modulePath
case (ScopeGraph.currentScope scopeGraph, Heap.currentFrame heap) of insertImportEdge moduleScope
(Just scope, Just frame) -> do fun (Map.singleton moduleScope moduleFrame)
insertImportEdge scope
fun (Map.singleton scope frame)
_ -> pure ()
-- withScope scopeAddress $ do
-- let
-- go [] = pure ()
-- go (modulePath :| paths) =
-- mkScopeMap modulePath (\scopeMap -> do
-- objFrame <- newFrame scopeAddress (Map.singleton ScopeGraph.Import scopeMap)
-- val <- object objFrame
-- assign aliasSlot val
-- for_ paths $ \modulePath ->
-- mkScopeMap modulePath (withFrame objFrame . insertFrameLink ScopeGraph.Import))
-- go paths
-- a/*.py
-- rvalBox =<< go (NonEmpty.zip (Data.Abstract.Evaluatable.name . T.pack <$> qualifiedName) modulePaths)
-- where
-- -- Evaluate and import the last module, updating the environment
-- go ((name, path) :| []) = evalQualifiedImport name path
-- -- Evaluate each parent module, just creating a namespace
-- go ((name, path) :| xs) = letrec' name $ \addr -> do
-- void $ require path
-- makeNamespace name addr Nothing (void (require path >> go (NonEmpty.fromList xs)))
data QualifiedAliasedImport a = QualifiedAliasedImport { qualifiedAliasedImportFrom :: QualifiedName, qualifiedAliasedImportAlias :: !a } data QualifiedAliasedImport a = QualifiedAliasedImport { qualifiedAliasedImportFrom :: QualifiedName, qualifiedAliasedImportAlias :: !a }
deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Message1, Named1, Ord, Show, ToJSONFields1, Traversable, NFData1) deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Message1, Named1, Ord, Show, ToJSONFields1, Traversable, NFData1)