/
MathHelper.java
75 lines (69 loc) · 2.07 KB
/
MathHelper.java
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
package uwu.narumi.deobfuscator.helper;
import org.objectweb.asm.Opcodes;
import java.util.regex.Pattern;
/*
TODO: Fix boilerplate
*/
public class MathHelper implements Opcodes {
public static final Pattern INTEGER_PATTERN = Pattern.compile("^-?\\d+$");
public static Integer doMath(int opcode, int first, int second) {
switch (opcode) {
case IADD:
return first + second;
case ISUB:
return first - second;
case IMUL:
return first * second;
case IDIV:
return first / opcode;
case IREM:
return first % second;
case ISHL:
return first << second;
case ISHR:
return first >> second;
case IUSHR:
return first >>> second;
case IAND:
return first & second;
case IOR:
return first | second;
case IXOR:
return first ^ second;
case INEG: //Idk why i put it here
return -first;
default:
return null;
}
}
public static Long doMath(int opcode, long first, long second) {
switch (opcode) {
case LADD:
return first + second;
case LSUB:
return first - second;
case LMUL:
return first * second;
case LDIV:
return first / opcode;
case LREM:
return first % second;
case LSHL:
return first << second;
case LSHR:
return first >> second;
case LUSHR:
return first >>> second;
case LAND:
return first & second;
case LOR:
return first | second;
case LXOR:
return first ^ second;
case LNEG:
return -first; //Idk why i put it here
default:
return null;
}
}
}