mirror of
https://github.com/gfx-rs/wgpu.git
synced 2025-02-16 17:02:32 +00:00
[glsl-new] put validation errors behind featureUsing glsl-validate feature (#127)
This commit is contained in:
parent
b4e1775b9e
commit
7f780e8efc
@ -24,6 +24,7 @@ serde = { version = "1.0", features = ["derive"], optional = true }
|
||||
default = []
|
||||
glsl_preprocessor = ["glsl"]
|
||||
glsl-new = ["pomelo"]
|
||||
glsl-validate = []
|
||||
glsl-out = []
|
||||
serialize = ["serde"]
|
||||
deserialize = ["serde"]
|
||||
|
@ -63,6 +63,7 @@ impl Context {
|
||||
None
|
||||
}
|
||||
|
||||
#[cfg(feature = "glsl-validate")]
|
||||
pub fn lookup_local_var_current_scope(&self, name: &str) -> Option<Handle<LocalVariable>> {
|
||||
if let Some(current) = self.scopes.last() {
|
||||
current.get(name).cloned()
|
||||
|
@ -14,6 +14,7 @@ pub enum ErrorKind {
|
||||
ParserStackOverflow,
|
||||
NotImplemented(&'static str),
|
||||
UnknownVariable(TokenMetadata, String),
|
||||
#[cfg(feature = "glsl-validate")]
|
||||
VariableAlreadyDeclared(String),
|
||||
ExpectedConstant,
|
||||
SemanticError(&'static str),
|
||||
@ -38,6 +39,7 @@ impl fmt::Display for ErrorKind {
|
||||
ErrorKind::UnknownVariable(meta, val) => {
|
||||
write!(f, "Unknown variable {} at {:?}", val, meta)
|
||||
}
|
||||
#[cfg(feature = "glsl-validate")]
|
||||
ErrorKind::VariableAlreadyDeclared(val) => {
|
||||
write!(f, "Variable {} already decalred in current scope", val)
|
||||
}
|
||||
|
@ -545,6 +545,7 @@ pomelo! {
|
||||
// local variables
|
||||
for (id, initializer) in d.ids_initializers {
|
||||
// check if already declared in current scope
|
||||
#[cfg(feature = "glsl-validate")]
|
||||
if extra.context.lookup_local_var_current_scope(&id).is_some() {
|
||||
return Err(ErrorKind::VariableAlreadyDeclared(id))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user