text.h 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (c) 2015-2016 The Khronos Group Inc.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef SOURCE_TEXT_H_
  15. #define SOURCE_TEXT_H_
  16. #include <string>
  17. #include "source/operand.h"
  18. #include "source/spirv_constant.h"
  19. #include "spirv-tools/libspirv.h"
  20. typedef enum spv_literal_type_t {
  21. SPV_LITERAL_TYPE_INT_32,
  22. SPV_LITERAL_TYPE_INT_64,
  23. SPV_LITERAL_TYPE_UINT_32,
  24. SPV_LITERAL_TYPE_UINT_64,
  25. SPV_LITERAL_TYPE_FLOAT_32,
  26. SPV_LITERAL_TYPE_FLOAT_64,
  27. SPV_LITERAL_TYPE_STRING,
  28. SPV_FORCE_32_BIT_ENUM(spv_literal_type_t)
  29. } spv_literal_type_t;
  30. typedef struct spv_literal_t {
  31. spv_literal_type_t type;
  32. union value_t {
  33. int32_t i32;
  34. int64_t i64;
  35. uint32_t u32;
  36. uint64_t u64;
  37. float f;
  38. double d;
  39. } value;
  40. std::string str; // Special field for literal string.
  41. } spv_literal_t;
  42. // Converts the given text string to a number/string literal and writes the
  43. // result to *literal. String literals must be surrounded by double-quotes ("),
  44. // which are then stripped.
  45. spv_result_t spvTextToLiteral(const char* text, spv_literal_t* literal);
  46. #endif // SOURCE_TEXT_H_