summaryrefslogtreecommitdiffstats
path: root/Source/cmMakefile.h
diff options
context:
space:
mode:
authorGregor Jasny <gjasny@googlemail.com>2014-11-18 15:34:30 (GMT)
committerBrad King <brad.king@kitware.com>2014-11-25 19:14:15 (GMT)
commitbae604d9a80d5d97c676c85848e37783a153ff19 (patch)
treef2b423072548cf614d9a4248381ad15f8800960a /Source/cmMakefile.h
parent66ba7ea831ca8d44b137e59e8271de3c7756cfe3 (diff)
downloadCMake-bae604d9a80d5d97c676c85848e37783a153ff19.zip
CMake-bae604d9a80d5d97c676c85848e37783a153ff19.tar.gz
CMake-bae604d9a80d5d97c676c85848e37783a153ff19.tar.bz2
Track nested loop levels in CMake language with a stack of counters
It gets incremented while entering a loop block (e.g. foreach or while) and gets decremented when leaving the block. Because scope borders for example at function borders must be taken into account the counter is put into a stack. With every new scope an empty counter is pushed on the stack, when leaving the scope the original value is restored. This will allow easy querying if the break command is properly nested within a loop scope. Signed-off-by: Gregor Jasny <gjasny@googlemail.com>
Diffstat (limited to 'Source/cmMakefile.h')
-rw-r--r--Source/cmMakefile.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/Source/cmMakefile.h b/Source/cmMakefile.h
index 0458d54..41dddc3 100644
--- a/Source/cmMakefile.h
+++ b/Source/cmMakefile.h
@@ -34,6 +34,8 @@
# include <cmsys/hash_map.hxx>
#endif
+#include <stack>
+
class cmFunctionBlocker;
class cmCommand;
class cmInstallGenerator;
@@ -123,6 +125,15 @@ public:
};
friend class LexicalPushPop;
+ class LoopBlockPop
+ {
+ public:
+ LoopBlockPop(cmMakefile* mf) { this->Makefile = mf; }
+ ~LoopBlockPop() { this->Makefile->PopLoopBlock(); }
+ private:
+ cmMakefile* Makefile;
+ };
+
/**
* Try running cmake and building a file. This is used for dynalically
* loaded commands, not as part of the usual build process.
@@ -900,6 +911,10 @@ public:
void PopScope();
void RaiseScope(const std::string& var, const char *value);
+ // push and pop loop scopes
+ void PushLoopBlockBarrier();
+ void PopLoopBlockBarrier();
+
/** Helper class to push and pop scopes automatically. */
class ScopePushPop
{
@@ -960,6 +975,10 @@ public:
void ClearMatches();
void StoreMatches(cmsys::RegularExpression& re);
+ void PushLoopBlock();
+ void PopLoopBlock();
+ bool IsLoopBlock() const;
+
protected:
// add link libraries and directories to the target
void AddGlobalLinkInformation(const std::string& name, cmTarget& target);
@@ -1054,6 +1073,8 @@ private:
void PushFunctionBlockerBarrier();
void PopFunctionBlockerBarrier(bool reportError = true);
+ std::stack<int> LoopBlockCounter;
+
typedef std::map<std::string, std::string> StringStringMap;
StringStringMap MacrosMap;