mirror of
https://gitlab.cern.ch/wotsubo/endcap-sl-software-ri-generator.git
synced 2025-02-23 09:07:07 +09:00
change(validator): add AddressOutofRange error
This commit is contained in:
parent
06a5429583
commit
76595d0c92
1 changed files with 12 additions and 3 deletions
|
@ -24,6 +24,8 @@ pub enum ValidationError {
|
||||||
existing_name: String,
|
existing_name: String,
|
||||||
new_name: String,
|
new_name: String,
|
||||||
},
|
},
|
||||||
|
#[error("address 0x{address:08x} is out of range: \"{name}\"")]
|
||||||
|
AddressOutofRange { address: u32, name: String },
|
||||||
#[error("unsupported structure: {msg}")]
|
#[error("unsupported structure: {msg}")]
|
||||||
UnsupportedStructure { msg: &'static str },
|
UnsupportedStructure { msg: &'static str },
|
||||||
}
|
}
|
||||||
|
@ -105,9 +107,16 @@ impl Validate for Register {
|
||||||
};
|
};
|
||||||
for id in 0..len {
|
for id in 0..len {
|
||||||
let addr = addr + id * offset;
|
let addr = addr + id * offset;
|
||||||
let regmap: &mut Option<_> = mapping
|
let regmap: &mut Option<_> = match mapping.get_mut::<usize>(addr.try_into().unwrap()) {
|
||||||
.get_mut::<usize>(addr.try_into().unwrap())
|
Some(regmap) => regmap,
|
||||||
.expect("index of mapping out of range");
|
None => {
|
||||||
|
errors.push(ValidationError::AddressOutofRange {
|
||||||
|
address: addr,
|
||||||
|
name: self.name.clone(),
|
||||||
|
});
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
};
|
||||||
if let Some(old) = regmap {
|
if let Some(old) = regmap {
|
||||||
let existing_name = {
|
let existing_name = {
|
||||||
let mut path = old.0.clone();
|
let mut path = old.0.clone();
|
||||||
|
|
Loading…
Reference in a new issue