本文整理汇总了Java中cuchaz.enigma.mapping.FieldEntry类的典型用法代码示例。如果您正苦于以下问题:Java FieldEntry类的具体用法?Java FieldEntry怎么用?Java FieldEntry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FieldEntry类属于cuchaz.enigma.mapping包,在下文中一共展示了FieldEntry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readEntry
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static <T extends Entry> T readEntry(String in) {
if (in.length() <= 0) {
return null;
}
String[] parts = in.split(" ");
if (parts.length == 3 && parts[2].indexOf('(') < 0) {
return (T)new FieldEntry(
new ClassEntry(parts[0]),
parts[1],
new Type(parts[2])
);
} else {
assert(parts.length == 2 || parts.length == 3);
if (parts.length == 2) {
return (T)EntryFactory.getBehaviorEntry(parts[0], parts[1]);
} else if (parts.length == 3) {
return (T)EntryFactory.getBehaviorEntry(parts[0], parts[1], parts[2]);
} else {
throw new Error("Malformed behavior entry: " + in);
}
}
}
示例2: translate
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static <T extends Entry> T translate(T in, BiMap<ClassEntry,ClassEntry> map) {
if (in instanceof FieldEntry) {
return (T)new FieldEntry(
map.get(in.getClassEntry()),
in.getName(),
translate(((FieldEntry)in).getType(), map)
);
} else if (in instanceof MethodEntry) {
return (T)new MethodEntry(
map.get(in.getClassEntry()),
in.getName(),
translate(((MethodEntry)in).getSignature(), map)
);
} else if (in instanceof ConstructorEntry) {
return (T)new ConstructorEntry(
map.get(in.getClassEntry()),
translate(((ConstructorEntry)in).getSignature(), map)
);
}
throw new Error("Unhandled entry type: " + in.getClass());
}
示例3: visitMemberReferenceExpression
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
@Override
public Void visitMemberReferenceExpression(MemberReferenceExpression node, SourceIndex index) {
MemberReference ref = node.getUserData(Keys.MEMBER_REFERENCE);
if (ref != null) {
// make sure this is actually a field
if (ref.getErasedSignature().indexOf('(') >= 0) {
throw new Error("Expected a field here! got " + ref);
}
ClassEntry classEntry = new ClassEntry(ref.getDeclaringType().getInternalName());
FieldEntry fieldEntry = new FieldEntry(classEntry, ref.getName(), new Type(ref.getErasedSignature()));
index.addReference(node.getMemberNameToken(), fieldEntry, m_behaviorEntry);
}
return recurse(node, index);
}
示例4: hasDeobfuscatedName
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
public boolean hasDeobfuscatedName(Entry obfEntry) {
Translator translator = getTranslator(TranslationDirection.Deobfuscating);
if (obfEntry instanceof ClassEntry) {
ClassEntry obfClass = (ClassEntry)obfEntry;
List<ClassMapping> mappingChain = m_mappings.getClassMappingChain(obfClass);
ClassMapping classMapping = mappingChain.get(mappingChain.size() - 1);
return classMapping != null && classMapping.getDeobfName() != null;
} else if (obfEntry instanceof FieldEntry) {
return translator.translate((FieldEntry)obfEntry) != null;
} else if (obfEntry instanceof MethodEntry) {
return translator.translate((MethodEntry)obfEntry) != null;
} else if (obfEntry instanceof ConstructorEntry) {
// constructors have no names
return false;
} else if (obfEntry instanceof ArgumentEntry) {
return translator.translate((ArgumentEntry)obfEntry) != null;
} else {
throw new Error("Unknown entry type: " + obfEntry.getClass().getName());
}
}
示例5: rename
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
public void rename(Entry obfEntry, String newName) {
if (obfEntry instanceof ClassEntry) {
m_renamer.setClassName((ClassEntry)obfEntry, Descriptor.toJvmName(newName));
} else if (obfEntry instanceof FieldEntry) {
m_renamer.setFieldName((FieldEntry)obfEntry, newName);
} else if (obfEntry instanceof MethodEntry) {
m_renamer.setMethodTreeName((MethodEntry)obfEntry, newName);
} else if (obfEntry instanceof ConstructorEntry) {
throw new IllegalArgumentException("Cannot rename constructors");
} else if (obfEntry instanceof ArgumentEntry) {
m_renamer.setArgumentName((ArgumentEntry)obfEntry, newName);
} else {
throw new Error("Unknown entry type: " + obfEntry.getClass().getName());
}
// clear caches
m_translatorCache.clear();
}
示例6: removeMapping
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
public void removeMapping(Entry obfEntry) {
if (obfEntry instanceof ClassEntry) {
m_renamer.removeClassMapping((ClassEntry)obfEntry);
} else if (obfEntry instanceof FieldEntry) {
m_renamer.removeFieldMapping((FieldEntry)obfEntry);
} else if (obfEntry instanceof MethodEntry) {
m_renamer.removeMethodTreeMapping((MethodEntry)obfEntry);
} else if (obfEntry instanceof ConstructorEntry) {
throw new IllegalArgumentException("Cannot rename constructors");
} else if (obfEntry instanceof ArgumentEntry) {
m_renamer.removeArgumentMapping((ArgumentEntry)obfEntry);
} else {
throw new Error("Unknown entry type: " + obfEntry);
}
// clear caches
m_translatorCache.clear();
}
示例7: markAsDeobfuscated
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
public void markAsDeobfuscated(Entry obfEntry) {
if (obfEntry instanceof ClassEntry) {
m_renamer.markClassAsDeobfuscated((ClassEntry)obfEntry);
} else if (obfEntry instanceof FieldEntry) {
m_renamer.markFieldAsDeobfuscated((FieldEntry)obfEntry);
} else if (obfEntry instanceof MethodEntry) {
m_renamer.markMethodTreeAsDeobfuscated((MethodEntry)obfEntry);
} else if (obfEntry instanceof ConstructorEntry) {
throw new IllegalArgumentException("Cannot rename constructors");
} else if (obfEntry instanceof ArgumentEntry) {
m_renamer.markArgumentAsDeobfuscated((ArgumentEntry)obfEntry);
} else {
throw new Error("Unknown entry type: " + obfEntry);
}
// clear caches
m_translatorCache.clear();
}
示例8: showReference
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
private void showReference(EntryReference<Entry,Entry> reference) {
if (reference == null) {
clearReference();
return;
}
m_reference = reference;
m_infoPanel.removeAll();
if (reference.entry instanceof ClassEntry) {
showClassEntry((ClassEntry)m_reference.entry);
} else if (m_reference.entry instanceof FieldEntry) {
showFieldEntry((FieldEntry)m_reference.entry);
} else if (m_reference.entry instanceof MethodEntry) {
showMethodEntry((MethodEntry)m_reference.entry);
} else if (m_reference.entry instanceof ConstructorEntry) {
showConstructorEntry((ConstructorEntry)m_reference.entry);
} else if (m_reference.entry instanceof ArgumentEntry) {
showArgumentEntry((ArgumentEntry)m_reference.entry);
} else {
throw new Error("Unknown entry type: " + m_reference.entry.getClass().getName());
}
redraw();
}
示例9: computeFieldMatches
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
private static void computeFieldMatches(File memberMatchesFile, JarFile destJar, File destMappingsFile, File classMatchesFile)
throws IOException, MappingParseException {
System.out.println("Reading class matches...");
ClassMatches classMatches = MatchesReader.readClasses(classMatchesFile);
System.out.println("Reading mappings...");
Mappings destMappings = new MappingsReader().read(new FileReader(destMappingsFile));
System.out.println("Indexing dest jar...");
Deobfuscator destDeobfuscator = new Deobfuscator(destJar);
System.out.println("Writing matches...");
// get the matched and unmatched mappings
MemberMatches<FieldEntry> fieldMatches = MappingsConverter.computeMemberMatches(
destDeobfuscator,
destMappings,
classMatches,
MappingsConverter.getFieldDoer()
);
MatchesWriter.writeMembers(fieldMatches, memberMatchesFile);
System.out.println("Wrote:\n\t" + memberMatchesFile.getAbsolutePath());
}
示例10: editFieldMatches
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
private static void editFieldMatches(JarFile sourceJar, JarFile destJar, File destMappingsFile, Mappings sourceMappings, File classMatchesFile, final File fieldMatchesFile)
throws IOException, MappingParseException {
System.out.println("Reading matches...");
ClassMatches classMatches = MatchesReader.readClasses(classMatchesFile);
MemberMatches<FieldEntry> fieldMatches = MatchesReader.readMembers(fieldMatchesFile);
// prep deobfuscators
Deobfuscators deobfuscators = new Deobfuscators(sourceJar, destJar);
deobfuscators.source.setMappings(sourceMappings);
Mappings destMappings = new MappingsReader().read(new FileReader(destMappingsFile));
MappingsChecker checker = new MappingsChecker(deobfuscators.dest.getJarIndex());
checker.dropBrokenMappings(destMappings);
deobfuscators.dest.setMappings(destMappings);
new MemberMatchingGui<FieldEntry>(classMatches, fieldMatches, deobfuscators.source, deobfuscators.dest).setSaveListener(new MemberMatchingGui.SaveListener<FieldEntry>() {
@Override
public void save(MemberMatches<FieldEntry> matches) {
try {
MatchesWriter.writeMembers(matches, fieldMatchesFile);
} catch (IOException ex) {
throw new Error(ex);
}
}
});
}
示例11: convertMappings
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
@SuppressWarnings("unused")
private static void convertMappings(File outMappingsFile, JarFile sourceJar, JarFile destJar, Mappings mappings, File classMatchesFile, File fieldMatchesFile)
throws IOException {
System.out.println("Reading matches...");
ClassMatches classMatches = MatchesReader.readClasses(classMatchesFile);
MemberMatches<FieldEntry> fieldMatches = MatchesReader.readMembers(fieldMatchesFile);
Deobfuscators deobfuscators = new Deobfuscators(sourceJar, destJar);
deobfuscators.source.setMappings(mappings);
// apply matches
Mappings newMappings = MappingsConverter.newMappings(classMatches, mappings, deobfuscators.source, deobfuscators.dest);
MappingsConverter.applyMemberMatches(newMappings, classMatches, fieldMatches, MappingsConverter.getFieldDoer());
// write out the converted mappings
try (FileWriter out = new FileWriter(outMappingsFile)) {
new MappingsWriter().write(out, newMappings);
}
System.out.println("Wrote converted mappings to:\n\t" + outMappingsFile.getAbsolutePath());
}
示例12: fieldReferences
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void fieldReferences() {
Collection<EntryReference<FieldEntry,BehaviorEntry>> references;
// name
references = m_index.getFieldReferences(m_nameField);
assertThat(references, containsInAnyOrder(
newFieldReferenceByConstructor(m_nameField, m_baseClass.getName(), "(Ljava/lang/String;)V"),
newFieldReferenceByMethod(m_nameField, m_baseClass.getName(), "a", "()Ljava/lang/String;")
));
// numThings
references = m_index.getFieldReferences(m_numThingsField);
assertThat(references, containsInAnyOrder(
newFieldReferenceByConstructor(m_numThingsField, m_subClassB.getName(), "()V"),
newFieldReferenceByMethod(m_numThingsField, m_subClassB.getName(), "b", "()V")
));
}
示例13: read
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
@SuppressWarnings("unchecked")
public void read(InputStream in) throws IOException
{
try
{
ObjectInputStream oin =
new ObjectInputStream(new GZIPInputStream(in));
m_superclasses = (HashMap<ClassEntry, ClassEntry>)oin.readObject();
m_fieldEntries =
(HashMultimap<ClassEntry, FieldEntry>)oin.readObject();
m_behaviorEntries =
(HashMultimap<ClassEntry, BehaviorEntry>)oin.readObject();
}catch(ClassNotFoundException ex)
{
throw new Error(ex);
}
}
示例14: fieldReferences
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
@Test
@SuppressWarnings("unchecked")
public void fieldReferences()
{
Collection<EntryReference<FieldEntry, BehaviorEntry>> references;
// name
references = m_index.getFieldReferences(m_nameField);
assertThat(
references,
containsInAnyOrder(
newFieldReferenceByConstructor(m_nameField,
m_baseClass.getName(), "(Ljava/lang/String;)V"),
newFieldReferenceByMethod(m_nameField, m_baseClass.getName(),
"a", "()Ljava/lang/String;")));
// numThings
references = m_index.getFieldReferences(m_numThingsField);
assertThat(
references,
containsInAnyOrder(
newFieldReferenceByConstructor(m_numThingsField,
m_subClassB.getName(), "()V"),
newFieldReferenceByMethod(m_numThingsField,
m_subClassB.getName(), "b", "()V")));
}
示例15: makeMatch
import cuchaz.enigma.mapping.FieldEntry; //导入依赖的package包/类
public void makeMatch(FieldEntry sourceField, FieldEntry destField) {
boolean wasRemoved = m_unmatchedSourceFields.remove(sourceField.getClassEntry(), sourceField);
assert (wasRemoved);
wasRemoved = m_unmatchedDestFields.remove(destField.getClassEntry(), destField);
assert (wasRemoved);
addMatch(sourceField, destField);
}