Skip to content

Commit

Permalink
module-loader: rewrite the creation of ResolveInfo
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Jun 27, 2024
1 parent 149260a commit e658be7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
16 changes: 8 additions & 8 deletions base/src/main/java/org/aya/resolve/module/ModuleLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Stmt> program, @NotNull ModuleLoader recurseLoader
default void resolveModule(
@NotNull ResolveInfo resolveInfo, @NotNull ImmutableSeq<Stmt> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,8 @@ private void loadFile(@NotNull Path file) {
return programOrExpr.map(
program -> {
var newDefs = MutableValue.<ImmutableSeq<TyckDef>>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();
Expand Down

0 comments on commit e658be7

Please sign in to comment.