提交 781c3a66 编写于 作者: S Scott Olson

Update for changes in rustc nightly.

上级 a8d0812e
......@@ -3,7 +3,7 @@ name = "miri"
version = "0.1.0"
dependencies = [
"byteorder 0.4.2 (registry+https://github.com/rust-lang/crates.io-index)",
"compiletest_rs 0.1.2 (registry+https://github.com/rust-lang/crates.io-index)",
"compiletest_rs 0.1.3 (registry+https://github.com/rust-lang/crates.io-index)",
"env_logger 0.3.3 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
"log_settings 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -24,7 +24,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "compiletest_rs"
version = "0.1.2"
version = "0.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"log 0.3.6 (registry+https://github.com/rust-lang/crates.io-index)",
......@@ -55,7 +55,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "libc"
version = "0.2.11"
version = "0.2.12"
source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
......@@ -76,7 +76,7 @@ name = "memchr"
version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......@@ -102,7 +102,7 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"kernel32-sys 0.2.2 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.11 (registry+https://github.com/rust-lang/crates.io-index)",
"libc 0.2.12 (registry+https://github.com/rust-lang/crates.io-index)",
]
[[package]]
......
......@@ -90,11 +90,11 @@ fn interpret_start_points<'a, 'tcx>(
fn report(tcx: TyCtxt, ecx: &EvalContext, e: EvalError) {
let frame = ecx.stack().last().expect("stackframe was empty");
let block = frame.mir.basic_block_data(frame.next_block);
let block = &frame.mir.basic_blocks()[frame.next_block];
let span = if frame.stmt < block.statements.len() {
block.statements[frame.stmt].span
block.statements[frame.stmt].source_info.span
} else {
block.terminator().span
block.terminator().source_info.span
};
let mut err = tcx.sess.struct_span_err(span, &e.to_string());
for &Frame { def_id, substs, span, .. } in ecx.stack().iter().rev() {
......@@ -105,7 +105,7 @@ fn report(tcx: TyCtxt, ecx: &EvalContext, e: EvalError) {
impl<'tcx> fmt::Display for Instance<'tcx> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
ppaux::parameterized(f, self.1, self.0, ppaux::Ns::Value, &[],
|tcx| tcx.lookup_item_type(self.0).generics)
|tcx| Some(tcx.lookup_item_type(self.0).generics))
}
}
err.span_note(span, &format!("inside call to {}", Instance(def_id, substs)));
......
......@@ -8,6 +8,7 @@
use rustc::ty::subst::{self, Subst, Substs};
use rustc::ty::{self, Ty, TyCtxt};
use rustc::util::nodemap::DefIdMap;
use rustc_data_structures::indexed_vec::Idx;
use std::cell::RefCell;
use std::ops::Deref;
use std::rc::Rc;
......@@ -118,7 +119,7 @@ struct ConstantId<'tcx> {
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
enum ConstantKind {
Promoted(usize),
Promoted(mir::Promoted),
/// Statics, constants and associated constants
Global,
}
......@@ -485,7 +486,10 @@ fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>)
}
let mir = self.load_mir(resolved_def_id);
self.push_stack_frame(def_id, terminator.span, mir, resolved_substs, return_ptr);
self.push_stack_frame(
def_id, terminator.source_info.span, mir, resolved_substs,
return_ptr
);
for (i, (src, src_ty)) in arg_srcs.into_iter().enumerate() {
let dest = self.frame().locals[i];
......@@ -501,14 +505,26 @@ fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>)
}
}
Drop { ref value, target, .. } => {
let ptr = self.eval_lvalue(value)?.to_ptr();
let ty = self.lvalue_ty(value);
Drop { ref location, target, .. } => {
let ptr = self.eval_lvalue(location)?.to_ptr();
let ty = self.lvalue_ty(location);
self.drop(ptr, ty)?;
self.frame_mut().next_block = target;
}
Assert { ref cond, expected, ref msg, target, cleanup } => {
let actual_ptr = self.eval_operand(cond)?;
let actual = self.memory.read_bool(actual_ptr)?;
if actual == expected {
self.frame_mut().next_block = target;
} else {
panic!("unimplemented: jump to {:?} and print {:?}", cleanup, msg);
}
}
DropAndReplace { .. } => unimplemented!(),
Resume => unimplemented!(),
Unreachable => unimplemented!(),
}
Ok(())
......@@ -845,6 +861,8 @@ fn eval_assignment(&mut self, lvalue: &mir::Lvalue<'tcx>, rvalue: &mir::Rvalue<'
self.memory.write_primval(dest, val)?;
}
CheckedBinaryOp(..) => unimplemented!(),
UnaryOp(un_op, ref operand) => {
let ptr = self.eval_operand(operand)?;
let ty = self.operand_ty(operand);
......@@ -1018,7 +1036,6 @@ fn eval_assignment(&mut self, lvalue: &mir::Lvalue<'tcx>, rvalue: &mir::Rvalue<'
}
}
Slice { .. } => unimplemented!(),
InlineAsm { .. } => unimplemented!(),
}
......@@ -1130,9 +1147,9 @@ fn eval_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>) -> EvalResult<Lvalue> {
let ptr = match *lvalue {
ReturnPointer => self.frame().return_ptr
.expect("ReturnPointer used in a function with no return value"),
Arg(i) => self.frame().locals[i as usize],
Var(i) => self.frame().locals[self.frame().var_offset + i as usize],
Temp(i) => self.frame().locals[self.frame().temp_offset + i as usize],
Arg(i) => self.frame().locals[i.index()],
Var(i) => self.frame().locals[self.frame().var_offset + i.index()],
Temp(i) => self.frame().locals[self.frame().temp_offset + i.index()],
Static(def_id) => {
let substs = self.tcx.mk_substs(subst::Substs::empty());
......@@ -1217,6 +1234,7 @@ fn eval_lvalue(&mut self, lvalue: &mir::Lvalue<'tcx>) -> EvalResult<Lvalue> {
}
ConstantIndex { .. } => unimplemented!(),
Subslice { .. } => unimplemented!(),
}
}
};
......
......@@ -51,12 +51,12 @@ pub(super) fn step(&mut self) -> EvalResult<bool> {
let block = self.ecx.frame().next_block;
let stmt = self.ecx.frame().stmt;
let mir = self.ecx.mir();
let basic_block = mir.basic_block_data(block);
let basic_block = &mir.basic_blocks()[block];
if let Some(ref stmt) = basic_block.statements.get(stmt) {
let current_stack = self.ecx.stack.len();
ConstantExtractor {
span: stmt.span,
span: stmt.source_info.span,
substs: self.ecx.substs(),
def_id: self.ecx.frame().def_id,
ecx: self.ecx,
......@@ -75,7 +75,7 @@ pub(super) fn step(&mut self) -> EvalResult<bool> {
let terminator = basic_block.terminator();
let current_stack = self.ecx.stack.len();
ConstantExtractor {
span: terminator.span,
span: terminator.source_info.span,
substs: self.ecx.substs(),
def_id: self.ecx.frame().def_id,
ecx: self.ecx,
......
......@@ -11,6 +11,7 @@
// From rustc.
#[macro_use] extern crate rustc;
extern crate rustc_data_structures;
extern crate rustc_mir;
extern crate syntax;
#[macro_use] extern crate log;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册