Jump.java
2.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/*
* This file is part of LiteLoader.
* Copyright (C) 2012-16 Adam Mummery-Smith
* All Rights Reserved.
*/
//package com.mumfrey.liteloader.transformers.event;
//
//import org.spongepowered.asm.lib.Opcodes;
//import org.spongepowered.asm.lib.tree.AbstractInsnNode;
//import org.spongepowered.asm.lib.tree.InsnList;
//import org.spongepowered.asm.lib.tree.InsnNode;
//import org.spongepowered.asm.lib.tree.JumpInsnNode;
//import org.spongepowered.asm.lib.tree.MethodInsnNode;
//import org.spongepowered.asm.lib.tree.VarInsnNode;
//
//public class Jump extends Event
//{
// Jump(String name, boolean cancellable, int priority)
// {
// super(name, cancellable, priority);
// }
//
// @Override
// protected void validate(AbstractInsnNode injectionPoint, boolean cancellable, int globalEventID)
// {
// if (!(injectionPoint instanceof JumpInsnNode))
// {
// throw new IllegalArgumentException("Attempted to inject a JUMP event where no JUMP is present");
// }
//
// super.validate(injectionPoint, cancellable, globalEventID);
// }
//
// @Override
// protected void injectCancellationCode(InsnList insns, AbstractInsnNode injectionPoint, int eventInfoVar) throws IllegalArgumentException
// {
// int opcode = injectionPoint.getOpcode();
//
// if (opcode == Opcodes.JSR) throw new IllegalArgumentException("Can't jump on finally clause");
//
// if (opcode == Opcodes.IFEQ || opcode == Opcodes.IFNE || opcode == Opcodes.IFLT || opcode == Opcodes.IFGE
// || opcode == Opcodes.IFGT || opcode == Opcodes.IFLE || opcode == Opcodes.IFNULL || opcode == Opcodes.IFNONNULL)
// {
// insns.add(new InsnNode(Opcodes.POP));
// }
//
// if (opcode == Opcodes.IF_ICMPEQ || opcode == Opcodes.IF_ICMPNE || opcode == Opcodes.IF_ICMPLT || opcode == Opcodes.IF_ICMPGE
// || opcode == Opcodes.IF_ICMPGT || opcode == Opcodes.IF_ICMPLE || opcode == Opcodes.IF_ACMPEQ || opcode == Opcodes.IF_ACMPNE)
// {
// insns.add(new InsnNode(Opcodes.POP));
// insns.add(new InsnNode(Opcodes.POP));
// }
//
// insns.add(new VarInsnNode(Opcodes.ALOAD, eventInfoVar));
// insns.add(new MethodInsnNode(Opcodes.INVOKEVIRTUAL, this.eventInfoClass, "isCancelled", "()Z"));
//
// ((JumpInsnNode)injectionPoint).setOpcode(Opcodes.IFEQ);
// }
//}