@@ -30,8 +30,7 @@ HeavyScheme::HeavyScheme(std::unique_ptr<heavy::Context> C)
3030 SourceFileStoragePtr(nullptr , [](SourceFileStorage*) { })
3131{
3232 // Create and store the default environment.
33- ContextPtr->EmbeddedEnvs [nullptr ] =
34- std::make_unique<heavy::Environment>(*ContextPtr);
33+ ContextPtr->DefaultEnv = std::make_unique<heavy::Environment>(*ContextPtr);
3534}
3635
3736HeavyScheme::HeavyScheme ()
@@ -54,32 +53,16 @@ heavy::Lexer HeavyScheme::createEmbeddedLexer(uintptr_t ExternalRawLoc,
5453 return Lexer (File, BufferPos);
5554}
5655
57- heavy::Environment* HeavyScheme::LoadEmbeddedEnv (void * Handle,
58- llvm::function_ref<heavy::Environment*(HeavyScheme&, void *)> LoadParent) {
59- auto & EmbeddedEnvs = getContext ().EmbeddedEnvs ;
60- auto itr = EmbeddedEnvs.find (Handle);
61- if (itr != EmbeddedEnvs.end ())
62- return itr->second .get ();
63-
64- assert (Handle != nullptr && " HeavyScheme should have root environment" );
65- Environment* Parent = LoadParent (*this , Handle);
66- auto & EnvPtr = EmbeddedEnvs[Handle] =
67- std::make_unique<Environment>(Parent);
68- return EnvPtr.get ();
69- }
70-
7156void HeavyScheme::ProcessTopLevelCommands (
7257 heavy::Lexer& Lexer,
7358 llvm::function_ref<ValueFnTy> ExprHandler,
7459 llvm::function_ref<ErrorHandlerFn> ErrorHandler,
75- heavy::Environment* Env,
7660 heavy::tok Terminator) {
7761 auto & Context = getContext ();
7862 auto & SM = getSourceManager ();
7963 auto ParserPtr = std::make_unique<Parser>(Lexer, Context);
8064 Parser& Parser = *ParserPtr;
81- if (Env == nullptr )
82- Env = Context.EmbeddedEnvs [nullptr ].get ();
65+ heavy::Environment* Env = Context.DefaultEnv .get ();
8366
8467 auto HandleErrorFn = [&](heavy::Context& Context, ValueRefs Args) {
8568 heavy::FullSourceLocation FullLoc = SM.getFullSourceLocation (
0 commit comments