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

Function makeSetValueImpl

src/parseTools.mjs:517–538  ·  view source on GitHub ↗
(ptr, pos, value, type)

Source from the content-addressed store, hash-verified

515}
516
517function makeSetValueImpl(ptr, pos, value, type) {
518 if (type == 'i64' && !WASM_BIGINT) {
519 // If we lack BigInt support we must fall back to an reading a pair of I32
520 // values.
521 // prettier-ignore
522 return '(tempI64 = [' + splitI64(value) + '], ' +
523 makeSetValueImpl(ptr, pos, 'tempI64[0]', 'i32') + ',' +
524 makeSetValueImpl(ptr, getFastValue(pos, '+', getNativeTypeSize('i32')), 'tempI64[1]', 'i32') + ')';
525 }
526
527 const offset = calcFastOffset(ptr, pos);
528
529 if (type === 'i53') {
530 return `writeI53ToI64(${offset}, ${value})`;
531 }
532
533 const slab = getHeapForType(type);
534 if (slab == 'HEAPU64' || slab == 'HEAP64') {
535 value = castToBigInt(value);
536 }
537 return `${slab}[${getHeapOffset(offset, type)}] = ${value}`;
538}
539
540function makeHEAPView(which, start, end) {
541 // The makeHEAPView, for legacy reasons, takes a heap "suffix"

Callers 1

makeSetValueFunction · 0.85

Calls 7

splitI64Function · 0.85
getFastValueFunction · 0.85
getNativeTypeSizeFunction · 0.85
calcFastOffsetFunction · 0.85
getHeapForTypeFunction · 0.85
castToBigIntFunction · 0.85
getHeapOffsetFunction · 0.85

Tested by

no test coverage detected