MCPcopy Create free account
hub / github.com/emscripten-core/emscripten / makeGetValue

Function makeGetValue

src/parseTools.mjs:478–494  ·  view source on GitHub ↗
(ptr, pos, type)

Source from the content-addressed store, hash-verified

476
477// See makeSetValue
478function makeGetValue(ptr, pos, type) {
479 assert(arguments.length == 3, 'makeGetValue expects 3 arguments');
480
481 const offset = calcFastOffset(ptr, pos);
482 if (type === 'i53' || type === 'u53') {
483 // Set `unsigned` based on the type name.
484 const unsigned = type.startsWith('u');
485 return `readI53From${unsigned ? 'U' : 'I'}64(${offset})`;
486 }
487
488 const slab = getHeapForType(type);
489 let ret = `${slab}[${getHeapOffset(offset, type)}]`;
490 if (MEMORY64 && isPointerType(type)) {
491 ret = `Number(${ret})`;
492 }
493 return ret;
494}
495
496/**
497 * @param {number} ptr The pointer. Used to find both the slab and the offset in that slab. If the pointer

Callers 5

libtime.jsFile · 0.85
libsdl.jsFile · 0.85
libembind.jsFile · 0.85
libgetvalue.jsFile · 0.85
libcore.jsFile · 0.85

Calls 5

calcFastOffsetFunction · 0.85
getHeapForTypeFunction · 0.85
getHeapOffsetFunction · 0.85
isPointerTypeFunction · 0.85
assertFunction · 0.70

Tested by

no test coverage detected