struct _mesa_glsl_parse_state *state,
YYLTYPE *loc)
{
- if (qual->invariant)
+ if (qual->flags.q.invariant)
var->invariant = 1;
/* FINISHME: Mark 'in' variables at global scope as read-only. */
- if (qual->constant || qual->attribute || qual->uniform
- || (qual->varying && (state->target == fragment_shader)))
+ if (qual->flags.q.constant || qual->flags.q.attribute
+ || qual->flags.q.uniform
+ || (qual->flags.q.varying && (state->target == fragment_shader)))
var->read_only = 1;
- if (qual->centroid)
+ if (qual->flags.q.centroid)
var->centroid = 1;
- if (qual->attribute && state->target != vertex_shader) {
+ if (qual->flags.q.attribute && state->target != vertex_shader) {
var->type = glsl_type::error_type;
_mesa_glsl_error(loc, state,
"`attribute' variables may not be declared in the "
* float, vec2, vec3, vec4, mat2, mat3, and mat4, or arrays of
* these."
*/
- if (qual->varying) {
+ if (qual->flags.q.varying) {
const glsl_type *non_array_type;
if (var->type && var->type->is_array())
/* If there is no qualifier that changes the mode of the variable, leave
* the setting alone.
*/
- if (qual->in && qual->out)
+ if (qual->flags.q.in && qual->flags.q.out)
var->mode = ir_var_inout;
- else if (qual->attribute || qual->in
- || (qual->varying && (state->target == fragment_shader)))
+ else if (qual->flags.q.attribute || qual->flags.q.in
+ || (qual->flags.q.varying && (state->target == fragment_shader)))
var->mode = ir_var_in;
- else if (qual->out || (qual->varying && (state->target == vertex_shader)))
+ else if (qual->flags.q.out
+ || (qual->flags.q.varying && (state->target == vertex_shader)))
var->mode = ir_var_out;
- else if (qual->uniform)
+ else if (qual->flags.q.uniform)
var->mode = ir_var_uniform;
- if (qual->flat)
+ if (qual->flags.q.flat)
var->interpolation = ir_var_flat;
- else if (qual->noperspective)
+ else if (qual->flags.q.noperspective)
var->interpolation = ir_var_noperspective;
else
var->interpolation = ir_var_smooth;
- var->pixel_center_integer = qual->pixel_center_integer;
- var->origin_upper_left = qual->origin_upper_left;
- if ((qual->origin_upper_left || qual->pixel_center_integer)
+ var->pixel_center_integer = qual->flags.q.pixel_center_integer;
+ var->origin_upper_left = qual->flags.q.origin_upper_left;
+ if ((qual->flags.q.origin_upper_left || qual->flags.q.pixel_center_integer)
&& (strcmp(var->name, "gl_FragCoord") != 0)) {
- const char *const qual_string = (qual->origin_upper_left)
+ const char *const qual_string = (qual->flags.q.origin_upper_left)
? "origin_upper_left" : "pixel_center_integer";
_mesa_glsl_error(loc, state,
* This is relaxed in GLSL 1.30.
*/
if (state->language_version < 120) {
- if (this->type->qualifier.out) {
+ if (this->type->qualifier.flags.q.out) {
_mesa_glsl_error(& loc, state,
"`out' qualifier in declaration of `%s' "
"only valid for function parameters in GLSL 1.10.",
decl->identifier);
}
- if (this->type->qualifier.in) {
+ if (this->type->qualifier.flags.q.in) {
_mesa_glsl_error(& loc, state,
"`in' qualifier in declaration of `%s' "
"only valid for function parameters in GLSL 1.10.",
apply_type_qualifier_to_variable(& this->type->qualifier, var, state,
& loc);
- if (this->type->qualifier.invariant) {
+ if (this->type->qualifier.flags.q.invariant) {
if ((state->target == vertex_shader) && !(var->mode == ir_var_out ||
var->mode == ir_var_inout)) {
/* FINISHME: Note that this doesn't work for invariant on
/* There is no need to check for 'inout' here because the parser will
* only allow that in function parameter lists.
*/
- if (this->type->qualifier.attribute) {
+ if (this->type->qualifier.flags.q.attribute) {
mode = "attribute";
- } else if (this->type->qualifier.uniform) {
+ } else if (this->type->qualifier.flags.q.uniform) {
mode = "uniform";
- } else if (this->type->qualifier.varying) {
+ } else if (this->type->qualifier.flags.q.varying) {
mode = "varying";
- } else if (this->type->qualifier.in) {
+ } else if (this->type->qualifier.flags.q.in) {
mode = "in";
extra = " or in function parameter list";
- } else if (this->type->qualifier.out) {
+ } else if (this->type->qualifier.flags.q.out) {
mode = "out";
extra = " or in function parameter list";
}
/* Calculate the constant value if this is a const or uniform
* declaration.
*/
- if (this->type->qualifier.constant || this->type->qualifier.uniform) {
+ if (this->type->qualifier.flags.q.constant
+ || this->type->qualifier.flags.q.uniform) {
ir_rvalue *new_rhs = validate_assignment(state, var->type, rhs);
if (new_rhs != NULL) {
rhs = new_rhs;
_mesa_glsl_error(& initializer_loc, state,
"initializer of %s variable `%s' must be a "
"constant expression",
- (this->type->qualifier.constant)
+ (this->type->qualifier.flags.q.constant)
? "const" : "uniform",
decl->identifier);
if (var->type->is_numeric()) {
if (rhs && !rhs->type->is_error()) {
bool temp = var->read_only;
- if (this->type->qualifier.constant)
+ if (this->type->qualifier.flags.q.constant)
var->read_only = false;
/* Never emit code to initialize a uniform.
*/
- if (!this->type->qualifier.uniform)
+ if (!this->type->qualifier.flags.q.uniform)
result = do_assignment(&initializer_instructions, state,
lhs, rhs,
this->get_location());
* its declaration, so they must be initialized when
* declared."
*/
- if (this->type->qualifier.constant && decl->initializer == NULL) {
+ if (this->type->qualifier.flags.q.constant && decl->initializer == NULL) {
_mesa_glsl_error(& loc, state,
"const declaration of `%s' must be initialized");
}
float real;
char *identifier;
- union {
- struct ast_type_qualifier q;
- unsigned i;
- } type_qualifier;
+ struct ast_type_qualifier type_qualifier;
ast_node *node;
ast_type_specifier *type_specifier;
parameter_declaration:
parameter_type_qualifier parameter_qualifier parameter_declarator
{
- $1.i |= $2.i;
+ $1.flags.i |= $2.flags.i;
$$ = $3;
- $$->type->qualifier = $1.q;
+ $$->type->qualifier = $1;
}
| parameter_qualifier parameter_declarator
{
$$ = $2;
- $$->type->qualifier = $1.q;
+ $$->type->qualifier = $1;
}
| parameter_type_qualifier parameter_qualifier parameter_type_specifier
{
void *ctx = state;
- $1.i |= $2.i;
+ $1.flags.i |= $2.flags.i;
$$ = new(ctx) ast_parameter_declarator();
$$->set_location(yylloc);
$$->type = new(ctx) ast_fully_specified_type();
- $$->type->qualifier = $1.q;
+ $$->type->qualifier = $1;
$$->type->specifier = $3;
}
| parameter_qualifier parameter_type_specifier
$$ = new(ctx) ast_parameter_declarator();
$$->set_location(yylloc);
$$->type = new(ctx) ast_fully_specified_type();
- $$->type->qualifier = $1.q;
+ $$->type->qualifier = $1;
$$->type->specifier = $2;
}
;
| IN_TOK
{
memset(& $$, 0, sizeof($$));
- $$.q.in = 1;
+ $$.flags.q.in = 1;
}
| OUT_TOK
{
memset(& $$, 0, sizeof($$));
- $$.q.out = 1;
+ $$.flags.q.out = 1;
}
| INOUT_TOK
{
memset(& $$, 0, sizeof($$));
- $$.q.in = 1; $$.q.out = 1;
+ $$.flags.q.in = 1;
+ $$.flags.q.out = 1;
}
;
void *ctx = state;
$$ = new(ctx) ast_fully_specified_type();
$$->set_location(yylloc);
- $$->qualifier = $1.q;
+ $$->qualifier = $1;
$$->specifier = $2;
}
;
layout_qualifier_id
| layout_qualifier_id_list ',' layout_qualifier_id
{
- $$.i = $1.i | $3.i;
+ /* FINISHME: Should check for conflicting / duplicate flags here.
+ */
+ $$ = $1;
+ $$.flags.i |= $3.flags.i;
}
;
if (state->ARB_fragment_coord_conventions_enable) {
if (strcmp($1, "origin_upper_left") == 0) {
got_one = true;
- $$.q.origin_upper_left = 1;
+ $$.flags.q.origin_upper_left = 1;
} else if (strcmp($1, "pixel_center_integer") == 0) {
got_one = true;
- $$.q.pixel_center_integer = 1;
+ $$.flags.q.pixel_center_integer = 1;
}
}
SMOOTH
{
memset(& $$, 0, sizeof($$));
- $$.q.smooth = 1;
+ $$.flags.q.smooth = 1;
}
| FLAT
{
memset(& $$, 0, sizeof($$));
- $$.q.flat = 1;
+ $$.flags.q.flat = 1;
}
| NOPERSPECTIVE
{
memset(& $$, 0, sizeof($$));
- $$.q.noperspective = 1;
+ $$.flags.q.noperspective = 1;
}
;
CONST_TOK
{
memset(& $$, 0, sizeof($$));
- $$.q.constant = 1;
+ $$.flags.q.constant = 1;
}
;
| layout_qualifier
| layout_qualifier storage_qualifier
{
- $$.i = $1.i | $2.i;
+ $$ = $1;
+ $$.flags.i |= $2.flags.i;
}
| interpolation_qualifier
| interpolation_qualifier storage_qualifier
{
- $$.i = $1.i | $2.i;
+ $$ = $1;
+ $$.flags.i |= $2.flags.i;
}
| INVARIANT storage_qualifier
{
$$ = $2;
- $$.q.invariant = 1;
+ $$.flags.q.invariant = 1;
}
| INVARIANT interpolation_qualifier storage_qualifier
{
- $$.i = $2.i | $3.i;
- $$.q.invariant = 1;
+ $$ = $2;
+ $$.flags.i |= $3.flags.i;
+ $$.flags.q.invariant = 1;
}
| INVARIANT
{
memset(& $$, 0, sizeof($$));
- $$.q.invariant = 1;
+ $$.flags.q.invariant = 1;
}
;
CONST_TOK
{
memset(& $$, 0, sizeof($$));
- $$.q.constant = 1;
+ $$.flags.q.constant = 1;
}
| ATTRIBUTE
{
memset(& $$, 0, sizeof($$));
- $$.q.attribute = 1;
+ $$.flags.q.attribute = 1;
}
| VARYING
{
memset(& $$, 0, sizeof($$));
- $$.q.varying = 1;
+ $$.flags.q.varying = 1;
}
| CENTROID VARYING
{
memset(& $$, 0, sizeof($$));
- $$.q.centroid = 1; $$.q.varying = 1;
+ $$.flags.q.centroid = 1;
+ $$.flags.q.varying = 1;
}
| IN_TOK
{
memset(& $$, 0, sizeof($$));
- $$.q.in = 1;
+ $$.flags.q.in = 1;
}
| OUT_TOK
{
memset(& $$, 0, sizeof($$));
- $$.q.out = 1;
+ $$.flags.q.out = 1;
}
| CENTROID IN_TOK
{
memset(& $$, 0, sizeof($$));
- $$.q.centroid = 1; $$.q.in = 1;
+ $$.flags.q.centroid = 1; $$.flags.q.in = 1;
}
| CENTROID OUT_TOK
{
memset(& $$, 0, sizeof($$));
- $$.q.centroid = 1; $$.q.out = 1;
+ $$.flags.q.centroid = 1; $$.flags.q.out = 1;
}
| UNIFORM
{
memset(& $$, 0, sizeof($$));
- $$.q.uniform = 1;
+ $$.flags.q.uniform = 1;
}
;