From 549962d619d032a68e524c482e2ebb12a1f143ec Mon Sep 17 00:00:00 2001 From: Timothy Clem Date: Tue, 15 May 2018 11:58:47 -0700 Subject: [PATCH] Eval prelude in front of all modules --- src/Data/Abstract/Evaluatable.hs | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Data/Abstract/Evaluatable.hs b/src/Data/Abstract/Evaluatable.hs index 493643630..e09db68c8 100644 --- a/src/Data/Abstract/Evaluatable.hs +++ b/src/Data/Abstract/Evaluatable.hs @@ -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