forked from kripken/Relooper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.cpp
91 lines (62 loc) · 1.67 KB
/
test.cpp
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include "Relooper.h"
int main() {
Debugging::On = 0;
char buffer[10000];
if (1) {
Relooper::SetOutputBuffer(buffer);
printf("\n\n-- If pattern --\n\n");
Block *b_a = new Block("// block A\n");
Block *b_b = new Block("// block B\n");
Block *b_c = new Block("// block C\n");
b_a->AddBranchTo(b_b, "check == 10");
b_a->AddBranchTo(b_c, NULL);
b_b->AddBranchTo(b_c, NULL);
Relooper r;
r.AddBlock(b_a);
r.AddBlock(b_b);
r.AddBlock(b_c);
r.Calculate(b_a);
printf("\n\n");
r.Render();
puts(buffer);
}
if (1) {
Relooper::SetOutputBuffer(buffer);
printf("\n\n-- If-else pattern --\n\n");
Block *b_a = new Block("// block A\n");
Block *b_b = new Block("// block B\n");
Block *b_c = new Block("// block C\n");
Block *b_d = new Block("// block D\n");
b_a->AddBranchTo(b_b, "check == 15");
b_a->AddBranchTo(b_c, NULL);
b_b->AddBranchTo(b_d, NULL);
b_c->AddBranchTo(b_d, NULL);
Relooper r;
r.AddBlock(b_a);
r.AddBlock(b_b);
r.AddBlock(b_c);
r.AddBlock(b_d);
r.Calculate(b_a);
printf("\n\n");
r.Render();
puts(buffer);
}
if (1) {
Relooper::SetOutputBuffer(buffer);
printf("\n\n-- Loop + tail pattern --\n\n");
Block *b_a = new Block("// block A\nvar check = maybe();\n");
Block *b_b = new Block("// block B\n");
Block *b_c = new Block("// block C\n");
b_a->AddBranchTo(b_b, NULL);
b_b->AddBranchTo(b_a, "check == 41");
b_b->AddBranchTo(b_c, NULL);
Relooper r;
r.AddBlock(b_a);
r.AddBlock(b_b);
r.AddBlock(b_c);
r.Calculate(b_a);
printf("\n\n");
r.Render();
puts(buffer);
}
}