|
@@ -4,21 +4,29 @@ import info.hkzlab.dupal.analyzer.exceptions.DuPALAnalyzerException;
|
|
|
|
|
|
public class OutState implements GraphState {
|
|
|
public final OutStatePins pins;
|
|
|
- private final OutLink[] links;
|
|
|
+ private final OutLink[] outLinks;
|
|
|
+ private final RegLink[] regLinks;
|
|
|
|
|
|
private int lastOutLinkIdx;
|
|
|
+ private int lastRegLinkIdx;
|
|
|
|
|
|
public OutState(OutStatePins pins, int maxLinks) {
|
|
|
+ this(pins, maxLinks, 0);
|
|
|
+ }
|
|
|
+
|
|
|
+ public OutState(OutStatePins pins, int maxLinks, int maxRegLinks) {
|
|
|
this.pins = pins;
|
|
|
- links = new OutLink[maxLinks];
|
|
|
+ outLinks = new OutLink[maxLinks];
|
|
|
+ regLinks = new RegLink[maxRegLinks];
|
|
|
|
|
|
lastOutLinkIdx = 0;
|
|
|
+ lastRegLinkIdx = 0;
|
|
|
}
|
|
|
|
|
|
public int addOutLink(OutLink link) throws DuPALAnalyzerException {
|
|
|
int idx = lastOutLinkIdx;
|
|
|
|
|
|
- if(idx >= links.length) throw new DuPALAnalyzerException("Tried to insert a link above maximum possible for this State " + this.toString());
|
|
|
+ if(idx >= outLinks.length) throw new DuPALAnalyzerException("Tried to insert a link above maximum possible for this State " + this.toString());
|
|
|
|
|
|
lastOutLinkIdx++;
|
|
|
|
|
@@ -27,17 +35,37 @@ public class OutState implements GraphState {
|
|
|
return idx;
|
|
|
}
|
|
|
|
|
|
- public int getMaxLinks() {
|
|
|
- return links.length;
|
|
|
+
|
|
|
+ public int addRegLink(RegLink link) throws DuPALAnalyzerException {
|
|
|
+ int idx = lastRegLinkIdx;
|
|
|
+
|
|
|
+ if(idx >= regLinks.length) throw new DuPALAnalyzerException("Tried to insert a registered link above maximum possible for this State " + this.toString());
|
|
|
+
|
|
|
+ lastRegLinkIdx++;
|
|
|
+
|
|
|
+ setRegLinkAtIdx(link, idx);
|
|
|
+
|
|
|
+ return idx;
|
|
|
}
|
|
|
|
|
|
public int getNextLinkIdx() {
|
|
|
return lastOutLinkIdx;
|
|
|
}
|
|
|
|
|
|
+ public int getNextRegLinkIdx() {
|
|
|
+ return lastRegLinkIdx;
|
|
|
+ }
|
|
|
+
|
|
|
private boolean setOutLinkAtIdx(OutLink link, int idx) {
|
|
|
- if(links[idx] != null) return false;
|
|
|
- links[idx] = link;
|
|
|
+ if(outLinks[idx] != null) return false;
|
|
|
+ outLinks[idx] = link;
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
+ private boolean setRegLinkAtIdx(RegLink link, int idx) {
|
|
|
+ if(regLinks[idx] != null) return false;
|
|
|
+ regLinks[idx] = link;
|
|
|
|
|
|
return true;
|
|
|
}
|
|
@@ -47,7 +75,8 @@ public class OutState implements GraphState {
|
|
|
int hash = 7;
|
|
|
|
|
|
hash = hash*31 + pins.hashCode();
|
|
|
- hash = hash*31 + links.length;
|
|
|
+ hash = hash*31 + outLinks.length;
|
|
|
+ hash = hash*31 + regLinks.length;
|
|
|
|
|
|
return hash;
|
|
|
}
|
|
@@ -76,11 +105,16 @@ public class OutState implements GraphState {
|
|
|
|
|
|
@Override
|
|
|
public boolean isStateFull() {
|
|
|
- return links.length == lastOutLinkIdx;
|
|
|
+ return (outLinks.length == lastOutLinkIdx) &&
|
|
|
+ (regLinks.length == lastRegLinkIdx);
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public GraphLink[] getLinks() {
|
|
|
- return links;
|
|
|
+ GraphLink[] linkArray = new GraphLink[outLinks.length + regLinks.length];
|
|
|
+ System.arraycopy(outLinks, 0, linkArray, 0, outLinks.length);
|
|
|
+ System.arraycopy(regLinks, 0, linkArray, outLinks.length, regLinks.length);
|
|
|
+
|
|
|
+ return linkArray;
|
|
|
}
|
|
|
}
|