MCPcopy Create free account
hub / github.com/WasmEdge/WasmEdge / readF64

Method readF64

lib/loader/filemgr.cpp:248–267  ·  view source on GitHub ↗

Copy bytes to a double. See "include/loader/filemgr.h".

Source from the content-addressed store, hash-verified

246
247// Copy bytes to a double. See "include/loader/filemgr.h".
248Expect<double> FileMgr::readF64() {
249 if (Status != ErrCode::Value::Success) {
250 return Unexpect(Status);
251 }
252 // Set the flag to the start offset.
253 LastPos = Pos;
254
255 uint64_t Buf = 0;
256 Byte Byte = 0x00;
257 // Check whether reading exceeds the data or section boundary.
258 EXPECTED_TRY(testRead(8));
259 for (uint32_t I = 0; I < 8; I++) {
260 Byte = Data[Pos++];
261 Buf |= (Byte & UINT64_C(0xFF)) << (I * UINT64_C(8));
262 }
263 double Result;
264 static_assert(sizeof(Buf) == sizeof(Result));
265 std::memcpy(&Result, &Buf, sizeof(Result));
266 return Result;
267}
268
269// Read a vector of bytes. See "include/loader/filemgr.h".
270Expect<std::string> FileMgr::readName() {

Callers 2

loadInstructionMethod · 0.80
TESTFunction · 0.80

Calls 2

UnexpectFunction · 0.85
EXPECTED_TRYFunction · 0.50

Tested by 1

TESTFunction · 0.64