Explorer

wasm.signed-leb128

description
Encode an integer as signed LEB128 bytes (for i64.const immediates)
type
Fn(n: Number) -> List<Number>
expression
fn(n$0) =>
  let q0$1 = @core.divide(left: $0, right: 128);
  let r0$2 = @core.remainder(left: $0, right: 128);
  let negative$3 = @core.less-than(left: $2, right: 0);
  let r$4 = match $3 {
      true =>
        @core.plus(left: $2, right: 128),
      false =>
        $2
    };
  let q$5 = match $3 {
      true =>
        @core.minus(left: $1, right: 1),
      false =>
        $1
    };
  match @core.or(
      left: @core.and(left: @core.equal(left: $5, right: 0), right: @core.less-than(left: $4, right: 64)),
      right: @core.and(left: @core.equal(left: $5, right: -1), right: @core.less-than(left: 63, right: $4))
    ) {
    true =>
      [$4],
    false =>
      @core.list-concat(left: [@core.plus(left: $4, right: 128)], right: @wasm.signed-leb128(n: $5))
  }
visibility
public
wasm.signed-leb128 (project definy, branch auto-release, snapshot oiQgPqhJm-TbM4kexXeRHBaJB_tS7gwBSewII64P-44)
id: JzyRjNSXlyW2KlmlTWnMEq9vv9GuKpey6q4nN2Q85gw
content hash: sUe2qxZTLqn6CPPurKGPRLginwwUdX_eB-pKupxUrnY