wag: github.com/tsavola/wag/section Index | Files

package section

import "github.com/tsavola/wag/section"

Package section contains binary stream manipulation utilities.

Index

Package Files

copy.go custom.go names.go sectionid.go sectionmap.go

Constants

const (
    Custom   = module.SectionCustom
    Type     = module.SectionType
    Import   = module.SectionImport
    Function = module.SectionFunction
    Table    = module.SectionTable
    Memory   = module.SectionMemory
    Global   = module.SectionGlobal
    Export   = module.SectionExport
    Start    = module.SectionStart
    Element  = module.SectionElement
    Code     = module.SectionCode
    Data     = module.SectionData
)
const CustomName = "name"

func CopyStandardSection Uses

func CopyStandardSection(w io.Writer, r reader.R, id ID, customLoader func(r Reader, payloadLen uint32) error) (length int64, err error)

CopyStandardSection with the given type if one is found. The returned length includes the copied section's header and payload (everything that was written). Custom sections preceding the standard section are processed by customLoader (or discarded if it's nil) - they are not included in the returned length. If another standard section type is found, it is left untouched (the reader will be backed up before the section id) and zero length is returned. If no standard section is encountered, zero length and io.EOF are returned. io.EOF is returned only when it occurs between sections.

func CustomLoader Uses

func CustomLoader(loaders map[string]CustomContentLoader) func(Reader, uint32) error

func SkipCustomSections Uses

func SkipCustomSections(r reader.R, customLoader func(Reader, uint32) error) (err error)

SkipCustomSections until the next standard section. The skipped sections are processed by customLoader (or discarded if it's nil). If no standard section is encountered, io.EOF is returned. io.EOF is returned only when it occurs between sections.

type ByteRange Uses

type ByteRange struct {
    Offset int64
    Length int64
}

type CustomContentLoader Uses

type CustomContentLoader func(sectionName string, r Reader, payloadLen uint32) error

type CustomMapping Uses

type CustomMapping ByteRange

func (*CustomMapping) Loader Uses

func (target *CustomMapping) Loader(sectionMap *Map) CustomContentLoader

Loader of arbitrary custom section. Remembers position, discards content.

type CustomSections Uses

type CustomSections struct {
    Sections map[string][]byte
}

func (*CustomSections) Load Uses

func (cs *CustomSections) Load(name string, r reader.R, length uint32) (err error)

type FuncName Uses

type FuncName struct {
    FuncName   string
    LocalNames []string
}

type ID Uses

type ID = module.SectionID

type Map Uses

type Map struct {
    Sections [module.NumSections]ByteRange
}

Map of section positions within the WebAssebly binary module. Map must me initialied with MakeMap or NewMap.

Section offset is always nonzero for standard sections; if the section is missing, it's the position where it would be. Section length is nonzero if the section is present.

Sections[Custom] holds information about the last (or latest) custom section. Its offset is zero if there are no custom sections.

func MakeMap Uses

func MakeMap() (m Map)

MakeMap which represents an empty module.

func NewMap Uses

func NewMap() *Map

NewMap which represents an empty module.

func (*Map) Mapper Uses

func (m *Map) Mapper() func(byte, Reader) (uint32, error)

type MappedNameSection Uses

type MappedNameSection struct {
    NameSection
    Mapping ByteRange
}

func (*MappedNameSection) Loader Uses

func (ns *MappedNameSection) Loader(sectionMap *Map) func(string, reader.R, uint32) error

Loader of "name" section. Remembers position.

type NameSection Uses

type NameSection struct {
    ModuleName string
    FuncNames  []FuncName
}

func (*NameSection) Load Uses

func (ns *NameSection) Load(_ string, r reader.R, length uint32) (err error)

Load "name" section.

type Reader Uses

type Reader = reader.R

Package section imports 10 packages (graph) and is imported by 11 packages. Updated 2019-11-26. Refresh now. Tools for package owners.