2021-03-18 09:46:55 +03:00
|
|
|
package vm_indent
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"math"
|
|
|
|
"sort"
|
|
|
|
"unsafe"
|
|
|
|
|
|
|
|
"github.com/goccy/go-json/internal/encoder"
|
|
|
|
"github.com/goccy/go-json/internal/runtime"
|
2021-03-18 10:17:14 +03:00
|
|
|
|
|
|
|
// HACK: compile order
|
2021-03-27 06:18:19 +03:00
|
|
|
// `vm`, `vm_escaped`, `vm_indent`, `vm_escaped_indent`, `vm_debug` packages uses a lot of memory to compile,
|
2021-03-18 10:17:14 +03:00
|
|
|
// so forcibly make dependencies and avoid compiling in concurrent.
|
2021-03-27 06:18:19 +03:00
|
|
|
// dependency order: vm => vm_escaped => vm_indent => vm_escaped_indent => vm_debug
|
2021-03-18 10:17:14 +03:00
|
|
|
_ "github.com/goccy/go-json/internal/encoder/vm_escaped_indent"
|
2021-03-18 09:46:55 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
const uintptrSize = 4 << (^uintptr(0) >> 63)
|
|
|
|
|
|
|
|
var (
|
2021-03-18 10:30:08 +03:00
|
|
|
appendInt = encoder.AppendInt
|
|
|
|
appendUint = encoder.AppendUint
|
|
|
|
appendFloat32 = encoder.AppendFloat32
|
|
|
|
appendFloat64 = encoder.AppendFloat64
|
|
|
|
appendString = encoder.AppendString
|
|
|
|
appendByteSlice = encoder.AppendByteSlice
|
|
|
|
appendNumber = encoder.AppendNumber
|
|
|
|
appendMarshalJSON = encoder.AppendMarshalJSONIndent
|
|
|
|
appendMarshalText = encoder.AppendMarshalTextIndent
|
2021-04-20 14:12:32 +03:00
|
|
|
appendStructEnd = encoder.AppendStructEndIndent
|
|
|
|
appendIndent = encoder.AppendIndent
|
2021-03-18 10:30:08 +03:00
|
|
|
errUnsupportedValue = encoder.ErrUnsupportedValue
|
|
|
|
errUnsupportedFloat = encoder.ErrUnsupportedFloat
|
|
|
|
mapiterinit = encoder.MapIterInit
|
|
|
|
mapiterkey = encoder.MapIterKey
|
|
|
|
mapitervalue = encoder.MapIterValue
|
|
|
|
mapiternext = encoder.MapIterNext
|
|
|
|
maplen = encoder.MapLen
|
2021-03-18 09:46:55 +03:00
|
|
|
)
|
|
|
|
|
|
|
|
type emptyInterface struct {
|
|
|
|
typ *runtime.Type
|
|
|
|
ptr unsafe.Pointer
|
|
|
|
}
|
|
|
|
|
|
|
|
func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet, opt encoder.Option) ([]byte, error) {
|
|
|
|
recursiveLevel := 0
|
|
|
|
ptrOffset := uintptr(0)
|
|
|
|
ctxptr := ctx.Ptr()
|
|
|
|
code := codeSet.Code
|
|
|
|
|
|
|
|
for {
|
|
|
|
switch code.Op {
|
|
|
|
default:
|
|
|
|
return nil, fmt.Errorf("encoder (indent): opcode %s has not been implemented", code.Op)
|
|
|
|
case encoder.OpPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, ptrToPtr(p))
|
|
|
|
case encoder.OpIntPtr:
|
|
|
|
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpInt:
|
|
|
|
b = appendInt(b, ptrToUint64(load(ctxptr, code.Idx)), code)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpUintPtr:
|
|
|
|
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpUint:
|
|
|
|
b = appendUint(b, ptrToUint64(load(ctxptr, code.Idx)), code)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpIntString:
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, ptrToUint64(load(ctxptr, code.Idx)), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpUintString:
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, ptrToUint64(load(ctxptr, code.Idx)), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpFloat32Ptr:
|
|
|
|
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpFloat32:
|
|
|
|
b = appendFloat32(b, ptrToFloat32(load(ctxptr, code.Idx)))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpFloat64Ptr:
|
|
|
|
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpFloat64:
|
|
|
|
v := ptrToFloat64(load(ctxptr, code.Idx))
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStringPtr:
|
|
|
|
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpString:
|
|
|
|
b = appendString(b, ptrToString(load(ctxptr, code.Idx)))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpBoolPtr:
|
|
|
|
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpBool:
|
|
|
|
b = appendBool(b, ptrToBool(load(ctxptr, code.Idx)))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpBytesPtr:
|
|
|
|
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpBytes:
|
|
|
|
b = appendByteSlice(b, ptrToBytes(load(ctxptr, code.Idx)))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpNumberPtr:
|
|
|
|
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpNumber:
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(load(ctxptr, code.Idx)))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendComma(bb)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpInterfacePtr:
|
|
|
|
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpInterface:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
for _, seen := range ctx.SeenPtr {
|
|
|
|
if p == seen {
|
|
|
|
return nil, errUnsupportedValue(code, p)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ctx.SeenPtr = append(ctx.SeenPtr, p)
|
|
|
|
iface := (*emptyInterface)(ptrToUnsafePtr(p))
|
|
|
|
if iface.ptr == nil {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(iface))
|
|
|
|
ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(iface.typ)))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
totalLength := uintptr(codeSet.CodeLength)
|
|
|
|
nextTotalLength := uintptr(ifaceCodeSet.CodeLength)
|
|
|
|
|
|
|
|
curlen := uintptr(len(ctx.Ptrs))
|
|
|
|
offsetNum := ptrOffset / uintptrSize
|
|
|
|
|
|
|
|
newLen := offsetNum + totalLength + nextTotalLength
|
|
|
|
if curlen < newLen {
|
|
|
|
ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...)
|
|
|
|
}
|
|
|
|
oldPtrs := ctx.Ptrs
|
|
|
|
|
|
|
|
newPtrs := ctx.Ptrs[(ptrOffset+totalLength*uintptrSize)/uintptrSize:]
|
|
|
|
newPtrs[0] = uintptr(iface.ptr)
|
|
|
|
|
|
|
|
ctx.Ptrs = newPtrs
|
|
|
|
|
|
|
|
oldBaseIndent := ctx.BaseIndent
|
|
|
|
ctx.BaseIndent = code.Indent
|
|
|
|
bb, err := Run(ctx, b, ifaceCodeSet, opt)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
ctx.BaseIndent = oldBaseIndent
|
|
|
|
|
|
|
|
ctx.Ptrs = oldPtrs
|
|
|
|
ctxptr = ctx.Ptr()
|
|
|
|
ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1]
|
|
|
|
|
|
|
|
b = bb
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpMarshalJSONPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpMarshalJSON:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
2021-03-22 15:29:16 +03:00
|
|
|
if code.IsNilableType && code.Indirect {
|
2021-03-18 17:56:56 +03:00
|
|
|
p = ptrToPtr(p)
|
|
|
|
}
|
2021-03-18 09:46:55 +03:00
|
|
|
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent, false)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendComma(bb)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpMarshalTextPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToPtr(p))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpMarshalText:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = append(b, `""`...)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
2021-03-22 15:29:16 +03:00
|
|
|
if code.IsNilableType && code.Indirect {
|
2021-03-18 17:56:56 +03:00
|
|
|
p = ptrToPtr(p)
|
|
|
|
}
|
2021-03-18 09:46:55 +03:00
|
|
|
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendComma(bb)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpSlicePtr:
|
|
|
|
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
2021-03-20 19:33:13 +03:00
|
|
|
code = code.End.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpSlice:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
slice := ptrToSlice(p)
|
|
|
|
if p == 0 || slice.Data == nil {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.ElemIdx, 0)
|
|
|
|
store(ctxptr, code.Length, uintptr(slice.Len))
|
|
|
|
store(ctxptr, code.Idx, uintptr(slice.Data))
|
|
|
|
if slice.Len > 0 {
|
|
|
|
b = append(b, '[', '\n')
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, uintptr(slice.Data))
|
|
|
|
} else {
|
|
|
|
b = append(b, '[', ']', ',', '\n')
|
|
|
|
code = code.End.Next
|
|
|
|
}
|
|
|
|
case encoder.OpSliceElem:
|
|
|
|
idx := load(ctxptr, code.ElemIdx)
|
|
|
|
length := load(ctxptr, code.Length)
|
|
|
|
idx++
|
|
|
|
if idx < length {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
store(ctxptr, code.ElemIdx, idx)
|
|
|
|
data := load(ctxptr, code.HeadIdx)
|
|
|
|
size := code.Size
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, data+idx*size)
|
|
|
|
} else {
|
|
|
|
b = b[:len(b)-2]
|
|
|
|
b = append(b, '\n')
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, ']', ',', '\n')
|
|
|
|
code = code.End.Next
|
|
|
|
}
|
|
|
|
case encoder.OpArrayPtr:
|
|
|
|
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
2021-03-20 19:33:13 +03:00
|
|
|
code = code.End.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpArray:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if code.Length > 0 {
|
|
|
|
b = append(b, '[', '\n')
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
store(ctxptr, code.ElemIdx, 0)
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
} else {
|
|
|
|
b = append(b, '[', ']', ',', '\n')
|
|
|
|
code = code.End.Next
|
|
|
|
}
|
|
|
|
case encoder.OpArrayElem:
|
|
|
|
idx := load(ctxptr, code.ElemIdx)
|
|
|
|
idx++
|
|
|
|
if idx < code.Length {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
store(ctxptr, code.ElemIdx, idx)
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
size := code.Size
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p+idx*size)
|
|
|
|
} else {
|
|
|
|
b = b[:len(b)-2]
|
|
|
|
b = append(b, '\n')
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, ']', ',', '\n')
|
|
|
|
code = code.End.Next
|
|
|
|
}
|
|
|
|
case encoder.OpMapPtr:
|
|
|
|
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpMap:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
uptr := ptrToUnsafePtr(p)
|
|
|
|
mlen := maplen(uptr)
|
|
|
|
if mlen <= 0 {
|
|
|
|
b = append(b, '{', '}', ',', '\n')
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
iter := mapiterinit(code.Type, uptr)
|
|
|
|
ctx.KeepRefs = append(ctx.KeepRefs, iter)
|
|
|
|
store(ctxptr, code.ElemIdx, 0)
|
|
|
|
store(ctxptr, code.Length, uintptr(mlen))
|
|
|
|
store(ctxptr, code.MapIter, uintptr(iter))
|
|
|
|
if (opt & encoder.UnorderedMapOption) == 0 {
|
|
|
|
mapCtx := encoder.NewMapContext(mlen)
|
|
|
|
mapCtx.Pos = append(mapCtx.Pos, len(b))
|
|
|
|
ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
|
|
|
|
store(ctxptr, code.End.MapPos, uintptr(unsafe.Pointer(mapCtx)))
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Next.Indent)
|
|
|
|
}
|
|
|
|
key := mapiterkey(iter)
|
|
|
|
store(ctxptr, code.Next.Idx, uintptr(key))
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpMapKey:
|
|
|
|
idx := load(ctxptr, code.ElemIdx)
|
|
|
|
length := load(ctxptr, code.Length)
|
|
|
|
idx++
|
|
|
|
if (opt & encoder.UnorderedMapOption) != 0 {
|
|
|
|
if idx < length {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
store(ctxptr, code.ElemIdx, idx)
|
|
|
|
ptr := load(ctxptr, code.MapIter)
|
|
|
|
iter := ptrToUnsafePtr(ptr)
|
|
|
|
key := mapiterkey(iter)
|
|
|
|
store(ctxptr, code.Next.Idx, uintptr(key))
|
|
|
|
code = code.Next
|
|
|
|
} else {
|
|
|
|
last := len(b) - 1
|
|
|
|
b[last] = '\n'
|
|
|
|
b = appendIndent(ctx, b, code.Indent-1)
|
|
|
|
b = append(b, '}', ',', '\n')
|
|
|
|
code = code.End.Next
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ptr := load(ctxptr, code.End.MapPos)
|
|
|
|
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
|
|
|
|
mapCtx.Pos = append(mapCtx.Pos, len(b))
|
|
|
|
if idx < length {
|
|
|
|
ptr := load(ctxptr, code.MapIter)
|
|
|
|
iter := ptrToUnsafePtr(ptr)
|
|
|
|
store(ctxptr, code.ElemIdx, idx)
|
|
|
|
key := mapiterkey(iter)
|
|
|
|
store(ctxptr, code.Next.Idx, uintptr(key))
|
|
|
|
code = code.Next
|
|
|
|
} else {
|
|
|
|
code = code.End
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case encoder.OpMapValue:
|
|
|
|
if (opt & encoder.UnorderedMapOption) != 0 {
|
|
|
|
b = append(b, ':', ' ')
|
|
|
|
} else {
|
|
|
|
ptr := load(ctxptr, code.End.MapPos)
|
|
|
|
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
|
|
|
|
mapCtx.Pos = append(mapCtx.Pos, len(b))
|
|
|
|
}
|
|
|
|
ptr := load(ctxptr, code.MapIter)
|
|
|
|
iter := ptrToUnsafePtr(ptr)
|
|
|
|
value := mapitervalue(iter)
|
|
|
|
store(ctxptr, code.Next.Idx, uintptr(value))
|
|
|
|
mapiternext(iter)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpMapEnd:
|
|
|
|
// this operation only used by sorted map
|
|
|
|
length := int(load(ctxptr, code.Length))
|
|
|
|
ptr := load(ctxptr, code.MapPos)
|
|
|
|
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(ptr))
|
|
|
|
pos := mapCtx.Pos
|
|
|
|
for i := 0; i < length; i++ {
|
|
|
|
startKey := pos[i*2]
|
|
|
|
startValue := pos[i*2+1]
|
|
|
|
var endValue int
|
|
|
|
if i+1 < length {
|
|
|
|
endValue = pos[i*2+2]
|
|
|
|
} else {
|
|
|
|
endValue = len(b)
|
|
|
|
}
|
|
|
|
mapCtx.Slice.Items = append(mapCtx.Slice.Items, encoder.MapItem{
|
|
|
|
Key: b[startKey:startValue],
|
|
|
|
Value: b[startValue:endValue],
|
|
|
|
})
|
|
|
|
}
|
|
|
|
sort.Sort(mapCtx.Slice)
|
|
|
|
buf := mapCtx.Buf
|
|
|
|
for _, item := range mapCtx.Slice.Items {
|
2021-04-20 14:12:32 +03:00
|
|
|
buf = appendIndent(ctx, buf, code.Indent+1)
|
2021-03-18 09:46:55 +03:00
|
|
|
buf = append(buf, item.Key...)
|
|
|
|
buf[len(buf)-2] = ':'
|
|
|
|
buf[len(buf)-1] = ' '
|
|
|
|
buf = append(buf, item.Value...)
|
|
|
|
}
|
|
|
|
buf = buf[:len(buf)-2]
|
|
|
|
buf = append(buf, '\n')
|
2021-04-20 14:12:32 +03:00
|
|
|
buf = appendIndent(ctx, buf, code.Indent)
|
2021-03-18 09:46:55 +03:00
|
|
|
buf = append(buf, '}', ',', '\n')
|
|
|
|
|
|
|
|
b = b[:pos[0]]
|
|
|
|
b = append(b, buf...)
|
|
|
|
mapCtx.Buf = buf
|
|
|
|
encoder.ReleaseMapContext(mapCtx)
|
|
|
|
code = code.Next
|
2021-03-19 09:46:53 +03:00
|
|
|
case encoder.OpRecursivePtr:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
2021-03-19 09:46:53 +03:00
|
|
|
case encoder.OpRecursive:
|
2021-03-18 09:46:55 +03:00
|
|
|
ptr := load(ctxptr, code.Idx)
|
|
|
|
if ptr != 0 {
|
|
|
|
if recursiveLevel > encoder.StartDetectingCyclesAfter {
|
|
|
|
for _, seen := range ctx.SeenPtr {
|
|
|
|
if ptr == seen {
|
|
|
|
return nil, errUnsupportedValue(code, ptr)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
ctx.SeenPtr = append(ctx.SeenPtr, ptr)
|
|
|
|
c := code.Jmp.Code
|
|
|
|
curlen := uintptr(len(ctx.Ptrs))
|
|
|
|
offsetNum := ptrOffset / uintptrSize
|
|
|
|
oldOffset := ptrOffset
|
|
|
|
ptrOffset += code.Jmp.CurLen * uintptrSize
|
2021-04-02 08:03:00 +03:00
|
|
|
oldBaseIndent := ctx.BaseIndent
|
|
|
|
ctx.BaseIndent += code.Indent - 1
|
2021-03-18 09:46:55 +03:00
|
|
|
|
|
|
|
newLen := offsetNum + code.Jmp.CurLen + code.Jmp.NextLen
|
|
|
|
if curlen < newLen {
|
|
|
|
ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...)
|
|
|
|
}
|
|
|
|
ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr
|
|
|
|
|
|
|
|
store(ctxptr, c.Idx, ptr)
|
|
|
|
store(ctxptr, c.End.Next.Idx, oldOffset)
|
|
|
|
store(ctxptr, c.End.Next.ElemIdx, uintptr(unsafe.Pointer(code.Next)))
|
2021-04-02 08:03:00 +03:00
|
|
|
store(ctxptr, c.End.Next.Length, uintptr(oldBaseIndent))
|
2021-03-18 09:46:55 +03:00
|
|
|
code = c
|
|
|
|
recursiveLevel++
|
2021-03-19 09:46:53 +03:00
|
|
|
case encoder.OpRecursiveEnd:
|
2021-03-18 09:46:55 +03:00
|
|
|
recursiveLevel--
|
|
|
|
|
|
|
|
// restore ctxptr
|
2021-04-02 08:03:00 +03:00
|
|
|
ctx.BaseIndent = int(load(ctxptr, code.Length))
|
2021-03-18 09:46:55 +03:00
|
|
|
offset := load(ctxptr, code.Idx)
|
|
|
|
ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1]
|
|
|
|
|
|
|
|
codePtr := load(ctxptr, code.ElemIdx)
|
|
|
|
code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr))
|
|
|
|
ctxptr = ctx.Ptr() + offset
|
|
|
|
ptrOffset = offset
|
|
|
|
case encoder.OpStructPtrHead:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHead:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && (code.Indirect || code.Next.Op == encoder.OpStructEnd) {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if !code.AnonymousKey && len(code.Key) > 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
}
|
|
|
|
p += code.Offset
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
case encoder.OpStructPtrHeadOmitEmpty:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmpty:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && (code.Indirect || code.Next.Op == encoder.OpStructEnd) {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
p += code.Offset
|
2021-03-20 14:35:44 +03:00
|
|
|
if p == 0 || (ptrToPtr(p) == 0 && code.IsNextOpPtrType) {
|
2021-03-18 09:46:55 +03:00
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
}
|
|
|
|
case encoder.OpStructPtrHeadInt:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadInt:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyInt:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyInt:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
u64 := ptrToUint64(p + code.Offset)
|
|
|
|
v := u64 & code.Mask
|
|
|
|
if v == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendInt(b, u64, code)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadIntString:
|
2021-03-18 09:46:55 +03:00
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadIntString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructPtrHeadOmitEmptyIntString:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyIntString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
u64 := ptrToUint64(p + code.Offset)
|
|
|
|
v := u64 & code.Mask
|
|
|
|
if v == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendInt(b, u64, code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructPtrHeadIntPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadIntPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyIntPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyIntPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadIntPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadIntPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructPtrHeadOmitEmptyIntPtrString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyIntPtrString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructPtrHeadUint:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadUint:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyUint:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyUint:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
u64 := ptrToUint64(p + code.Offset)
|
|
|
|
v := u64 & code.Mask
|
|
|
|
if v == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendUint(b, u64, code)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadUintString:
|
2021-03-18 09:46:55 +03:00
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadUintString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructPtrHeadOmitEmptyUintString:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyUintString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
u64 := ptrToUint64(p + code.Offset)
|
|
|
|
v := u64 & code.Mask
|
|
|
|
if v == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendUint(b, u64, code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructPtrHeadUintPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadUintPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyUintPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyUintPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadUintPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadUintPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructPtrHeadOmitEmptyUintPtrString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyUintPtrString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructPtrHeadFloat32:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadFloat32:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyFloat32:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyFloat32:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
v := ptrToFloat32(p + code.Offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendFloat32(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadFloat32String:
|
2021-03-18 09:46:55 +03:00
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadFloat32String:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructPtrHeadOmitEmptyFloat32String:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyFloat32String:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
v := ptrToFloat32(p + code.Offset)
|
|
|
|
if v == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendFloat32(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructPtrHeadFloat32Ptr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadFloat32Ptr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p))
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyFloat32Ptr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyFloat32Ptr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p))
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadFloat32PtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadFloat32PtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p))
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructPtrHeadOmitEmptyFloat32PtrString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyFloat32PtrString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructPtrHeadFloat64:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadFloat64:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
v := ptrToFloat64(p + code.Offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyFloat64:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyFloat64:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
v := ptrToFloat64(p + code.Offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
if v == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadFloat64String:
|
2021-03-18 09:46:55 +03:00
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadFloat64String:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
v := ptrToFloat64(p + code.Offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructPtrHeadOmitEmptyFloat64String:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyFloat64String:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
v := ptrToFloat64(p + code.Offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
if v == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructPtrHeadFloat64Ptr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadFloat64Ptr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyFloat64Ptr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyFloat64Ptr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadFloat64PtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadFloat64PtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructPtrHeadOmitEmptyFloat64PtrString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyFloat64PtrString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructPtrHeadString:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendString(b, ptrToString(p+code.Offset))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyString:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
v := ptrToString(p + code.Offset)
|
|
|
|
if v == "" {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendString(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadStringString:
|
2021-03-18 09:46:55 +03:00
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadStringString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
v := ptrToString(p + code.Offset)
|
|
|
|
b = appendString(b, string(appendString([]byte{}, v)))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructPtrHeadOmitEmptyStringString:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyStringString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
v := ptrToString(p + code.Offset)
|
|
|
|
if v == "" {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendString(b, string(appendString([]byte{}, v)))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructPtrHeadStringPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadStringPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendString(b, ptrToString(p))
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyStringPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyStringPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendString(b, ptrToString(p))
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadStringPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadStringPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendString(b, string(appendString([]byte{}, ptrToString(p))))
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructPtrHeadOmitEmptyStringPtrString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyStringPtrString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendString(b, string(appendString([]byte{}, ptrToString(p))))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructPtrHeadBool:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadBool:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendBool(b, ptrToBool(p+code.Offset))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyBool:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyBool:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
v := ptrToBool(p + code.Offset)
|
|
|
|
if v {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendBool(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
} else {
|
|
|
|
code = code.NextField
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadBoolString:
|
2021-03-18 09:46:55 +03:00
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadBoolString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendBool(b, ptrToBool(p+code.Offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructPtrHeadOmitEmptyBoolString:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyBoolString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
v := ptrToBool(p + code.Offset)
|
|
|
|
if v {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendBool(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
} else {
|
|
|
|
code = code.NextField
|
|
|
|
}
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructPtrHeadBoolPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadBoolPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendBool(b, ptrToBool(p+code.Offset))
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyBoolPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructHeadOmitEmptyBoolPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendBool(b, ptrToBool(p))
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadBoolPtrString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadBoolPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
2021-03-18 09:46:55 +03:00
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
2021-05-06 18:12:59 +03:00
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendBool(b, ptrToBool(p))
|
2021-05-06 18:12:59 +03:00
|
|
|
b = append(b, '"')
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendComma(b)
|
2021-03-18 09:46:55 +03:00
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructPtrHeadOmitEmptyBoolPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructHeadOmitEmptyBoolPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
2021-05-06 18:12:59 +03:00
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendBool(b, ptrToBool(p))
|
|
|
|
b = append(b, '"')
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendComma(b)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadBytes:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadBytes:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyBytes:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyBytes:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
v := ptrToBytes(p + code.Offset)
|
|
|
|
if len(v) == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendByteSlice(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
|
|
|
case encoder.OpStructPtrHeadBytesPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadBytesPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendByteSlice(b, ptrToBytes(p))
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyBytesPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyBytesPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendByteSlice(b, ptrToBytes(p))
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadNumber:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadNumber:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p+code.Offset))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendComma(bb)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyNumber:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyNumber:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
v := ptrToNumber(p + code.Offset)
|
|
|
|
if v == "" {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
bb, err := appendNumber(b, v)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendComma(bb)
|
|
|
|
code = code.Next
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadNumberString:
|
2021-03-18 09:46:55 +03:00
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadNumberString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = append(b, '"')
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p+code.Offset))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(bb, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructPtrHeadOmitEmptyNumberString:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyNumberString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
v := ptrToNumber(p + code.Offset)
|
|
|
|
if v == "" {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
bb, err := appendNumber(b, v)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(bb)
|
|
|
|
code = code.Next
|
|
|
|
}
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructPtrHeadNumberPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadNumberPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyNumberPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyNumberPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
2021-03-20 13:01:04 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
2021-03-18 09:46:55 +03:00
|
|
|
b = append(b, code.Key...)
|
2021-03-20 13:01:04 +03:00
|
|
|
b = append(b, ' ')
|
2021-03-18 09:46:55 +03:00
|
|
|
bb, err := appendNumber(b, ptrToNumber(p))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendComma(bb)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadNumberPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadNumberPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(bb, '"')
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructPtrHeadOmitEmptyNumberPtrString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyNumberPtrString:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(bb)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice:
|
2021-03-18 09:46:55 +03:00
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadArray, encoder.OpStructHeadSlice:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p += code.Offset
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyArray:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyArray:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
p += code.Offset
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptySlice:
|
|
|
|
if code.Indirect {
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptySlice:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
p += code.Offset
|
|
|
|
slice := ptrToSlice(p)
|
2021-04-10 10:25:45 +03:00
|
|
|
if slice.Len == 0 {
|
2021-03-18 09:46:55 +03:00
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
}
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyArrayPtr, encoder.OpStructPtrHeadOmitEmptySlicePtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyArrayPtr, encoder.OpStructHeadOmitEmptySlicePtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadMap:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadMap:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if p != 0 && code.Indirect {
|
|
|
|
p = ptrToPtr(p + code.Offset)
|
|
|
|
}
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyMap:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyMap:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if p != 0 && code.Indirect {
|
|
|
|
p = ptrToPtr(p + code.Offset)
|
|
|
|
}
|
|
|
|
if maplen(ptrToUnsafePtr(p)) == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadMapPtr:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadMapPtr:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.NextField
|
|
|
|
break
|
|
|
|
}
|
|
|
|
p = ptrToPtr(p + code.Offset)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p, code.PtrNum)
|
|
|
|
}
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
}
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyMapPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyMapPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
break
|
|
|
|
}
|
|
|
|
p = ptrToPtr(p + code.Offset)
|
|
|
|
if p == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p, code.PtrNum)
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
}
|
|
|
|
case encoder.OpStructPtrHeadMarshalJSON:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadMarshalJSON:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
2021-03-22 15:29:16 +03:00
|
|
|
if code.IsNilableType {
|
2021-03-18 09:46:55 +03:00
|
|
|
if code.Indirect || code.Op == encoder.OpStructPtrHeadMarshalJSON {
|
|
|
|
p = ptrToPtr(p + code.Offset)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if p == 0 && code.Nilcheck {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
2021-03-20 14:13:55 +03:00
|
|
|
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent+1, false)
|
2021-03-18 09:46:55 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyMarshalJSON:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyMarshalJSON:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
2021-03-22 15:29:16 +03:00
|
|
|
if code.IsNilableType {
|
2021-03-18 09:46:55 +03:00
|
|
|
if code.Indirect || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalJSON {
|
|
|
|
p = ptrToPtr(p + code.Offset)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
iface := ptrToInterface(code, p)
|
|
|
|
if code.Nilcheck && encoder.IsNilForMarshaler(iface) {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
2021-03-20 14:13:55 +03:00
|
|
|
bb, err := appendMarshalJSON(ctx, code, b, iface, code.Indent+1, false)
|
2021-03-18 09:46:55 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadMarshalJSONPtr:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadMarshalJSONPtr:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
2021-03-20 14:13:55 +03:00
|
|
|
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent+1, false)
|
2021-03-18 09:46:55 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyMarshalJSONPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyMarshalJSONPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
2021-03-20 14:13:55 +03:00
|
|
|
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent+1, false)
|
2021-03-18 09:46:55 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
|
|
|
case encoder.OpStructPtrHeadMarshalText:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadMarshalText:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
2021-03-22 15:29:16 +03:00
|
|
|
if code.IsNilableType {
|
2021-03-18 09:46:55 +03:00
|
|
|
if code.Indirect || code.Op == encoder.OpStructPtrHeadMarshalText {
|
|
|
|
p = ptrToPtr(p + code.Offset)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if p == 0 && code.Nilcheck {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyMarshalText:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
}
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyMarshalText:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
2021-03-22 15:29:16 +03:00
|
|
|
if code.IsNilableType {
|
2021-03-18 09:46:55 +03:00
|
|
|
if code.Indirect || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalText {
|
|
|
|
p = ptrToPtr(p + code.Offset)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if p == 0 && code.Nilcheck {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructPtrHeadMarshalTextPtr:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructHeadMarshalTextPtr:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructPtrHeadOmitEmptyMarshalTextPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
|
|
|
|
fallthrough
|
|
|
|
case encoder.OpStructHeadOmitEmptyMarshalTextPtr:
|
|
|
|
p := load(ctxptr, code.Idx)
|
|
|
|
if p == 0 && code.Indirect {
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = appendNull(b)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.End.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if code.Indirect {
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
}
|
|
|
|
if !code.AnonymousHead {
|
|
|
|
b = append(b, '{', '\n')
|
|
|
|
}
|
|
|
|
if p == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent+1)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
}
|
|
|
|
case encoder.OpStructField:
|
|
|
|
if !code.AnonymousKey {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
}
|
|
|
|
p := load(ctxptr, code.HeadIdx) + code.Offset
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
case encoder.OpStructFieldOmitEmpty:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p += code.Offset
|
2021-03-20 14:35:44 +03:00
|
|
|
if ptrToPtr(p) == 0 && code.IsNextOpPtrType {
|
2021-03-18 09:46:55 +03:00
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
}
|
|
|
|
case encoder.OpStructFieldInt:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyInt:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
u64 := ptrToUint64(p + code.Offset)
|
|
|
|
v := u64 & code.Mask
|
|
|
|
if v != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendInt(b, u64, code)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldIntString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructFieldOmitEmptyIntString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
u64 := ptrToUint64(p + code.Offset)
|
|
|
|
v := u64 & code.Mask
|
|
|
|
if v != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendInt(b, u64, code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructFieldIntPtr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyIntPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldIntPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructFieldOmitEmptyIntPtrString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructFieldUint:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyUint:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
u64 := ptrToUint64(p + code.Offset)
|
|
|
|
v := u64 & code.Mask
|
|
|
|
if v != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendUint(b, u64, code)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldUintString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructFieldOmitEmptyUintString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
u64 := ptrToUint64(p + code.Offset)
|
|
|
|
v := u64 & code.Mask
|
|
|
|
if v != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendUint(b, u64, code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructFieldUintPtr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyUintPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldUintPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructFieldOmitEmptyUintPtrString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructFieldFloat32:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyFloat32:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToFloat32(p + code.Offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendFloat32(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldFloat32String:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructFieldOmitEmptyFloat32String:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToFloat32(p + code.Offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendFloat32(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructFieldFloat32Ptr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p))
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyFloat32Ptr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p))
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldFloat32PtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p))
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructFieldOmitEmptyFloat32PtrString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructFieldFloat64:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToFloat64(p + code.Offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyFloat64:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToFloat64(p + code.Offset)
|
|
|
|
if v != 0 {
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldFloat64String:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToFloat64(p + code.Offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructFieldOmitEmptyFloat64String:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToFloat64(p + code.Offset)
|
|
|
|
if v != 0 {
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructFieldFloat64Ptr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyFloat64Ptr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldFloat64PtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructFieldOmitEmptyFloat64PtrString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructFieldString:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendString(b, ptrToString(p+code.Offset))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToString(p + code.Offset)
|
|
|
|
if v != "" {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendString(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldStringString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
s := ptrToString(p + code.Offset)
|
|
|
|
b = appendString(b, string(appendString([]byte{}, s)))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructFieldOmitEmptyStringString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToString(p + code.Offset)
|
|
|
|
if v != "" {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendString(b, string(appendString([]byte{}, v)))
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructFieldStringPtr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendString(b, ptrToString(p))
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyStringPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendString(b, ptrToString(p))
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldStringPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendString(b, string(appendString([]byte{}, ptrToString(p))))
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructFieldOmitEmptyStringPtrString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendString(b, string(appendString([]byte{}, ptrToString(p))))
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructFieldBool:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendBool(b, ptrToBool(p+code.Offset))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyBool:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToBool(p + code.Offset)
|
|
|
|
if v {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendBool(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldBoolString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendBool(b, ptrToBool(p+code.Offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructFieldOmitEmptyBoolString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToBool(p + code.Offset)
|
|
|
|
if v {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendBool(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructFieldBoolPtr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendBool(b, ptrToBool(p))
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyBoolPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendBool(b, ptrToBool(p))
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldBoolPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendBool(b, ptrToBool(p))
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructFieldOmitEmptyBoolPtrString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendBool(b, ptrToBool(p))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructFieldBytes:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyBytes:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToBytes(p + code.Offset)
|
|
|
|
if len(v) > 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendByteSlice(b, v)
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldBytesPtr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendByteSlice(b, ptrToBytes(p))
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyBytesPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendByteSlice(b, ptrToBytes(p))
|
|
|
|
b = appendComma(b)
|
|
|
|
}
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldNumber:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p+code.Offset))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendComma(bb)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyNumber:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToNumber(p + code.Offset)
|
|
|
|
if v != "" {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
bb, err := appendNumber(b, v)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendComma(bb)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldNumberString:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = append(b, '"')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p+code.Offset))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(bb, '"')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructFieldOmitEmptyNumberString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToNumber(p + code.Offset)
|
|
|
|
if v != "" {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
bb, err := appendNumber(b, v)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(bb)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructFieldNumberPtr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyNumberPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendComma(bb)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldNumberPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2021-05-06 18:12:59 +03:00
|
|
|
b = append(bb, '"')
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyNumberPtrString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendComma(bb)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldMarshalJSON:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p += code.Offset
|
2021-03-22 15:29:16 +03:00
|
|
|
if code.IsNilableType {
|
2021-03-18 09:46:55 +03:00
|
|
|
p = ptrToPtr(p)
|
|
|
|
}
|
|
|
|
if p == 0 && code.Nilcheck {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
2021-03-20 14:13:55 +03:00
|
|
|
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent+1, false)
|
2021-03-18 09:46:55 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyMarshalJSON:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p += code.Offset
|
2021-03-22 15:29:16 +03:00
|
|
|
if code.IsNilableType {
|
2021-03-18 09:46:55 +03:00
|
|
|
p = ptrToPtr(p)
|
|
|
|
}
|
|
|
|
if p == 0 && code.Nilcheck {
|
|
|
|
code = code.NextField
|
|
|
|
break
|
|
|
|
}
|
2021-04-12 11:41:31 +03:00
|
|
|
iface := ptrToInterface(code, p)
|
|
|
|
if code.Nilcheck && encoder.IsNilForMarshaler(iface) {
|
|
|
|
code = code.NextField
|
|
|
|
break
|
|
|
|
}
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
2021-04-12 11:41:31 +03:00
|
|
|
bb, err := appendMarshalJSON(ctx, code, b, iface, code.Indent+1, false)
|
2021-03-18 09:46:55 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendComma(bb)
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldMarshalJSONPtr:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
2021-03-20 14:13:55 +03:00
|
|
|
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent+1, false)
|
2021-03-18 09:46:55 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyMarshalJSONPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
2021-03-20 14:13:55 +03:00
|
|
|
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p), code.Indent+1, false)
|
2021-03-18 09:46:55 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendComma(bb)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldMarshalText:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p += code.Offset
|
2021-03-22 15:29:16 +03:00
|
|
|
if code.IsNilableType {
|
2021-03-18 09:46:55 +03:00
|
|
|
p = ptrToPtr(p)
|
|
|
|
}
|
|
|
|
if p == 0 && code.Nilcheck {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyMarshalText:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p += code.Offset
|
2021-03-22 15:29:16 +03:00
|
|
|
if code.IsNilableType {
|
2021-03-18 09:46:55 +03:00
|
|
|
p = ptrToPtr(p)
|
|
|
|
}
|
|
|
|
if p == 0 && code.Nilcheck {
|
|
|
|
code = code.NextField
|
|
|
|
break
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendComma(bb)
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldMarshalTextPtr:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
}
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructFieldOmitEmptyMarshalTextPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
bb, err := appendMarshalText(code, b, ptrToInterface(code, p), false)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendComma(bb)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldArray:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p += code.Offset
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
case encoder.OpStructFieldOmitEmptyArray:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p += code.Offset
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldArrayPtr:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
case encoder.OpStructFieldOmitEmptyArrayPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
} else {
|
|
|
|
code = code.NextField
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldSlice:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p += code.Offset
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
case encoder.OpStructFieldOmitEmptySlice:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p += code.Offset
|
|
|
|
slice := ptrToSlice(p)
|
2021-04-10 10:25:45 +03:00
|
|
|
if slice.Len == 0 {
|
2021-03-18 09:46:55 +03:00
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldSlicePtr:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
case encoder.OpStructFieldOmitEmptySlicePtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
} else {
|
|
|
|
code = code.NextField
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldMap:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToPtr(p + code.Offset)
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
case encoder.OpStructFieldOmitEmptyMap:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToPtr(p + code.Offset)
|
|
|
|
if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 {
|
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldMapPtr:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToPtr(p + code.Offset)
|
|
|
|
if p != 0 {
|
|
|
|
p = ptrToNPtr(p, code.PtrNum)
|
|
|
|
}
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
case encoder.OpStructFieldOmitEmptyMapPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToPtr(p + code.Offset)
|
|
|
|
if p != 0 {
|
|
|
|
p = ptrToNPtr(p, code.PtrNum)
|
|
|
|
}
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
} else {
|
|
|
|
code = code.NextField
|
|
|
|
}
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructFieldStruct:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p += code.Offset
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
case encoder.OpStructFieldOmitEmptyStruct:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p += code.Offset
|
2021-03-20 14:35:44 +03:00
|
|
|
if ptrToPtr(p) == 0 && code.IsNextOpPtrType {
|
2021-03-18 09:46:55 +03:00
|
|
|
code = code.NextField
|
|
|
|
} else {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
code = code.Next
|
|
|
|
store(ctxptr, code.Idx, p)
|
|
|
|
}
|
|
|
|
case encoder.OpStructAnonymousEnd:
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEnd:
|
|
|
|
last := len(b) - 1
|
|
|
|
if b[last-1] == '{' {
|
|
|
|
b[last] = '}'
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
break
|
|
|
|
}
|
|
|
|
if b[last] == '\n' {
|
|
|
|
// to remove ',' and '\n' characters
|
|
|
|
b = b[:len(b)-2]
|
|
|
|
}
|
|
|
|
b = append(b, '\n')
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, '}')
|
|
|
|
b = appendComma(b)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndInt:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyInt:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
u64 := ptrToUint64(p + code.Offset)
|
|
|
|
v := u64 & code.Mask
|
|
|
|
if v != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendInt(b, u64, code)
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructEndIntString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendInt(b, ptrToUint64(p+code.Offset), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructEndOmitEmptyIntString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
u64 := ptrToUint64(p + code.Offset)
|
|
|
|
v := u64 & code.Mask
|
|
|
|
if v != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendInt(b, u64, code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructEndIntPtr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyIntPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructEndIntPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructEndOmitEmptyIntPtrString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendInt(b, ptrToUint64(p), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructEndUint:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyUint:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
u64 := ptrToUint64(p + code.Offset)
|
|
|
|
v := u64 & code.Mask
|
|
|
|
if v != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendUint(b, u64, code)
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructEndUintString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendUint(b, ptrToUint64(p+code.Offset), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructEndOmitEmptyUintString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
u64 := ptrToUint64(p + code.Offset)
|
|
|
|
v := u64 & code.Mask
|
|
|
|
if v != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendUint(b, u64, code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructEndUintPtr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyUintPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructEndUintPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructEndOmitEmptyUintPtrString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendUint(b, ptrToUint64(p), code)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructEndFloat32:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyFloat32:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToFloat32(p + code.Offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendFloat32(b, v)
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructEndFloat32String:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p+code.Offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructEndOmitEmptyFloat32String:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToFloat32(p + code.Offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendFloat32(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructEndFloat32Ptr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p))
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyFloat32Ptr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p))
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructEndFloat32PtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p))
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructEndOmitEmptyFloat32PtrString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendFloat32(b, ptrToFloat32(p))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructEndFloat64:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToFloat64(p + code.Offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyFloat64:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToFloat64(p + code.Offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructEndFloat64String:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToFloat64(p + code.Offset)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructEndOmitEmptyFloat64String:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToFloat64(p + code.Offset)
|
|
|
|
if v != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructEndFloat64Ptr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyFloat64Ptr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructEndFloat64PtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructEndOmitEmptyFloat64PtrString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
v := ptrToFloat64(p)
|
|
|
|
if math.IsInf(v, 0) || math.IsNaN(v) {
|
|
|
|
return nil, errUnsupportedFloat(v)
|
|
|
|
}
|
|
|
|
b = appendFloat64(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructEndString:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendString(b, ptrToString(p+code.Offset))
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToString(p + code.Offset)
|
|
|
|
if v != "" {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendString(b, v)
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructEndStringString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
s := ptrToString(p + code.Offset)
|
|
|
|
b = appendString(b, string(appendString([]byte{}, s)))
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructEndOmitEmptyStringString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToString(p + code.Offset)
|
|
|
|
if v != "" {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendString(b, string(appendString([]byte{}, v)))
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructEndStringPtr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendString(b, ptrToString(p))
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyStringPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendString(b, ptrToString(p))
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructEndStringPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendString(b, string(appendString([]byte{}, ptrToString(p))))
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructEndOmitEmptyStringPtrString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendString(b, string(appendString([]byte{}, ptrToString(p))))
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructEndBool:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendBool(b, ptrToBool(p+code.Offset))
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyBool:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToBool(p + code.Offset)
|
|
|
|
if v {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendBool(b, v)
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructEndBoolString:
|
2021-03-18 09:46:55 +03:00
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendBool(b, ptrToBool(p+code.Offset))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructEndOmitEmptyBoolString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToBool(p + code.Offset)
|
|
|
|
if v {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendBool(b, v)
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructEndBoolPtr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendBool(b, ptrToBool(p))
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyBoolPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendBool(b, ptrToBool(p))
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructEndBoolPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendBool(b, ptrToBool(p))
|
|
|
|
b = append(b, '"')
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructEndOmitEmptyBoolPtrString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
b = appendBool(b, ptrToBool(p))
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructEndBytes:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
b = appendByteSlice(b, ptrToBytes(p+code.Offset))
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyBytes:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToBytes(p + code.Offset)
|
|
|
|
if len(v) > 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendByteSlice(b, v)
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndBytesPtr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = appendByteSlice(b, ptrToBytes(p))
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyBytesPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = appendByteSlice(b, ptrToBytes(p))
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndNumber:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p+code.Offset))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, bb, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyNumber:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToNumber(p + code.Offset)
|
|
|
|
if v != "" {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
bb, err := appendNumber(b, v)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, bb, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructEndNumberString:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
b = append(b, '"')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p+code.Offset))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(bb, '"')
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructEndOmitEmptyNumberString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
v := ptrToNumber(p + code.Offset)
|
|
|
|
if v != "" {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
bb, err := appendNumber(b, v)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, bb, code.Indent-1)
|
|
|
|
} else {
|
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpStructEndNumberPtr:
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = bb
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
|
|
|
case encoder.OpStructEndOmitEmptyNumberPtr:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, bb, code.Indent-1)
|
|
|
|
} else {
|
2021-05-06 18:12:59 +03:00
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
2021-03-18 09:46:55 +03:00
|
|
|
}
|
|
|
|
code = code.Next
|
2021-05-06 14:54:22 +03:00
|
|
|
case encoder.OpStructEndNumberPtrString:
|
2021-03-18 09:46:55 +03:00
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ')
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p == 0 {
|
|
|
|
b = appendNull(b)
|
|
|
|
} else {
|
|
|
|
b = append(b, '"')
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(bb, '"')
|
|
|
|
}
|
|
|
|
b = appendStructEnd(ctx, b, code.Indent-1)
|
|
|
|
code = code.Next
|
2021-05-06 18:12:59 +03:00
|
|
|
case encoder.OpStructEndOmitEmptyNumberPtrString:
|
|
|
|
p := load(ctxptr, code.HeadIdx)
|
|
|
|
p = ptrToNPtr(p+code.Offset, code.PtrNum)
|
|
|
|
if p != 0 {
|
|
|
|
b = appendIndent(ctx, b, code.Indent)
|
|
|
|
b = append(b, code.Key...)
|
|
|
|
b = append(b, ' ', '"')
|
|
|
|
bb, err := appendNumber(b, ptrToNumber(p))
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
b = append(b, '"')
|
|
|
|
b = appendStructEnd(ctx, bb, code.Indent-1)
|
|
|
|
} else {
|
|
|
|
b = appendStructEndSkipLast(ctx, b, code)
|
|
|
|
}
|
|
|
|
code = code.Next
|
2021-03-18 09:46:55 +03:00
|
|
|
case encoder.OpEnd:
|
|
|
|
goto END
|
|
|
|
}
|
|
|
|
}
|
|
|
|
END:
|
|
|
|
return b, nil
|
|
|
|
}
|