]> git.lizzy.rs Git - rust.git/blobdiff - src/machine.rs
Add communicate field to evaluator and fix formatting
[rust.git] / src / machine.rs
index cdac9fb815cc7685a2722c55a0e0e5fec014d1f1..ed9a8a1c46346f320149b1a9e473cbc56e3e124a 100644 (file)
@@ -93,10 +93,13 @@ pub struct Evaluator<'tcx> {
 
     /// TLS state.
     pub(crate) tls: TlsData<'tcx>,
+
+    /// If enabled, the `env_vars` field is populated with the host env vars during initialization.
+    pub(crate) communicate: bool,
 }
 
 impl<'tcx> Evaluator<'tcx> {
-    pub(crate) fn new() -> Self {
+    pub(crate) fn new(communicate: bool) -> Self {
         Evaluator {
             env_vars: HashMap::default(),
             argc: None,
@@ -104,6 +107,7 @@ pub(crate) fn new() -> Self {
             cmd_line: None,
             last_error: 0,
             tls: TlsData::default(),
+            communicate,
         }
     }
 }
@@ -141,6 +145,8 @@ impl<'mir, 'tcx> Machine<'mir, 'tcx> for Evaluator<'tcx> {
 
     const STATIC_KIND: Option<MiriMemoryKind> = Some(MiriMemoryKind::Static);
 
+    const CHECK_ALIGN: bool = true;
+
     #[inline(always)]
     fn enforce_validity(ecx: &InterpCx<'mir, 'tcx, Self>) -> bool {
         ecx.memory().extra.validate
@@ -179,13 +185,13 @@ fn call_intrinsic(
     }
 
     #[inline(always)]
-    fn ptr_op(
+    fn binary_ptr_op(
         ecx: &rustc_mir::interpret::InterpCx<'mir, 'tcx, Self>,
         bin_op: mir::BinOp,
         left: ImmTy<'tcx, Tag>,
         right: ImmTy<'tcx, Tag>,
     ) -> InterpResult<'tcx, (Scalar<Tag>, bool)> {
-        ecx.ptr_op(bin_op, left, right)
+        ecx.binary_ptr_op(bin_op, left, right)
     }
 
     fn box_alloc(
@@ -247,9 +253,7 @@ fn find_foreign_static(
                 let data = vec![0; size.bytes() as usize];
                 Allocation::from_bytes(&data, tcx.data_layout.pointer_align.abi)
             }
-            _ => throw_unsup!(Unimplemented(
-                    format!("can't access foreign static: {}", link_name),
-                )),
+            _ => throw_unsup_format!("can't access foreign static: {}", link_name),
         };
         Ok(Cow::Owned(alloc))
     }