cmConditionEvaluator.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 "cmExpandedCommandArgument.h"
  9. #include "cmListFileCache.h"
  10. #include "cmMessageType.h"
  11. #include "cmPolicies.h"
  12. #include "cmProperty.h"
  13. class cmMakefile;
  14. class cmConditionEvaluator
  15. {
  16. public:
  17. using cmArgumentList = std::list<cmExpandedCommandArgument>;
  18. cmConditionEvaluator(cmMakefile& makefile, cmListFileContext context,
  19. 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(std::string const& 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 IncrementArguments(cmArgumentList& newArgs,
  40. cmArgumentList::iterator& argP1,
  41. cmArgumentList::iterator& argP2) const;
  42. void HandlePredicate(bool value, int& reducible,
  43. cmArgumentList::iterator& arg, cmArgumentList& newArgs,
  44. cmArgumentList::iterator& argP1,
  45. cmArgumentList::iterator& argP2) const;
  46. void HandleBinaryOp(bool value, int& reducible,
  47. cmArgumentList::iterator& arg, cmArgumentList& newArgs,
  48. cmArgumentList::iterator& argP1,
  49. cmArgumentList::iterator& argP2);
  50. bool HandleLevel0(cmArgumentList& newArgs, std::string& errorString,
  51. MessageType& status);
  52. bool HandleLevel1(cmArgumentList& newArgs, std::string&, MessageType&);
  53. bool HandleLevel2(cmArgumentList& newArgs, std::string& errorString,
  54. MessageType& status);
  55. bool HandleLevel3(cmArgumentList& newArgs, std::string& errorString,
  56. MessageType& status);
  57. bool HandleLevel4(cmArgumentList& newArgs, std::string& errorString,
  58. MessageType& status);
  59. cmMakefile& Makefile;
  60. cmListFileContext ExecutionContext;
  61. cmListFileBacktrace Backtrace;
  62. cmPolicies::PolicyStatus Policy12Status;
  63. cmPolicies::PolicyStatus Policy54Status;
  64. cmPolicies::PolicyStatus Policy57Status;
  65. cmPolicies::PolicyStatus Policy64Status;
  66. };