Skip to content

Commit

Permalink
proj: move more to fix compile
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Dec 13, 2023
1 parent 09490b8 commit eaaf182
Show file tree
Hide file tree
Showing 10 changed files with 25 additions and 19 deletions.
4 changes: 2 additions & 2 deletions base/src/main/java/org/aya/concrete/Expr.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@
import org.aya.resolve.visitor.ExprResolver;
import org.aya.resolve.visitor.StmtShallowResolver;
import org.aya.tyck.Result;
import org.aya.util.BinOpElem;
import org.aya.util.ForLSP;
import org.aya.util.binop.BinOpParser;
import org.aya.util.error.SourceNode;
import org.aya.util.error.SourcePos;
import org.aya.util.error.WithPos;
Expand Down Expand Up @@ -158,7 +158,7 @@ record App(
* @author AustinZhu
*/
record NamedArg(@Override boolean explicit, @Nullable String name, @Override @NotNull Expr term)
implements AyaDocile, SourceNode, BinOpParser.Elem<Expr> {
implements AyaDocile, SourceNode, BinOpElem<Expr> {

public NamedArg(boolean explicit, @NotNull Expr expr) {
this(explicit, null, expr);
Expand Down
12 changes: 6 additions & 6 deletions base/src/main/java/org/aya/prettier/BasePrettier.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
import org.aya.ref.DefVar;
import org.aya.ref.LocalVar;
import org.aya.util.Arg;
import org.aya.util.BinOpElem;
import org.aya.util.binop.Assoc;
import org.aya.util.binop.BinOpParser;
import org.aya.util.prettier.PrettierOptions;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand Down Expand Up @@ -76,7 +76,7 @@ protected BasePrettier(@NotNull PrettierOptions options) {

public @NotNull Doc visitCalls(
@Nullable Assoc assoc, @NotNull Doc fn,
@NotNull SeqView<? extends BinOpParser.@NotNull Elem<Term>> args,
@NotNull SeqView<? extends @NotNull BinOpElem<Term>> args,
@NotNull Outer outer, boolean showImplicits
) {
return visitCalls(assoc, fn, this::term, outer, args, showImplicits);
Expand Down Expand Up @@ -109,9 +109,9 @@ protected BasePrettier(@NotNull PrettierOptions options) {
*/
<T extends AyaDocile> @NotNull Doc visitCalls(
@Nullable Assoc assoc, @NotNull Doc fn, @NotNull Fmt<T> fmt, Outer outer,
@NotNull SeqView<? extends BinOpParser.@NotNull Elem<@NotNull T>> args, boolean showImplicits
@NotNull SeqView<? extends @NotNull BinOpElem<@NotNull T>> args, boolean showImplicits
) {
var visibleArgs = (showImplicits ? args : args.filter(BinOpParser.Elem::explicit)).toImmutableSeq();
var visibleArgs = (showImplicits ? args : args.filter(BinOpElem::explicit)).toImmutableSeq();
if (visibleArgs.isEmpty()) return assoc != null ? Doc.parened(fn) : fn;
if (assoc != null) {
var firstArg = visibleArgs.getFirst();
Expand All @@ -137,14 +137,14 @@ protected BasePrettier(@NotNull PrettierOptions options) {
* @see #visitCalls(Assoc, Doc, Fmt, Outer, SeqView, boolean)
*/
private <T extends AyaDocile> @NotNull Doc
prefix(@NotNull Doc fn, @NotNull Fmt<T> fmt, Outer outer, SeqView<? extends BinOpParser.@NotNull Elem<T>> args) {
prefix(@NotNull Doc fn, @NotNull Fmt<T> fmt, Outer outer, SeqView<? extends @NotNull BinOpElem<T>> args) {
var call = Doc.sep(fn, Doc.sep(args.map(arg ->
arg(fmt, arg, Outer.AppSpine))));
// If we're in a spine, add parentheses
return checkParen(outer, call, Outer.AppSpine);
}

public static <T extends AyaDocile> Doc arg(@NotNull Fmt<T> fmt, @NotNull BinOpParser.Elem<T> arg, @NotNull Outer outer) {
public static <T extends AyaDocile> Doc arg(@NotNull Fmt<T> fmt, @NotNull BinOpElem<T> arg, @NotNull Outer outer) {
if (arg.explicit()) return fmt.apply(outer, arg.term());
return Doc.braced(fmt.apply(Outer.Free, arg.term()));
}
Expand Down
1 change: 1 addition & 0 deletions tools-kala/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
requires static org.jetbrains.annotations;
requires transitive kala.collection.primitive;

exports org.aya.util.binop;
exports org.aya.util.more;
exports org.aya.util.terck;
exports org.aya.util.tyck.pat;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2022 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2023 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.util.binop;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import kala.collection.mutable.*;
import kala.tuple.Tuple;
import kala.tuple.Tuple2;
import org.aya.util.BinOpElem;
import org.aya.util.error.SourceNode;
import org.aya.util.error.SourcePos;
import org.jetbrains.annotations.NotNull;
Expand All @@ -18,7 +19,7 @@
public abstract class BinOpParser<
OpSet extends BinOpSet,
Expr extends SourceNode,
Elm extends BinOpParser.Elem<Expr>> {
Elm extends BinOpElem<Expr>> {
protected final @NotNull OpSet opSet;
private final @NotNull SeqView<@NotNull Elm> seq;

Expand Down Expand Up @@ -214,8 +215,4 @@ enum AppliedSide {
return a.term().sourcePos();
}

public interface Elem<Expr> {
@NotNull Expr term();
boolean explicit();
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2022 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2023 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.util.binop;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2022 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2023 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.util.binop;

Expand Down
1 change: 0 additions & 1 deletion tools/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
requires static org.jetbrains.annotations;
requires transitive kala.collection.primitive;

exports org.aya.util.binop;
exports org.aya.util.error;
exports org.aya.util.prettier;
exports org.aya.util.reporter;
Expand Down
3 changes: 1 addition & 2 deletions tools/src/main/java/org/aya/util/Arg.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

import kala.collection.SeqView;
import kala.collection.immutable.ImmutableSeq;
import org.aya.util.binop.BinOpParser;
import org.jetbrains.annotations.NotNull;

import java.util.function.Consumer;
Expand All @@ -16,7 +15,7 @@
* In Aya, it is either core term, core pattern, concrete term, or concrete pattern.
* @author ice1000
*/
public record Arg<T>(@Override @NotNull T term, @Override boolean explicit) implements BinOpParser.Elem<T> {
public record Arg<T>(@Override @NotNull T term, @Override boolean explicit) implements BinOpElem<T> {
public static <T> @NotNull Arg<T> ofExplicitly(@NotNull T term) {
return new Arg<>(term, true);
}
Expand Down
10 changes: 10 additions & 0 deletions tools/src/main/java/org/aya/util/BinOpElem.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2020-2023 Tesla (Yinsen) Zhang.
// Use of this source code is governed by the MIT license that can be found in the LICENSE.md file.
package org.aya.util;

import org.jetbrains.annotations.NotNull;

public interface BinOpElem<Expr> {
@NotNull Expr term();
boolean explicit();
}

0 comments on commit eaaf182

Please sign in to comment.