Skip to content

Commit 4ee31ce

Browse files
committed
Address review comments.
1 parent b11e1db commit 4ee31ce

File tree

3 files changed

+12
-17
lines changed

3 files changed

+12
-17
lines changed

src/codegen/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,7 @@ impl ToRustTy for Type {
14621462
IntKind::U32 => aster::ty::TyBuilder::new().u32(),
14631463
IntKind::I64 => aster::ty::TyBuilder::new().i64(),
14641464
IntKind::U64 => aster::ty::TyBuilder::new().u64(),
1465-
IntKind::Custom(name, _signed) => {
1465+
IntKind::Custom { name, .. } => {
14661466
let ident = ctx.rust_ident_raw(name);
14671467
quote_ty!(ctx.ext_cx(), $ident)
14681468
}

src/ir/int.rs

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,12 @@ pub enum IntKind {
6868

6969
/// A custom integer type, used to allow custom macro types depending on
7070
/// range.
71-
///
72-
/// The boolean means a whether this is a signed integer type or not.
73-
Custom(&'static str, bool),
71+
Custom {
72+
/// The name of the type, which would be used without modification.
73+
name: &'static str,
74+
/// Whether the type is signed or not.
75+
is_signed: bool,
76+
},
7477
}
7578

7679
impl IntKind {
@@ -84,7 +87,7 @@ impl IntKind {
8487
Char | Short | Int | Long | LongLong | I8 | I16 | I32 | I64 |
8588
I128 => true,
8689

87-
Custom(_, signed) => signed,
90+
Custom { is_signed, .. } => is_signed,
8891
}
8992
}
9093
}

src/ir/var.rs

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,16 +111,9 @@ impl ClangSubItemParser for Var {
111111
EvalResult::Invalid => return Err(ParseError::Continue),
112112

113113
EvalResult::Int(Wrapping(value)) => {
114-
let kind = match ctx.options().type_chooser {
115-
Some(ref chooser) => {
116-
chooser.int_macro(&name, value)
117-
}
118-
None => None,
119-
};
120-
121-
let kind = match kind {
122-
Some(kind) => kind,
123-
None => {
114+
let kind = ctx.options().type_chooser.as_ref()
115+
.and_then(|c| c.int_macro(&name, value))
116+
.unwrap_or_else(|| {
124117
if value < 0 {
125118
if value < i32::min_value() as i64 {
126119
IntKind::LongLong
@@ -132,8 +125,7 @@ impl ClangSubItemParser for Var {
132125
} else {
133126
IntKind::UInt
134127
}
135-
}
136-
};
128+
});
137129

138130
(kind, value)
139131
}

0 commit comments

Comments
 (0)