Skip to content

Commit e70c1b5

Browse files
committed
Added support for size types in C integer rank system
1 parent 2ac7ee9 commit e70c1b5

File tree

1 file changed

+8
-4
lines changed
  • src/c/implicit_conversions

1 file changed

+8
-4
lines changed

src/c/implicit_conversions/mod.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ pub enum IntegerRank {
1010
Int,
1111
Long,
1212
LongLong,
13+
Size,
1314
FixedInt(BitUnits),
1415
}
1516

1617
impl IntegerRank {
17-
pub fn compare_for_target(left: Self, right: Self, target: &Target) -> Ordering {
18-
let left_precision = left.precision(target);
19-
let right_precision = right.precision(target);
20-
left_precision.cmp(&right_precision)
18+
pub fn compare_for_target(self, other: &Self, target: &Target) -> Ordering {
19+
self.precision(target).cmp(&other.precision(target))
2120
}
2221

2322
pub fn precision(&self, target: &Target) -> IntegerPrecision {
@@ -30,6 +29,11 @@ impl IntegerRank {
3029
IntegerRank::LongLong => {
3130
IntegerPrecision::flexible(target.longlong_layout().width.to_bits())
3231
}
32+
IntegerRank::Size => {
33+
// This means that size types have the same effective rank as the type they would
34+
// be in C for this target.
35+
IntegerPrecision::flexible(target.size_layout().width.to_bits())
36+
}
3337
IntegerRank::FixedInt(bits) => IntegerPrecision::fixed(*bits),
3438
}
3539
}

0 commit comments

Comments
 (0)