diff options
author | Sergey Pepyakin <s.pepyakin@gmail.com> | 2017-10-10 15:39:06 +0300 |
---|---|---|
committer | Sergey Pepyakin <s.pepyakin@gmail.com> | 2017-10-10 22:58:33 +0300 |
commit | cb7495d2b318d0986229e53c04a2e975f9ec8f15 (patch) | |
tree | e3aa0fdb9d13ba32d66b78e0496814dc7f193bf7 /src/codegen/helpers.rs | |
parent | 5dbdadc5cc1d15e23d804b4d0ce80cae90338ef7 (diff) |
Emit hex bitfield masks
Diffstat (limited to 'src/codegen/helpers.rs')
-rw-r--r-- | src/codegen/helpers.rs | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/codegen/helpers.rs b/src/codegen/helpers.rs index 9a8b0576..4ff398c4 100644 --- a/src/codegen/helpers.rs +++ b/src/codegen/helpers.rs @@ -143,6 +143,13 @@ pub mod ast_ty { tokens } + /// Returns hex representation of the given value. + pub fn hex_expr(val: u64) -> quote::Tokens { + let mut tokens = quote! {}; + tokens.append(format!("{:#x}", val)); + tokens + } + pub fn byte_array_expr(bytes: &[u8]) -> quote::Tokens { let mut bytes: Vec<_> = bytes.iter().cloned().collect(); bytes.push(0); |