From e658be740233f0672241f9dec139cb29fcb786a5 Mon Sep 17 00:00:00 2001 From: ice1000 Date: Thu, 27 Jun 2024 03:13:03 -0400 Subject: [PATCH] module-loader: rewrite the creation of `ResolveInfo` --- .../org/aya/resolve/module/ModuleLoader.java | 16 ++++++++-------- .../org/aya/cli/interactive/ReplCompiler.java | 3 ++- 2 files changed, 10 insertions(+), 9 deletions(-) diff --git a/base/src/main/java/org/aya/resolve/module/ModuleLoader.java b/base/src/main/java/org/aya/resolve/module/ModuleLoader.java index 831157b00d..be3a32843b 100644 --- a/base/src/main/java/org/aya/resolve/module/ModuleLoader.java +++ b/base/src/main/java/org/aya/resolve/module/ModuleLoader.java @@ -62,26 +62,26 @@ public interface ModuleLoader extends Problematic { @NotNull ModuleLoader recurseLoader ) { var opSet = new AyaBinOpSet(reporter()); - return resolveModule(primFactory, new ShapeFactory(), opSet, context, program, recurseLoader); + var resolveInfo = new ResolveInfo(context, primFactory, new ShapeFactory(), opSet); + resolveModule(resolveInfo, program, recurseLoader); + return resolveInfo; } /** * Resolve a certain module. * - * @param context the context of the module - * @param program the statements of the module + * @param context the context of the module + * @param program the statements of the module * @param recurseLoader the module loader that used to resolve */ @ApiStatus.Internal - default @NotNull ResolveInfo resolveModule( - @NotNull PrimFactory primFactory, @NotNull ShapeFactory shapeFactory, @NotNull AyaBinOpSet opSet, - @NotNull ModuleContext context, @NotNull ImmutableSeq program, @NotNull ModuleLoader recurseLoader + default void resolveModule( + @NotNull ResolveInfo resolveInfo, @NotNull ImmutableSeq program, + @NotNull ModuleLoader recurseLoader ) { - var resolveInfo = new ResolveInfo(context, primFactory, shapeFactory, opSet); var resolver = new StmtResolvers(recurseLoader, resolveInfo); resolver.resolve(program); resolver.desugar(program); - return resolveInfo; } @Nullable ResolveInfo load(@NotNull ModulePath path, @NotNull ModuleLoader recurseLoader); diff --git a/cli-impl/src/main/java/org/aya/cli/interactive/ReplCompiler.java b/cli-impl/src/main/java/org/aya/cli/interactive/ReplCompiler.java index e04707d44a..425e7f06fa 100644 --- a/cli-impl/src/main/java/org/aya/cli/interactive/ReplCompiler.java +++ b/cli-impl/src/main/java/org/aya/cli/interactive/ReplCompiler.java @@ -143,7 +143,8 @@ private void loadFile(@NotNull Path file) { return programOrExpr.map( program -> { var newDefs = MutableValue.>create(); - var resolveInfo = loader.resolveModule(primFactory, shapeFactory, opSet, context.fork(), program, loader); + var resolveInfo = new ResolveInfo(context.fork(), primFactory, shapeFactory, opSet); + loader.resolveModule(resolveInfo, program, loader); resolveInfo.shapeFactory().discovered = shapeFactory.fork().discovered; loader.tyckModule(resolveInfo, ((_, defs) -> newDefs.set(defs))); if (reporter.anyError()) return ImmutableSeq.empty();