2 * Mesa 3-D graphics library
5 * Copyright (C) 2005-2006 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 #ifndef SLANG_TYPEINFO_H
26 #define SLANG_TYPEINFO_H 1
30 #include "slang_utility.h"
31 #include "slang_vartable.h"
34 struct slang_operation_
;
38 * Holds complete information about vector swizzle - the <swizzle>
39 * array contains vector component source indices, where 0 is "x", 1
40 * is "y", 2 is "z" and 3 is "w".
41 * Example: "xwz" --> { 3, { 0, 3, 2, not used } }.
43 typedef struct slang_swizzle_
45 GLuint num_components
;
49 typedef struct slang_name_space_
51 struct slang_function_scope_
*funcs
;
52 struct slang_struct_scope_
*structs
;
53 struct slang_variable_scope_
*vars
;
57 typedef struct slang_assemble_ctx_
59 slang_atom_pool
*atoms
;
60 slang_name_space space
;
62 struct gl_program
*program
;
63 slang_var_table
*vartable
;
65 struct slang_function_
*CurFunction
;
66 slang_atom CurLoopBreak
;
67 slang_atom CurLoopCont
;
70 extern struct slang_function_
*
71 _slang_locate_function(const struct slang_function_scope_
*funcs
,
72 slang_atom name
, const struct slang_operation_
*params
,
74 const slang_name_space
*space
,
79 _slang_is_swizzle(const char *field
, GLuint rows
, slang_swizzle
*swz
);
82 _slang_is_swizzle_mask(const slang_swizzle
*swz
, GLuint rows
);
85 _slang_multiply_swizzles(slang_swizzle
*, const slang_swizzle
*,
86 const slang_swizzle
*);
90 * The basic shading language types (float, vec4, mat3, etc)
92 typedef enum slang_type_specifier_type_
110 slang_spec_sampler1D
,
111 slang_spec_sampler2D
,
112 slang_spec_sampler3D
,
113 slang_spec_samplerCube
,
114 slang_spec_sampler1DShadow
,
115 slang_spec_sampler2DShadow
,
118 } slang_type_specifier_type
;
122 * Describes more sophisticated types, like structs and arrays.
124 typedef struct slang_type_specifier_
126 slang_type_specifier_type type
;
127 struct slang_struct_
*_struct
; /**< used if type == spec_struct */
128 struct slang_type_specifier_
*_array
; /**< used if type == spec_array */
129 } slang_type_specifier
;
133 slang_type_specifier_ctr(slang_type_specifier
*);
136 slang_type_specifier_dtr(slang_type_specifier
*);
139 slang_type_specifier_copy(slang_type_specifier
*, const slang_type_specifier
*);
142 slang_type_specifier_equal(const slang_type_specifier
*,
143 const slang_type_specifier
*);
146 typedef struct slang_typeinfo_
148 GLboolean can_be_referenced
;
149 GLboolean is_swizzled
;
151 slang_type_specifier spec
;
156 slang_typeinfo_construct(slang_typeinfo
*);
159 slang_typeinfo_destruct(slang_typeinfo
*);
163 * Retrieves type information about an operation.
164 * Returns GL_TRUE on success.
165 * Returns GL_FALSE otherwise.
168 _slang_typeof_operation(const slang_assemble_ctx
*,
169 const struct slang_operation_
*,
173 _slang_typeof_operation_(const struct slang_operation_
*,
174 const slang_name_space
*,
175 slang_typeinfo
*, slang_atom_pool
*);
178 * Retrieves type of a function prototype, if one exists.
179 * Returns GL_TRUE on success, even if the function was not found.
180 * Returns GL_FALSE otherwise.
183 _slang_typeof_function(slang_atom a_name
,
184 const struct slang_operation_
*params
,
185 GLuint num_params
, const slang_name_space
*,
186 slang_type_specifier
*spec
, GLboolean
*exists
,
190 _slang_type_is_matrix(slang_type_specifier_type
);
193 _slang_type_is_vector(slang_type_specifier_type
);
195 extern slang_type_specifier_type
196 _slang_type_base(slang_type_specifier_type
);
199 _slang_type_dim(slang_type_specifier_type
);