From 1fc0b8ec7af1faa3cba5209fb72c3373b3ff29e4 Mon Sep 17 00:00:00 2001 From: Julian Burner <48808497+NebelNidas@users.noreply.github.com> Date: Mon, 20 Jan 2025 12:44:09 +0100 Subject: [PATCH] Support local variable remapping (#114) * Support local variables * Update copyright date --- src/main/java/net/fabricmc/tinyremapper/AsmRemapper.java | 5 +++-- src/main/java/net/fabricmc/tinyremapper/TinyRemapper.java | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main/java/net/fabricmc/tinyremapper/AsmRemapper.java b/src/main/java/net/fabricmc/tinyremapper/AsmRemapper.java index 35e8d6f6..eb9581a4 100644 --- a/src/main/java/net/fabricmc/tinyremapper/AsmRemapper.java +++ b/src/main/java/net/fabricmc/tinyremapper/AsmRemapper.java @@ -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 @@ -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 diff --git a/src/main/java/net/fabricmc/tinyremapper/TinyRemapper.java b/src/main/java/net/fabricmc/tinyremapper/TinyRemapper.java index 4b03624a..c9dedc84 100644 --- a/src/main/java/net/fabricmc/tinyremapper/TinyRemapper.java +++ b/src/main/java/net/fabricmc/tinyremapper/TinyRemapper.java @@ -705,7 +705,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 @@ -1411,6 +1411,7 @@ public void propagate(TrMember m, String newName) { final Map classMap = new HashMap<>(); final Map methodMap = new HashMap<>(); final Map methodArgMap = new HashMap<>(); + final Map methodVarMap = new HashMap<>(); final Map fieldMap = new HashMap<>(); final Map> conflicts = new ConcurrentHashMap<>(); final Set classesToMakePublic = Collections.newSetFromMap(new ConcurrentHashMap<>());