Skip to content
This repository has been archived by the owner on Jan 29, 2025. It is now read-only.

Commit

Permalink
Check if the declaration is constant.
Browse files Browse the repository at this point in the history
  • Loading branch information
sjinno committed Nov 9, 2021
1 parent 0eb72b3 commit 86ccdd7
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/front/glsl/parser/declarations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,14 +206,21 @@ impl<'source> ParsingContext<'source> {
// produce a constant just means we emit the expression as code;
// that is not an error.
let maybe_constant = if let Some((root, meta)) = init {
let expr = &ctx.ctx.expressions[root];
match *expr {
Expression::Load { .. } => None,
_ => match parser.solve_constant(ctx.ctx, root, meta) {
if !ctx.qualifiers.is_empty()
&& ctx.qualifiers.iter().all(|&(ref qualifier, _meta)| {
matches!(
*qualifier,
TypeQualifier::StorageQualifier(StorageQualifier::Const)
)
})
{
match parser.solve_constant(ctx.ctx, root, meta) {
Ok(res) => Some(res),
Err(err) if ctx.external => return Err(err),
_ => None,
},
}
} else {
None
}
} else {
None
Expand Down

0 comments on commit 86ccdd7

Please sign in to comment.