summaryrefslogtreecommitdiffstats
path: root/org.eclipse.cdt.codan.extension/src/org/eclipse/cdt/codan/extension/ExecutionState.java
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.cdt.codan.extension/src/org/eclipse/cdt/codan/extension/ExecutionState.java')
-rw-r--r--org.eclipse.cdt.codan.extension/src/org/eclipse/cdt/codan/extension/ExecutionState.java46
1 files changed, 35 insertions, 11 deletions
diff --git a/org.eclipse.cdt.codan.extension/src/org/eclipse/cdt/codan/extension/ExecutionState.java b/org.eclipse.cdt.codan.extension/src/org/eclipse/cdt/codan/extension/ExecutionState.java
index ffefec7..6f4f496 100644
--- a/org.eclipse.cdt.codan.extension/src/org/eclipse/cdt/codan/extension/ExecutionState.java
+++ b/org.eclipse.cdt.codan.extension/src/org/eclipse/cdt/codan/extension/ExecutionState.java
@@ -13,33 +13,31 @@ package org.eclipse.cdt.codan.extension;
import java.util.ArrayList;
import java.util.List;
-import org.eclipse.cdt.core.dom.ast.IASTNode;
-
public class ExecutionState {
- private List<IASTNode> nodes;
+ private List<ExecutionStateClause> clauses;
private boolean top;
private boolean bottom;
public ExecutionState() {
- nodes = new ArrayList<IASTNode>();
+ clauses = new ArrayList<ExecutionStateClause>();
}
- public void addClause(IASTNode node) {
+ public void addClause(ExecutionStateClause node) {
setTop(false);
setBottom(false);
- nodes.add(node);
+ clauses.add(node);
}
- public void removeClause(IASTNode node) {
- nodes.remove(node);
- if (nodes.size() == 0) {
+ public void removeClause(ExecutionStateClause node) {
+ clauses.remove(node);
+ if (clauses.size() == 0) {
setTop(true);
setBottom(false);
}
}
- public IASTNode[] getClauses() {
- return nodes.toArray(new IASTNode[nodes.size()]);
+ public ExecutionStateClause[] getClauses() {
+ return clauses.toArray(new ExecutionStateClause[clauses.size()]);
}
public boolean isTop() {
@@ -57,5 +55,31 @@ public class ExecutionState {
public void setBottom(boolean bottom) {
this.bottom = bottom;
}
+
+ @Override
+ public String toString() {
+ String ret;
+ if (top) {
+ ret = "[TOP]";
+ }
+ else if (bottom) {
+ ret = "[BOTTOM]";
+ }
+ else {
+ StringBuffer buf = new StringBuffer();
+ if (clauses.size() > 0) {
+ for (ExecutionStateClause c : clauses) {
+ if (!c.isTrue()) {
+ buf.append("NOT ");
+ }
+ buf.append(c.getNode().getRawSignature());
+ buf.append(" AND ");
+ }
+ buf.delete(buf.length() - 5 /* " AND ".length() */, buf.length());
+ }
+ ret = buf.toString();
+ }
+ return ret;
+ }
}