Minor refactor for slice host

This commit is contained in:
Mumfrey committed 2017-01-30 22:03:57 +00:00
1 parent d794ae7476
commit 9fd488cd62
3 files changed
+8 -6

No files matched your search

@@ -31,4 +31,6 @@ import org.spongepowered.asm.mixin.injection.IInjectionPointContext;
*/
public interface ISliceContext extends IInjectionPointContext {
public abstract MethodSlice getSlice(String id);
}
@@ -30,7 +30,6 @@ import java.util.Map;
import org.spongepowered.asm.lib.tree.InsnList;
import org.spongepowered.asm.lib.tree.MethodNode;
import org.spongepowered.asm.mixin.injection.InjectionPoint;
import org.spongepowered.asm.mixin.injection.struct.InjectionInfo;
import org.spongepowered.asm.mixin.injection.struct.Target;
/**
@@ -42,7 +41,7 @@ public class InjectorTarget {
/**
* Owner injector
*/
private final InjectionInfo info;
private final ISliceContext context;
/**
* Cache of slices
@@ -57,11 +56,11 @@ public class InjectorTarget {
/**
* ctor
*
* @param info owner
* @param context owner
* @param target target
*/
public InjectorTarget(InjectionInfo info, Target target) {
this.info = info;
public InjectorTarget(ISliceContext context, Target target) {
this.context = context;
this.target = target;
}
@@ -88,7 +87,7 @@ public class InjectorTarget {
public InsnList getSlice(String id) {
ReadOnlyInsnList slice = this.cache.get(id);
if (slice == null) {
MethodSlice sliceInfo = this.info.getSlice(id);
MethodSlice sliceInfo = this.context.getSlice(id);
if (sliceInfo != null) {
slice = sliceInfo.getSlice(this.target.method);
} else {
@@ -287,6 +287,7 @@ public abstract class InjectionInfo extends SpecialMethodInfo implements ISliceC
/**
* Get the slice descriptors
*/
@Override
public MethodSlice getSlice(String id) {
return this.slices.get(this.getSliceId(id));
}