mirror of
https://github.com/vosen/ZLUDA.git
synced 2025-07-20 18:56:24 +03:00
More descriptive message for unknown symbol (#411)
This commit is contained in:
@ -34,7 +34,9 @@ const ZLUDA_PTX_PREFIX: &'static str = "__zluda_ptx_impl_";
|
|||||||
quick_error! {
|
quick_error! {
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub enum TranslateError {
|
pub enum TranslateError {
|
||||||
UnknownSymbol {}
|
UnknownSymbol(symbol: String) {
|
||||||
|
display("Unknown symbol: \"{}\"", symbol)
|
||||||
|
}
|
||||||
UntypedSymbol {}
|
UntypedSymbol {}
|
||||||
MismatchedType {}
|
MismatchedType {}
|
||||||
Unreachable {}
|
Unreachable {}
|
||||||
@ -170,13 +172,13 @@ fn error_todo() -> TranslateError {
|
|||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
fn error_unknown_symbol() -> TranslateError {
|
fn error_unknown_symbol<T: Into<String>>(symbol: T) -> TranslateError {
|
||||||
panic!()
|
panic!("Unknown symbol: \"{}\"", symbol.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
fn error_unknown_symbol() -> TranslateError {
|
fn error_unknown_symbol<T: Into<String>>(symbol: T) -> TranslateError {
|
||||||
TranslateError::UnknownSymbol
|
TranslateError::UnknownSymbol(symbol.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
@ -691,7 +693,7 @@ impl<'input> GlobalStringIdentResolver2<'input> {
|
|||||||
type_space: Some(type_space),
|
type_space: Some(type_space),
|
||||||
..
|
..
|
||||||
}) => Ok(type_space),
|
}) => Ok(type_space),
|
||||||
_ => Err(error_unknown_symbol()),
|
_ => Err(error_unknown_symbol(format!("{:?}", id))),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -737,7 +739,7 @@ impl<'input, 'b> ScopedResolver<'input, 'b> {
|
|||||||
.get(&ident)
|
.get(&ident)
|
||||||
.ok_or_else(|| error_unreachable())?;
|
.ok_or_else(|| error_unreachable())?;
|
||||||
if entry.type_space.is_some() {
|
if entry.type_space.is_some() {
|
||||||
return Err(error_unknown_symbol());
|
return Err(error_unknown_symbol(name));
|
||||||
}
|
}
|
||||||
ident
|
ident
|
||||||
}
|
}
|
||||||
@ -771,7 +773,7 @@ impl<'input, 'b> ScopedResolver<'input, 'b> {
|
|||||||
.insert(name.clone(), result)
|
.insert(name.clone(), result)
|
||||||
.is_some()
|
.is_some()
|
||||||
{
|
{
|
||||||
return Err(error_unknown_symbol());
|
return Err(error_unknown_symbol(name));
|
||||||
}
|
}
|
||||||
current_scope.ident_map.insert(
|
current_scope.ident_map.insert(
|
||||||
result,
|
result,
|
||||||
@ -788,7 +790,7 @@ impl<'input, 'b> ScopedResolver<'input, 'b> {
|
|||||||
.iter()
|
.iter()
|
||||||
.rev()
|
.rev()
|
||||||
.find_map(|resolver| resolver.name_to_ident.get(name).copied())
|
.find_map(|resolver| resolver.name_to_ident.get(name).copied())
|
||||||
.ok_or_else(|| error_unreachable())
|
.ok_or_else(|| error_unknown_symbol(name))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_in_current_scope(&self, label: &'input str) -> Result<SpirvWord, TranslateError> {
|
fn get_in_current_scope(&self, label: &'input str) -> Result<SpirvWord, TranslateError> {
|
||||||
|
Reference in New Issue
Block a user