| 73 | return h; |
| 74 | } |
| 75 | function 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 | } |
| 86 | function encodeBool(exps, b) { |
| 87 | const buf = exps.wasm_alloc(1); |
| 88 | new Uint8Array(exps.memory.buffer, buf, 1)[0] = b ? 1 : 0; |