summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/standalone_miri/hir_sim.cpp1
-rw-r--r--tools/standalone_miri/main.cpp17
-rw-r--r--tools/standalone_miri/value.cpp12
3 files changed, 20 insertions, 10 deletions
diff --git a/tools/standalone_miri/hir_sim.cpp b/tools/standalone_miri/hir_sim.cpp
index 7fccc806..c4232343 100644
--- a/tools/standalone_miri/hir_sim.cpp
+++ b/tools/standalone_miri/hir_sim.cpp
@@ -14,7 +14,6 @@ const size_t POINTER_SIZE = 8;
size_t HIR::TypeRef::get_size(size_t ofs) const
{
- const size_t POINTER_SIZE = 8;
if( this->wrappers.size() <= ofs )
{
switch(this->inner_type)
diff --git a/tools/standalone_miri/main.cpp b/tools/standalone_miri/main.cpp
index c7069ed2..8a54c321 100644
--- a/tools/standalone_miri/main.cpp
+++ b/tools/standalone_miri/main.cpp
@@ -107,6 +107,7 @@ Value MIRI_Invoke(ModuleTree& modtree, ::HIR::Path path, ::std::vector<Value> ar
return args.at(e.idx);
} break;
TU_ARM(lv, Static, e) {
+ // TODO: Type!
return modtree.get_static(e);
} break;
TU_ARM(lv, Index, e) {
@@ -301,22 +302,26 @@ Value MIRI_Invoke(ModuleTree& modtree, ::HIR::Path path, ::std::vector<Value> ar
TU_ARM(se.src, Borrow, re) {
::HIR::TypeRef src_ty;
size_t ofs = 0;
- Value& base_value = state.get_value_type_and_ofs(re.val, ofs, src_ty);
- if( !base_value.allocation )
+ Value& src_base_value = state.get_value_type_and_ofs(re.val, ofs, src_ty);
+ if( !src_base_value.allocation )
{
// TODO: Need to convert this value into an allocation version
::std::cerr << "TODO: RValue::Borrow - " << se.src << " - convert to non-inline" << ::std::endl;
throw "TODO";
//base_value.to_allocation();
}
- ofs += base_value.meta.indirect_meta.offset;
+ ofs += src_base_value.meta.indirect_meta.offset;
src_ty.wrappers.insert(src_ty.wrappers.begin(), TypeWrapper { TypeWrapper::Ty::Borrow, static_cast<size_t>(re.type) });
Value new_val = Value(src_ty);
// ^ Pointer value
- new_val.allocation.alloc().relocations.push_back(Relocation { 0, base_value.allocation });
+ new_val.allocation.alloc().relocations.push_back(Relocation { 0, src_base_value.allocation });
new_val.write_bytes(0, &ofs, src_ty.get_size());
- ::std::cerr << "TODO: RValue::Borrow - " << se.src << ::std::endl;
- throw "TODO";
+
+ ::HIR::TypeRef dst_ty;
+ // TODO: Check type equality
+ size_t dst_ofs = 0;
+ Value& dst_base_value = state.get_value_type_and_ofs(se.dst, dst_ofs, dst_ty);
+ dst_base_value.write_value(dst_ofs, ::std::move(new_val));
} break;
TU_ARM(se.src, SizedArray, re) {
throw "TODO";
diff --git a/tools/standalone_miri/value.cpp b/tools/standalone_miri/value.cpp
index 59b68ea0..db8ec085 100644
--- a/tools/standalone_miri/value.cpp
+++ b/tools/standalone_miri/value.cpp
@@ -238,12 +238,18 @@ void Value::write_bytes(size_t ofs, const void* src, size_t count)
{
if( this->allocation )
{
- if(ofs >= this->meta.indirect_meta.size )
+ if(ofs >= this->meta.indirect_meta.size ) {
+ ::std::cerr << "Value::write_bytes - Out of bounds write, " << ofs << " >= " << this->meta.indirect_meta.size << ::std::endl;
throw "ERROR";
- if(count > this->meta.indirect_meta.size )
+ }
+ if(count > this->meta.indirect_meta.size ) {
+ ::std::cerr << "Value::write_bytes - Out of bounds write, count " << count << " > size " << this->meta.indirect_meta.size << ::std::endl;
throw "ERROR";
- if(ofs+count > this->meta.indirect_meta.size )
+ }
+ if(ofs+count > this->meta.indirect_meta.size ) {
+ ::std::cerr << "Value::write_bytes - Out of bounds write, " << ofs << "+" << count << " > size " << this->meta.indirect_meta.size << ::std::endl;
throw "ERROR";
+ }
}
else
{