diff options
author | Jez Ng <me@jezng.com> | 2013-06-27 01:06:35 -0700 |
---|---|---|
committer | Jez Ng <me@jezng.com> | 2013-06-27 01:06:35 -0700 |
commit | 4dd1e475281b2fa94b757b3f40b5849981a73346 (patch) | |
tree | b237a3ae902ea3c16a3e90dced3e811ef7eee958 | |
parent | 84e1197b40b2b625b2ee9f6fa417132506f824e8 (diff) |
Make DefaultTarget a local variable.
-rw-r--r-- | src/relooper/Relooper.cpp | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/src/relooper/Relooper.cpp b/src/relooper/Relooper.cpp index 39f1eed3..ca9c6ab1 100644 --- a/src/relooper/Relooper.cpp +++ b/src/relooper/Relooper.cpp @@ -104,7 +104,7 @@ void Branch::Render(Block *Target, bool SetLabel) { int Block::IdCounter = 1; // 0 is reserved for clearings -Block::Block(const char *CodeInit) : Parent(NULL), Id(Block::IdCounter++), DefaultTarget(NULL), IsCheckedMultipleEntry(false) { +Block::Block(const char *CodeInit) : Parent(NULL), Id(Block::IdCounter++), IsCheckedMultipleEntry(false) { Code = strdup(CodeInit); } @@ -178,6 +178,8 @@ void Block::Render(bool InLoop) { } } + Block *DefaultTarget(NULL); // The block we branch to without checking the condition, if none of the other conditions held. + // We must do this here, because blocks can be split and even comparing their Ids is not enough. We must check the conditions. for (BlockBranchMap::iterator iter = ProcessedBranchesOut.begin(); iter != ProcessedBranchesOut.end(); iter++) { if (!iter->second->Condition) { @@ -185,7 +187,7 @@ void Block::Render(bool InLoop) { DefaultTarget = iter->first; } } - assert(DefaultTarget); // Must be a default + assert(DefaultTarget); // Since each block *must* branch somewhere, this must be set ministring RemainingConditions; bool First = true; |