diff options
| author | 2018-05-19 17:02:46 +0200 | |
|---|---|---|
| committer | 2018-05-19 17:02:46 +0200 | |
| commit | 2b2249e873c4adfd2dd6e8f1f2489ccd9f6aa021 (patch) | |
| tree | 14c8b1e806449ace1641a1dbafae162855f79670 /src/main/java/cuchaz/enigma/mapping/ReferencedEntryPool.java | |
| parent | Fix build (diff) | |
| download | enigma-fork-2b2249e873c4adfd2dd6e8f1f2489ccd9f6aa021.tar.gz enigma-fork-2b2249e873c4adfd2dd6e8f1f2489ccd9f6aa021.tar.xz enigma-fork-2b2249e873c4adfd2dd6e8f1f2489ccd9f6aa021.zip | |
Initial port to ASM
Diffstat (limited to 'src/main/java/cuchaz/enigma/mapping/ReferencedEntryPool.java')
| -rw-r--r-- | src/main/java/cuchaz/enigma/mapping/ReferencedEntryPool.java | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/main/java/cuchaz/enigma/mapping/ReferencedEntryPool.java b/src/main/java/cuchaz/enigma/mapping/ReferencedEntryPool.java new file mode 100644 index 0000000..2abc76c --- /dev/null +++ b/src/main/java/cuchaz/enigma/mapping/ReferencedEntryPool.java | |||
| @@ -0,0 +1,50 @@ | |||
| 1 | /******************************************************************************* | ||
| 2 | * Copyright (c) 2015 Jeff Martin. | ||
| 3 | * All rights reserved. This program and the accompanying materials | ||
| 4 | * are made available under the terms of the GNU Lesser General Public | ||
| 5 | * License v3.0 which accompanies this distribution, and is available at | ||
| 6 | * http://www.gnu.org/licenses/lgpl.html | ||
| 7 | * <p> | ||
| 8 | * Contributors: | ||
| 9 | * Jeff Martin - initial API and implementation | ||
| 10 | ******************************************************************************/ | ||
| 11 | |||
| 12 | package cuchaz.enigma.mapping; | ||
| 13 | |||
| 14 | import java.util.HashMap; | ||
| 15 | import java.util.Map; | ||
| 16 | |||
| 17 | public class ReferencedEntryPool { | ||
| 18 | private final Map<String, ClassEntry> classEntries = new HashMap<>(); | ||
| 19 | private final Map<String, Map<String, MethodEntry>> methodEntries = new HashMap<>(); | ||
| 20 | private final Map<String, Map<String, FieldEntry>> fieldEntries = new HashMap<>(); | ||
| 21 | |||
| 22 | public ClassEntry getClass(String name) { | ||
| 23 | return this.classEntries.computeIfAbsent(name, s -> new ClassEntry(name)); | ||
| 24 | } | ||
| 25 | |||
| 26 | public MethodEntry getMethod(ClassEntry ownerEntry, String name, String desc) { | ||
| 27 | return getMethod(ownerEntry, name, new MethodDescriptor(desc)); | ||
| 28 | } | ||
| 29 | |||
| 30 | public MethodEntry getMethod(ClassEntry ownerEntry, String name, MethodDescriptor desc) { | ||
| 31 | String key = name + desc.toString(); | ||
| 32 | return getClassMethods(ownerEntry.getName()).computeIfAbsent(key, s -> new MethodEntry(ownerEntry, name, desc)); | ||
| 33 | } | ||
| 34 | |||
| 35 | public FieldEntry getField(ClassEntry ownerEntry, String name, String desc) { | ||
| 36 | return getField(ownerEntry, name, new TypeDescriptor(desc)); | ||
| 37 | } | ||
| 38 | |||
| 39 | public FieldEntry getField(ClassEntry ownerEntry, String name, TypeDescriptor desc) { | ||
| 40 | return getClassFields(ownerEntry.getName()).computeIfAbsent(name, s -> new FieldEntry(ownerEntry, name, desc)); | ||
| 41 | } | ||
| 42 | |||
| 43 | private Map<String, MethodEntry> getClassMethods(String name) { | ||
| 44 | return methodEntries.computeIfAbsent(name, s -> new HashMap<>()); | ||
| 45 | } | ||
| 46 | |||
| 47 | private Map<String, FieldEntry> getClassFields(String name) { | ||
| 48 | return fieldEntries.computeIfAbsent(name, s -> new HashMap<>()); | ||
| 49 | } | ||
| 50 | } | ||