diff options
Diffstat (limited to 'tools/standalone_miri/value.hpp')
-rw-r--r-- | tools/standalone_miri/value.hpp | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tools/standalone_miri/value.hpp b/tools/standalone_miri/value.hpp index 03689215..ca15dea9 100644 --- a/tools/standalone_miri/value.hpp +++ b/tools/standalone_miri/value.hpp @@ -15,6 +15,12 @@ namespace HIR { class Allocation; struct Value; +struct FFIPointer +{ + const char* source_function; + void* ptr_value; +}; + class AllocationPtr { friend class Allocation; @@ -26,7 +32,7 @@ public: Allocation, Function, // m_ptr is a pointer to the function. StdString, - Unused2, + FfiPointer, }; private: @@ -44,6 +50,7 @@ public: static AllocationPtr new_fcn(::HIR::Path p); //static AllocationPtr new_rawdata(const void* buf, size_t len); static AllocationPtr new_string(const ::std::string* s); // NOTE: The string must have a stable pointer + static AllocationPtr new_ffi(FFIPointer info); AllocationPtr& operator=(const AllocationPtr& x) = delete; AllocationPtr& operator=(AllocationPtr&& x) { @@ -77,6 +84,11 @@ public: assert(get_ty() == Ty::StdString); return *static_cast<const ::std::string*>(get_ptr()); } + const FFIPointer& ffi() const { + assert(*this); + assert(get_ty() == Ty::FfiPointer); + return *static_cast<const FFIPointer*>(get_ptr()); + } Ty get_ty() const { return static_cast<Ty>( reinterpret_cast<uintptr_t>(m_ptr) & 3 ); @@ -172,6 +184,7 @@ struct Value Value(); Value(::HIR::TypeRef ty); static Value new_fnptr(const ::HIR::Path& fn_path); + static Value new_ffiptr(FFIPointer ffi); void create_allocation(); size_t size() const { return allocation ? allocation.alloc().size() : direct_data.size; } |