Implement Rvalue::Repeat

This commit is contained in:
bjorn3 2018-08-08 12:30:25 +02:00
parent efd203aa0b
commit 1305d1ef23
2 changed files with 10 additions and 1 deletions

View File

@ -146,3 +146,7 @@ unsafe fn call_uninit() -> u8 {
fn use_array(arr: [u8; 3]) -> u8 {
arr[1]
}
fn repeat_array() -> [u8; 3] {
[0; 3]
}

View File

@ -412,7 +412,12 @@ fn trans_stmt<'a, 'tcx: 'a>(
lval.write_cvalue(fx, discr);
}
Rvalue::Repeat(operand, times) => {
unimplemented!("rval repeat {:?} {:?}", operand, times)
let operand = trans_operand(fx, operand);
for i in 0..*times {
let index = fx.bcx.ins().iconst(types::I64, i as i64);
let to = lval.place_index(fx, index);
to.write_cvalue(fx, operand);
}
}
Rvalue::Len(lval) => return Err(format!("rval len {:?}", lval)),
Rvalue::NullaryOp(NullOp::Box, ty) => unimplemented!("rval box {:?}", ty),