mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[wgsl] fix boolean types and bang parsing
This commit is contained in:
committed by
Dzmitry Malyshau
parent
91a1f581e0
commit
e6251a23fe
@@ -130,6 +130,7 @@ fn consume_token(mut input: &str) -> (Token<'_>, &str) {
|
||||
}
|
||||
'+' | '*' | '/' | '%' | '^' => (Token::Operation(cur), chars.as_str()),
|
||||
'!' => {
|
||||
input = chars.as_str();
|
||||
if chars.next() == Some('=') {
|
||||
(Token::LogicalOperation(cur), chars.as_str())
|
||||
} else {
|
||||
|
||||
@@ -1258,6 +1258,10 @@ impl Parser {
|
||||
kind: crate::ScalarKind::Uint,
|
||||
width: 4,
|
||||
},
|
||||
"bool" => crate::TypeInner::Scalar {
|
||||
kind: crate::ScalarKind::Bool,
|
||||
width: 1,
|
||||
},
|
||||
"vec2" => {
|
||||
let (kind, width) = lexer.next_scalar_generic()?;
|
||||
crate::TypeInner::Vector {
|
||||
|
||||
@@ -216,5 +216,6 @@ fn parse_expressions() {
|
||||
parse_str("fn foo() {
|
||||
const x: f32 = select(0.0, 1.0, true);
|
||||
const y: vec2<f32> = select(vec2<f32>(1.0, 1.0), vec2<f32>(x, x), vec2<bool>(x < 0.5, x > 0.5));
|
||||
const z: bool = !(0.0 == 1.0);
|
||||
}").unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user