本文整理匯總了Golang中github.com/tsavola/wag/internal/loader.L.Bytes方法的典型用法代碼示例。如果您正苦於以下問題:Golang L.Bytes方法的具體用法?Golang L.Bytes怎麽用?Golang L.Bytes使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/tsavola/wag/internal/loader.L
的用法示例。
在下文中一共展示了L.Bytes方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: Load
func (ns *NameSection) Load(_ string, r reader.Reader) (err error) {
defer func() {
err = errutil.ErrorOrPanic(recover())
}()
load := loader.L{r}
count := load.Varuint32()
ns.FunctionNames = make([]FunctionName, count)
for i := range ns.FunctionNames {
fn := &ns.FunctionNames[i]
funNameLen := load.Varuint32()
fn.FunName = string(load.Bytes(funNameLen))
localCount := load.Varuint32()
fn.LocalNames = make([]string, localCount)
for j := range fn.LocalNames {
localNameLen := load.Varuint32()
fn.LocalNames[j] = string(load.Bytes(localNameLen))
}
}
return
}
示例2: Load
func (uls UnknownLoaders) Load(r reader.Reader, payloadLen uint32) (err error) {
defer func() {
err = errutil.ErrorOrPanic(recover())
}()
load := loader.L{r}
nameLen := load.Varuint32()
if nameLen > maxSectionNameLen {
panic(errors.New("unknown section name is too long"))
}
name := string(load.Bytes(nameLen))
if f := uls[name]; f != nil {
if err := f(name, load); err != nil {
panic(err)
}
} else {
if _, err := io.CopyN(ioutil.Discard, load, int64(payloadLen)); err != nil {
panic(err)
}
}
return
}