cmConditionEvaluator.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <list>
  6. #include <string>
  7. #include <vector>
  8. #include <cmext/string_view>
  9. #include "cmExpandedCommandArgument.h"
  10. #include "cmListFileCache.h"
  11. #include "cmMessageType.h"
  12. #include "cmPolicies.h"
  13. #include "cmProperty.h"
  14. class cmMakefile;
  15. class cmConditionEvaluator
  16. {
  17. public:
  18. using cmArgumentList = std::list<cmExpandedCommandArgument>;
  19. cmConditionEvaluator(cmMakefile& makefile, cmListFileBacktrace bt);
  20. // this is a shared function for both If and Else to determine if the
  21. // arguments were valid, and if so, was the response true. If there is
  22. // an error, the errorString will be set.
  23. bool IsTrue(const std::vector<cmExpandedCommandArgument>& args,
  24. std::string& errorString, MessageType& status);
  25. private:
  26. // Filter the given variable definition based on policy CMP0054.
  27. cmProp GetDefinitionIfUnquoted(
  28. const cmExpandedCommandArgument& argument) const;
  29. cmProp GetVariableOrString(const cmExpandedCommandArgument& argument) const;
  30. bool IsKeyword(cm::string_view keyword,
  31. cmExpandedCommandArgument& argument) const;
  32. bool GetBooleanValue(cmExpandedCommandArgument& arg) const;
  33. bool GetBooleanValueOld(cmExpandedCommandArgument const& arg,
  34. bool one) const;
  35. bool GetBooleanValueWithAutoDereference(cmExpandedCommandArgument& newArg,
  36. std::string& errorString,
  37. MessageType& status,
  38. bool oneArg = false) const;
  39. void HandlePredicate(bool value, bool& reducible,
  40. cmArgumentList::iterator& arg, cmArgumentList& newArgs,
  41. cmArgumentList::iterator& argP1,
  42. cmArgumentList::iterator& argP2) const;
  43. void HandleBinaryOp(bool value, bool& reducible,
  44. cmArgumentList::iterator& arg, cmArgumentList& newArgs,
  45. cmArgumentList::iterator& argP1,
  46. cmArgumentList::iterator& argP2);
  47. bool HandleLevel0(cmArgumentList& newArgs, std::string& errorString,
  48. MessageType& status);
  49. bool HandleLevel1(cmArgumentList& newArgs, std::string&, MessageType&);
  50. bool HandleLevel2(cmArgumentList& newArgs, std::string& errorString,
  51. MessageType& status);
  52. bool HandleLevel3(cmArgumentList& newArgs, std::string& errorString,
  53. MessageType& status);
  54. bool HandleLevel4(cmArgumentList& newArgs, std::string& errorString,
  55. MessageType& status);
  56. cmMakefile& Makefile;
  57. cmListFileBacktrace Backtrace;
  58. cmPolicies::PolicyStatus Policy12Status;
  59. cmPolicies::PolicyStatus Policy54Status;
  60. cmPolicies::PolicyStatus Policy57Status;
  61. cmPolicies::PolicyStatus Policy64Status;
  62. };