| 103 | } |
| 104 | |
| 105 | fn swap_bytes(self) -> Self { |
| 106 | match self { |
| 107 | DataValue::I8(i) => DataValue::I8(i.swap_bytes()), |
| 108 | DataValue::I16(i) => DataValue::I16(i.swap_bytes()), |
| 109 | DataValue::I32(i) => DataValue::I32(i.swap_bytes()), |
| 110 | DataValue::I64(i) => DataValue::I64(i.swap_bytes()), |
| 111 | DataValue::I128(i) => DataValue::I128(i.swap_bytes()), |
| 112 | DataValue::F16(f) => DataValue::F16(Ieee16::with_bits(f.bits().swap_bytes())), |
| 113 | DataValue::F32(f) => DataValue::F32(Ieee32::with_bits(f.bits().swap_bytes())), |
| 114 | DataValue::F64(f) => DataValue::F64(Ieee64::with_bits(f.bits().swap_bytes())), |
| 115 | DataValue::F128(f) => DataValue::F128(Ieee128::with_bits(f.bits().swap_bytes())), |
| 116 | DataValue::V128(mut v) => { |
| 117 | v.reverse(); |
| 118 | DataValue::V128(v) |
| 119 | } |
| 120 | DataValue::V64(mut v) => { |
| 121 | v.reverse(); |
| 122 | DataValue::V64(v) |
| 123 | } |
| 124 | DataValue::V32(mut v) => { |
| 125 | v.reverse(); |
| 126 | DataValue::V32(v) |
| 127 | } |
| 128 | DataValue::V16(mut v) => { |
| 129 | v.reverse(); |
| 130 | DataValue::V16(v) |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | |
| 135 | /// Converts `self` to big endian from target's endianness. |
| 136 | pub fn to_be(self) -> Self { |