rename evaluator -> interpreter to make eddyb happy
This commit is contained in:
parent
169f7911e9
commit
018d128325
8 changed files with 21 additions and 34 deletions
|
|
@ -10,7 +10,7 @@
|
|||
|
||||
use llvm;
|
||||
use rustc::mir::interpret::{ConstEvalErr, read_target_uint};
|
||||
use rustc_mir::interpret::{const_field};
|
||||
use rustc_mir::const_eval::const_field;
|
||||
use rustc::hir::def_id::DefId;
|
||||
use rustc::mir;
|
||||
use rustc_data_structures::indexed_vec::Idx;
|
||||
|
|
|
|||
|
|
@ -1612,7 +1612,7 @@ fn validate_const<'a, 'tcx>(
|
|||
gid: ::rustc::mir::interpret::GlobalId<'tcx>,
|
||||
what: &str,
|
||||
) {
|
||||
let ecx = ::rustc_mir::interpret::mk_eval_cx(tcx, gid.instance, param_env).unwrap();
|
||||
let ecx = ::rustc_mir::const_eval::mk_eval_cx(tcx, gid.instance, param_env).unwrap();
|
||||
let result = (|| {
|
||||
let op = ecx.const_to_op(constant)?;
|
||||
let mut todo = vec![(op, Vec::new())];
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ pub fn mk_borrowck_eval_cx<'a, 'mir, 'tcx>(
|
|||
) -> EvalResult<'tcx, CompileTimeEvalContext<'a, 'mir, 'tcx>> {
|
||||
debug!("mk_borrowck_eval_cx: {:?}", instance);
|
||||
let param_env = tcx.param_env(instance.def_id());
|
||||
let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeEvaluator::new(), ());
|
||||
let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeInterpreter::new(), ());
|
||||
// insert a stack frame so any queries have the correct substs
|
||||
ecx.stack.push(interpret::Frame {
|
||||
block: mir::START_BLOCK,
|
||||
|
|
@ -64,7 +64,7 @@ pub fn mk_eval_cx<'a, 'tcx>(
|
|||
) -> EvalResult<'tcx, CompileTimeEvalContext<'a, 'tcx, 'tcx>> {
|
||||
debug!("mk_eval_cx: {:?}, {:?}", instance, param_env);
|
||||
let span = tcx.def_span(instance.def_id());
|
||||
let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeEvaluator::new(), ());
|
||||
let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeInterpreter::new(), ());
|
||||
let mir = ecx.load_mir(instance.def)?;
|
||||
// insert a stack frame so any queries have the correct substs
|
||||
ecx.push_stack_frame(
|
||||
|
|
@ -133,7 +133,7 @@ fn eval_body_and_ecx<'a, 'mir, 'tcx>(
|
|||
// and try improving it down the road when more information is available
|
||||
let span = tcx.def_span(cid.instance.def_id());
|
||||
let span = mir.map(|mir| mir.span).unwrap_or(span);
|
||||
let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeEvaluator::new(), ());
|
||||
let mut ecx = EvalContext::new(tcx.at(span), param_env, CompileTimeInterpreter::new(), ());
|
||||
let r = eval_body_using_ecx(&mut ecx, cid, mir, param_env);
|
||||
(r, ecx)
|
||||
}
|
||||
|
|
@ -230,7 +230,7 @@ impl Error for ConstEvalError {
|
|||
}
|
||||
|
||||
// Extra machine state for CTFE, and the Machine instance
|
||||
pub struct CompileTimeEvaluator<'a, 'mir, 'tcx: 'a+'mir> {
|
||||
pub struct CompileTimeInterpreter<'a, 'mir, 'tcx: 'a+'mir> {
|
||||
/// When this value is negative, it indicates the number of interpreter
|
||||
/// steps *until* the loop detector is enabled. When it is positive, it is
|
||||
/// the number of steps after the detector has been enabled modulo the loop
|
||||
|
|
@ -241,9 +241,9 @@ pub struct CompileTimeEvaluator<'a, 'mir, 'tcx: 'a+'mir> {
|
|||
pub(super) loop_detector: snapshot::InfiniteLoopDetector<'a, 'mir, 'tcx>,
|
||||
}
|
||||
|
||||
impl<'a, 'mir, 'tcx> CompileTimeEvaluator<'a, 'mir, 'tcx> {
|
||||
impl<'a, 'mir, 'tcx> CompileTimeInterpreter<'a, 'mir, 'tcx> {
|
||||
fn new() -> Self {
|
||||
CompileTimeEvaluator {
|
||||
CompileTimeInterpreter {
|
||||
loop_detector: Default::default(),
|
||||
steps_since_detector_enabled: -snapshot::STEPS_UNTIL_DETECTOR_ENABLED,
|
||||
}
|
||||
|
|
@ -251,10 +251,10 @@ impl<'a, 'mir, 'tcx> CompileTimeEvaluator<'a, 'mir, 'tcx> {
|
|||
}
|
||||
|
||||
type CompileTimeEvalContext<'a, 'mir, 'tcx> =
|
||||
EvalContext<'a, 'mir, 'tcx, CompileTimeEvaluator<'a, 'mir, 'tcx>>;
|
||||
EvalContext<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>;
|
||||
|
||||
impl<'a, 'mir, 'tcx> interpret::Machine<'a, 'mir, 'tcx>
|
||||
for CompileTimeEvaluator<'a, 'mir, 'tcx>
|
||||
for CompileTimeInterpreter<'a, 'mir, 'tcx>
|
||||
{
|
||||
type MemoryData = ();
|
||||
type MemoryKinds = !;
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ mod check_match;
|
|||
pub use self::check_match::check_crate;
|
||||
pub(crate) use self::check_match::check_match;
|
||||
|
||||
use interpret::{const_field, const_variant_index};
|
||||
use const_eval::{const_field, const_variant_index};
|
||||
|
||||
use rustc::mir::{fmt_const_val, Field, BorrowKind, Mutability};
|
||||
use rustc::mir::interpret::{Scalar, GlobalId, ConstValue, sign_extend};
|
||||
|
|
|
|||
|
|
@ -35,16 +35,3 @@ pub use self::memory::{Memory, MemoryKind};
|
|||
pub use self::machine::Machine;
|
||||
|
||||
pub use self::operand::{Value, ValTy, Operand, OpTy};
|
||||
|
||||
// reexports for compatibility
|
||||
pub use const_eval::{
|
||||
eval_promoted,
|
||||
mk_borrowck_eval_cx,
|
||||
mk_eval_cx,
|
||||
CompileTimeEvaluator,
|
||||
const_to_allocation_provider,
|
||||
const_eval_provider,
|
||||
const_field,
|
||||
const_variant_index,
|
||||
op_to_const,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -26,7 +26,7 @@ use syntax::source_map::Span;
|
|||
|
||||
use super::eval_context::{LocalValue, StackPopCleanup};
|
||||
use super::{Frame, Memory, Operand, MemPlace, Place, Value};
|
||||
use const_eval::CompileTimeEvaluator;
|
||||
use const_eval::CompileTimeInterpreter;
|
||||
|
||||
/// Number of steps until the detector even starts doing anything.
|
||||
/// Also, a warning is shown to the user when this number is reached.
|
||||
|
|
@ -61,7 +61,7 @@ impl<'a, 'mir, 'tcx> InfiniteLoopDetector<'a, 'mir, 'tcx>
|
|||
pub fn observe_and_analyze<'b>(
|
||||
&mut self,
|
||||
tcx: &TyCtxt<'b, 'tcx, 'tcx>,
|
||||
memory: &Memory<'a, 'mir, 'tcx, CompileTimeEvaluator<'a, 'mir, 'tcx>>,
|
||||
memory: &Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>,
|
||||
stack: &[Frame<'mir, 'tcx>],
|
||||
) -> EvalResult<'tcx, ()> {
|
||||
|
||||
|
|
@ -391,7 +391,7 @@ impl<'a, 'mir, 'tcx, Ctx> Snapshot<'a, Ctx> for &'a Frame<'mir, 'tcx>
|
|||
}
|
||||
|
||||
impl<'a, 'b, 'mir, 'tcx: 'a+'mir> SnapshotContext<'b>
|
||||
for Memory<'a, 'mir, 'tcx, CompileTimeEvaluator<'a, 'mir, 'tcx>>
|
||||
for Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>
|
||||
{
|
||||
fn resolve(&'b self, id: &AllocId) -> Option<&'b Allocation> {
|
||||
self.get(*id).ok()
|
||||
|
|
@ -399,17 +399,17 @@ impl<'a, 'b, 'mir, 'tcx: 'a+'mir> SnapshotContext<'b>
|
|||
}
|
||||
|
||||
/// The virtual machine state during const-evaluation at a given point in time.
|
||||
/// We assume the `CompileTimeEvaluator` has no interesting extra state that
|
||||
/// We assume the `CompileTimeInterpreter` has no interesting extra state that
|
||||
/// is worth considering here.
|
||||
struct EvalSnapshot<'a, 'mir, 'tcx: 'a + 'mir> {
|
||||
memory: Memory<'a, 'mir, 'tcx, CompileTimeEvaluator<'a, 'mir, 'tcx>>,
|
||||
memory: Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>,
|
||||
stack: Vec<Frame<'mir, 'tcx>>,
|
||||
}
|
||||
|
||||
impl<'a, 'mir, 'tcx: 'a + 'mir> EvalSnapshot<'a, 'mir, 'tcx>
|
||||
{
|
||||
fn new(
|
||||
memory: &Memory<'a, 'mir, 'tcx, CompileTimeEvaluator<'a, 'mir, 'tcx>>,
|
||||
memory: &Memory<'a, 'mir, 'tcx, CompileTimeInterpreter<'a, 'mir, 'tcx>>,
|
||||
stack: &[Frame<'mir, 'tcx>]
|
||||
) -> Self {
|
||||
EvalSnapshot {
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ pub fn provide(providers: &mut Providers) {
|
|||
borrow_check::provide(providers);
|
||||
shim::provide(providers);
|
||||
transform::provide(providers);
|
||||
providers.const_eval = interpret::const_eval_provider;
|
||||
providers.const_eval = const_eval::const_eval_provider;
|
||||
providers.check_match = hair::pattern::check_match;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,8 +21,8 @@ use rustc::mir::interpret::{
|
|||
ConstEvalErr, EvalErrorKind, ScalarMaybeUndef, Scalar, GlobalId, EvalResult
|
||||
};
|
||||
use rustc::ty::{TyCtxt, self, Instance};
|
||||
use interpret::{EvalContext, CompileTimeEvaluator, eval_promoted, mk_borrowck_eval_cx};
|
||||
use interpret::{self, Value, OpTy, MemoryKind};
|
||||
use interpret::{self, EvalContext, Value, OpTy, MemoryKind};
|
||||
use const_eval::{CompileTimeInterpreter, eval_promoted, mk_borrowck_eval_cx};
|
||||
use transform::{MirPass, MirSource};
|
||||
use syntax::source_map::{Span, DUMMY_SP};
|
||||
use rustc::ty::subst::Substs;
|
||||
|
|
@ -69,7 +69,7 @@ type Const<'tcx> = (OpTy<'tcx>, Span);
|
|||
|
||||
/// Finds optimization opportunities on the MIR.
|
||||
struct ConstPropagator<'b, 'a, 'tcx:'a+'b> {
|
||||
ecx: EvalContext<'a, 'b, 'tcx, CompileTimeEvaluator<'a, 'b, 'tcx>>,
|
||||
ecx: EvalContext<'a, 'b, 'tcx, CompileTimeInterpreter<'a, 'b, 'tcx>>,
|
||||
mir: &'b Mir<'tcx>,
|
||||
tcx: TyCtxt<'a, 'tcx, 'tcx>,
|
||||
source: MirSource,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue