Skip to content

Commit ddb1fc9

Browse files
committed
store scalars where appropriate
1 parent 1e0b398 commit ddb1fc9

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

src/eval.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
105105
{
106106
let argc_place = ecx.allocate(dest.layout, MiriMemoryKind::Env.into());
107107
ecx.write_scalar(argc, argc_place.into())?;
108-
ecx.machine.argc = Some(argc_place.ptr.to_ptr()?);
108+
ecx.machine.argc = Some(argc_place.ptr);
109109
}
110110

111111
// Third argument (`argv`): created from `config.args`.
@@ -149,14 +149,14 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
149149
{
150150
let argv_place = ecx.allocate(dest.layout, MiriMemoryKind::Env.into());
151151
ecx.write_scalar(argv, argv_place.into())?;
152-
ecx.machine.argv = Some(argv_place.ptr.to_ptr()?);
152+
ecx.machine.argv = Some(argv_place.ptr);
153153
}
154154
// Store command line as UTF-16 for Windows `GetCommandLineW`.
155155
{
156156
let cmd_utf16: Vec<u16> = cmd.encode_utf16().collect();
157157
let cmd_type = tcx.mk_array(tcx.types.u16, cmd_utf16.len() as u64);
158158
let cmd_place = ecx.allocate(ecx.layout_of(cmd_type)?, MiriMemoryKind::Env.into());
159-
ecx.machine.cmd_line = Some(cmd_place.ptr.to_ptr()?);
159+
ecx.machine.cmd_line = Some(cmd_place.ptr);
160160
// Store the UTF-16 string. We just allocated so we know the bounds are fine.
161161
let char_size = Size::from_bytes(2);
162162
for (idx, &c) in cmd_utf16.iter().enumerate() {

src/machine.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ pub struct Evaluator<'tcx> {
8686
/// Program arguments (`Option` because we can only initialize them after creating the ecx).
8787
/// These are *pointers* to argc/argv because macOS.
8888
/// We also need the full command line as one string because of Windows.
89-
pub(crate) argc: Option<Pointer<Tag>>,
90-
pub(crate) argv: Option<Pointer<Tag>>,
91-
pub(crate) cmd_line: Option<Pointer<Tag>>,
89+
pub(crate) argc: Option<Scalar<Tag>>,
90+
pub(crate) argv: Option<Scalar<Tag>>,
91+
pub(crate) cmd_line: Option<Scalar<Tag>>,
9292

9393
/// Last OS error location in memory. It is a 32-bit integer.
9494
pub(crate) last_error: Option<MPlaceTy<'tcx, Tag>>,

src/shims/foreign_items.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -765,10 +765,10 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
765765
// FIXME: register the destructor.
766766
}
767767
"_NSGetArgc" => {
768-
this.write_scalar(Scalar::Ptr(this.machine.argc.unwrap()), dest)?;
768+
this.write_scalar(this.machine.argc.expect("machine must be initialized"), dest)?;
769769
}
770770
"_NSGetArgv" => {
771-
this.write_scalar(Scalar::Ptr(this.machine.argv.unwrap()), dest)?;
771+
this.write_scalar(this.machine.argv.expect("machine must be initialized"), dest)?;
772772
}
773773
"SecRandomCopyBytes" => {
774774
let len = this.read_scalar(args[1])?.to_usize(this)?;
@@ -927,7 +927,7 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx
927927
this.write_null(dest)?;
928928
}
929929
"GetCommandLineW" => {
930-
this.write_scalar(Scalar::Ptr(this.machine.cmd_line.unwrap()), dest)?;
930+
this.write_scalar(this.machine.cmd_line.expect("machine must be initialized"), dest)?;
931931
}
932932
// The actual name of 'RtlGenRandom'
933933
"SystemFunction036" => {

0 commit comments

Comments
 (0)