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

Support local variable remapping #114

Merged
merged 2 commits into from
Jan 20, 2025
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
5 changes: 3 additions & 2 deletions src/main/java/net/fabricmc/tinyremapper/AsmRemapper.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (c) 2016, 2018, Player, asie
* Copyright (c) 2018, 2021, FabricMC
* Copyright (c) 2018, 2023, FabricMC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
Expand Down Expand Up @@ -135,7 +135,8 @@ public String mapMethodArg(String methodOwner, String methodName, String methodD
}

public String mapMethodVar(String methodOwner, String methodName, String methodDesc, int lvIndex, int startOpIdx, int asmIndex, String name) {
return name; // TODO: implement
String newName = tr.methodVarMap.get(methodOwner+"/"+MemberInstance.getMethodId(methodName, methodDesc)+lvIndex);
return newName != null ? newName : name;
}

@Override
Expand Down
3 changes: 2 additions & 1 deletion src/main/java/net/fabricmc/tinyremapper/TinyRemapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -663,7 +663,7 @@ public void acceptMethodVar(Member method, int lvIndex, int startOpIdx, int asmI
if (method.desc == null) throw new NullPointerException("null src method desc");
if (dstName == null) throw new NullPointerException("null dst name");

// TODO Auto-generated method stub
methodVarMap.put(method.owner+"/"+MemberInstance.getMethodId(method.name, method.desc)+lvIndex, dstName);
}

@Override
Expand Down Expand Up @@ -1356,6 +1356,7 @@ public void propagate(TrMember m, String newName) {
final Map<String, String> classMap = new HashMap<>();
final Map<String, String> methodMap = new HashMap<>();
final Map<String, String> methodArgMap = new HashMap<>();
final Map<String, String> methodVarMap = new HashMap<>();
final Map<String, String> fieldMap = new HashMap<>();
final Map<MemberInstance, Set<String>> conflicts = new ConcurrentHashMap<>();
final Set<ClassInstance> classesToMakePublic = Collections.newSetFromMap(new ConcurrentHashMap<>());
Expand Down