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

WIP handle distance-related names #4

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
13 changes: 13 additions & 0 deletions src/main/java/io/papermc/codebook/lvt/LvtAssignmentSuggester.java
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,11 @@ private LvtAssignmentSuggester() {}
return suggested;
}

suggested = suggestNameFromDistanceToSqr(methodName, insn);
if (suggested != null) {
return suggested;
}

suggested = suggestNameFromStrings(methodName, insn);
return suggested;
}
Expand Down Expand Up @@ -171,6 +176,14 @@ public static String suggestNameFromRecord(final String methodName) {
return null;
}

private static @Nullable String suggestNameFromDistanceToSqr(final String methodName, final MethodInsnNode insn) {
if (!"distanceToSqr".equals(methodName) || insn.desc == null || !(insn.desc.endsWith("D") || insn.desc.endsWith("I") || insn.desc.endsWith("F"))) {
return null;
}

return "distanceSqr";
}

private static final Type stringType = Type.getType("Ljava/lang/String;");

private static @Nullable String suggestNameFromStrings(final String methodName, final MethodInsnNode insn) {
Expand Down
Loading