Skip to content

Commit

Permalink
free: fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
ice1000 committed Jan 4, 2025
1 parent 30bc0f7 commit 8a1bba2
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 58 deletions.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Copyright (c) 2020-2024 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2025 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.compiler.free.morphism.free;

import kala.collection.immutable.ImmutableSeq;
import kala.collection.mutable.FreezableMutableList;
import org.aya.compiler.free.*;
import org.aya.compiler.free.data.MethodRef;
import org.aya.compiler.free.data.FieldRef;
import org.aya.compiler.free.data.MethodRef;
import org.aya.syntax.compile.CompiledAya;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -31,8 +31,7 @@ public record FreeClassBuilderImpl(
return nested == null ? parentOrThis : parentOrThis.nested(nested);
}

@Override
public void buildNestedClass(
@Override public void buildNestedClass(
@NotNull CompiledAya compiledAya,
@NotNull String name,
@NotNull Class<?> superclass,
Expand All @@ -52,8 +51,7 @@ private void buildMethod(
members.append(new FreeDecl.Method(ref, codeBuilder.build()));
}

@Override
public @NotNull MethodRef buildMethod(
@Override public @NotNull MethodRef buildMethod(
@NotNull ClassDesc returnType,
@NotNull String name,
@NotNull ImmutableSeq<ClassDesc> paramTypes,
Expand All @@ -64,8 +62,7 @@ private void buildMethod(
return ref;
}

@Override
public @NotNull MethodRef buildConstructor(
@Override public @NotNull MethodRef buildConstructor(
@NotNull ImmutableSeq<ClassDesc> paramTypes,
@NotNull BiConsumer<ArgumentProvider, FreeCodeBuilder> builder
) {
Expand All @@ -74,8 +71,7 @@ private void buildMethod(
return ref;
}

@Override
public @NotNull FieldRef buildConstantField(
@Override public @NotNull FieldRef buildConstantField(
@NotNull ClassDesc returnType,
@NotNull String name,
@NotNull Function<FreeExprBuilder, FreeJavaExpr> initializer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright (c) 2020-2024 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2025 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.compiler.free.morphism.free;

Expand Down Expand Up @@ -174,8 +174,7 @@ public void returnWith(@NotNull FreeJavaExpr expr) {
return FreeExprBuilderImpl.INSTANCE.invoke(method, args);
}

@Override
public @NotNull FreeJavaExpr refField(@NotNull FieldRef field) {
@Override public @NotNull FreeJavaExpr refField(@NotNull FieldRef field) {
return FreeExprBuilderImpl.INSTANCE.refField(field);
}

Expand Down Expand Up @@ -204,18 +203,15 @@ public void returnWith(@NotNull FreeJavaExpr expr) {
return FreeExprBuilderImpl.INSTANCE.iconst(b);
}

@Override
public @NotNull FreeJavaExpr aconst(@NotNull String value) {
@Override public @NotNull FreeJavaExpr aconst(@NotNull String value) {
return FreeExprBuilderImpl.INSTANCE.aconst(value);
}

@Override
public @NotNull FreeJavaExpr aconstNull(@NotNull ClassDesc type) {
@Override public @NotNull FreeJavaExpr aconstNull(@NotNull ClassDesc type) {
return FreeExprBuilderImpl.INSTANCE.aconstNull(type);
}

@Override
public @NotNull FreeJavaExpr thisRef() {
@Override public @NotNull FreeJavaExpr thisRef() {
return FreeExprBuilderImpl.INSTANCE.thisRef();
}

Expand All @@ -224,13 +220,11 @@ public void returnWith(@NotNull FreeJavaExpr expr) {
return FreeExprBuilderImpl.INSTANCE.mkArray(type, length, initializer);
}

@Override
public @NotNull FreeJavaExpr getArray(@NotNull FreeJavaExpr array, int index) {
@Override public @NotNull FreeJavaExpr getArray(@NotNull FreeJavaExpr array, int index) {
return FreeExprBuilderImpl.INSTANCE.getArray(array, index);
}

@Override
public @NotNull FreeJavaExpr checkcast(@NotNull FreeJavaExpr obj, @NotNull ClassDesc as) {
@Override public @NotNull FreeJavaExpr checkcast(@NotNull FreeJavaExpr obj, @NotNull ClassDesc as) {
return FreeExprBuilderImpl.INSTANCE.checkcast(obj, as);
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
// Copyright (c) 2020-2024 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2025 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.compiler.free.morphism.free;

import kala.collection.immutable.ImmutableSeq;
import kala.collection.mutable.FreezableMutableList;
import org.aya.compiler.free.*;
import org.aya.compiler.free.ArgumentProvider;
import org.aya.compiler.free.FreeCodeBuilder;
import org.aya.compiler.free.FreeExprBuilder;
import org.aya.compiler.free.FreeJavaExpr;
import org.aya.compiler.free.data.FieldRef;
import org.aya.compiler.free.data.MethodRef;
import org.jetbrains.annotations.NotNull;
Expand All @@ -13,7 +16,7 @@
import java.lang.constant.ClassDesc;
import java.util.function.BiConsumer;

import static org.aya.compiler.free.morphism.free.FreeCodeBuilderImpl.*;
import static org.aya.compiler.free.morphism.free.FreeCodeBuilderImpl.assertFreeExpr;

public final class FreeExprBuilderImpl implements FreeExprBuilder {
public static final @NotNull FreeExprBuilderImpl INSTANCE = new FreeExprBuilderImpl();
Expand Down Expand Up @@ -66,44 +69,24 @@ private FreeExprBuilderImpl() { }

return new FreeExpr.Lambda(assertFreeExpr(captures), method, lambdaBody);

Check warning on line 70 in jit-compiler/src/main/java/org/aya/compiler/free/morphism/free/FreeExprBuilderImpl.java

View check run for this annotation

Codecov / codecov/patch

jit-compiler/src/main/java/org/aya/compiler/free/morphism/free/FreeExprBuilderImpl.java#L70

Added line #L70 was not covered by tests
}

@Override
public @NotNull FreeJavaExpr iconst(int i) {
return new FreeExpr.Iconst(i);
}

@Override
public @NotNull FreeJavaExpr iconst(boolean b) {
return new FreeExpr.Bconst(b);
}

@Override
public @NotNull FreeJavaExpr aconst(@NotNull String value) {
return new FreeExpr.Sconst(value);
}

@Override
public @NotNull FreeJavaExpr aconstNull(@NotNull ClassDesc type) {
return new FreeExpr.Null(type);
}

@Override
public @NotNull FreeJavaExpr thisRef() {
@Override public @NotNull FreeJavaExpr iconst(int i) { return new FreeExpr.Iconst(i); }
@Override public @NotNull FreeJavaExpr iconst(boolean b) { return new FreeExpr.Bconst(b); }
@Override public @NotNull FreeJavaExpr aconst(@NotNull String value) { return new FreeExpr.Sconst(value); }
@Override public @NotNull FreeJavaExpr aconstNull(@NotNull ClassDesc type) { return new FreeExpr.Null(type); }
@Override public @NotNull FreeJavaExpr thisRef() {
return FreeExpr.This.INSTANCE;
}

@Override
public @NotNull FreeJavaExpr mkArray(@NotNull ClassDesc type, int length, @Nullable ImmutableSeq<FreeJavaExpr> initializer) {
return new FreeExpr.Array(type, length, assertFreeExpr(initializer));
return new FreeExpr.Array(type, length, initializer == null ? null : assertFreeExpr(initializer));
}

@Override
public @NotNull FreeJavaExpr getArray(@NotNull FreeJavaExpr array, int index) {
@Override public @NotNull FreeJavaExpr getArray(@NotNull FreeJavaExpr array, int index) {
return new FreeExpr.GetArray(assertFreeExpr(array), index);
}

@Override
public @NotNull FreeJavaExpr checkcast(@NotNull FreeJavaExpr obj, @NotNull ClassDesc as) {
@Override public @NotNull FreeJavaExpr checkcast(@NotNull FreeJavaExpr obj, @NotNull ClassDesc as) {
return new FreeExpr.CheckCast(assertFreeExpr(obj), as);
}
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
// Copyright (c) 2020-2024 Tesla (Yinsen) Zhang.
// Copyright (c) 2020-2025 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.compiler.free.morphism.free;

import kala.collection.mutable.FreezableMutableList;
import org.aya.compiler.free.*;
import org.aya.compiler.free.FreeClassBuilder;
import org.aya.compiler.free.FreeJavaBuilder;
import org.aya.syntax.compile.CompiledAya;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
Expand All @@ -14,8 +15,7 @@
public enum FreeJavaBuilderImpl implements FreeJavaBuilder<FreeDecl.Clazz> {
INSTANCE;

@Override
public @NotNull FreeDecl.Clazz buildClass(
@Override public @NotNull FreeDecl.Clazz buildClass(
@Nullable CompiledAya compiledAya,
@NotNull ClassDesc className,
@NotNull Class<?> superclass,
Expand Down

0 comments on commit 8a1bba2

Please sign in to comment.