Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do something maybe addresses Hoshino's goal #1124

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions base/src/main/java/org/aya/resolve/StmtResolvers.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ private void resolveBind(@NotNull ImmutableSeq<ResolvingStmt> stmts) {
binder.bind(rename.bindCtx(), rename.bind(), var));
}

private void desugar(@NotNull ImmutableSeq<Stmt> stmts) {
public void desugar(@NotNull ImmutableSeq<Stmt> stmts) {
var salt = new Desalt(info);
stmts.forEach(stmt -> stmt.descentInPlace(salt, salt.pattern()));
}
Expand All @@ -39,7 +39,6 @@ public void resolve(@NotNull ImmutableSeq<Stmt> stmts) {
var resolving = fillContext(stmts);
resolveStmts(resolving); // resolve mutates stmts
resolveBind(resolving); // mutates bind blocks
desugar(stmts);
info.opSet().reportIfCyclic();
}
}
20 changes: 11 additions & 9 deletions base/src/main/java/org/aya/resolve/module/ModuleLoader.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +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);
new StmtResolvers(recurseLoader, resolveInfo).resolve(program);
return resolveInfo;
var resolver = new StmtResolvers(recurseLoader, resolveInfo);
resolver.resolve(program);
resolver.desugar(program);
}

@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
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-rc-1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.8-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
Loading