-
Notifications
You must be signed in to change notification settings - Fork 20
/
State.java
46 lines (34 loc) · 978 Bytes
/
State.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
package eu.stamp_project.mutationtest.descartes.bodyanalysis;
import java.util.LinkedList;
public class State {
public static State SINK = new State();
LinkedList<Transition> transitions;
private boolean isFinal = false;
public State() {
transitions = new LinkedList<Transition>();
}
public State next(int opcode) {
for (Transition tr :
transitions) {
if (tr.accepts(opcode))
return tr.getState();
}
return SINK;
}
public Transition has(Transition tr) {
transitions.add(tr);
return tr;
}
public Transition movesWith(int opcode) {
return has(Transition.withOpcode(opcode));
}
public void alwaysMovesTo(State other) {
has(Transition.withAnyOpcode()).to(other);
}
public boolean isFinal() {
return isFinal;
}
public void setFinal(boolean isFinal) {
this.isFinal = isFinal;
}
}