mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[wgsl] add min/max support
This commit is contained in:
committed by
Dzmitry Malyshau
parent
ef4e8cacf9
commit
b597bc5af6
@@ -626,6 +626,17 @@ impl Parser {
|
||||
})
|
||||
} else {
|
||||
match word {
|
||||
"min" | "max" => {
|
||||
lexer.expect(Token::Paren('('))?;
|
||||
let a = self.parse_primary_expression(lexer, ctx.reborrow())?;
|
||||
lexer.expect(Token::Separator(','))?;
|
||||
let b = self.parse_primary_expression(lexer, ctx.reborrow())?;
|
||||
lexer.expect(Token::Paren(')'))?;
|
||||
Some(crate::Expression::Call {
|
||||
origin: crate::FunctionOrigin::External(word.to_string()),
|
||||
arguments: vec![a, b],
|
||||
})
|
||||
}
|
||||
"dot" => {
|
||||
lexer.expect(Token::Paren('('))?;
|
||||
let a = self.parse_primary_expression(lexer, ctx.reborrow())?;
|
||||
|
||||
@@ -6,6 +6,20 @@ fn parse_types() {
|
||||
assert!(parse_str("const a : x32 = 2;").is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_type_cast() {
|
||||
parse_str(
|
||||
"
|
||||
const a : i32 = 2;
|
||||
fn main() {
|
||||
var x: f32 = f32(a);
|
||||
#x = f32(i32(a + 1) / 2); //TODO
|
||||
}
|
||||
",
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parse_if() {
|
||||
parse_str(
|
||||
|
||||
Reference in New Issue
Block a user