MCPcopy Create free account
hub / github.com/dylan-sutton-chavez/edge-python / encodeInt

Function encodeInt

runtime/src/rt.js:75–85  ·  view source on GitHub ↗
(exps, n)

Source from the content-addressed store, hash-verified

73 return h;
74}
75function encodeInt(exps, n) {
76 const buf = exps.wasm_alloc(16);
77 const view = new DataView(exps.memory.buffer);
78 const big = BigInt(n);
79 view.setBigInt64(buf, big, true);
80 /* Sign-extend upper 64 bits so the i128 round-trip preserves negative values. */
81 view.setBigInt64(buf + 8, big < 0n ? -1n : 0n, true);
82 const h = exps.host_edge_encode(TAG_INT, buf, 16);
83 exps.wasm_free(buf, 16);
84 return h;
85}
86function encodeBool(exps, b) {
87 const buf = exps.wasm_alloc(1);
88 new Uint8Array(exps.memory.buffer, buf, 1)[0] = b ? 1 : 0;

Callers 2

makeRtFunction · 0.85
encodeAnyFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected