summaryrefslogtreecommitdiff
path: root/Source/cmWhileCommand.cxx
diff options
context:
space:
mode:
authorRegina Pfeifer <regina@mailbox.org>2019-07-30 18:15:13 +0200
committerRegina Pfeifer <regina@mailbox.org>2019-07-31 00:03:17 +0200
commitaf24e4ef6e216184b8c207728d6b0312ce3c1525 (patch)
treed6bf6ab881d5bac857339b2c0e86bb660d13d54c /Source/cmWhileCommand.cxx
parentef38ff22f71ad0ffe83db42d903d26d4a41f4114 (diff)
downloadcmake-af24e4ef6e216184b8c207728d6b0312ce3c1525.tar.gz
cmFunctionBlocker: Move common logic to base
Diffstat (limited to 'Source/cmWhileCommand.cxx')
-rw-r--r--Source/cmWhileCommand.cxx43
1 files changed, 7 insertions, 36 deletions
diff --git a/Source/cmWhileCommand.cxx b/Source/cmWhileCommand.cxx
index 025d14ac17..bacee58ce5 100644
--- a/Source/cmWhileCommand.cxx
+++ b/Source/cmWhileCommand.cxx
@@ -3,6 +3,8 @@
#include "cmWhileCommand.h"
#include "cm_memory.hxx"
+#include "cm_static_string_view.hxx"
+#include "cm_string_view.hxx"
#include "cmConditionEvaluator.h"
#include "cmExecutionStatus.h"
@@ -21,23 +23,22 @@ class cmWhileFunctionBlocker : public cmFunctionBlocker
public:
cmWhileFunctionBlocker(cmMakefile* mf);
~cmWhileFunctionBlocker() override;
- bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf,
- cmExecutionStatus&) override;
+
+ cm::string_view StartCommandName() const override { return "while"_s; }
+ cm::string_view EndCommandName() const override { return "endwhile"_s; }
+
bool ShouldRemove(const cmListFileFunction& lff, cmMakefile& mf) override;
bool Replay(std::vector<cmListFileFunction> const& functions,
- cmExecutionStatus& inStatus);
+ cmExecutionStatus& inStatus) override;
std::vector<cmListFileArgument> Args;
- std::vector<cmListFileFunction> Functions;
private:
cmMakefile* Makefile;
- int Depth;
};
cmWhileFunctionBlocker::cmWhileFunctionBlocker(cmMakefile* mf)
: Makefile(mf)
- , Depth(0)
{
this->Makefile->PushLoopBlock();
}
@@ -47,36 +48,6 @@ cmWhileFunctionBlocker::~cmWhileFunctionBlocker()
this->Makefile->PopLoopBlock();
}
-bool cmWhileFunctionBlocker::IsFunctionBlocked(const cmListFileFunction& lff,
- cmMakefile& mf,
- cmExecutionStatus& inStatus)
-{
- // at end of for each execute recorded commands
- if (lff.Name.Lower == "while") {
- // record the number of while commands past this one
- this->Depth++;
- } else if (lff.Name.Lower == "endwhile") {
- // if this is the endwhile for this while loop then execute
- if (!this->Depth) {
- // Remove the function blocker for this scope or bail.
- std::unique_ptr<cmFunctionBlocker> fb(
- mf.RemoveFunctionBlocker(this, lff));
- if (!fb) {
- return false;
- }
- return this->Replay(this->Functions, inStatus);
- }
- // decrement for each nested while that ends
- this->Depth--;
- }
-
- // record the command
- this->Functions.push_back(lff);
-
- // always return true
- return true;
-}
-
bool cmWhileFunctionBlocker::ShouldRemove(const cmListFileFunction& lff,
cmMakefile&)
{