diff --git a/src/main/java/org/spongepowered/asm/mixin/transformer/ClassInfo.java b/src/main/java/org/spongepowered/asm/mixin/transformer/ClassInfo.java index ff0b28f4..5aefc08d 100644 --- a/src/main/java/org/spongepowered/asm/mixin/transformer/ClassInfo.java +++ b/src/main/java/org/spongepowered/asm/mixin/transformer/ClassInfo.java @@ -56,6 +56,9 @@ import com.google.common.collect.ImmutableSet; */ public class ClassInfo extends TreeInfo { + public static final int INCLUDE_PRIVATE = 0x0002; + public static final int INCLUDE_STATIC = 0x0008; + /** *
To all intents and purposes, the "real" class hierarchy and the mixin
* class hierarchy exist in parallel, this means that for some hierarchy
@@ -230,6 +233,15 @@ public class ClassInfo extends TreeInfo {
return (this.modifiers & Opcodes.ACC_PRIVATE) != 0;
}
+ public boolean isStatic() {
+ return (this.modifiers & Opcodes.ACC_STATIC) != 0;
+ }
+
+ public boolean matchesFlags(int flags) {
+ return (((~this.modifiers | (flags & ClassInfo.INCLUDE_PRIVATE)) & ClassInfo.INCLUDE_PRIVATE) != 0
+ && ((~this.modifiers | (flags & ClassInfo.INCLUDE_STATIC)) & ClassInfo.INCLUDE_STATIC) != 0);
+ }
+
// Abstract because this has to be static in order to contain the enum
public abstract ClassInfo getOwner();
@@ -553,7 +565,7 @@ public class ClassInfo extends TreeInfo {
}
private void addMethod(MethodNode method, boolean injected) {
- if (!method.name.startsWith("<") && (method.access & Opcodes.ACC_STATIC) == 0) {
+ if (!method.name.startsWith("<")) {
this.methods.add(new Method(method, injected));
}
}
@@ -963,11 +975,11 @@ public class ClassInfo extends TreeInfo {
* @param method Method to search for
* @param includeThisClass True to return this class if the method exists
* here, or false to search only superclasses
- * @param includePrivate Include private members in the search
+ * @param flags search flags
* @return the method object or null if the method could not be resolved
*/
- public Method findMethodInHierarchy(MethodNode method, boolean includeThisClass, boolean includePrivate) {
- return this.findMethodInHierarchy(method.name, method.desc, includeThisClass, Traversal.NONE, includePrivate);
+ public Method findMethodInHierarchy(MethodNode method, boolean includeThisClass, int flags) {
+ return this.findMethodInHierarchy(method.name, method.desc, includeThisClass, Traversal.NONE, flags);
}
/**
@@ -988,11 +1000,11 @@ public class ClassInfo extends TreeInfo {
* @param method Method to search for
* @param includeThisClass True to return this class if the method exists
* here, or false to search only superclasses
- * @param includePrivate Include private members in the search
+ * @param flags search flags
* @return the method object or null if the method could not be resolved
*/
- public Method findMethodInHierarchy(MethodInsnNode method, boolean includeThisClass, boolean includePrivate) {
- return this.findMethodInHierarchy(method.name, method.desc, includeThisClass, Traversal.NONE, includePrivate);
+ public Method findMethodInHierarchy(MethodInsnNode method, boolean includeThisClass, int flags) {
+ return this.findMethodInHierarchy(method.name, method.desc, includeThisClass, Traversal.NONE, flags);
}
/**
@@ -1019,7 +1031,7 @@ public class ClassInfo extends TreeInfo {
* @return the method object or null if the method could not be resolved
*/
public Method findMethodInHierarchy(String name, String desc, boolean includeThisClass, Traversal traversal) {
- return this.findMethodInHierarchy(name, desc, includeThisClass, traversal, false);
+ return this.findMethodInHierarchy(name, desc, includeThisClass, traversal, 0);
}
/**
@@ -1030,11 +1042,11 @@ public class ClassInfo extends TreeInfo {
* @param includeThisClass True to return this class if the method exists
* here, or false to search only superclasses
* @param traversal Traversal type to allow during this lookup
- * @param includePrivate Include private members in the search
+ * @param flags search flags
* @return the method object or null if the method could not be resolved
*/
- public Method findMethodInHierarchy(String name, String desc, boolean includeThisClass, Traversal traversal, boolean includePrivate) {
- return this.findInHierarchy(name, desc, includeThisClass, traversal, includePrivate, Type.METHOD);
+ public Method findMethodInHierarchy(String name, String desc, boolean includeThisClass, Traversal traversal, int flags) {
+ return this.findInHierarchy(name, desc, includeThisClass, traversal, flags, Type.METHOD);
}
/**
@@ -1055,11 +1067,11 @@ public class ClassInfo extends TreeInfo {
* @param field Field to search for
* @param includeThisClass True to return this class if the field exists
* here, or false to search only superclasses
- * @param includePrivate Include private members in the search
+ * @param flags search flags
* @return the field object or null if the field could not be resolved
*/
- public Field findFieldInHierarchy(FieldNode field, boolean includeThisClass, boolean includePrivate) {
- return this.findFieldInHierarchy(field.name, field.desc, includeThisClass, Traversal.NONE, includePrivate);
+ public Field findFieldInHierarchy(FieldNode field, boolean includeThisClass, int flags) {
+ return this.findFieldInHierarchy(field.name, field.desc, includeThisClass, Traversal.NONE, flags);
}
/**
@@ -1080,11 +1092,11 @@ public class ClassInfo extends TreeInfo {
* @param field Field to search for
* @param includeThisClass True to return this class if the field exists
* here, or false to search only superclasses
- * @param includePrivate Include private members in the search
+ * @param flags search flags
* @return the field object or null if the field could not be resolved
*/
- public Field findFieldInHierarchy(FieldInsnNode field, boolean includeThisClass, boolean includePrivate) {
- return this.findFieldInHierarchy(field.name, field.desc, includeThisClass, Traversal.NONE, includePrivate);
+ public Field findFieldInHierarchy(FieldInsnNode field, boolean includeThisClass, int flags) {
+ return this.findFieldInHierarchy(field.name, field.desc, includeThisClass, Traversal.NONE, flags);
}
/**
@@ -1111,7 +1123,7 @@ public class ClassInfo extends TreeInfo {
* @return the field object or null if the field could not be resolved
*/
public Field findFieldInHierarchy(String name, String desc, boolean includeThisClass, Traversal traversal) {
- return this.findFieldInHierarchy(name, desc, includeThisClass, traversal, false);
+ return this.findFieldInHierarchy(name, desc, includeThisClass, traversal, 0);
}
/**
@@ -1122,11 +1134,11 @@ public class ClassInfo extends TreeInfo {
* @param includeThisClass True to return this class if the field exists
* here, or false to search only superclasses
* @param traversal Traversal type to allow during this lookup
- * @param includePrivate Include private members in the search
+ * @param flags search flags
* @return the field object or null if the field could not be resolved
*/
- public Field findFieldInHierarchy(String name, String desc, boolean includeThisClass, Traversal traversal, boolean includePrivate) {
- return this.findInHierarchy(name, desc, includeThisClass, traversal, includePrivate, Type.FIELD);
+ public Field findFieldInHierarchy(String name, String desc, boolean includeThisClass, Traversal traversal, int flags) {
+ return this.findInHierarchy(name, desc, includeThisClass, traversal, flags, Type.FIELD);
}
/**
@@ -1138,20 +1150,20 @@ public class ClassInfo extends TreeInfo {
* @param includeThisClass True to return this class if the field exists
* here, or false to search only superclasses
* @param traversal Traversal type to allow during this lookup
- * @param priv Include private members in the search
+ * @param flags Inclusion flags
* @param type Type of member to search for (field or method)
* @return the discovered member or null if the member could not be resolved
*/
- private