summaryrefslogtreecommitdiff
path: root/src/main/java/cuchaz/enigma/bytecode/AccessFlags.java
diff options
context:
space:
mode:
authorGravatar gegy10002018-07-17 19:14:08 +0200
committerGravatar GitHub2018-07-17 19:14:08 +0200
commita88175ffc95792b88a8724f66db6dda2b8cc32ee (patch)
tree65895bbc6cf1766f4ca01e1257619ab1993e71dc /src/main/java/cuchaz/enigma/bytecode/AccessFlags.java
parentMerge pull request #3 from thiakil/src-jar (diff)
downloadenigma-fork-a88175ffc95792b88a8724f66db6dda2b8cc32ee.tar.gz
enigma-fork-a88175ffc95792b88a8724f66db6dda2b8cc32ee.tar.xz
enigma-fork-a88175ffc95792b88a8724f66db6dda2b8cc32ee.zip
ASM Based Class Translator (#1)
* Initial port to ASM * Package updates * Annotation + inner class translation * Fix inner class mapping * More bytecode translation * Signature refactoring * Fix highlighting of mapped names * Fix parameter name offset * Fix anonymous class generation * Fix issues with inner class signature transformation * Fix bridged method detection * Fix compile issues * Resolve all failed tests * Apply deobfuscated name to transformed classes * Fix class signatures not being translated * Fix frame array type translation * Fix frame array type translation * Fix array translation in method calls * Fix method reference and bridge detection * Fix handling of null deobf mappings * Parameter translation in interfaces * Fix enum parameter index offset * Fix parsed local variable indexing * Fix stackoverflow on rebuilding method names * Ignore invalid decompiled variable indices * basic source jar * Output directly to file on source export * Make decompile parallel * fix incorrect super calls * Use previous save state to delete old mapping files * Fix old mappings not properly being removed * Fix old mappings not properly being removed * make isMethodProvider public (cherry picked from commit ebad6a9) * speed up Deobfuscator's getSources by using a single TranslatingTypeloader and caching the ClassLoaderTypeloader * ignore .idea project folders * move SynchronizedTypeLoader to a non-inner * fix signature remap of inners for now * index & resolve method/field references for usages view * Allow reader/writer subclasses to provide the underlying file operations * fix giving obf classes a name not removing them from the panel * buffer the ParsedJar class entry inputstream, allow use with a jarinputstream * make CachingClasspathTypeLoader public * make CachingClasspathTypeLoader public * support enum switches with obfuscated SwitchMaps
Diffstat (limited to 'src/main/java/cuchaz/enigma/bytecode/AccessFlags.java')
-rw-r--r--src/main/java/cuchaz/enigma/bytecode/AccessFlags.java80
1 files changed, 80 insertions, 0 deletions
diff --git a/src/main/java/cuchaz/enigma/bytecode/AccessFlags.java b/src/main/java/cuchaz/enigma/bytecode/AccessFlags.java
new file mode 100644
index 0000000..21b2489
--- /dev/null
+++ b/src/main/java/cuchaz/enigma/bytecode/AccessFlags.java
@@ -0,0 +1,80 @@
1package cuchaz.enigma.bytecode;
2
3import org.objectweb.asm.Opcodes;
4
5import java.lang.reflect.Modifier;
6
7public class AccessFlags {
8 private int flags;
9
10 public AccessFlags(int flags) {
11 this.flags = flags;
12 }
13
14 public boolean isPrivate() {
15 return Modifier.isPrivate(this.flags);
16 }
17
18 public boolean isProtected() {
19 return Modifier.isProtected(this.flags);
20 }
21
22 public boolean isPublic() {
23 return Modifier.isPublic(this.flags);
24 }
25
26 public boolean isSynthetic() {
27 return (this.flags & Opcodes.ACC_SYNTHETIC) != 0;
28 }
29
30 public boolean isStatic() {
31 return Modifier.isStatic(this.flags);
32 }
33
34 public boolean isEnum() {
35 return (flags & Opcodes.ACC_ENUM) != 0;
36 }
37
38 public AccessFlags setPrivate() {
39 this.setVisibility(Opcodes.ACC_PRIVATE);
40 return this;
41 }
42
43 public AccessFlags setProtected() {
44 this.setVisibility(Opcodes.ACC_PROTECTED);
45 return this;
46 }
47
48 public AccessFlags setPublic() {
49 this.setVisibility(Opcodes.ACC_PUBLIC);
50 return this;
51 }
52
53 public AccessFlags setBridged() {
54 this.setVisibility(Opcodes.ACC_BRIDGE);
55 return this;
56 }
57
58 public void setVisibility(int visibility) {
59 this.resetVisibility();
60 this.flags |= visibility;
61 }
62
63 private void resetVisibility() {
64 this.flags &= ~(Opcodes.ACC_PRIVATE | Opcodes.ACC_PROTECTED | Opcodes.ACC_PUBLIC);
65 }
66
67 public int getFlags() {
68 return this.flags;
69 }
70
71 @Override
72 public boolean equals(Object obj) {
73 return obj instanceof AccessFlags && ((AccessFlags) obj).flags == flags;
74 }
75
76 @Override
77 public int hashCode() {
78 return flags;
79 }
80}