func DecodeModule(r io.Reader) (*Module, error) {
	reader := &readpos.ReadPos{
		R:      r,
		CurPos: 0,
	}
	m := &Module{}
	magic, err := readU32(reader)
	if err != nil {
		return nil, err
	}
	if magic != Magic {
		return nil, ErrInvalidMagic
	}
	if m.Version, err = readU32(reader); err != nil {
		return nil, err
	}
	if m.Version != Version {
		return nil, fmt.Errorf("wasm: unknown binary version: %d", m.Version)
	}
	err = newSectionsReader(m).readSections(reader)
	if err != nil {
		return nil, err
	}
	return m, nil
}
DecodeModule is the same as ReadModule, but it only decodes the module without
initializing the index space or resolving imports.
package wasm
import (
	"errors"
	"fmt"
	"io"
	"reflect"
	"github.com/go-interpreter/wagon/wasm/internal/readpos"
)
var ErrInvalidMagic = errors.New("wasm: Invalid magic number")
const (
	Magic   uint32 = 0x6d736100
	Version uint32 = 0x1
)
type Function struct {
	Sig  *FunctionSig
	Body *FunctionBody
	Host reflect.Value
	Name string
}
func (fct *Function) IsHost() bool {
	return fct.Host != reflect.Value{}
}
type Module struct {
	Version  uint32
	Sections []Section
	Types    *SectionTypes
	Import   *SectionImports
	Function *SectionFunctions
	Table    *SectionTables
	Memory   *SectionMemories
	Global   *SectionGlobals
	Export   *SectionExports
	Start    *SectionStartFunction
	Elements *SectionElements
	Code     *SectionCode
	Data     *SectionData
	Customs  []*SectionCustom
	FunctionIndexSpace []Function
	GlobalIndexSpace   []GlobalEntry
	TableIndexSpace        [][]TableEntry
	LinearMemoryIndexSpace [][]byte
	imports struct {
		Funcs    []uint32
		Globals  int
		Tables   int
		Memories int
	}
}
type TableEntry struct {
	Index       uint32
	Initialized bool
}
func (m *Module) Custom(name string) *SectionCustom {
	for _, s := range m.Customs {
		if s.Name == name {
			return s
		}
	}
	return nil
}
func NewModule() *Module {
	return &Module{
		Types:    &SectionTypes{},
		Import:   &SectionImports{},
		Table:    &SectionTables{},
		Memory:   &SectionMemories{},
		Global:   &SectionGlobals{},
		Export:   &SectionExports{},
		Start:    &SectionStartFunction{},
		Elements: &SectionElements{},
		Data:     &SectionData{},
	}
}
type ResolveFunc func(name string) (*Module, error)