1
1
mirror of https://github.com/github/semantic.git synced 2025-01-02 20:41:38 +03:00

Eval prelude in front of all modules

This commit is contained in:
Timothy Clem 2018-05-15 11:58:47 -07:00 committed by Rob Rix
parent a442683e85
commit 549962d619

View File

@ -213,8 +213,8 @@ evaluatePackageWith analyzeModule analyzeTerm package
. fmap fst
. runState (lowerBound :: Gotos location value (Reader Span ': Reader PackageInfo ': outer))
. runReader (packageModules (packageBody package))
. raiseHandler (runModules (runTermEvaluator . evalModule))
. withPrelude (packagePrelude (packageBody package))
. raiseHandler (runModules (runTermEvaluator . evalModule))
$ traverse (uncurry evaluateEntryPoint) (ModuleTable.toPairs (packageEntryPoints (packageBody package)))
where evalModule m
= pairValueWithEnv
@ -233,12 +233,15 @@ evaluatePackageWith analyzeModule analyzeTerm package
v <- maybe unit (pure . snd) <$> require m
maybe v ((`call` []) <=< variable) sym
withPrelude Nothing a = a
withPrelude (Just prelude) a = do
evalPrelude prelude = raiseHandler (runModules (runTermEvaluator . evalModule)) $ do
_ <- runInModule moduleInfoFromCallStack . TermEvaluator $ do
builtin "print" (closure ["s"] lowerBound (variable "s" >>= asString >>= trace . unpack >> unit))
unit
preludeEnv <- fst <$> evalModule prelude
fst <$> evalModule prelude
withPrelude Nothing a = a
withPrelude (Just prelude) a = do
preludeEnv <- evalPrelude prelude
raiseHandler (withDefaultEnvironment preludeEnv) a
-- TODO: If the set of exports is empty because no exports have been