summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsrc/codegen/mod.rs2
-rw-r--r--src/ir/int.rs11
-rw-r--r--src/ir/var.rs16
3 files changed, 12 insertions, 17 deletions
diff --git a/src/codegen/mod.rs b/src/codegen/mod.rs
index e8c507a1..0c1c31da 100755
--- a/src/codegen/mod.rs
+++ b/src/codegen/mod.rs
@@ -1462,7 +1462,7 @@ impl ToRustTy for Type {
IntKind::U32 => aster::ty::TyBuilder::new().u32(),
IntKind::I64 => aster::ty::TyBuilder::new().i64(),
IntKind::U64 => aster::ty::TyBuilder::new().u64(),
- IntKind::Custom(name, _signed) => {
+ IntKind::Custom { name, .. } => {
let ident = ctx.rust_ident_raw(name);
quote_ty!(ctx.ext_cx(), $ident)
}
diff --git a/src/ir/int.rs b/src/ir/int.rs
index 562169f7..2d85db83 100644
--- a/src/ir/int.rs
+++ b/src/ir/int.rs
@@ -68,9 +68,12 @@ pub enum IntKind {
/// A custom integer type, used to allow custom macro types depending on
/// range.
- ///
- /// The boolean means a whether this is a signed integer type or not.
- Custom(&'static str, bool),
+ Custom {
+ /// The name of the type, which would be used without modification.
+ name: &'static str,
+ /// Whether the type is signed or not.
+ is_signed: bool,
+ },
}
impl IntKind {
@@ -84,7 +87,7 @@ impl IntKind {
Char | Short | Int | Long | LongLong | I8 | I16 | I32 | I64 |
I128 => true,
- Custom(_, signed) => signed,
+ Custom { is_signed, .. } => is_signed,
}
}
}
diff --git a/src/ir/var.rs b/src/ir/var.rs
index 0c09bad4..047e8642 100644
--- a/src/ir/var.rs
+++ b/src/ir/var.rs
@@ -111,16 +111,9 @@ impl ClangSubItemParser for Var {
EvalResult::Invalid => return Err(ParseError::Continue),
EvalResult::Int(Wrapping(value)) => {
- let kind = match ctx.options().type_chooser {
- Some(ref chooser) => {
- chooser.int_macro(&name, value)
- }
- None => None,
- };
-
- let kind = match kind {
- Some(kind) => kind,
- None => {
+ let kind = ctx.options().type_chooser.as_ref()
+ .and_then(|c| c.int_macro(&name, value))
+ .unwrap_or_else(|| {
if value < 0 {
if value < i32::min_value() as i64 {
IntKind::LongLong
@@ -132,8 +125,7 @@ impl ClangSubItemParser for Var {
} else {
IntKind::UInt
}
- }
- };
+ });
(kind, value)
}