@@ -57,7 +57,7 @@ struct Block {
57
57
BlockBranchMap ProcessedBranchesOut;
58
58
BlockSet ProcessedBranchesIn;
59
59
Shape *Parent; // The shape we are directly inside
60
- int Id; // A unique identifier
60
+ int Id; // A unique identifier, defined when added to relooper
61
61
const char *Code; // The string representation of the code in this block. Owning pointer (we copy the input)
62
62
const char *BranchVar; // If we have more than one branch out, the variable whose value determines where we go
63
63
bool IsCheckedMultipleEntry; // If true, we are a multiple entry, so reaching us requires setting the label variable
@@ -69,9 +69,6 @@ struct Block {
69
69
70
70
// Prints out the instructions code and branchings
71
71
void Render (bool InLoop);
72
-
73
- // INTERNAL
74
- static int IdCounter;
75
72
};
76
73
77
74
// Represents a structured control flow shape, one of
@@ -99,7 +96,7 @@ class LoopShape;
99
96
class EmulatedShape ;
100
97
101
98
struct Shape {
102
- int Id; // A unique identifier. Used to identify loops, labels are Lx where x is the Id.
99
+ int Id; // A unique identifier. Used to identify loops, labels are Lx where x is the Id. Defined when added to relooper
103
100
Shape *Next; // The shape that will appear in the code right after this one
104
101
Shape *Natural; // The shape that control flow gets to naturally (if there is Next, then this is Next)
105
102
@@ -111,7 +108,7 @@ struct Shape {
111
108
};
112
109
ShapeType Type;
113
110
114
- Shape (ShapeType TypeInit) : Id(Shape::IdCounter++ ), Next(NULL ), Type(TypeInit) {}
111
+ Shape (ShapeType TypeInit) : Id(- 1 ), Next(NULL ), Type(TypeInit) {}
115
112
virtual ~Shape () {}
116
113
117
114
virtual void Render (bool InLoop) = 0;
@@ -121,9 +118,6 @@ struct Shape {
121
118
static LoopShape *IsLoop (Shape *It) { return It && It->Type == Loop ? (LoopShape*)It : NULL ; }
122
119
static LabeledShape *IsLabeled (Shape *It) { return IsMultiple (It) || IsLoop (It) ? (LabeledShape*)It : NULL ; }
123
120
static EmulatedShape *IsEmulated (Shape *It) { return It && It->Type == Emulated ? (EmulatedShape*)It : NULL ; }
124
-
125
- // INTERNAL
126
- static int IdCounter;
127
121
};
128
122
129
123
struct SimpleShape : public Shape {
@@ -191,6 +185,8 @@ struct Relooper {
191
185
std::deque<Shape*> Shapes;
192
186
Shape *Root;
193
187
bool Emulate;
188
+ int BlockIdCounter;
189
+ int ShapeIdCounter;
194
190
195
191
Relooper ();
196
192
~Relooper ();
0 commit comments