@@ -36,6 +36,20 @@ public final class EdgeGraph {
36
36
37
37
private boolean frozen = false ;
38
38
39
+ public EdgeGraph copy () {
40
+ EdgeGraph edgeGraph = new EdgeGraph ();
41
+ for ( State state : this .getStates () ) {
42
+ edgeGraph .addState ( state );
43
+ }
44
+ for ( State state : this .getStates () ) {
45
+ for ( EdgeGraph .Edge edge : this .getEdges ( state ) ) {
46
+ EdgeGraph .Edge edgeCpy = new EdgeGraph .Edge ( new HashSet <>( edge .memoryAction ), edge .destination );
47
+ edgeGraph .addEdge ( state , edgeCpy );
48
+ }
49
+ }
50
+ return edgeGraph ;
51
+ }
52
+
39
53
public void freeze () {
40
54
this .frozen = true ;
41
55
for ( Map .Entry <Integer , Set <Edge >> entry : this .edges .entrySet () ) {
@@ -48,6 +62,7 @@ public void freeze() {
48
62
this .boundEdges .put ( src , boundEdges );
49
63
entry .getValue ().forEach (
50
64
(edge ) -> {
65
+ edge .freeze ();
51
66
State state = this .states .get ( edge .destination );
52
67
if ( state .isStatic () ) {
53
68
//only called for terminals so null is fine
@@ -88,9 +103,13 @@ public Edge(Set<MemoryAction> memoryAction, Integer destination) {
88
103
this .destination = destination ;
89
104
}
90
105
91
- public final Set <MemoryAction > memoryAction ;
106
+ public Set <MemoryAction > memoryAction ;
92
107
public final Integer destination ;
93
108
109
+ public void freeze () {
110
+ this .memoryAction = Collections .unmodifiableSet ( this .memoryAction );
111
+ }
112
+
94
113
@ Override
95
114
public String toString () {
96
115
return "Edge{" +
0 commit comments