From 92b5d82cfb05a787be8295bcd4acde45506497c4 Mon Sep 17 00:00:00 2001 From: Rick Winfrey Date: Tue, 27 Nov 2018 15:42:07 -0800 Subject: [PATCH] Update Python QualifiedImport for scope / frames Co-Authored-By: Josh Vera --- src/Language/Python/Syntax.hs | 31 +++---------------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/src/Language/Python/Syntax.hs b/src/Language/Python/Syntax.hs index bf3c9cd98..f4fff485d 100644 --- a/src/Language/Python/Syntax.hs +++ b/src/Language/Python/Syntax.hs @@ -238,34 +238,9 @@ instance Evaluatable QualifiedImport where insertFrameLink ScopeGraph.Import scopeMap go rest) mkScopeMap modulePath fun = do - (scopeGraph, (heap, _)) <- require modulePath - case (ScopeGraph.currentScope scopeGraph, Heap.currentFrame heap) of - (Just scope, Just frame) -> do - 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))) + (moduleScope, (moduleFrame, _)) <- require modulePath + insertImportEdge moduleScope + fun (Map.singleton moduleScope moduleFrame) data QualifiedAliasedImport a = QualifiedAliasedImport { qualifiedAliasedImportFrom :: QualifiedName, qualifiedAliasedImportAlias :: !a } deriving (Declarations1, Diffable, Eq, Foldable, FreeVariables1, Functor, Generic1, Hashable1, Message1, Named1, Ord, Show, ToJSONFields1, Traversable, NFData1)