mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
Add ArrayLength expression
This commit is contained in:
committed by
Dzmitry Malyshau
parent
bcd3db2dad
commit
74c4a3ce18
@@ -1042,6 +1042,10 @@ fn write_expression<'a, 'b>(
|
||||
.join(","),
|
||||
))
|
||||
}
|
||||
Expression::ArrayLength(expr) => {
|
||||
let base = write_expression(&builder.expressions[expr], module, builder)?;
|
||||
Cow::Owned(format!("uint({}.length())", base))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -635,6 +635,8 @@ pub enum Expression {
|
||||
origin: FunctionOrigin,
|
||||
arguments: Vec<Handle<Expression>>,
|
||||
},
|
||||
/// Get dynamic array length.
|
||||
ArrayLength(Handle<Expression>),
|
||||
}
|
||||
|
||||
/// A code block is just a vector of statements.
|
||||
|
||||
@@ -100,6 +100,9 @@ where
|
||||
self.traverse_expr(argument);
|
||||
}
|
||||
}
|
||||
E::ArrayLength(expr) => {
|
||||
self.traverse_expr(expr);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -262,6 +262,10 @@ impl Typifier {
|
||||
.ok_or(ResolveError::FunctionReturnsVoid)?;
|
||||
Resolution::Handle(ty)
|
||||
}
|
||||
crate::Expression::ArrayLength(_) => Resolution::Value(crate::TypeInner::Scalar {
|
||||
kind: crate::ScalarKind::Uint,
|
||||
width: 4,
|
||||
}),
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user