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 {
let ExprLit { attrs, lit } = literal;
match &lit {
Lit::Byte(lit_byte) if lit_byte.suffix() == "hdl" => {
if let Some(retval) = self.process_int_literal(
lit_byte.span(),
&lit_byte.value().to_string(),
"hdl_u8",
) {
return retval;
Lit::Byte(lit_byte) => {
let trimmed_suffix = lit_byte.suffix().trim_start_matches('_');
if trimmed_suffix == "hdl" || trimmed_suffix == "hdl_u8" {
if let Some(retval) = self.process_int_literal(
lit_byte.span(),
&lit_byte.value().to_string(),
"hdl_u8",
) {
return retval;
}
}
}
Lit::Int(lit_int) => {

View file

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