diff options
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/entry')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/entry/MethodDefEntry.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/entry/MethodDefEntry.java b/src/main/java/cuchaz/enigma/mapping/entry/MethodDefEntry.java index 960b08d..fa9e668 100644 --- a/src/main/java/cuchaz/enigma/mapping/entry/MethodDefEntry.java +++ b/src/main/java/cuchaz/enigma/mapping/entry/MethodDefEntry.java | |||
| @@ -42,4 +42,20 @@ public class MethodDefEntry extends MethodEntry implements DefEntry { | |||
| 42 | public MethodDefEntry updateOwnership(ClassEntry classEntry) { | 42 | public MethodDefEntry updateOwnership(ClassEntry classEntry) { |
| 43 | return new MethodDefEntry(new ClassEntry(classEntry.getName()), name, descriptor, signature, access); | 43 | return new MethodDefEntry(new ClassEntry(classEntry.getName()), name, descriptor, signature, access); |
| 44 | } | 44 | } |
| 45 | |||
| 46 | public int getArgumentIndex(ClassDefEntry ownerEntry, int localVariableIndex) { | ||
| 47 | int argumentIndex = localVariableIndex; | ||
| 48 | |||
| 49 | // Enum constructors have an implicit "name" and "ordinal" parameter as well as "this" | ||
| 50 | if (ownerEntry.getAccess().isEnum() && getName().startsWith("<")) { | ||
| 51 | argumentIndex -= 2; | ||
| 52 | } | ||
| 53 | |||
| 54 | // If we're not static, "this" is bound to index 0 | ||
| 55 | if (!getAccess().isStatic()) { | ||
| 56 | argumentIndex -= 1; | ||
| 57 | } | ||
| 58 | |||
| 59 | return argumentIndex; | ||
| 60 | } | ||
| 45 | } | 61 | } |