1 // Copyright 2023 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file.
9 func (funcProps *FuncProps) SerializeToString() string {
13 var sb strings.Builder
14 writeUleb128(&sb, uint64(funcProps.Flags))
15 writeUleb128(&sb, uint64(len(funcProps.ParamFlags)))
16 for _, pf := range funcProps.ParamFlags {
17 writeUleb128(&sb, uint64(pf))
19 writeUleb128(&sb, uint64(len(funcProps.ResultFlags)))
20 for _, rf := range funcProps.ResultFlags {
21 writeUleb128(&sb, uint64(rf))
26 func DeserializeFromString(s string) *FuncProps {
30 var funcProps FuncProps
33 v, sl = readULEB128(sl)
34 funcProps.Flags = FuncPropBits(v)
35 v, sl = readULEB128(sl)
36 funcProps.ParamFlags = make([]ParamPropBits, v)
37 for i := range funcProps.ParamFlags {
38 v, sl = readULEB128(sl)
39 funcProps.ParamFlags[i] = ParamPropBits(v)
41 v, sl = readULEB128(sl)
42 funcProps.ResultFlags = make([]ResultPropBits, v)
43 for i := range funcProps.ResultFlags {
44 v, sl = readULEB128(sl)
45 funcProps.ResultFlags[i] = ResultPropBits(v)
50 func readULEB128(sl []byte) (value uint64, rsl []byte) {
56 value |= (uint64(b&0x7F) << shift)
65 func writeUleb128(sb *strings.Builder, v uint64) {
67 sb.WriteByte(uint8(v))