Skip to content

Commit

Permalink
fix field derive
Browse files Browse the repository at this point in the history
  • Loading branch information
burrbull committed Oct 1, 2023
1 parent 8dd361f commit e3087cc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/).

## [Unreleased]

- Fix `derivedFrom` on field

## [v0.30.0] - 2023-08-16

- Add `aarch64` target for releases, more readme badges
Expand Down
11 changes: 6 additions & 5 deletions src/generate/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -554,12 +554,11 @@ pub fn fields(
let inline = quote! { #[inline(always)] };
for &f in fields.iter() {
let mut f = f.clone();
let mut fpath = None;
let dpath = f.derived_from.take();
if let Some(dpath) = dpath {
fpath = derive_field(&mut f, &dpath, rpath, index)?;
let mut fdpath = None;
if let Some(dpath) = f.derived_from.take() {
fdpath = derive_field(&mut f, &dpath, rpath, index)?;
}
let fpath = fpath.unwrap_or_else(|| rpath.new_field(&f.name));
let fpath = rpath.new_field(&f.name);
// TODO(AJM) - do we need to do anything with this range type?
let BitRange { offset, width, .. } = f.bit_range;

Expand Down Expand Up @@ -601,6 +600,8 @@ pub fn fields(
let dpath = ev.derived_from.take();
if let Some(dpath) = dpath {
epath = Some(derive_enumerated_values(&mut ev, &dpath, &fpath, index)?);
} else if let Some(path) = fdpath.as_ref() {
epath = Some(path.new_enum(ev.name.clone().unwrap()));
}
// TODO: remove this hack
if let Some(epath) = epath.as_ref() {
Expand Down

0 comments on commit e3087cc

Please sign in to comment.