Implement ProjectionElem::ConstantIndex
This commit is contained in:
parent
e5ab49e762
commit
127e080f62
2 changed files with 33 additions and 69 deletions
|
@ -5,7 +5,6 @@ Subject: [PATCH] [alloc] Disable some unsupported stuff
|
||||||
|
|
||||||
---
|
---
|
||||||
src/liballoc/boxed.rs | 6 ------
|
src/liballoc/boxed.rs | 6 ------
|
||||||
src/liballoc/str.rs | 4 ++++
|
|
||||||
src/liballoc/vec.rs | 2 --
|
src/liballoc/vec.rs | 2 --
|
||||||
3 files changed, 4 insertions(+), 8 deletions(-)
|
3 files changed, 4 insertions(+), 8 deletions(-)
|
||||||
|
|
||||||
|
@ -33,42 +32,6 @@ index f989e70..597dd15 100644
|
||||||
fn write_isize(&mut self, i: isize) {
|
fn write_isize(&mut self, i: isize) {
|
||||||
(**self).write_isize(i)
|
(**self).write_isize(i)
|
||||||
}
|
}
|
||||||
diff --git a/src/liballoc/str.rs b/src/liballoc/str.rs
|
|
||||||
index 2af8956..23dbb79 100644
|
|
||||||
--- a/src/liballoc/str.rs
|
|
||||||
+++ b/src/liballoc/str.rs
|
|
||||||
@@ -361,6 +361,7 @@ impl str {
|
|
||||||
#[stable(feature = "unicode_case_mapping", since = "1.2.0")]
|
|
||||||
pub fn to_lowercase(&self) -> String {
|
|
||||||
let mut s = String::with_capacity(self.len());
|
|
||||||
+ /*
|
|
||||||
for (i, c) in self[..].char_indices() {
|
|
||||||
if c == 'Σ' {
|
|
||||||
// Σ maps to σ, except at the end of a word where it maps to ς.
|
|
||||||
@@ -384,6 +385,7 @@ impl str {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+ */
|
|
||||||
return s;
|
|
||||||
|
|
||||||
fn map_uppercase_sigma(from: &str, i: usize, to: &mut String) {
|
|
||||||
@@ -435,6 +437,7 @@ impl str {
|
|
||||||
#[stable(feature = "unicode_case_mapping", since = "1.2.0")]
|
|
||||||
pub fn to_uppercase(&self) -> String {
|
|
||||||
let mut s = String::with_capacity(self.len());
|
|
||||||
+ /*
|
|
||||||
for c in self[..].chars() {
|
|
||||||
match conversions::to_upper(c) {
|
|
||||||
[a, '\0', _] => s.push(a),
|
|
||||||
@@ -449,6 +452,7 @@ impl str {
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+ */
|
|
||||||
return s;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs
|
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs
|
||||||
index 2bc037e..2fe8894 100644
|
index 2bc037e..2fe8894 100644
|
||||||
--- a/src/liballoc/vec.rs
|
--- a/src/liballoc/vec.rs
|
||||||
|
@ -79,14 +42,13 @@ index 2bc037e..2fe8894 100644
|
||||||
impl_is_zero!(i64, |x| x == 0);
|
impl_is_zero!(i64, |x| x == 0);
|
||||||
-impl_is_zero!(i128, |x| x == 0);
|
-impl_is_zero!(i128, |x| x == 0);
|
||||||
impl_is_zero!(isize, |x| x == 0);
|
impl_is_zero!(isize, |x| x == 0);
|
||||||
|
|
||||||
impl_is_zero!(u16, |x| x == 0);
|
impl_is_zero!(u16, |x| x == 0);
|
||||||
impl_is_zero!(u32, |x| x == 0);
|
impl_is_zero!(u32, |x| x == 0);
|
||||||
impl_is_zero!(u64, |x| x == 0);
|
impl_is_zero!(u64, |x| x == 0);
|
||||||
-impl_is_zero!(u128, |x| x == 0);
|
-impl_is_zero!(u128, |x| x == 0);
|
||||||
impl_is_zero!(usize, |x| x == 0);
|
impl_is_zero!(usize, |x| x == 0);
|
||||||
|
|
||||||
impl_is_zero!(char, |x| x == '\0');
|
|
||||||
--
|
|
||||||
2.17.1 (Apple Git-112)
|
|
||||||
|
|
||||||
|
impl_is_zero!(char, |x| x == '\0');
|
||||||
|
--
|
||||||
|
2.17.1 (Apple Git-112)
|
||||||
|
|
56
src/base.rs
56
src/base.rs
|
@ -588,18 +588,7 @@ fn trans_stmt<'a, 'tcx: 'a>(
|
||||||
Rvalue::Len(place) => {
|
Rvalue::Len(place) => {
|
||||||
let place = trans_place(fx, place);
|
let place = trans_place(fx, place);
|
||||||
let usize_layout = fx.layout_of(fx.tcx.types.usize);
|
let usize_layout = fx.layout_of(fx.tcx.types.usize);
|
||||||
let len = match place.layout().ty.sty {
|
let len = codegen_array_len(fx, place);
|
||||||
ty::Array(_elem_ty, len) => {
|
|
||||||
let len = crate::constant::force_eval_const(fx, len)
|
|
||||||
.unwrap_usize(fx.tcx) as i64;
|
|
||||||
fx.bcx.ins().iconst(fx.pointer_type, len)
|
|
||||||
}
|
|
||||||
ty::Slice(_elem_ty) => match place {
|
|
||||||
CPlace::Addr(_, size, _) => size.unwrap(),
|
|
||||||
CPlace::Var(_, _) => unreachable!(),
|
|
||||||
},
|
|
||||||
_ => bug!("Rvalue::Len({:?})", place),
|
|
||||||
};
|
|
||||||
lval.write_cvalue(fx, CValue::ByVal(len, usize_layout));
|
lval.write_cvalue(fx, CValue::ByVal(len, usize_layout));
|
||||||
}
|
}
|
||||||
Rvalue::NullaryOp(NullOp::Box, content_ty) => {
|
Rvalue::NullaryOp(NullOp::Box, content_ty) => {
|
||||||
|
@ -660,6 +649,24 @@ fn trans_stmt<'a, 'tcx: 'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn codegen_array_len<'a, 'tcx: 'a>(
|
||||||
|
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
|
||||||
|
place: CPlace<'tcx>,
|
||||||
|
) -> Value {
|
||||||
|
match place.layout().ty.sty {
|
||||||
|
ty::Array(_elem_ty, len) => {
|
||||||
|
let len = crate::constant::force_eval_const(fx, len)
|
||||||
|
.unwrap_usize(fx.tcx) as i64;
|
||||||
|
fx.bcx.ins().iconst(fx.pointer_type, len)
|
||||||
|
}
|
||||||
|
ty::Slice(_elem_ty) => match place {
|
||||||
|
CPlace::Addr(_, size, _) => size.unwrap(),
|
||||||
|
CPlace::Var(_, _) => unreachable!(),
|
||||||
|
},
|
||||||
|
_ => bug!("Rvalue::Len({:?})", place),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn trans_get_discriminant<'a, 'tcx: 'a>(
|
pub fn trans_get_discriminant<'a, 'tcx: 'a>(
|
||||||
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
|
fx: &mut FunctionCx<'a, 'tcx, impl Backend>,
|
||||||
value: CValue<'tcx>,
|
value: CValue<'tcx>,
|
||||||
|
@ -1060,21 +1067,16 @@ pub fn trans_place<'a, 'tcx: 'a>(
|
||||||
ProjectionElem::ConstantIndex {
|
ProjectionElem::ConstantIndex {
|
||||||
offset,
|
offset,
|
||||||
min_length: _,
|
min_length: _,
|
||||||
from_end: false,
|
from_end,
|
||||||
} => unimpl!(
|
} => {
|
||||||
"projection const index {:?} offset {:?} not from end",
|
let index = if !from_end {
|
||||||
projection.base,
|
fx.bcx.ins().iconst(fx.pointer_type, offset as i64)
|
||||||
offset
|
} else {
|
||||||
),
|
let len = codegen_array_len(fx, base);
|
||||||
ProjectionElem::ConstantIndex {
|
fx.bcx.ins().iadd_imm(len, -(offset as i64))
|
||||||
offset,
|
};
|
||||||
min_length: _,
|
base.place_index(fx, index)
|
||||||
from_end: true,
|
},
|
||||||
} => unimpl!(
|
|
||||||
"projection const index {:?} offset {:?} from end",
|
|
||||||
projection.base,
|
|
||||||
offset
|
|
||||||
),
|
|
||||||
ProjectionElem::Subslice { from, to } => unimpl!(
|
ProjectionElem::Subslice { from, to } => unimpl!(
|
||||||
"projection subslice {:?} from {} to {}",
|
"projection subslice {:?} from {} to {}",
|
||||||
projection.base,
|
projection.base,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue