Fixes CorrectParse1.frag and makes for a ton of folding in
CorrectParse2.frag.
* declaration.
*/
if (this->type->qualifier.constant) {
- rhs = rhs->constant_expression_value();
- if (!rhs) {
+ ir_constant *constant_value = rhs->constant_expression_value();
+ if (!constant_value) {
_mesa_glsl_error(& initializer_loc, state,
"initializer of const variable `%s' must be a "
"constant expression",
decl->identifier);
+ } else {
+ rhs = constant_value;
+ var->constant_value = constant_value;
}
}
{
this->type = type;
this->name = name;
+ this->constant_value = NULL;
if (type && type->base_type == GLSL_TYPE_SAMPLER)
this->read_only = true;
* equality). This flag enables this behavior.
*/
unsigned array_lvalue:1;
+
+ /**
+ * Value assigned in the initializer of a variable declared "const"
+ */
+ ir_constant *constant_value;
};
void
ir_constant_visitor::visit(ir_dereference *ir)
{
- (void) ir;
value = NULL;
+
+ if (ir->mode == ir_dereference::ir_reference_variable) {
+ ir_variable *var = ir->var->as_variable();
+ if (var && var->constant_value) {
+ value = new ir_constant(ir->type, &var->constant_value->value);
+ }
+ }
+ /* FINISHME: Other dereference modes. */
}