]> git.lizzy.rs Git - rust.git/commitdiff
Rename next_block to block and reorganize Frame fields.
authorScott Olson <scott@solson.me>
Wed, 15 Jun 2016 02:13:59 +0000 (20:13 -0600)
committerScott Olson <scott@solson.me>
Wed, 15 Jun 2016 02:13:59 +0000 (20:13 -0600)
src/bin/miri.rs
src/interpreter/mod.rs
src/interpreter/stepper.rs

index a29e44cf96066d19ffab6ad57d31aba7ebc336b4..2d6cf22d589585b6feacba0712bd8cea2b9e2468 100644 (file)
@@ -90,7 +90,7 @@ 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_blocks()[frame.next_block];
+    let block = &frame.mir.basic_blocks()[frame.block];
     let span = if frame.stmt < block.statements.len() {
         block.statements[frame.stmt].source_info.span
     } else {
index 1b0b416e0e12c1097500479fbfecf59a0487c9cf..8b69fc6c2483c420a2e521756190ce7c88593de0 100644 (file)
@@ -42,7 +42,7 @@ pub struct EvalContext<'a, 'tcx: 'a> {
     /// The virtual memory system.
     memory: Memory<'tcx>,
 
-    /// Precomputed statics, constants and promoteds
+    /// Precomputed statics, constants and promoteds.
     statics: HashMap<ConstantId<'tcx>, Pointer>,
 
     /// The virtual call stack.
@@ -51,20 +51,25 @@ pub struct EvalContext<'a, 'tcx: 'a> {
 
 /// A stack frame.
 pub struct Frame<'a, 'tcx: 'a> {
-    /// The def_id of the current function
-    pub def_id: DefId,
+    ////////////////////////////////////////////////////////////////////////////////
+    // Function and callsite information
+    ////////////////////////////////////////////////////////////////////////////////
 
-    /// The span of the call site
-    pub span: codemap::Span,
+    /// The MIR for the function called on this frame.
+    pub mir: CachedMir<'a, 'tcx>,
+
+    /// The def_id of the current function.
+    pub def_id: DefId,
 
-    /// type substitutions for the current function invocation
+    /// type substitutions for the current function invocation.
     pub substs: &'tcx Substs<'tcx>,
 
-    /// The MIR for the function called on this frame.
-    pub mir: CachedMir<'a, 'tcx>,
+    /// The span of the call site.
+    pub span: codemap::Span,
 
-    /// The block that is currently executed (or will be executed after the above call stacks return)
-    pub next_block: mir::BasicBlock,
+    ////////////////////////////////////////////////////////////////////////////////
+    // Return pointer and local allocations
+    ////////////////////////////////////////////////////////////////////////////////
 
     /// A pointer for writing the return value of the current call if it's not a diverging call.
     pub return_ptr: Option<Pointer>,
@@ -80,7 +85,15 @@ pub struct Frame<'a, 'tcx: 'a> {
     /// The offset of the first temporary in `self.locals`.
     pub temp_offset: usize,
 
-    /// The index of the currently evaluated statment
+    ////////////////////////////////////////////////////////////////////////////////
+    // Current position within the function
+    ////////////////////////////////////////////////////////////////////////////////
+
+    /// The block that is currently executed (or will be executed after the above call stacks
+    /// return).
+    pub block: mir::BasicBlock,
+
+    /// The index of the currently evaluated statment.
     pub stmt: usize,
 }
 
@@ -349,7 +362,7 @@ pub fn push_stack_frame(&mut self, def_id: DefId, span: codemap::Span, mir: Cach
 
         self.stack.push(Frame {
             mir: mir.clone(),
-            next_block: mir::START_BLOCK,
+            block: mir::START_BLOCK,
             return_ptr: return_ptr,
             locals: locals,
             var_offset: num_args,
@@ -374,13 +387,13 @@ fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>)
             Return => self.pop_stack_frame(),
 
             Goto { target } => {
-                self.frame_mut().next_block = target;
+                self.frame_mut().block = target;
             },
 
             If { ref cond, targets: (then_target, else_target) } => {
                 let cond_ptr = self.eval_operand(cond)?;
                 let cond_val = self.memory.read_bool(cond_ptr)?;
-                self.frame_mut().next_block = if cond_val { then_target } else { else_target };
+                self.frame_mut().block = if cond_val { then_target } else { else_target };
             }
 
             SwitchInt { ref discr, ref values, ref targets, .. } => {
@@ -403,7 +416,7 @@ fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>)
                     }
                 }
 
-                self.frame_mut().next_block = target_block;
+                self.frame_mut().block = target_block;
             }
 
             Switch { ref discr, ref targets, adt_def } => {
@@ -415,7 +428,7 @@ fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>)
 
                 match matching {
                     Some(i) => {
-                        self.frame_mut().next_block = targets[i];
+                        self.frame_mut().block = targets[i];
                     },
                     None => return Err(EvalError::InvalidDiscriminant),
                 }
@@ -424,7 +437,7 @@ fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>)
             Call { ref func, ref args, ref destination, .. } => {
                 let mut return_ptr = None;
                 if let Some((ref lv, target)) = *destination {
-                    self.frame_mut().next_block = target;
+                    self.frame_mut().block = target;
                     return_ptr = Some(self.eval_lvalue(lv)?.to_ptr());
                 }
 
@@ -451,14 +464,14 @@ fn eval_terminator(&mut self, terminator: &mir::Terminator<'tcx>)
                 let ptr = self.eval_lvalue(location)?.to_ptr();
                 let ty = self.lvalue_ty(location);
                 self.drop(ptr, ty)?;
-                self.frame_mut().next_block = target;
+                self.frame_mut().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;
+                    self.frame_mut().block = target;
                 } else {
                     panic!("unimplemented: jump to {:?} and print {:?}", cleanup, msg);
                 }
index 8603054d124c25fb57e89191f3516314959ddb1b..e92ddd1faa2df97beb0b13ddd901c438e8acb458 100644 (file)
@@ -37,7 +37,7 @@ fn terminator(&mut self, terminator: &mir::Terminator<'tcx>) -> EvalResult<()> {
         trace!("{:?}", terminator.kind);
         self.ecx.eval_terminator(terminator)?;
         if !self.ecx.stack.is_empty() {
-            trace!("// {:?}", self.ecx.frame().next_block);
+            trace!("// {:?}", self.ecx.frame().block);
         }
         Ok(())
     }
@@ -48,7 +48,7 @@ pub(super) fn step(&mut self) -> EvalResult<bool> {
             return Ok(false);
         }
 
-        let block = self.ecx.frame().next_block;
+        let block = self.ecx.frame().block;
         let stmt = self.ecx.frame().stmt;
         let mir = self.ecx.mir();
         let basic_block = &mir.basic_blocks()[block];