mirror of
https://github.com/rust-lang/rust.git
synced 2026-05-31 13:40:15 +03:00
store scalars where appropriate
This commit is contained in:
+3
-3
@@ -105,7 +105,7 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
|
||||
{
|
||||
let argc_place = ecx.allocate(dest.layout, MiriMemoryKind::Env.into());
|
||||
ecx.write_scalar(argc, argc_place.into())?;
|
||||
ecx.machine.argc = Some(argc_place.ptr.to_ptr()?);
|
||||
ecx.machine.argc = Some(argc_place.ptr);
|
||||
}
|
||||
|
||||
// Third argument (`argv`): created from `config.args`.
|
||||
@@ -149,14 +149,14 @@ pub fn create_ecx<'mir, 'tcx: 'mir>(
|
||||
{
|
||||
let argv_place = ecx.allocate(dest.layout, MiriMemoryKind::Env.into());
|
||||
ecx.write_scalar(argv, argv_place.into())?;
|
||||
ecx.machine.argv = Some(argv_place.ptr.to_ptr()?);
|
||||
ecx.machine.argv = Some(argv_place.ptr);
|
||||
}
|
||||
// Store command line as UTF-16 for Windows `GetCommandLineW`.
|
||||
{
|
||||
let cmd_utf16: Vec<u16> = cmd.encode_utf16().collect();
|
||||
let cmd_type = tcx.mk_array(tcx.types.u16, cmd_utf16.len() as u64);
|
||||
let cmd_place = ecx.allocate(ecx.layout_of(cmd_type)?, MiriMemoryKind::Env.into());
|
||||
ecx.machine.cmd_line = Some(cmd_place.ptr.to_ptr()?);
|
||||
ecx.machine.cmd_line = Some(cmd_place.ptr);
|
||||
// Store the UTF-16 string. We just allocated so we know the bounds are fine.
|
||||
let char_size = Size::from_bytes(2);
|
||||
for (idx, &c) in cmd_utf16.iter().enumerate() {
|
||||
|
||||
+3
-3
@@ -86,9 +86,9 @@ pub struct Evaluator<'tcx> {
|
||||
/// Program arguments (`Option` because we can only initialize them after creating the ecx).
|
||||
/// These are *pointers* to argc/argv because macOS.
|
||||
/// We also need the full command line as one string because of Windows.
|
||||
pub(crate) argc: Option<Pointer<Tag>>,
|
||||
pub(crate) argv: Option<Pointer<Tag>>,
|
||||
pub(crate) cmd_line: Option<Pointer<Tag>>,
|
||||
pub(crate) argc: Option<Scalar<Tag>>,
|
||||
pub(crate) argv: Option<Scalar<Tag>>,
|
||||
pub(crate) cmd_line: Option<Scalar<Tag>>,
|
||||
|
||||
/// Last OS error location in memory. It is a 32-bit integer.
|
||||
pub(crate) last_error: Option<MPlaceTy<'tcx, Tag>>,
|
||||
|
||||
@@ -765,10 +765,10 @@ fn emulate_foreign_item(
|
||||
// FIXME: register the destructor.
|
||||
}
|
||||
"_NSGetArgc" => {
|
||||
this.write_scalar(Scalar::Ptr(this.machine.argc.unwrap()), dest)?;
|
||||
this.write_scalar(this.machine.argc.expect("machine must be initialized"), dest)?;
|
||||
}
|
||||
"_NSGetArgv" => {
|
||||
this.write_scalar(Scalar::Ptr(this.machine.argv.unwrap()), dest)?;
|
||||
this.write_scalar(this.machine.argv.expect("machine must be initialized"), dest)?;
|
||||
}
|
||||
"SecRandomCopyBytes" => {
|
||||
let len = this.read_scalar(args[1])?.to_usize(this)?;
|
||||
@@ -927,7 +927,7 @@ fn emulate_foreign_item(
|
||||
this.write_null(dest)?;
|
||||
}
|
||||
"GetCommandLineW" => {
|
||||
this.write_scalar(Scalar::Ptr(this.machine.cmd_line.unwrap()), dest)?;
|
||||
this.write_scalar(this.machine.cmd_line.expect("machine must be initialized"), dest)?;
|
||||
}
|
||||
// The actual name of 'RtlGenRandom'
|
||||
"SystemFunction036" => {
|
||||
|
||||
Reference in New Issue
Block a user