Clone of mesa.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ast_type.cpp 2.7KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. /*
  2. * Copyright © 2010 Intel Corporation
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice (including the next
  12. * paragraph) shall be included in all copies or substantial portions of the
  13. * Software.
  14. *
  15. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  16. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  17. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  18. * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  19. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  20. * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  21. * DEALINGS IN THE SOFTWARE.
  22. */
  23. #include <cstdio>
  24. #include "ast.h"
  25. #include "symbol_table.h"
  26. void
  27. ast_type_specifier::print(void) const
  28. {
  29. if (type_specifier == ast_struct) {
  30. structure->print();
  31. } else {
  32. printf("%s ", type_name);
  33. }
  34. if (is_array) {
  35. printf("[ ");
  36. if (array_size) {
  37. array_size->print();
  38. }
  39. printf("] ");
  40. }
  41. }
  42. ast_type_specifier::ast_type_specifier(int specifier)
  43. : type_specifier(ast_types(specifier)), type_name(NULL), structure(NULL),
  44. is_array(false), array_size(NULL), precision(ast_precision_high)
  45. {
  46. static const char *const names[] = {
  47. "void",
  48. "float",
  49. "int",
  50. "uint",
  51. "bool",
  52. "vec2",
  53. "vec3",
  54. "vec4",
  55. "bvec2",
  56. "bvec3",
  57. "bvec4",
  58. "ivec2",
  59. "ivec3",
  60. "ivec4",
  61. "uvec2",
  62. "uvec3",
  63. "uvec4",
  64. "mat2",
  65. "mat2x3",
  66. "mat2x4",
  67. "mat3x2",
  68. "mat3",
  69. "mat3x4",
  70. "mat4x2",
  71. "mat4x3",
  72. "mat4",
  73. "sampler1D",
  74. "sampler2D",
  75. "sampler2DRect",
  76. "sampler3D",
  77. "samplerCube",
  78. "sampler1DShadow",
  79. "sampler2DShadow",
  80. "sampler2DRectShadow",
  81. "samplerCubeShadow",
  82. "sampler1DArray",
  83. "sampler2DArray",
  84. "sampler1DArrayShadow",
  85. "sampler2DArrayShadow",
  86. "isampler1D",
  87. "isampler2D",
  88. "isampler3D",
  89. "isamplerCube",
  90. "isampler1DArray",
  91. "isampler2DArray",
  92. "usampler1D",
  93. "usampler2D",
  94. "usampler3D",
  95. "usamplerCube",
  96. "usampler1DArray",
  97. "usampler2DArray",
  98. NULL, /* ast_struct */
  99. NULL /* ast_type_name */
  100. };
  101. type_name = names[specifier];
  102. }