Remove now-redundant overload for match

This commit is contained in:
Mumfrey committed 2021-03-17 21:21:09 +00:00
1 parent 29c6cc03f4
commit b1cd46c8c4
7 files changed
+24 -85

No files matched your search

@@ -38,6 +38,7 @@ import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.IInjectionPointContext;
import org.spongepowered.asm.mixin.injection.InjectionPoint;
import org.spongepowered.asm.mixin.injection.InjectionPoint.AtCode;
import org.spongepowered.asm.mixin.injection.selectors.ElementNode;
import org.spongepowered.asm.mixin.injection.selectors.ITargetSelector;
import org.spongepowered.asm.mixin.injection.selectors.ITargetSelectorByName;
import org.spongepowered.asm.mixin.injection.selectors.ITargetSelector.Configure;
@@ -196,7 +197,7 @@ public class BeforeInvoke extends InjectionPoint {
MemberInfo nodeInfo = new MemberInfo(insn);
this.log("{}->{} is considering {}", this.context, this.className, nodeInfo);
if (target.match(insn).isExactMatch()) {
if (target.match(ElementNode.<AbstractInsnNode>of(insn)).isExactMatch()) {
this.log("{}->{} > found a matching insn, checking preconditions...", this.context, this.className);
if (++matchCount > target.getMaxMatchCount()) {
break;
@@ -39,7 +39,6 @@ import org.objectweb.asm.tree.InsnList;
import org.objectweb.asm.tree.InvokeDynamicInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.objectweb.asm.tree.MethodNode;
import org.spongepowered.asm.util.Handles;
import com.google.common.base.Strings;
@@ -188,7 +187,7 @@ public abstract class ElementNode<TNode> {
}
@Override
public boolean isMethod() {
public boolean isInsn() {
return true;
}
@@ -263,8 +262,13 @@ public abstract class ElementNode<TNode> {
}
@Override
public boolean isMethod() {
return this.implMethod == null || !Handles.isField(this.implMethod);
public boolean isInvokeDynamic() {
return true;
}
@Override
public boolean isInsn() {
return true;
}
@Override
@@ -336,7 +340,7 @@ public abstract class ElementNode<TNode> {
}
@Override
public boolean isField() {
public boolean isInsn() {
return true;
}
@@ -431,26 +435,36 @@ public abstract class ElementNode<TNode> {
}
/**
* Get whether this element is a method
* Get whether this element is a method, implies getMethod() will return
* a value
*/
public boolean isMethod() {
return false;
}
/**
* get whether this element is a field
* get whether this element is a field, implies getField() will return
* a value
*/
public boolean isField() {
return false;
}
/**
* get whether this element is an instruction
* get whether this element is an instruction, implies getInsn() will return
* a value
*/
public boolean isInsn() {
return false;
}
/**
* get whether this element is an INVOKEDYNAMIC insn
*/
public boolean isInvokeDynamic() {
return false;
}
/**
* Get the {@link MethodNode} if this member is a method, otherwise returns
* <tt>null</tt>
@@ -24,7 +24,6 @@
*/
package org.spongepowered.asm.mixin.injection.selectors;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.spongepowered.asm.mixin.injection.Desc;
import org.spongepowered.asm.mixin.injection.selectors.dynamic.DynamicSelectorDesc;
import org.spongepowered.asm.mixin.injection.struct.MemberInfo;
@@ -235,13 +234,5 @@ public interface ITargetSelector {
* @return true if this selector can match the supplied field
*/
public abstract <TNode> MatchResult match(ElementNode<TNode> node);
/**
* Test whether this selector matches the supplied instruction node
*
* @param insn instruction node to test
* @return true if this selector can match the supplied instruction
*/
public abstract MatchResult match(AbstractInsnNode insn);
}
@@ -24,8 +24,6 @@
*/
package org.spongepowered.asm.mixin.injection.selectors;
import org.objectweb.asm.tree.AbstractInsnNode;
/**
* Since the contract of {@link TargetSelector#parse} prohibits returing <tt>
* null</tt>, instances of this selector are returned when supplied arguments
@@ -138,14 +136,4 @@ public class InvalidSelector implements ITargetSelector {
return MatchResult.NONE;
}
/* (non-Javadoc)
* @see org.spongepowered.asm.mixin.injection.selectors.ITargetSelector
* #match(org.objectweb.asm.tree.AbstractInsnNode)
*/
@Override
public MatchResult match(AbstractInsnNode insn) {
this.validate();
return MatchResult.NONE;
}
}
@@ -28,10 +28,6 @@ import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
/**
* A {@link ITargetSelector Target Selector} which matches an element of
* candidate members using a regular expression. This selector is not remappable
@@ -233,22 +229,6 @@ public final class MemberMatcher implements ITargetSelector {
return node == null ? MatchResult.NONE : this.matches(node.getOwner(), node.getName(), node.getDesc());
}
/* (non-Javadoc)
* @see org.spongepowered.asm.mixin.injection.selectors.ITargetSelector
* #matches(org.objectweb.asm.tree.AbstractInsnNode)
*/
@Override
public MatchResult match(AbstractInsnNode insn) {
if (insn instanceof MethodInsnNode) {
MethodInsnNode method = (MethodInsnNode)insn;
return this.matches(method.owner, method.name, method.desc);
} else if (insn instanceof FieldInsnNode) {
FieldInsnNode field = (FieldInsnNode)insn;
return this.matches(field.owner, field.name, field.desc);
}
return MatchResult.NONE;
}
private MatchResult matches(String... args) {
MatchResult result = MatchResult.NONE;
// boolean exactOnly = true;
@@ -27,9 +27,6 @@ package org.spongepowered.asm.mixin.injection.selectors.dynamic;
import java.util.List;
import org.objectweb.asm.Type;
import org.objectweb.asm.tree.AbstractInsnNode;
import org.objectweb.asm.tree.FieldInsnNode;
import org.objectweb.asm.tree.MethodInsnNode;
import org.spongepowered.asm.mixin.injection.At;
import org.spongepowered.asm.mixin.injection.Desc;
import org.spongepowered.asm.mixin.injection.Inject;
@@ -506,22 +503,6 @@ public class DynamicSelectorDesc implements ITargetSelectorDynamic, ITargetSelec
}
}
/* (non-Javadoc)
* @see org.spongepowered.asm.mixin.injection.selectors.ITargetSelector
* #matches(org.objectweb.asm.tree.AbstractInsnNode)
*/
@Override
public MatchResult match(AbstractInsnNode insn) {
if (insn instanceof MethodInsnNode) {
MethodInsnNode method = (MethodInsnNode)insn;
return this.matches(method.owner, method.name, method.desc, this.methodDesc);
} else if (insn instanceof FieldInsnNode) {
FieldInsnNode field = (FieldInsnNode)insn;
return this.matches(field.owner, field.name, field.desc, this.returnType.getInternalName());
}
return MatchResult.NONE;
}
private MatchResult matches(String owner, String name, String desc, String compareWithDesc) {
if (!compareWithDesc.equals(desc)) {
return MatchResult.NONE;
@@ -698,22 +698,6 @@ public final class MemberInfo implements ITargetSelectorRemappable, ITargetSelec
return node == null ? MatchResult.NONE : this.matches(node.getOwner(), node.getName(), node.getDesc());
}
/* (non-Javadoc)
* @see org.spongepowered.asm.mixin.injection.selectors.ITargetSelector
* #matches(org.objectweb.asm.tree.AbstractInsnNode)
*/
@Override
public MatchResult match(AbstractInsnNode insn) {
if (insn instanceof MethodInsnNode) {
MethodInsnNode method = (MethodInsnNode)insn;
return this.matches(method.owner, method.name, method.desc);
} else if (insn instanceof FieldInsnNode) {
FieldInsnNode field = (FieldInsnNode)insn;
return this.matches(field.owner, field.name, field.desc);
}
return MatchResult.NONE;
}
/* (non-Javadoc)
* @see org.spongepowered.asm.mixin.injection.selectors.ITargetSelector
* #matches(java.lang.String, java.lang.String, java.lang.String)