@@ -129,8 +129,8 @@ Branch::Branch(const char *ConditionInit, const char *CodeInit) : Ancestor(NULL)
129
129
}
130
130
131
131
Branch::~Branch () {
132
- if (Condition) free (( void *) Condition);
133
- if (Code) free (( void *) Code);
132
+ free (static_cast < void *>( const_cast < char *>( Condition)) );
133
+ free (static_cast < void *>( const_cast < char *>( Code)) );
134
134
}
135
135
136
136
void Branch::Render (Block *Target, bool SetLabel) {
@@ -155,8 +155,8 @@ Block::Block(const char *CodeInit, const char *BranchVarInit) : Parent(NULL), Id
155
155
}
156
156
157
157
Block::~Block () {
158
- if (Code) free (( void *) Code);
159
- if (BranchVar) free (( void *) BranchVar);
158
+ free (static_cast < void *>( const_cast < char *>( Code)) );
159
+ free (static_cast < void *>( const_cast < char *>( BranchVar)) );
160
160
for (BlockBranchMap::iterator iter = ProcessedBranchesOut.begin (); iter != ProcessedBranchesOut.end (); iter++) {
161
161
delete iter->second ;
162
162
}
@@ -215,7 +215,7 @@ void Block::Render(bool InLoop) {
215
215
// into the Simple's branches.
216
216
MultipleShape *Fused = Shape::IsMultiple (Parent->Next );
217
217
if (Fused) {
218
- PrintDebug (" Fusing Multiple to Simple\n " );
218
+ PrintDebug (" Fusing Multiple to Simple\n " , 0 );
219
219
Parent->Next = Parent->Next ->Next ;
220
220
Fused->UseSwitch = false ; // TODO: emit switches here
221
221
Fused->RenderLoopPrefix ();
@@ -710,7 +710,7 @@ void Relooper::Calculate(Block *Entry) {
710
710
}
711
711
#endif
712
712
713
- PrintDebug (" creating loop block:\n " );
713
+ PrintDebug (" creating loop block:\n " , 0 );
714
714
DebugDump (InnerBlocks, " inner blocks:" );
715
715
DebugDump (Entries, " inner entries:" );
716
716
DebugDump (Blocks, " outer blocks:" );
@@ -912,7 +912,7 @@ void Relooper::Calculate(Block *Entry) {
912
912
// ->Next block on them, and the blocks are what remains in Blocks (which Make* modify). In this way
913
913
// we avoid recursing on Next (imagine a long chain of Simples, if we recursed we could blow the stack).
914
914
Shape *Process (BlockSet &Blocks, BlockSet& InitialEntries, Shape *Prev) {
915
- PrintDebug (" Process() called\n " );
915
+ PrintDebug (" Process() called\n " , 0 );
916
916
BlockSet *Entries = &InitialEntries;
917
917
BlockSet TempEntries[2 ];
918
918
int CurrTempIndex = 0 ;
@@ -922,12 +922,12 @@ void Relooper::Calculate(Block *Entry) {
922
922
Shape *Temp = call; \
923
923
if (Prev) Prev->Next = Temp; \
924
924
if (!Ret) Ret = Temp; \
925
- if (!NextEntries->size ()) { PrintDebug (" Process() returning\n " ); return Ret; } \
925
+ if (!NextEntries->size ()) { PrintDebug (" Process() returning\n " , 0 ); return Ret; } \
926
926
Prev = Temp; \
927
927
Entries = NextEntries; \
928
928
continue ;
929
929
while (1 ) {
930
- PrintDebug (" Process() running\n " );
930
+ PrintDebug (" Process() running\n " , 0 );
931
931
DebugDump (Blocks, " blocks : " );
932
932
DebugDump (*Entries, " entries: " );
933
933
@@ -1013,7 +1013,7 @@ void Relooper::Calculate(Block *Entry) {
1013
1013
if (!DeadEnd) break ;
1014
1014
}
1015
1015
if (DeadEnd) {
1016
- PrintDebug (" Removing nesting by not handling large group because small group is dead end\n " );
1016
+ PrintDebug (" Removing nesting by not handling large group because small group is dead end\n " , 0 );
1017
1017
IndependentGroups.erase (LargeEntry);
1018
1018
}
1019
1019
}
@@ -1052,7 +1052,7 @@ void Relooper::Calculate(Block *Entry) {
1052
1052
1053
1053
struct PostOptimizer {
1054
1054
Relooper *Parent;
1055
- void *Closure;
1055
+ std::stack<Shape*> *Closure;
1056
1056
1057
1057
PostOptimizer (Relooper *ParentInit) : Parent(ParentInit), Closure(NULL ) {}
1058
1058
@@ -1066,10 +1066,13 @@ void Relooper::Calculate(Block *Entry) {
1066
1066
1067
1067
#define SHAPE_SWITCH (var, simple, multiple, loop ) \
1068
1068
if (SimpleShape *Simple = Shape::IsSimple(var)) { \
1069
+ (void )Simple; \
1069
1070
simple; \
1070
1071
} else if (MultipleShape *Multiple = Shape::IsMultiple(var)) { \
1072
+ (void )Multiple; \
1071
1073
multiple; \
1072
1074
} else if (LoopShape *Loop = Shape::IsLoop(var)) { \
1075
+ (void )Loop; \
1073
1076
loop; \
1074
1077
}
1075
1078
@@ -1142,7 +1145,6 @@ void Relooper::Calculate(Block *Entry) {
1142
1145
}
1143
1146
if (Found && !Abort) {
1144
1147
for (BlockBranchMap::iterator iter = Simple->Inner ->ProcessedBranchesOut .begin (); iter != Simple->Inner ->ProcessedBranchesOut .end (); iter++) {
1145
- Block *Target = iter->first ;
1146
1148
Branch *Details = iter->second ;
1147
1149
if (Details->Type == Branch::Break) {
1148
1150
Details->Type = Branch::Direct;
@@ -1194,9 +1196,9 @@ void Relooper::Calculate(Block *Entry) {
1194
1196
void FindLabeledLoops (Shape *Root) {
1195
1197
bool First = Closure == NULL ;
1196
1198
if (First) {
1197
- Closure = ( void *)( new std::stack<Shape*>) ;
1199
+ Closure = new std::stack<Shape*>;
1198
1200
}
1199
- std::stack<Shape*> &LoopStack = *((std::stack<Shape*>*) Closure) ;
1201
+ std::stack<Shape*> &LoopStack = *Closure;
1200
1202
1201
1203
Shape *Next = Root;
1202
1204
while (Next) {
@@ -1219,7 +1221,6 @@ void Relooper::Calculate(Block *Entry) {
1219
1221
RECURSE_Multiple (Fused, FindLabeledLoops);
1220
1222
}
1221
1223
for (BlockBranchMap::iterator iter = Simple->Inner ->ProcessedBranchesOut .begin (); iter != Simple->Inner ->ProcessedBranchesOut .end (); iter++) {
1222
- Block *Target = iter->first ;
1223
1224
Branch *Details = iter->second ;
1224
1225
if (Details->Type == Branch::Break || Details->Type == Branch::Continue) {
1225
1226
assert (LoopStack.size () > 0 );
@@ -1263,7 +1264,7 @@ void Relooper::Calculate(Block *Entry) {
1263
1264
}
1264
1265
1265
1266
if (First) {
1266
- delete (std::stack<Shape*>*) Closure;
1267
+ delete Closure;
1267
1268
}
1268
1269
}
1269
1270
@@ -1274,7 +1275,7 @@ void Relooper::Calculate(Block *Entry) {
1274
1275
}
1275
1276
};
1276
1277
1277
- PrintDebug (" === Optimizing shapes ===\n " );
1278
+ PrintDebug (" === Optimizing shapes ===\n " , 0 );
1278
1279
1279
1280
PostOptimizer (this ).Process (Root);
1280
1281
}
@@ -1435,4 +1436,3 @@ RELOOPERDLL_API void rl_relooper_render(void *relooper) {
1435
1436
}
1436
1437
1437
1438
}
1438
-
0 commit comments