mirror of
https://github.com/gfx-rs/wgpu.git
synced 2026-04-22 03:02:01 -04:00
[glsl-in] return error in constant math functions
This commit is contained in:
committed by
Dzmitry Malyshau
parent
7ef095881b
commit
e4bc844ba0
@@ -153,9 +153,7 @@ impl<'a> Program<'a> {
|
||||
constants: &mut self.module.constants,
|
||||
};
|
||||
|
||||
solver
|
||||
.solve(root)
|
||||
.map_err(|_| ErrorKind::SemanticError(meta, "Can't solve constant".into()))
|
||||
solver.solve(root).map_err(|e| (meta, e).into())
|
||||
}
|
||||
|
||||
pub fn function_args_prelude(&self) -> (Vec<FunctionArgument>, Vec<ParameterQualifier>) {
|
||||
|
||||
@@ -51,6 +51,8 @@ pub enum ConstantSolvingError {
|
||||
InvalidBinaryOpArgs,
|
||||
#[error("Splat/swizzle type is not registered")]
|
||||
DestinationTypeNotFound,
|
||||
#[error("Not implemented: {0}")]
|
||||
NotImplemented(String),
|
||||
}
|
||||
|
||||
impl<'a> ConstantSolver<'a> {
|
||||
@@ -152,7 +154,9 @@ impl<'a> ConstantSolver<'a> {
|
||||
|
||||
self.binary_op(op, left_constant, right_constant)
|
||||
}
|
||||
Expression::Math { .. } => todo!(),
|
||||
Expression::Math { fun, .. } => {
|
||||
Err(ConstantSolvingError::NotImplemented(format!("{:?}", fun)))
|
||||
}
|
||||
Expression::As {
|
||||
convert,
|
||||
expr,
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
use super::token::{SourceMetadata, Token};
|
||||
use super::{
|
||||
constants::ConstantSolvingError,
|
||||
token::{SourceMetadata, Token},
|
||||
};
|
||||
use std::borrow::Cow;
|
||||
use thiserror::Error;
|
||||
|
||||
@@ -58,6 +61,12 @@ impl ErrorKind {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<(SourceMetadata, ConstantSolvingError)> for ErrorKind {
|
||||
fn from((meta, err): (SourceMetadata, ConstantSolvingError)) -> Self {
|
||||
ErrorKind::SemanticError(meta, err.to_string().into())
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Error)]
|
||||
#[error("{kind}")]
|
||||
pub struct ParseError {
|
||||
|
||||
@@ -499,7 +499,7 @@ impl<'source, 'program, 'options> Parser<'source, 'program, 'options> {
|
||||
|
||||
let init = self
|
||||
.bump_if(TokenValue::Assign)
|
||||
.map(|_| {
|
||||
.map::<Result<_>, _>(|_| {
|
||||
let (expr, init_meta) = self.parse_initializer(ty, ctx.ctx, ctx.body)?;
|
||||
meta = meta.union(&init_meta);
|
||||
Ok((expr, init_meta))
|
||||
|
||||
Reference in New Issue
Block a user