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.

slang_compile.h 5.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. /*
  2. * Mesa 3-D graphics library
  3. * Version: 6.3
  4. *
  5. * Copyright (C) 2005 Brian Paul All Rights Reserved.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  11. * and/or sell copies of the Software, and to permit persons to whom the
  12. * Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice shall be included
  15. * in all copies or substantial portions of the Software.
  16. *
  17. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  18. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  19. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  20. * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  21. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  22. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  23. */
  24. #if !defined SLANG_COMPILE_H
  25. #define SLANG_COMPILE_H
  26. #if defined __cplusplus
  27. extern "C" {
  28. #endif
  29. typedef enum slang_type_qualifier_
  30. {
  31. slang_qual_none,
  32. slang_qual_const,
  33. slang_qual_attribute,
  34. slang_qual_varying,
  35. slang_qual_uniform,
  36. slang_qual_out,
  37. slang_qual_inout,
  38. slang_qual_fixedoutput, /* internal */
  39. slang_qual_fixedinput /* internal */
  40. } slang_type_qualifier;
  41. typedef enum slang_type_specifier_type_
  42. {
  43. slang_spec_void,
  44. slang_spec_bool,
  45. slang_spec_bvec2,
  46. slang_spec_bvec3,
  47. slang_spec_bvec4,
  48. slang_spec_int,
  49. slang_spec_ivec2,
  50. slang_spec_ivec3,
  51. slang_spec_ivec4,
  52. slang_spec_float,
  53. slang_spec_vec2,
  54. slang_spec_vec3,
  55. slang_spec_vec4,
  56. slang_spec_mat2,
  57. slang_spec_mat3,
  58. slang_spec_mat4,
  59. slang_spec_sampler1D,
  60. slang_spec_sampler2D,
  61. slang_spec_sampler3D,
  62. slang_spec_samplerCube,
  63. slang_spec_sampler1DShadow,
  64. slang_spec_sampler2DShadow,
  65. slang_spec_struct,
  66. slang_spec_array
  67. } slang_type_specifier_type;
  68. typedef struct slang_type_specifier_
  69. {
  70. slang_type_specifier_type type;
  71. struct slang_struct_ *_struct; /* spec_struct */
  72. struct slang_type_specifier_ *_array; /* spec_array */
  73. } slang_type_specifier;
  74. typedef struct slang_fully_specified_type_
  75. {
  76. slang_type_qualifier qualifier;
  77. slang_type_specifier specifier;
  78. } slang_fully_specified_type;
  79. typedef struct slang_variable_scope_
  80. {
  81. struct slang_variable_ *variables;
  82. unsigned int num_variables;
  83. struct slang_variable_scope_ *outer_scope;
  84. } slang_variable_scope;
  85. typedef enum slang_operation_type_
  86. {
  87. slang_oper_none,
  88. slang_oper_block_no_new_scope,
  89. slang_oper_block_new_scope,
  90. slang_oper_variable_decl,
  91. slang_oper_asm,
  92. slang_oper_break,
  93. slang_oper_continue,
  94. slang_oper_discard,
  95. slang_oper_return,
  96. slang_oper_expression,
  97. slang_oper_if,
  98. slang_oper_while,
  99. slang_oper_do,
  100. slang_oper_for,
  101. slang_oper_void,
  102. slang_oper_literal_bool,
  103. slang_oper_literal_int,
  104. slang_oper_literal_float,
  105. slang_oper_identifier,
  106. slang_oper_sequence,
  107. slang_oper_assign,
  108. slang_oper_addassign,
  109. slang_oper_subassign,
  110. slang_oper_mulassign,
  111. slang_oper_divassign,
  112. /*slang_oper_modassign,*/
  113. /*slang_oper_lshassign,*/
  114. /*slang_oper_rshassign,*/
  115. /*slang_oper_orassign,*/
  116. /*slang_oper_xorassign,*/
  117. /*slang_oper_andassign,*/
  118. slang_oper_select,
  119. slang_oper_logicalor,
  120. slang_oper_logicalxor,
  121. slang_oper_logicaland,
  122. /*slang_oper_bitor,*/
  123. /*slang_oper_bitxor,*/
  124. /*slang_oper_bitand,*/
  125. slang_oper_equal,
  126. slang_oper_notequal,
  127. slang_oper_less,
  128. slang_oper_greater,
  129. slang_oper_lessequal,
  130. slang_oper_greaterequal,
  131. /*slang_oper_lshift,*/
  132. /*slang_oper_rshift,*/
  133. slang_oper_add,
  134. slang_oper_subtract,
  135. slang_oper_multiply,
  136. slang_oper_divide,
  137. /*slang_oper_modulus,*/
  138. slang_oper_preincrement,
  139. slang_oper_predecrement,
  140. slang_oper_plus,
  141. slang_oper_minus,
  142. /*slang_oper_complement,*/
  143. slang_oper_not,
  144. slang_oper_subscript,
  145. slang_oper_call,
  146. slang_oper_field,
  147. slang_oper_postincrement,
  148. slang_oper_postdecrement
  149. } slang_operation_type;
  150. typedef struct slang_operation_
  151. {
  152. slang_operation_type type;
  153. struct slang_operation_ *children;
  154. unsigned int num_children;
  155. float literal; /* bool, literal_int, literal_float */
  156. char *identifier; /* asm, identifier, call, field */
  157. slang_variable_scope *locals;
  158. } slang_operation;
  159. typedef struct slang_variable_
  160. {
  161. slang_fully_specified_type type;
  162. char *name;
  163. slang_operation *array_size; /* spec_array */
  164. slang_operation *initializer;
  165. } slang_variable;
  166. typedef struct slang_struct_scope_
  167. {
  168. struct slang_struct_ *structs;
  169. unsigned int num_structs;
  170. struct slang_struct_scope_ *outer_scope;
  171. } slang_struct_scope;
  172. typedef struct slang_struct_
  173. {
  174. char *name;
  175. slang_variable_scope *fields;
  176. slang_struct_scope *structs;
  177. } slang_struct;
  178. typedef enum slang_function_kind_
  179. {
  180. slang_func_ordinary,
  181. slang_func_constructor,
  182. slang_func_operator
  183. } slang_function_kind;
  184. typedef struct slang_function_
  185. {
  186. slang_function_kind kind;
  187. slang_variable header;
  188. slang_variable_scope *parameters;
  189. unsigned int param_count;
  190. slang_operation *body;
  191. } slang_function;
  192. typedef struct slang_function_scope_
  193. {
  194. slang_function *functions;
  195. unsigned int num_functions;
  196. struct slang_function_scope_ *outer_scope;
  197. } slang_function_scope;
  198. typedef enum slang_unit_type_
  199. {
  200. slang_unit_fragment_shader,
  201. slang_unit_vertex_shader
  202. } slang_unit_type;
  203. typedef struct slang_translation_unit_
  204. {
  205. slang_variable_scope *globals;
  206. slang_function_scope functions;
  207. slang_struct_scope *structs;
  208. slang_unit_type type;
  209. } slang_translation_unit;
  210. int _slang_compile (const char *, slang_translation_unit *, slang_unit_type type);
  211. #ifdef __cplusplus
  212. }
  213. #endif
  214. #endif