-
Notifications
You must be signed in to change notification settings - Fork 20
/
Transition.java
73 lines (61 loc) · 1.82 KB
/
Transition.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
package eu.stamp_project.mutationtest.descartes.bodyanalysis;
import org.pitest.reloc.asm.Opcodes;
import org.pitest.functional.predicate.Predicate;
public abstract class Transition {
private State state;
public State getState() {
return state;
}
public void to(State state) {
this.state = state;
}
public abstract boolean accepts(int opcode);
public static Transition withAnyOpcode() {
return new Transition() {
@Override
public boolean accepts(int opcode) {
return true;
}
};
}
public static Transition withOpcode(final int requiredOpcode) {
return new Transition() {
@Override
public boolean accepts(int opcode) {
return requiredOpcode == opcode;
}
};
}
public static Transition withConstantOnStack() {
return new Transition() {
@Override
public boolean accepts(int opcode) {
return opcode > 0 && opcode <= 20;
}
};
}
public static Transition withXLOAD() {
return new Transition() {
@Override
public boolean accepts(int opcode) {
return opcode >= Opcodes.ILOAD && opcode <= Opcodes.ALOAD;
}
};
}
public static Transition withXReturn() {
return new Transition() {
@Override
public boolean accepts(int opcode) {
return opcode >= Opcodes.IRETURN && opcode <= Opcodes.RETURN;
}
};
}
public static Transition with(final Predicate<Integer> pred){
return new Transition() {
@Override
public boolean accepts(int opcode) {
return pred.apply(opcode);
}
};
}
}