Refactor PrimVal::relocation out of existence.
This commit is contained in:
parent
29e690fe14
commit
d63ab5f8c3
@ -315,15 +315,15 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
.expect("global should have been cached (freeze)");
|
||||
match global_value.data.expect("global should have been initialized") {
|
||||
Value::ByRef(ptr) => self.memory.freeze(ptr.alloc_id)?,
|
||||
Value::ByVal(val) => if let Some(alloc_id) = val.relocation() {
|
||||
self.memory.freeze(alloc_id)?;
|
||||
Value::ByVal(val) => if let PrimVal::Ptr(ptr) = val {
|
||||
self.memory.freeze(ptr.alloc_id)?;
|
||||
},
|
||||
Value::ByValPair(a, b) => {
|
||||
if let Some(alloc_id) = a.relocation() {
|
||||
self.memory.freeze(alloc_id)?;
|
||||
Value::ByValPair(val1, val2) => {
|
||||
if let PrimVal::Ptr(ptr) = val1 {
|
||||
self.memory.freeze(ptr.alloc_id)?;
|
||||
}
|
||||
if let Some(alloc_id) = b.relocation() {
|
||||
self.memory.freeze(alloc_id)?;
|
||||
if let PrimVal::Ptr(ptr) = val2 {
|
||||
self.memory.freeze(ptr.alloc_id)?;
|
||||
}
|
||||
},
|
||||
}
|
||||
@ -1301,12 +1301,12 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
}
|
||||
Value::ByVal(val) => {
|
||||
trace!("frame[{}] {:?}: {:?}", frame, local, val);
|
||||
if let Some(alloc_id) = val.relocation() { allocs.push(alloc_id); }
|
||||
if let PrimVal::Ptr(ptr) = val { allocs.push(ptr.alloc_id); }
|
||||
}
|
||||
Value::ByValPair(val1, val2) => {
|
||||
trace!("frame[{}] {:?}: ({:?}, {:?})", frame, local, val1, val2);
|
||||
if let Some(alloc_id) = val1.relocation() { allocs.push(alloc_id); }
|
||||
if let Some(alloc_id) = val2.relocation() { allocs.push(alloc_id); }
|
||||
if let PrimVal::Ptr(ptr) = val1 { allocs.push(ptr.alloc_id); }
|
||||
if let PrimVal::Ptr(ptr) = val2 { allocs.push(ptr.alloc_id); }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
12
src/value.rs
12
src/value.rs
@ -4,7 +4,7 @@
|
||||
use std::mem::transmute;
|
||||
|
||||
use error::{EvalError, EvalResult};
|
||||
use memory::{AllocId, Memory, Pointer};
|
||||
use memory::{Memory, Pointer};
|
||||
|
||||
pub(super) fn bits_to_f32(bits: u64) -> f32 {
|
||||
unsafe { transmute::<u32, f32>(bits as u32) }
|
||||
@ -127,16 +127,6 @@ impl<'tcx> PrimVal {
|
||||
}
|
||||
}
|
||||
|
||||
// FIXME(solson): Remove this. It's a temporary function to aid refactoring, but it shouldn't
|
||||
// stick around with this name.
|
||||
pub fn relocation(self) -> Option<AllocId> {
|
||||
if let PrimVal::Ptr(ref p) = self {
|
||||
Some(p.alloc_id)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
}
|
||||
|
||||
pub fn from_u64(n: u64) -> Self {
|
||||
PrimVal::Bytes(n)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user