(val, max_len = 5)
| 2399 | } |
| 2400 | |
| 2401 | function 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 | |
| 2418 | function wasmSignedLeb64(val, max_len = 10) { |
| 2419 | if (val == null) throw new Error("Leb value may not be null/undefined"); |
no test coverage detected