MCPcopy Create free account
hub / github.com/nodejs/node / wasmSignedLeb

Function wasmSignedLeb

test/fixtures/wpt/wasm/jsapi/wasm-module-builder.js:1606–1620  ·  view source on GitHub ↗
(val, max_len = 5)

Source from the content-addressed store, hash-verified

1604globalThis.WasmModuleBuilder = WasmModuleBuilder;
1605
1606function wasmSignedLeb(val, max_len = 5) {
1607 let res = [];
1608 for (let i = 0; i < max_len; ++i) {
1609 let v = val & 0x7f;
1610 // If {v} sign-extended from 7 to 32 bits is equal to val, we are done.
1611 if (((v << 25) >> 25) == val) {
1612 res.push(v);
1613 return res;
1614 }
1615 res.push(v | 0x80);
1616 val = val >> 7;
1617 }
1618 throw new Error(
1619 'Leb value <' + val + '> exceeds maximum length of ' + max_len);
1620}
1621globalThis.wasmSignedLeb = wasmSignedLeb;
1622
1623function wasmI32Const(val) {

Callers 5

emit_heap_typeMethod · 0.70
defaultForMethod · 0.70
wasmI32ConstFunction · 0.70
polyfill.jsFile · 0.50
basic.any.jsFile · 0.50

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected