1
Fork 0

Implement bytestring literals.

This commit is contained in:
Scott Olson 2016-03-18 23:20:59 -06:00
parent 26c4772f51
commit 668f2b6fd4
2 changed files with 13 additions and 1 deletions

View file

@ -620,7 +620,14 @@ impl<'a, 'tcx: 'a, 'arena> Interpreter<'a, 'tcx, 'arena> {
try!(self.memory.write_uint(ptr.offset(psize as isize), s.len() as u64, psize)); try!(self.memory.write_uint(ptr.offset(psize as isize), s.len() as u64, psize));
Ok(ptr) Ok(ptr)
} }
ByteStr(ref _bs) => unimplemented!(), ByteStr(ref bs) => {
let psize = self.memory.pointer_size;
let static_ptr = self.memory.allocate(bs.len());
let ptr = self.memory.allocate(psize);
try!(self.memory.write_bytes(static_ptr, bs));
try!(self.memory.write_ptr(ptr, static_ptr));
Ok(ptr)
}
Bool(b) => { Bool(b) => {
let ptr = self.memory.allocate(1); let ptr = self.memory.allocate(1);
try!(self.memory.write_bool(ptr, b)); try!(self.memory.write_bool(ptr, b));

View file

@ -10,3 +10,8 @@ fn empty() -> &'static str {
fn hello() -> &'static str { fn hello() -> &'static str {
"Hello, world!" "Hello, world!"
} }
#[miri_run]
fn hello_bytes() -> &'static [u8; 13] {
b"Hello, world!"
}