 |
|
 |
|
| Files: |
1 |
|
Branches Taken: |
47.5% |
19 / 40 |
| Generated: |
2009-05-17 22:47 |
|
Branches Executed: |
70.0% |
28 / 40 |
| |
|
Line Coverage: |
45.5% |
25 / 55 |
| |
 |
|
 |
1 : #include "PTree.h"
2 :
3 : #include <klee/Expr.h>
4 : #include <klee/util/ExprPPrinter.h>
5 :
6 : #include <vector>
7 : #include <iostream>
8 :
9 : using namespace klee;
10 :
11 : /* *** */
12 :
13 103: PTree::PTree(const data_type &_root) : root(new Node(0,_root)) {
14 103: }
15 :
16 103: PTree::~PTree() {}
17 :
18 : std::pair<PTreeNode*, PTreeNode*>
19 : PTree::split(Node *n,
20 : const data_type &leftData,
21 687: const data_type &rightData) {
687: branch 0 taken
0: branch 1 not taken
687: branch 2 taken
0: branch 3 not taken
0: branch 4 not taken
687: branch 5 taken
22 687: assert(n && !n->left && !n->right);
23 687: n->left = new Node(n, leftData);
24 687: n->right = new Node(n, rightData);
25 687: return std::make_pair(n->left, n->right);
26 : }
27 :
28 790: void PTree::remove(Node *n) {
790: branch 0 taken
0: branch 1 not taken
0: branch 2 not taken
790: branch 3 taken
29 790: assert(!n->left && !n->right);
1374: branch 0 taken
103: branch 1 taken
1036: branch 2 taken
338: branch 3 taken
687: branch 4 taken
349: branch 5 taken
30 1477: do {
31 1477: Node *p = n->parent;
1477: branch 0 taken
0: branch 1 not taken
32 1477: delete n;
1374: branch 0 taken
103: branch 1 taken
33 1477: if (p) {
687: branch 0 taken
687: branch 1 taken
34 1374: if (n == p->left) {
35 687: p->left = 0;
36 : } else {
0: branch 0 not taken
687: branch 1 taken
37 687: assert(n == p->right);
38 687: p->right = 0;
39 : }
40 : }
41 1477: n = p;
42 : } while (n && !n->left && !n->right);
43 790: }
44 :
45 0: void PTree::dump(std::ostream &os) {
46 0: ExprPPrinter *pp = ExprPPrinter::create(os);
47 0: pp->setNewline("\\l");
48 0: os << "digraph G {\n";
49 0: os << "\tsize=\"10,7.5\";\n";
50 0: os << "\tratio=fill;\n";
51 0: os << "\trotate=90;\n";
52 0: os << "\tcenter = \"true\";\n";
53 0: os << "\tnode [style=\"filled\",width=.1,height=.1,fontname=\"Terminus\"]\n";
54 0: os << "\tedge [arrowsize=.3]\n";
55 : std::vector<PTree::Node*> stack;
56 0: stack.push_back(root);
0: branch 0 not taken
0: branch 1 not taken
57 0: while (!stack.empty()) {
58 0: PTree::Node *n = stack.back();
59 : stack.pop_back();
0: branch 0 not taken
0: branch 1 not taken
60 0: if (n->condition.isNull()) {
61 0: os << "\tn" << n << " [label=\"\"";
62 : } else {
63 0: os << "\tn" << n << " [label=\"";
64 0: pp->print(n->condition);
65 0: os << "\",shape=diamond";
66 : }
0: branch 0 not taken
0: branch 1 not taken
67 0: if (n->data)
68 0: os << ",fillcolor=green";
69 0: os << "];\n";
0: branch 0 not taken
0: branch 1 not taken
70 0: if (n->left) {
71 0: os << "\tn" << n << " -> n" << n->left << ";\n";
72 0: stack.push_back(n->left);
73 : }
0: branch 0 not taken
0: branch 1 not taken
74 0: if (n->right) {
75 0: os << "\tn" << n << " -> n" << n->right << ";\n";
76 0: stack.push_back(n->right);
77 : }
78 : }
79 0: os << "}\n";
0: branch 0 not taken
0: branch 1 not taken
80 0: delete pp;
81 0: }
82 :
83 : PTreeNode::PTreeNode(PTreeNode *_parent,
84 1477: ExecutionState *_data)
85 : : parent(_parent),
86 : left(0),
87 : right(0),
88 : data(_data),
89 1477: condition(0) {
90 1477: }
91 :
92 1477: PTreeNode::~PTreeNode() {
103: branch 0 taken
0: branch 1 not taken
103: branch 2 taken
0: branch 3 not taken
93 3160: }
94 :
Generated: 2009-05-17 22:47 by zcov