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

Function wasmSignedLeb

deps/v8/test/mjsunit/wasm/wasm-module-builder.js:2401–2416  ·  view source on GitHub ↗
(val, max_len = 5)

Source from the content-addressed store, hash-verified

2399}
2400
2401function wasmSignedLeb(val, max_len = 5) {
2402 if (val == null) throw new Error("Leb value may not be null/undefined");
2403 let res = [];
2404 for (let i = 0; i < max_len; ++i) {
2405 let v = val & 0x7f;
2406 // If {v} sign-extended from 7 to 32 bits is equal to val, we are done.
2407 if (((v << 25) >> 25) == val) {
2408 res.push(v);
2409 return res;
2410 }
2411 res.push(v | 0x80);
2412 val = val >> 7;
2413 }
2414 throw new Error(
2415 'Leb value <' + val + '> exceeds maximum length of ' + max_len);
2416}
2417
2418function wasmSignedLeb64(val, max_len = 10) {
2419 if (val == null) throw new Error("Leb value may not be null/undefined");

Callers 15

many-modules.jsFile · 0.70
emit_heap_typeMethod · 0.70
defaultForMethod · 0.70
wasmSignedLeb64Function · 0.70
wasmI32ConstFunction · 0.70
wasmEncodeHeapTypeFunction · 0.70

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected