mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[glsl-in] Handle simple casts
This commit is contained in:
committed by
Timo de Kort
parent
022b42c44b
commit
9041cd4b10
@@ -244,10 +244,25 @@ pomelo! {
|
||||
function_call ::= function_call_or_method(fc) {
|
||||
match fc.kind {
|
||||
FunctionCallKind::TypeConstructor(ty) => {
|
||||
let h = extra.context.expressions.append(Expression::Compose {
|
||||
ty,
|
||||
components: fc.args.iter().map(|a| a.expression).collect(),
|
||||
});
|
||||
let h = if fc.args.len() == 1 {
|
||||
let kind = match extra.module.types[ty].inner {
|
||||
TypeInner::Scalar{kind, ..} => kind,
|
||||
TypeInner::Vector{kind, ..} => kind,
|
||||
_ => {
|
||||
return Err(ErrorKind::SemanticError("Can only cast to scalar or vector"));
|
||||
}
|
||||
};
|
||||
extra.context.expressions.append(Expression::As {
|
||||
kind,
|
||||
expr: fc.args[0].expression,
|
||||
convert: true,
|
||||
})
|
||||
} else {
|
||||
extra.context.expressions.append(Expression::Compose {
|
||||
ty,
|
||||
components: fc.args.iter().map(|a| a.expression).collect(),
|
||||
})
|
||||
};
|
||||
ExpressionRule {
|
||||
expression: h,
|
||||
statements: fc.args.into_iter().map(|a| a.statements).flatten().collect(),
|
||||
|
||||
Reference in New Issue
Block a user