mirror of
https://github.com/gfx-rs/wgpu.git
synced 2024-11-30 02:33:38 +00:00
TypifyError with the expression handle
This commit is contained in:
parent
19e7f456c4
commit
db0a8875d9
@ -158,16 +158,16 @@ fn main() {
|
||||
}
|
||||
};
|
||||
|
||||
// validate the IR
|
||||
let analysis = naga::proc::Validator::new()
|
||||
.validate(&module)
|
||||
.unwrap_pretty();
|
||||
|
||||
if args.len() <= 2 {
|
||||
println!("{:#?}", module);
|
||||
return;
|
||||
}
|
||||
|
||||
// validate the IR
|
||||
let analysis = naga::proc::Validator::new()
|
||||
.validate(&module)
|
||||
.unwrap_pretty();
|
||||
|
||||
match Path::new(&args[2])
|
||||
.extension()
|
||||
.expect("Output has no extension?")
|
||||
|
@ -44,7 +44,7 @@
|
||||
pub use features::Features;
|
||||
|
||||
use crate::{
|
||||
proc::{analyzer::Analysis, NameKey, Namer, ResolveContext, ResolveError, Typifier},
|
||||
proc::{analyzer::Analysis, NameKey, Namer, ResolveContext, TypifyError, Typifier},
|
||||
Arena, ArraySize, BinaryOperator, Binding, BuiltIn, Bytes, ConservativeDepth, Constant,
|
||||
ConstantInner, DerivativeAxis, Expression, FastHashMap, Function, GlobalVariable, Handle,
|
||||
ImageClass, Interpolation, LocalVariable, Module, RelationalFunction, ScalarKind, ScalarValue,
|
||||
@ -220,7 +220,7 @@ pub enum Error {
|
||||
IoError(#[from] IoError),
|
||||
/// The [`Module`](crate::Module) failed type resolution
|
||||
#[error("Type error: {0}")]
|
||||
Type(#[from] ResolveError),
|
||||
Type(#[from] TypifyError),
|
||||
/// The specified [`Version`](Version) doesn't have all required [`Features`](super)
|
||||
///
|
||||
/// Contains the missing [`Features`](Features)
|
||||
|
@ -16,7 +16,7 @@ we move them up to the root output structure that we define ourselves.
|
||||
|
||||
use crate::{
|
||||
arena::Handle,
|
||||
proc::{analyzer::Analysis, ResolveError},
|
||||
proc::{analyzer::Analysis, TypifyError},
|
||||
FastHashMap,
|
||||
};
|
||||
use std::{
|
||||
@ -60,7 +60,7 @@ enum ResolvedBinding {
|
||||
pub enum Error {
|
||||
IO(IoError),
|
||||
Utf8(FromUtf8Error),
|
||||
Type(ResolveError),
|
||||
Type(TypifyError),
|
||||
MissingBindTarget(BindSource),
|
||||
InvalidImageAccess(crate::StorageAccess),
|
||||
BadName(String),
|
||||
@ -87,8 +87,8 @@ impl From<FromUtf8Error> for Error {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<ResolveError> for Error {
|
||||
fn from(e: ResolveError) -> Self {
|
||||
impl From<TypifyError> for Error {
|
||||
fn from(e: TypifyError) -> Self {
|
||||
Error::Type(e)
|
||||
}
|
||||
}
|
||||
@ -155,10 +155,8 @@ impl Options {
|
||||
group,
|
||||
binding,
|
||||
};
|
||||
self.binding_map
|
||||
.get(&source)
|
||||
.cloned()
|
||||
.map(ResolvedBinding::Resource)
|
||||
ResolvedBinding::Resource(
|
||||
self.binding_map.get(&source).cloned().
|
||||
.ok_or(Error::MissingBindTarget(source))
|
||||
}
|
||||
None => {
|
||||
|
@ -4,7 +4,7 @@ use crate::{
|
||||
arena::{Arena, Handle},
|
||||
proc::{
|
||||
analyzer::{Analysis, FunctionInfo},
|
||||
Layouter, ResolveContext, ResolveError, Typifier,
|
||||
Layouter, ResolveContext, TypifyError, Typifier,
|
||||
},
|
||||
};
|
||||
use spirv::Word;
|
||||
@ -22,7 +22,7 @@ pub enum Error {
|
||||
#[error("unimplemented {0:}")]
|
||||
FeatureNotImplemented(&'static str),
|
||||
#[error(transparent)]
|
||||
Resolve(#[from] ResolveError),
|
||||
Resolve(#[from] TypifyError),
|
||||
}
|
||||
|
||||
struct Block {
|
||||
|
@ -12,7 +12,7 @@ pub use interface::{Interface, Visitor};
|
||||
pub use layouter::{Alignment, Layouter};
|
||||
pub use namer::{EntryPointIndex, NameKey, Namer};
|
||||
pub use terminator::ensure_block_returns;
|
||||
pub use typifier::{ResolveContext, ResolveError, Typifier};
|
||||
pub use typifier::{ResolveContext, ResolveError, Typifier, TypifyError};
|
||||
pub use validator::{ValidationError, Validator};
|
||||
|
||||
impl From<super::StorageFormat> for super::ScalarKind {
|
||||
|
@ -62,6 +62,10 @@ pub enum ResolveError {
|
||||
},
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Error, PartialEq)]
|
||||
#[error("Type resolution of {0:?} failed: {1}")]
|
||||
pub struct TypifyError(Handle<crate::Expression>, #[source] ResolveError);
|
||||
|
||||
pub struct ResolveContext<'a> {
|
||||
pub constants: &'a Arena<crate::Constant>,
|
||||
pub global_vars: &'a Arena<crate::GlobalVariable>,
|
||||
@ -527,10 +531,12 @@ impl Typifier {
|
||||
expressions: &Arena<crate::Expression>,
|
||||
types: &Arena<crate::Type>,
|
||||
ctx: &ResolveContext,
|
||||
) -> Result<(), ResolveError> {
|
||||
) -> Result<(), TypifyError> {
|
||||
self.clear();
|
||||
for (_, expr) in expressions.iter() {
|
||||
let resolution = self.resolve_impl(expr, types, ctx)?;
|
||||
for (handle, expr) in expressions.iter() {
|
||||
let resolution = self
|
||||
.resolve_impl(expr, types, ctx)
|
||||
.map_err(|err| TypifyError(handle, err))?;
|
||||
self.resolutions.push(resolution);
|
||||
}
|
||||
Ok(())
|
||||
|
@ -1,6 +1,6 @@
|
||||
use super::{
|
||||
analyzer::{Analysis, AnalysisError, FunctionInfo, GlobalUse},
|
||||
typifier::{ResolveContext, ResolveError, Typifier},
|
||||
typifier::{TypifyError, ResolveContext, Typifier},
|
||||
};
|
||||
use crate::arena::{Arena, Handle};
|
||||
use bit_set::BitSet;
|
||||
@ -78,7 +78,7 @@ pub enum LocalVariableError {
|
||||
#[derive(Clone, Debug, thiserror::Error)]
|
||||
pub enum FunctionError {
|
||||
#[error(transparent)]
|
||||
Resolve(#[from] ResolveError),
|
||||
Resolve(#[from] TypifyError),
|
||||
#[error("There are instructions after `return`/`break`/`continue`")]
|
||||
InvalidControlFlowExitTail,
|
||||
#[error("Local variable {handle:?} '{name}' is invalid: {error:?}")]
|
||||
|
Loading…
Reference in New Issue
Block a user