pub fn vli_encode(&mut self, mut value: i64) -> &WasmEncoder {
        // first group of 6 bits
        // 1st byte encodes 0 as positive in bit 6
        let mut b = value as u8 & 0x3f;
        value >>= 6;

        let mut final_value = 0_i64;
        if value < 0 {
            // encode negative value
            // 1st byte encodes 1 as negative in bit 6
            b |= 0x40;
            final_value = -1_i64;
        }

        // keep shifting until all bits are done
        while value != final_value {
            // emit with continuation bit
            self.buf.push(b | 0x80);

            // next group of 7 bits
            b = value as u8 & 0x7f;
            value >>= 7;
        }

        // emit without continuation bit
        self.buf.push(b);
        self
    }
// encodes an int64 into the byte buffer
// note that these are encoded using vli encoding to conserve space
// vli (variable length integer) encoder
encodes an int64 into the byte buffer
note that these are encoded using vli encoding to conserve space
vli (variable length integer) encoder
encodes an int64 into the byte buffer note that these are encoded using vli encoding to conserve space vli ( variable length integer ) encoder
pub fn vli_encode(&mut self, mut value: i64) -> &WasmEncoder {
        // first group of 6 bits
        // 1st byte encodes 0 as positive in bit 6
        let mut b = value as u8 & 0x3f;
        value >>= 6;
        let mut final_value = 0_i64;
        if value < 0 {
            // encode negative value
            // 1st byte encodes 1 as negative in bit 6
            b |= 0x40;
            final_value = -1_i64;
        }
        // keep shifting until all bits are done
        while value != final_value {
            // emit with continuation bit
            self.buf.push(b | 0x80);
            // next group of 7 bits
            b = value as u8 & 0x7f;
            value >>= 7;
        }
        // emit without continuation bit
        self.buf.push(b);
        self
    }
pub fn vli_encode ( & mut self , mut value : i64 ) -> & WasmEncoder { // first group of 6 bits // 1st byte encodes 0 as positive in bit 6 let mut b = value as u8 & 0x3f ; value >>= 6 ; let mut final_value = 0_i64 ; if value < 0 { // encode negative value // 1st byte encodes 1 as negative in bit 6 b |= 0x40 ; final_value = - 1_i64 ; } // keep shifting until all bits are done while value != final_value { // emit with continuation bit self . buf . push ( b | 0x80 ) ; // next group of 7 bits b = value as u8 & 0x7f ; value >>= 7 ; } // emit without continuation bit self . buf . push ( b ) ; self }
encodes an int64 into the byte buffer
note that these are encoded using vli encoding to conserve space
vli (variable length integer) encoder
encodes an int64 into the byte buffer note that these are encoded using vli encoding to conserve space vli ( variable length integer ) encoder
&mut self
value
i64