Skip to content

Commit

Permalink
refactor: rename method collectArgsWithoutLoading into `collectArgN…
Browse files Browse the repository at this point in the history
…odes` in MethodNode (#2142)
  • Loading branch information
skylot committed Apr 7, 2024
1 parent 0f52077 commit dbadbb0
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public boolean isVoidReturn() {
return mthInfo.getReturnType().equals(ArgType.VOID);
}

public List<VarNode> collectArgsWithoutLoading() {
public List<VarNode> collectArgNodes() {
ICodeInfo codeInfo = getTopParentClass().getCode();
int mthDefPos = getDefPosition();
int lineEndPos = CodeUtils.getLineEndForPos(codeInfo.getCodeStr(), mthDefPos);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private String generateMethodSnippet(JMethod jMth) {
} else {
overload = "";
}
List<String> argNames = mth.collectArgsWithoutLoading().stream()
List<String> argNames = mth.collectArgNodes().stream()
.map(VarNode::getName).collect(Collectors.toList());
String args = String.join(", ", argNames);
String logArgs;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void exportMappings(Path path, JadxCodeData codeData, MappingFormat mappi
}
// Method args
int lvtIndex = mth.getAccessFlags().isStatic() ? 0 : 1;
List<VarNode> args = mth.collectArgsWithoutLoading();
List<VarNode> args = mth.collectArgNodes();
for (VarNode arg : args) {
Integer lvIndex = DalvikToJavaBytecodeUtils.getMethodArgLvIndex(arg);
if (lvIndex == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public static Integer getMethodArgLvIndex(VarNode methodArg) {
if (lvIndex != null) {
return lvIndex;
}
List<VarNode> args = mth.collectArgsWithoutLoading();
List<VarNode> args = mth.collectArgNodes();
for (VarNode arg : args) {
lvIndex = arg.getReg() - args.get(0).getReg() + (mth.getAccessFlags().isStatic() ? 0 : 1);
if (arg.equals(methodArg)) {
Expand Down Expand Up @@ -53,7 +53,7 @@ public static Integer getMethodVarLvIndex(VarNode methodVar) {
return lvIndex;
}
Integer lastArgLvIndex = mth.getAccessFlags().isStatic() ? -1 : 0;
List<VarNode> args = mth.collectArgsWithoutLoading();
List<VarNode> args = mth.collectArgNodes();
if (!args.isEmpty()) {
lastArgLvIndex = getMethodArgLvIndex(args.get(args.size() - 1));
}
Expand Down Expand Up @@ -86,7 +86,7 @@ private static Integer getMethodVarLvIndexViaSsaVars(int regNum, MethodNode mth)
public static Integer getMethodArgLvtIndex(VarNode methodArg) {
MethodNode mth = methodArg.getMth();
int lvtIndex = mth.getAccessFlags().isStatic() ? 0 : 1;
List<VarNode> args = mth.collectArgsWithoutLoading();
List<VarNode> args = mth.collectArgNodes();
for (VarNode arg : args) {
if (arg.equals(methodArg)) {
return lvtIndex;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ fun generateMethodSnippet(mthNode: MethodNode): String {
""
}
val shortClassName = mthNode.parentClass.name
val argNames = mthNode.collectArgsWithoutLoading().map { a -> a.name }
val argNames = mthNode.collectArgNodes().map { a -> a.name }
val args = argNames.joinToString(separator = ", ")
val logArgs = if (argNames.isNotEmpty()) {
argNames.joinToString(separator = " + ', ' + ", prefix = " + ', ' + ") { p -> "'$p: ' + $p" }
Expand Down

0 comments on commit dbadbb0

Please sign in to comment.