Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add reset_align function #494

Merged
merged 2 commits into from
Feb 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions crates/emitter/src/aligner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,10 @@ impl Aligner {
}
}

fn reset_align(&mut self) {
self.finish_group();
}

fn space(&mut self, repeat: usize) {
for i in 0..self.aligns.len() {
self.aligns[i].space(repeat);
Expand Down Expand Up @@ -778,8 +782,8 @@ impl VerylWalker for Aligner {
}
if let Some(ref x) = arg.function_declaration_opt1 {
self.minus_g_t(&x.minus_g_t);
// skip type align
//self.scalar_type(&x.scalar_type);
self.scalar_type(&x.scalar_type);
self.reset_align();
}
self.l_brace(&arg.l_brace);
for x in &arg.function_declaration_list {
Expand Down
14 changes: 9 additions & 5 deletions crates/formatter/src/aligner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,9 +94,9 @@ impl Align {
}
}

fn space(&mut self, x: u32) {
fn space(&mut self, x: usize) {
if self.enable {
self.width += x;
self.width += x as u32;
}
}
}
Expand Down Expand Up @@ -143,6 +143,10 @@ impl Aligner {
}
}

fn reset_align(&mut self) {
self.finish_group();
}

fn insert(&mut self, token: &VerylToken, width: usize) {
let loc: Location = token.token.into();
self.additions
Expand All @@ -151,7 +155,7 @@ impl Aligner {
.or_insert(width as u32);
}

fn space(&mut self, repeat: u32) {
fn space(&mut self, repeat: usize) {
for i in 0..self.aligns.len() {
self.aligns[i].space(repeat);
}
Expand Down Expand Up @@ -723,9 +727,9 @@ impl VerylWalker for Aligner {
}
if let Some(ref x) = arg.function_declaration_opt1 {
self.minus_g_t(&x.minus_g_t);
self.scalar_type(&x.scalar_type);
self.reset_align();
}
// skip type align
//self.scalar_type(&arg.scalar_type);
self.l_brace(&arg.l_brace);
for x in &arg.function_declaration_list {
self.function_item(&x.function_item);
Expand Down
Loading