2 * Mesa 3-D graphics library
5 * Copyright (C) 2005 Brian Paul All Rights Reserved.
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:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
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.
25 #if !defined SLANG_COMPILE_H
26 #define SLANG_COMPILE_H
28 #if defined __cplusplus
32 typedef enum slang_type_qualifier_
41 slang_qual_fixedoutput
, /* internal */
42 slang_qual_fixedinput
/* internal */
43 } slang_type_qualifier
;
45 typedef enum slang_type_specifier_type_
66 slang_spec_samplerCube
,
67 slang_spec_sampler1DShadow
,
68 slang_spec_sampler2DShadow
,
71 } slang_type_specifier_type
;
73 typedef struct slang_type_specifier_
75 slang_type_specifier_type type
;
76 struct slang_struct_
*_struct
; /* spec_struct */
77 struct slang_type_specifier_
*_array
; /* spec_array */
78 } slang_type_specifier
;
80 typedef struct slang_fully_specified_type_
82 slang_type_qualifier qualifier
;
83 slang_type_specifier specifier
;
84 } slang_fully_specified_type
;
86 typedef struct slang_variable_scope_
88 struct slang_variable_
*variables
;
89 unsigned int num_variables
;
90 struct slang_variable_scope_
*outer_scope
;
91 } slang_variable_scope
;
93 typedef enum slang_operation_type_
96 slang_oper_block_no_new_scope
,
97 slang_oper_block_new_scope
,
98 slang_oper_variable_decl
,
104 slang_oper_expression
,
110 slang_oper_literal_bool
,
111 slang_oper_literal_int
,
112 slang_oper_literal_float
,
113 slang_oper_identifier
,
116 slang_oper_addassign
,
117 slang_oper_subassign
,
118 slang_oper_mulassign
,
119 slang_oper_divassign
,
120 /*slang_oper_modassign,*/
121 /*slang_oper_lshassign,*/
122 /*slang_oper_rshassign,*/
123 /*slang_oper_orassign,*/
124 /*slang_oper_xorassign,*/
125 /*slang_oper_andassign,*/
127 slang_oper_logicalor
,
128 slang_oper_logicalxor
,
129 slang_oper_logicaland
,
130 /*slang_oper_bitor,*/
131 /*slang_oper_bitxor,*/
132 /*slang_oper_bitand,*/
137 slang_oper_lessequal
,
138 slang_oper_greaterequal
,
139 /*slang_oper_lshift,*/
140 /*slang_oper_rshift,*/
145 /*slang_oper_modulus,*/
146 slang_oper_preincrement
,
147 slang_oper_predecrement
,
150 /*slang_oper_complement,*/
152 slang_oper_subscript
,
155 slang_oper_postincrement
,
156 slang_oper_postdecrement
157 } slang_operation_type
;
159 typedef struct slang_operation_
161 slang_operation_type type
;
162 struct slang_operation_
*children
;
163 unsigned int num_children
;
164 float literal
; /* bool, literal_int, literal_float */
165 char *identifier
; /* asm, identifier, call, field */
166 slang_variable_scope
*locals
;
169 typedef struct slang_variable_
171 slang_fully_specified_type type
;
173 slang_operation
*array_size
; /* spec_array */
174 slang_operation
*initializer
;
177 typedef struct slang_struct_scope_
179 struct slang_struct_
*structs
;
180 unsigned int num_structs
;
181 struct slang_struct_scope_
*outer_scope
;
182 } slang_struct_scope
;
184 typedef struct slang_struct_
187 slang_variable_scope
*fields
;
188 slang_struct_scope
*structs
;
191 typedef enum slang_function_kind_
194 slang_func_constructor
,
196 } slang_function_kind
;
198 typedef struct slang_function_
200 slang_function_kind kind
;
201 slang_variable header
;
202 slang_variable_scope
*parameters
;
203 unsigned int param_count
;
204 slang_operation
*body
;
207 typedef struct slang_function_scope_
209 slang_function
*functions
;
210 unsigned int num_functions
;
211 struct slang_function_scope_
*outer_scope
;
212 } slang_function_scope
;
214 typedef enum slang_unit_type_
216 slang_unit_fragment_shader
,
217 slang_unit_vertex_shader
220 typedef struct slang_translation_unit_
222 slang_variable_scope
*globals
;
223 slang_function_scope functions
;
224 slang_struct_scope
*structs
;
225 slang_unit_type type
;
226 } slang_translation_unit
;
228 int _slang_compile (const char *, slang_translation_unit
*, slang_unit_type type
);