correctly handle hdl byte literal suffixes

This commit is contained in:
Jacob Lifshay 2024-07-16 19:45:12 -07:00
parent c2e5ea8e89
commit 63fd038729
Signed by: programmerjake
SSH key fingerprint: SHA256:B1iRVvUJkvd7upMIiMqn6OyxvD2SgJkAH3ZnUOj6z+c
2 changed files with 11 additions and 8 deletions

View file

@ -1392,13 +1392,16 @@ impl Visitor {
fn process_literal(&mut self, literal: ExprLit) -> Expr { fn process_literal(&mut self, literal: ExprLit) -> Expr {
let ExprLit { attrs, lit } = literal; let ExprLit { attrs, lit } = literal;
match &lit { match &lit {
Lit::Byte(lit_byte) if lit_byte.suffix() == "hdl" => { Lit::Byte(lit_byte) => {
if let Some(retval) = self.process_int_literal( let trimmed_suffix = lit_byte.suffix().trim_start_matches('_');
lit_byte.span(), if trimmed_suffix == "hdl" || trimmed_suffix == "hdl_u8" {
&lit_byte.value().to_string(), if let Some(retval) = self.process_int_literal(
"hdl_u8", lit_byte.span(),
) { &lit_byte.value().to_string(),
return retval; "hdl_u8",
) {
return retval;
}
} }
} }
Lit::Int(lit_int) => { Lit::Int(lit_int) => {

View file

@ -57,7 +57,7 @@ pub fn my_module(width: usize) {
m.connect( m.connect(
o, o,
#[hdl] #[hdl]
[r, r, 13_hdl_u8], [r, r, b'\r'_hdl],
); );
m.connect(o[1], 30_hdl_u8); m.connect(o[1], 30_hdl_u8);
m.connect(o2, i2); m.connect(o2, i2);