Skip to content

Commit

Permalink
clean
Browse files Browse the repository at this point in the history
  • Loading branch information
janmasrovira authored and lukaszcz committed Dec 19, 2024
1 parent e0399f4 commit d194ac1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 23 deletions.
26 changes: 6 additions & 20 deletions src/Juvix/Compiler/Pipeline/Driver.hs
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ processModuleCacheMissDecide entryIx = do
unless (info ^. Store.moduleInfoSHA256 == sha256) (throw RecompileSourceChanged)
unless (info ^. Store.moduleInfoOptions == opts) (throw RecompileSourceChanged)
unless (info ^. Store.moduleInfoFieldSize == entry ^. entryPointFieldSize) (throw RecompileFieldSizeChanged)
CompileResult {..} <- runReader entry (processImports (entryIx ^. entryIxImportNode . importNodeAbsFile) (info ^. Store.moduleInfoImports))
CompileResult {..} <- runReader entry (processImports (info ^. Store.moduleInfoImports))
if
| _compileResultChanged -> throw RecompileImportsChanged
| otherwise ->
Expand Down Expand Up @@ -326,30 +326,17 @@ processRecursiveUpToTyped = do
processImport ::
forall r.
(Members '[ModuleInfoCache, Reader EntryPoint, Error JuvixError, Files, PathResolver] r) =>
Path Abs File ->
TopModulePath ->
Sem r (PipelineResult Store.ModuleInfo)
processImport importingModule p = withPathFile p getCachedImport
processImport p = withPathFile p getCachedImport
where
getCachedImport :: ImportNode -> Sem r (PipelineResult Store.ModuleInfo)
getCachedImport node = do
hasParallelSupport <- supportsParallel
eix <- mkEntryIndex node
if
| hasParallelSupport -> do
res <- cacheLookup eix
return $ fromMaybe err res
| hasParallelSupport -> cacheGet eix
| otherwise -> processModule eix
where
err :: forall a. a
err =
impossibleError
( "While compiling\n"
<> prettyText importingModule
<> "\nexpected the module:\n"
<> prettyText (node ^. importNodeAbsFile)
<> "\nto be already compiled"
)

processFileUpToParsing ::
forall r.
Expand All @@ -359,7 +346,7 @@ processFileUpToParsing ::
processFileUpToParsing entry = do
res <- runReader entry upToParsing
let imports :: [Import 'Parsed] = res ^. Parser.resultParserState . Parser.parserStateImports
mtab <- (^. compileResultModuleTable) <$> processImports (fromJust (entry ^. entryPointModulePath)) (map (^. importModulePath) imports)
mtab <- (^. compileResultModuleTable) <$> processImports (map (^. importModulePath) imports)
return
PipelineResult
{ _pipelineResult = res,
Expand Down Expand Up @@ -387,11 +374,10 @@ processFileUpTo a = do
processImports ::
forall r.
(Members '[Reader EntryPoint, ModuleInfoCache, Error JuvixError, Files, PathResolver] r) =>
Path Abs File ->
[TopModulePath] ->
Sem r CompileResult
processImports importingModule imports = do
ms :: [PipelineResult Store.ModuleInfo] <- forM imports (processImport importingModule)
processImports imports = do
ms :: [PipelineResult Store.ModuleInfo] <- forM imports processImport
let mtab =
Store.mkModuleTable (map (^. pipelineResult) ms)
<> mconcatMap (^. pipelineResultImports) ms
Expand Down
4 changes: 2 additions & 2 deletions src/Juvix/Compiler/Pipeline/Loader/PathResolver/ImportTree.hs
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,12 @@ mkImportTree mentrypointModulePath =
) =>
ImportNode ->
Sem r' ()
scanNode fromNode = withImportNode fromNode $ do
scanNode fromNode = withResolverRoot (fromNode ^. importNodePackageRoot) . withImportNode fromNode $ do
scans <- toList <$> getNodeImports fromNode
imports :: [ImportNode] <- mapM resolveImportScan scans
forM_ (zipExact scans imports) $ \(importscan, toNode) -> do
importTreeAddEdge importscan toNode
withResolverRoot (toNode ^. importNodePackageRoot) (visit toNode)
visit toNode

resolveImportScan :: forall r'. (Members '[PathResolver] r') => ImportScan -> Sem r' ImportNode
resolveImportScan s = do
Expand Down
2 changes: 1 addition & 1 deletion src/Juvix/Compiler/Pipeline/Repl.hs
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ registerImport ::
Import 'Parsed ->
Sem r ()
registerImport i = do
PipelineResult {..} <- processImport $(mkAbsFile "/<repl>") (i ^. importModulePath)
PipelineResult {..} <- processImport (i ^. importModulePath)
let mtab' = Store.insertModule (i ^. importModulePath) _pipelineResult _pipelineResultImports
modify' (appendArtifactsModuleTable mtab')
scopeTable <- gets (^. artifactScopeTable)
Expand Down

0 comments on commit d194ac1

Please sign in to comment.