Machine.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. 
  2. #ifndef DSR_BUILDER_MACHINE_MODULE
  3. #define DSR_BUILDER_MACHINE_MODULE
  4. #include "../../DFPSR/api/stringAPI.h"
  5. using namespace dsr;
  6. struct Flag {
  7. dsr::String key, value;
  8. Flag() {}
  9. Flag(const dsr::ReadableString &key, const dsr::ReadableString &value)
  10. : key(key), value(value) {}
  11. };
  12. struct Machine {
  13. List<Flag> variables;
  14. List<String> compilerFlags, linkerFlags;
  15. // When activeStackDepth < currentStackDepth, we are skipping false cases.
  16. int64_t currentStackDepth = 0; // How many scopes we are inside of, from the root script including all the others.
  17. int64_t activeStackDepth = 0;
  18. };
  19. // Returns the first case insensitive match for key in target, or -1 if not found.
  20. int64_t findFlag(const Machine &target, const dsr::ReadableString &key);
  21. // Returns the value of key in target, or defaultValue if not found.
  22. ReadableString getFlag(const Machine &target, const dsr::ReadableString &key, const dsr::ReadableString &defaultValue);
  23. // Returns the value of key in target, defaultValue if not found, or 0 if not an integer.
  24. int64_t getFlagAsInteger(const Machine &target, const dsr::ReadableString &key, int64_t defaultValue = 0);
  25. // Assigns value to key in target. Allocates key in target if it does not already exist.
  26. void assignValue(Machine &target, const dsr::ReadableString &key, const dsr::ReadableString &value);
  27. // Modifies the flags in target using the script in scriptPath.
  28. // Recursively including other scripts using the script's folder as the origin for relative paths.
  29. void evaluateScript(Machine &target, const ReadableString &scriptPath);
  30. #endif