-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
76 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,39 @@ | ||
module Juvix.Compiler.Store.Extra where | ||
|
||
import Data.HashMap.Strict qualified as HashMap | ||
import Juvix.Compiler.Concrete.Data.ScopedName qualified as S | ||
import Juvix.Compiler.Concrete.Language (TopModulePath) | ||
import Juvix.Compiler.Core.Data.InfoTable qualified as Core | ||
import Juvix.Compiler.Store.Core.Extra | ||
import Juvix.Compiler.Store.Internal.Language | ||
import Juvix.Compiler.Store.Language | ||
import Juvix.Compiler.Store.Scoped.Language | ||
import Juvix.Prelude | ||
|
||
getModulePath :: ModuleInfo -> TopModulePath | ||
getModulePath mi = mi ^. moduleInfoScopedModule . scopedModulePath . S.nameConcrete | ||
|
||
getModuleId :: ModuleInfo -> ModuleId | ||
getModuleId mi = mi ^. moduleInfoScopedModule . scopedModuleId | ||
|
||
getScopedModuleTable :: ModuleTable -> ScopedModuleTable | ||
getScopedModuleTable mtab = | ||
ScopedModuleTable $ fmap (^. moduleInfoScopedModule) (mtab ^. moduleTable) | ||
|
||
getInternalModuleTable :: ModuleTable -> InternalModuleTable | ||
getInternalModuleTable mtab = | ||
InternalModuleTable $ | ||
HashMap.fromList (map (\mi -> (mi ^. moduleInfoInternalModule . internalModuleName, mi ^. moduleInfoInternalModule)) (HashMap.elems (mtab ^. moduleTable))) | ||
|
||
mkModuleTable :: [ModuleInfo] -> ModuleTable | ||
mkModuleTable = ModuleTable . HashMap.fromList . map (\mi -> (getModulePath mi, mi)) | ||
|
||
lookupModule :: ModuleTable -> TopModulePath -> ModuleInfo | ||
lookupModule mtab n = fromJust $ HashMap.lookup n (mtab ^. moduleTable) | ||
|
||
insertModule :: TopModulePath -> ModuleInfo -> ModuleTable -> ModuleTable | ||
insertModule p mi = over moduleTable (HashMap.insert p mi) | ||
|
||
computeCombinedCoreInfoTable :: ModuleTable -> Core.InfoTable | ||
computeCombinedCoreInfoTable mtab = | ||
mconcatMap (toCore . (^. moduleInfoCoreTable)) (HashMap.elems (mtab ^. moduleTable)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters