diff options
author | John Hodge <tpg@ucc.asn.au> | 2019-08-03 23:26:39 +0800 |
---|---|---|
committer | John Hodge <tpg@ucc.asn.au> | 2019-08-03 23:26:39 +0800 |
commit | 40c8b8cdfd8dd4eca18a255f8b7b71e916ed6a38 (patch) | |
tree | a8de73236b230816090e6880e083f973561bc6f2 /tools/standalone_miri/miri.cpp | |
parent | 126900aa8e24523a23fcef11bcfca976e8afc120 (diff) | |
download | mrust-40c8b8cdfd8dd4eca18a255f8b7b71e916ed6a38.tar.gz |
Standalone MIRI - u8/u16 arithmatic
Diffstat (limited to 'tools/standalone_miri/miri.cpp')
-rw-r--r-- | tools/standalone_miri/miri.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tools/standalone_miri/miri.cpp b/tools/standalone_miri/miri.cpp index 67023205..9468303c 100644 --- a/tools/standalone_miri/miri.cpp +++ b/tools/standalone_miri/miri.cpp @@ -107,6 +107,20 @@ struct PrimitiveU32: public PrimitiveUInt<uint32_t> tgt.write_u32(ofs, this->v); } }; +struct PrimitiveU16: public PrimitiveUInt<uint16_t> +{ + PrimitiveU16(uint16_t v): PrimitiveUInt(v) {} + void write_to_value(ValueCommonWrite& tgt, size_t ofs) const override { + tgt.write_u16(ofs, this->v); + } +}; +struct PrimitiveU8: public PrimitiveUInt<uint8_t> +{ + PrimitiveU8(uint8_t v): PrimitiveUInt(v) {} + void write_to_value(ValueCommonWrite& tgt, size_t ofs) const override { + tgt.write_u8(ofs, this->v); + } +}; template<typename T> struct PrimitiveSInt: public PrimitiveValue @@ -189,6 +203,12 @@ public: LOG_ASSERT(t.get_wrapper() == nullptr, "PrimitiveValueVirt::from_value: " << t); switch(t.inner_type) { + case RawType::U8: + new(&rv.buf) PrimitiveU8(v.read_u8(0)); + break; + case RawType::U16: + new(&rv.buf) PrimitiveU16(v.read_u16(0)); + break; case RawType::U32: new(&rv.buf) PrimitiveU32(v.read_u32(0)); break; |