leb128

package
v0.10.4 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 26, 2021 License: ISC Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppendSleb128

func AppendSleb128(b []byte, v int64) []byte

AppendSleb128 appends v to b using DWARF's signed LEB128 encoding.

func AppendUleb128

func AppendUleb128(b []byte, v uint64) []byte

AppendUleb128 appends v to b using DWARF's unsigned LEB128 encoding.

func FromBigInt

func FromBigInt(n *big.Int) (out []byte)

FromBigInt encodes the signed big integer n in two's complement, LEB128-encodes it, and returns the encoded bytes.

func FromUInt64

func FromUInt64(n uint64) (out []byte)

FromUInt64 encodes n with LEB128 and returns the encoded bytes.

func Sleb128FromInt64

func Sleb128FromInt64(v int64) []byte

Sleb128FromInt64 encode int64 v to []byte using signed LEB128 encoding.

func Sleb128ToInt64

func Sleb128ToInt64(b []byte) (s int64, n uint8)

Sleb128ToInt64 decodes b to s with signed LEB128 encoding and returns the number of bytes read. On error (bad encoded b), n will be 0 and therefore s must not be trusted.

func ToBigInt

func ToBigInt(encoded []byte) *big.Int

ToBigInt decodes the signed big integer found in the given bytes.

func ToUInt64

func ToUInt64(encoded []byte) uint64

TODO, not check the input overflow ToUInt64 decodes LEB128-encoded bytes into a uint64.

func Uleb128FromInt64

func Uleb128FromInt64(v int64) []byte

Uleb128FromInt64 encode int64 v to []byte using unsigned LEB128 encoding.

func Uleb128ToUint64

func Uleb128ToUint64(b []byte) (u uint64, n uint8)

Uleb128ToUint64 decodes b to u with unsigned LEB128 encoding and returns the number of bytes read. On error (bad encoded b), n will be 0 and therefore u must not be trusted.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL