Skip to content

Commit

Permalink
a few type handling improvements (#46)
Browse files Browse the repository at this point in the history
- pass booleans by value through action parameters
- use full form of BitVec::<u8,Msb0> in code generation to allow
  for default instantiation.
  • Loading branch information
rcgoodfellow committed Apr 29, 2024
1 parent da51567 commit 526a5bd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion codegen/rust/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ fn rust_type(ty: &Type) -> TokenStream {
Type::Bool => quote! { bool },
Type::Error => todo!("generate error type"),
Type::Bit(_size) => {
quote! { BitVec<u8, Msb0> }
quote! { BitVec::<u8, Msb0> }
}
Type::Int(_size) => todo!("generate int type"),
Type::Varbit(_size) => todo!("generate varbit type"),
Expand Down
12 changes: 10 additions & 2 deletions codegen/rust/src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -840,7 +840,11 @@ impl<'a> PipelineGenerator<'a> {
control_param_types.push(quote! { &mut #ty });
}
_ => {
control_param_types.push(quote! { &#ty });
if p.ty == Type::Bool {
control_param_types.push(quote! { #ty });
} else {
control_param_types.push(quote! { &#ty });
}
}
}
}
Expand Down Expand Up @@ -949,7 +953,11 @@ impl<'a> PipelineGenerator<'a> {
control_param_types.push(quote! { &mut #ty });
}
_ => {
control_param_types.push(quote! { &#ty });
if p.ty == Type::Bool {
control_param_types.push(quote! { #ty });
} else {
control_param_types.push(quote! { &#ty });
}
}
}
}
Expand Down

0 comments on commit 526a5bd

Please sign in to comment.