go-json/internal/encoder/vm/vm.go

4851 lines
134 KiB
Go
Raw Normal View History

2021-05-19 06:34:40 +03:00
// Code generated by internal/cmd/generator. DO NOT EDIT!
2021-03-16 18:22:19 +03:00
package vm
2021-03-15 20:50:19 +03:00
import (
"math"
"sort"
"unsafe"
"github.com/goccy/go-json/internal/encoder"
"github.com/goccy/go-json/internal/runtime"
2021-03-15 20:50:19 +03:00
)
2021-05-31 16:25:33 +03:00
func Run(ctx *encoder.RuntimeContext, b []byte, codeSet *encoder.OpcodeSet) ([]byte, error) {
2021-03-15 20:50:19 +03:00
recursiveLevel := 0
ptrOffset := uintptr(0)
ctxptr := ctx.Ptr()
2021-05-31 19:25:05 +03:00
var code *encoder.Opcode
2021-06-01 07:40:15 +03:00
if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 {
2021-05-31 19:25:05 +03:00
code = codeSet.EscapeKeyCode
} else {
code = codeSet.NoescapeKeyCode
}
2021-03-15 20:50:19 +03:00
for {
switch code.Op {
default:
return nil, errUnimplementedOp(code.Op)
2021-03-15 20:50:19 +03:00
case encoder.OpPtr:
p := load(ctxptr, code.Idx)
code = code.Next
store(ctxptr, code.Idx, ptrToPtr(p))
case encoder.OpIntPtr:
2021-03-16 18:22:19 +03:00
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
code = code.Next
break
}
store(ctxptr, code.Idx, p)
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpInt:
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, load(ctxptr, code.Idx), code)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpUintPtr:
2021-03-16 18:22:19 +03:00
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
code = code.Next
break
}
store(ctxptr, code.Idx, p)
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpUint:
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, load(ctxptr, code.Idx), code)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpIntString:
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, load(ctxptr, code.Idx), code)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpUintString:
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, load(ctxptr, code.Idx), code)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpFloat32Ptr:
2021-03-16 18:22:19 +03:00
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
b = appendNull(ctx, b)
b = appendComma(ctx, b)
2021-03-16 18:22:19 +03:00
code = code.Next
break
}
store(ctxptr, code.Idx, p)
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpFloat32:
b = appendFloat32(ctx, b, ptrToFloat32(load(ctxptr, code.Idx)))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpFloat64Ptr:
2021-03-16 18:22:19 +03:00
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
code = code.Next
break
}
store(ctxptr, code.Idx, p)
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpFloat64:
v := ptrToFloat64(load(ctxptr, code.Idx))
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
2021-03-15 20:50:19 +03:00
}
b = appendFloat64(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStringPtr:
2021-03-16 18:22:19 +03:00
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
code = code.Next
break
}
store(ctxptr, code.Idx, p)
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpString:
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, ptrToString(load(ctxptr, code.Idx)))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpBoolPtr:
2021-03-16 18:22:19 +03:00
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
code = code.Next
break
}
store(ctxptr, code.Idx, p)
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpBool:
b = appendBool(ctx, b, ptrToBool(load(ctxptr, code.Idx)))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpBytesPtr:
2021-03-16 18:22:19 +03:00
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
code = code.Next
break
}
store(ctxptr, code.Idx, p)
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpBytes:
b = appendByteSlice(ctx, b, ptrToBytes(load(ctxptr, code.Idx)))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpNumberPtr:
2021-03-16 18:22:19 +03:00
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
code = code.Next
break
}
store(ctxptr, code.Idx, p)
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpNumber:
bb, err := appendNumber(ctx, b, ptrToNumber(load(ctxptr, code.Idx)))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendComma(ctx, bb)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpInterfacePtr:
2021-03-16 18:22:19 +03:00
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
code = code.Next
break
}
store(ctxptr, code.Idx, p)
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpInterface:
p := load(ctxptr, code.Idx)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
break
}
if recursiveLevel > encoder.StartDetectingCyclesAfter {
for _, seen := range ctx.SeenPtr {
if p == seen {
return nil, errUnsupportedValue(code, p)
}
2021-03-15 20:50:19 +03:00
}
}
ctx.SeenPtr = append(ctx.SeenPtr, p)
var (
typ *runtime.Type
ifacePtr unsafe.Pointer
)
2021-08-30 07:11:44 +03:00
up := ptrToUnsafePtr(p)
if code.Flags&encoder.NonEmptyInterfaceFlags != 0 {
2021-08-30 07:11:44 +03:00
iface := (*nonEmptyInterface)(up)
ifacePtr = iface.ptr
if iface.itab != nil {
typ = iface.itab.typ
}
} else {
2021-08-30 07:11:44 +03:00
iface := (*emptyInterface)(up)
ifacePtr = iface.ptr
typ = iface.typ
}
if ifacePtr == nil {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
break
}
2021-08-30 07:11:44 +03:00
ctx.KeepRefs = append(ctx.KeepRefs, up)
ifaceCodeSet, err := encoder.CompileToGetCodeSet(uintptr(unsafe.Pointer(typ)))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
2021-06-25 14:17:12 +03:00
totalLength := uintptr(code.Length) + 3
nextTotalLength := uintptr(ifaceCodeSet.CodeLength) + 3
var c *encoder.Opcode
if (ctx.Option.Flag & encoder.HTMLEscapeOption) != 0 {
c = ifaceCodeSet.InterfaceEscapeKeyCode
} else {
c = ifaceCodeSet.InterfaceNoescapeKeyCode
}
curlen := uintptr(len(ctx.Ptrs))
offsetNum := ptrOffset / uintptrSize
oldOffset := ptrOffset
ptrOffset += totalLength * uintptrSize
oldBaseIndent := ctx.BaseIndent
indentDiffFromTop := c.Indent - 1
ctx.BaseIndent += code.Indent - indentDiffFromTop
newLen := offsetNum + totalLength + nextTotalLength
if curlen < newLen {
ctx.Ptrs = append(ctx.Ptrs, make([]uintptr, newLen-curlen)...)
}
ctxptr = ctx.Ptr() + ptrOffset // assign new ctxptr
end := ifaceCodeSet.EndCode
store(ctxptr, c.Idx, uintptr(ifacePtr))
2021-06-25 14:17:12 +03:00
store(ctxptr, end.Idx, oldOffset)
store(ctxptr, end.ElemIdx, uintptr(unsafe.Pointer(code.Next)))
2021-06-25 16:27:00 +03:00
storeIndent(ctxptr, end, uintptr(oldBaseIndent))
2021-06-25 14:17:12 +03:00
code = c
recursiveLevel++
2021-06-25 14:17:12 +03:00
case encoder.OpInterfaceEnd:
recursiveLevel--
2021-06-25 14:17:12 +03:00
// restore ctxptr
offset := load(ctxptr, code.Idx)
2021-06-25 14:17:12 +03:00
restoreIndent(ctx, code, ctxptr)
2021-03-15 20:50:19 +03:00
ctx.SeenPtr = ctx.SeenPtr[:len(ctx.SeenPtr)-1]
2021-06-25 14:17:12 +03:00
codePtr := load(ctxptr, code.ElemIdx)
code = (*encoder.Opcode)(ptrToUnsafePtr(codePtr))
ctxptr = ctx.Ptr() + offset
ptrOffset = offset
2021-03-15 20:50:19 +03:00
case encoder.OpMarshalJSONPtr:
p := load(ctxptr, code.Idx)
2021-03-16 18:22:19 +03:00
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
code = code.Next
break
}
store(ctxptr, code.Idx, ptrToPtr(p))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
break
}
if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2021-03-18 17:56:56 +03:00
p = ptrToPtr(p)
}
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendComma(ctx, bb)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpMarshalTextPtr:
p := load(ctxptr, code.Idx)
2021-03-16 18:22:19 +03:00
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
code = code.Next
break
}
store(ctxptr, code.Idx, ptrToPtr(p))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpMarshalText:
p := load(ctxptr, code.Idx)
if p == 0 {
b = append(b, `""`...)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
break
}
if (code.Flags&encoder.IsNilableTypeFlags) != 0 && (code.Flags&encoder.IndirectFlags) != 0 {
2021-03-18 17:56:56 +03:00
p = ptrToPtr(p)
}
2021-05-31 19:25:05 +03:00
bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendComma(ctx, bb)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpSlicePtr:
2021-03-16 18:22:19 +03:00
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-20 19:33:13 +03:00
code = code.End.Next
2021-03-16 18:22:19 +03:00
break
}
store(ctxptr, code.Idx, p)
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpSlice:
p := load(ctxptr, code.Idx)
slice := ptrToSlice(p)
if p == 0 || slice.Data == nil {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.End.Next
break
}
store(ctxptr, code.ElemIdx, 0)
store(ctxptr, code.Length, uintptr(slice.Len))
store(ctxptr, code.Idx, uintptr(slice.Data))
2021-03-15 20:50:19 +03:00
if slice.Len > 0 {
b = appendArrayHead(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, uintptr(slice.Data))
} else {
b = appendEmptyArray(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.End.Next
}
case encoder.OpSliceElem:
idx := load(ctxptr, code.ElemIdx)
length := load(ctxptr, code.Length)
idx++
if idx < length {
b = appendArrayElemIndent(ctx, code, b)
2021-03-15 20:50:19 +03:00
store(ctxptr, code.ElemIdx, idx)
data := load(ctxptr, code.Idx)
size := uintptr(code.Size)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, data+idx*size)
} else {
b = appendArrayEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.End.Next
}
case encoder.OpArrayPtr:
2021-03-16 18:22:19 +03:00
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-20 19:33:13 +03:00
code = code.End.Next
2021-03-16 18:22:19 +03:00
break
}
store(ctxptr, code.Idx, p)
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpArray:
p := load(ctxptr, code.Idx)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.End.Next
break
}
if code.Length > 0 {
b = appendArrayHead(ctx, code, b)
2021-03-15 20:50:19 +03:00
store(ctxptr, code.ElemIdx, 0)
code = code.Next
store(ctxptr, code.Idx, p)
} else {
b = appendEmptyArray(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.End.Next
}
case encoder.OpArrayElem:
idx := load(ctxptr, code.ElemIdx)
idx++
if idx < uintptr(code.Length) {
b = appendArrayElemIndent(ctx, code, b)
2021-03-15 20:50:19 +03:00
store(ctxptr, code.ElemIdx, idx)
p := load(ctxptr, code.Idx)
size := uintptr(code.Size)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p+idx*size)
} else {
b = appendArrayEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.End.Next
}
case encoder.OpMapPtr:
2021-03-16 18:22:19 +03:00
p := loadNPtr(ctxptr, code.Idx, code.PtrNum)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
code = code.End.Next
2021-03-16 18:22:19 +03:00
break
}
store(ctxptr, code.Idx, p)
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpMap:
p := load(ctxptr, code.Idx)
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.End.Next
break
}
uptr := ptrToUnsafePtr(p)
mlen := maplen(uptr)
if mlen <= 0 {
b = appendEmptyObject(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.End.Next
break
}
b = appendStructHead(ctx, b)
2021-12-27 05:14:42 +03:00
mapCtx := encoder.NewMapContext(mlen)
mapiterinit(code.Type, uptr, &mapCtx.Iter)
store(ctxptr, code.MapIter, uintptr(unsafe.Pointer(mapCtx)))
ctx.KeepRefs = append(ctx.KeepRefs, unsafe.Pointer(mapCtx))
2021-06-01 07:40:15 +03:00
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
2021-05-31 16:25:33 +03:00
b = appendMapKeyIndent(ctx, code.Next, b)
} else {
2021-12-27 05:14:42 +03:00
mapCtx.Start = len(b)
mapCtx.First = len(b)
2021-03-15 20:50:19 +03:00
}
2021-12-27 05:14:42 +03:00
key := mapiterkey(&mapCtx.Iter)
2021-03-15 20:50:19 +03:00
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
case encoder.OpMapKey:
2021-12-27 05:14:42 +03:00
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter)))
idx := mapCtx.Idx
2021-03-15 20:50:19 +03:00
idx++
2021-06-01 07:40:15 +03:00
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
2021-12-27 05:14:42 +03:00
if idx < mapCtx.Len {
b = appendMapKeyIndent(ctx, code, b)
2021-12-27 05:14:42 +03:00
mapCtx.Idx = int(idx)
key := mapiterkey(&mapCtx.Iter)
2021-03-15 20:50:19 +03:00
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
} else {
b = appendObjectEnd(ctx, code, b)
2021-12-27 05:14:42 +03:00
encoder.ReleaseMapContext(mapCtx)
2021-03-15 20:50:19 +03:00
code = code.End.Next
}
} else {
2021-12-27 05:14:42 +03:00
mapCtx.Slice.Items[mapCtx.Idx].Value = b[mapCtx.Start:len(b)]
if idx < mapCtx.Len {
mapCtx.Idx = int(idx)
mapCtx.Start = len(b)
key := mapiterkey(&mapCtx.Iter)
2021-03-15 20:50:19 +03:00
store(ctxptr, code.Next.Idx, uintptr(key))
code = code.Next
} else {
code = code.End
}
}
case encoder.OpMapValue:
2021-12-27 05:14:42 +03:00
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter)))
2021-06-01 07:40:15 +03:00
if (ctx.Option.Flag & encoder.UnorderedMapOption) != 0 {
b = appendColon(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-12-27 05:14:42 +03:00
mapCtx.Slice.Items[mapCtx.Idx].Key = b[mapCtx.Start:len(b)]
mapCtx.Start = len(b)
2021-03-15 20:50:19 +03:00
}
2021-12-27 05:14:42 +03:00
value := mapitervalue(&mapCtx.Iter)
2021-03-15 20:50:19 +03:00
store(ctxptr, code.Next.Idx, uintptr(value))
2021-12-27 05:14:42 +03:00
mapiternext(&mapCtx.Iter)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpMapEnd:
// this operation only used by sorted map.
2021-12-27 05:14:42 +03:00
mapCtx := (*encoder.MapContext)(ptrToUnsafePtr(load(ctxptr, code.MapIter)))
2021-03-15 20:50:19 +03:00
sort.Sort(mapCtx.Slice)
buf := mapCtx.Buf
for _, item := range mapCtx.Slice.Items {
buf = appendMapKeyValue(ctx, code, buf, item.Key, item.Value)
2021-03-15 20:50:19 +03:00
}
buf = appendMapEnd(ctx, code, buf)
2021-12-27 05:14:42 +03:00
b = b[:mapCtx.First]
2021-03-15 20:50:19 +03:00
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-15 20:50:19 +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-15 20:50:19 +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
oldBaseIndent := ctx.BaseIndent
2021-06-12 16:38:52 +03:00
indentDiffFromTop := c.Indent - 1
ctx.BaseIndent += code.Indent - indentDiffFromTop
2021-03-15 20:50:19 +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-06-25 16:27:00 +03:00
storeIndent(ctxptr, c.End.Next, uintptr(oldBaseIndent))
2021-03-15 20:50:19 +03:00
code = c
recursiveLevel++
2021-03-19 09:46:53 +03:00
case encoder.OpRecursiveEnd:
2021-03-15 20:50:19 +03:00
recursiveLevel--
// restore ctxptr
restoreIndent(ctx, code, ctxptr)
2021-03-15 20:50:19 +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:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHead:
p := load(ctxptr, code.Idx)
if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if len(code.Key) > 0 {
if (code.Flags&encoder.IsTaggedKeyFlags) != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 {
b = appendStructKey(ctx, code, b)
}
2021-03-15 20:50:19 +03:00
}
p += uintptr(code.Offset)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructPtrHeadOmitEmpty:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmpty:
p := load(ctxptr, code.Idx)
if p == 0 && ((code.Flags&encoder.IndirectFlags) != 0 || code.Next.Op == encoder.OpStructEnd) {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
p += uintptr(code.Offset)
if p == 0 || (ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0) {
2021-03-15 20:50:19 +03:00
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
}
case encoder.OpStructPtrHeadInt:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadInt:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p+uintptr(code.Offset), code)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyInt:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadOmitEmptyInt:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
2021-10-14 09:00:28 +03:00
u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
v := u64 & ((1 << code.NumBitSize) - 1)
2021-03-15 20:50:19 +03:00
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p+uintptr(code.Offset), code)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadIntString:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadIntString:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p+uintptr(code.Offset), code)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyIntString:
if (code.Flags & encoder.IndirectFlags) != 0 {
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, 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.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
2021-10-14 09:00:28 +03:00
u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p+uintptr(code.Offset), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
}
2021-03-15 20:50:19 +03:00
case encoder.OpStructPtrHeadIntPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadIntPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p, code)
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyIntPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyIntPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p, code)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadIntPtrString:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadIntPtrString:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p, code)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyIntPtrString:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, 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.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
}
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p, code)
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructPtrHeadUint:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadUint:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p+uintptr(code.Offset), code)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyUint:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadOmitEmptyUint:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
2021-10-14 09:00:28 +03:00
u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
v := u64 & ((1 << code.NumBitSize) - 1)
2021-03-15 20:50:19 +03:00
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p+uintptr(code.Offset), code)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadUintString:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadUintString:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p+uintptr(code.Offset), code)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyUintString:
if (code.Flags & encoder.IndirectFlags) != 0 {
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, 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.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
2021-10-14 09:00:28 +03:00
u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
v := u64 & ((1 << code.NumBitSize) - 1)
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p+uintptr(code.Offset), code)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
}
2021-03-15 20:50:19 +03:00
case encoder.OpStructPtrHeadUintPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadUintPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p, code)
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyUintPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyUintPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p, code)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadUintPtrString:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadUintPtrString:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p, code)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyUintPtrString:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, 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.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
}
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p, code)
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructPtrHeadFloat32:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadFloat32:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset)))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyFloat32:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadOmitEmptyFloat32:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
v := ptrToFloat32(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
b = appendFloat32(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadFloat32String:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadFloat32String:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset)))
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyFloat32String:
if (code.Flags & encoder.IndirectFlags) != 0 {
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, 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.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
v := ptrToFloat32(p + uintptr(code.Offset))
if v == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendFloat32(ctx, b, v)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
}
2021-03-15 20:50:19 +03:00
case encoder.OpStructPtrHeadFloat32Ptr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadFloat32Ptr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendFloat32(ctx, b, ptrToFloat32(p))
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyFloat32Ptr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyFloat32Ptr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p != 0 {
b = appendStructKey(ctx, code, b)
b = appendFloat32(ctx, b, ptrToFloat32(p))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadFloat32PtrString:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadFloat32PtrString:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
b = appendFloat32(ctx, b, ptrToFloat32(p))
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyFloat32PtrString:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, 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.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
}
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendFloat32(ctx, b, ptrToFloat32(p))
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructPtrHeadFloat64:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadFloat64:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
v := ptrToFloat64(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
b = appendFloat64(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyFloat64:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadOmitEmptyFloat64:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
v := ptrToFloat64(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v == 0 {
code = code.NextField
} else {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendStructKey(ctx, code, b)
b = appendFloat64(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadFloat64String:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadFloat64String:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
v := ptrToFloat64(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendFloat64(ctx, b, v)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyFloat64String:
if (code.Flags & encoder.IndirectFlags) != 0 {
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, 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.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
v := ptrToFloat64(p + uintptr(code.Offset))
if v == 0 {
code = code.NextField
} else {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendFloat64(ctx, b, v)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
}
2021-03-15 20:50:19 +03:00
case encoder.OpStructPtrHeadFloat64Ptr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadFloat64Ptr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendFloat64(ctx, b, v)
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyFloat64Ptr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyFloat64Ptr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendFloat64(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadFloat64PtrString:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadFloat64PtrString:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendFloat64(ctx, b, v)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyFloat64PtrString:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, 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.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
}
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendFloat64(ctx, b, v)
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
case encoder.OpStructPtrHeadString:
if (code.Flags & encoder.IndirectFlags) != 0 {
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadString:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendNull(ctx, b)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset)))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyString:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadOmitEmptyString:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
v := ptrToString(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v == "" {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadStringString:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadStringString:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p+uintptr(code.Offset)))))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyStringString:
if (code.Flags & encoder.IndirectFlags) != 0 {
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, 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.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
v := ptrToString(p + uintptr(code.Offset))
if v == "" {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, string(appendString(ctx, []byte{}, v)))
b = appendComma(ctx, b)
code = code.Next
}
2021-03-15 20:50:19 +03:00
case encoder.OpStructPtrHeadStringPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadStringPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, ptrToString(p))
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyStringPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyStringPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, ptrToString(p))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadStringPtrString:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadStringPtrString:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p))))
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyStringPtrString:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, 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.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
}
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p))))
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructPtrHeadBool:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadBool:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset)))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyBool:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadOmitEmptyBool:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
v := ptrToBool(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v {
b = appendStructKey(ctx, code, b)
b = appendBool(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
} else {
code = code.NextField
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadBoolString:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadBoolString:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset)))
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyBoolString:
if (code.Flags & encoder.IndirectFlags) != 0 {
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, 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.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
v := ptrToBool(p + uintptr(code.Offset))
if v {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendBool(ctx, b, v)
b = append(b, '"')
b = appendComma(ctx, b)
code = code.Next
} else {
code = code.NextField
}
2021-03-15 20:50:19 +03:00
case encoder.OpStructPtrHeadBoolPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadBoolPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendBool(ctx, b, ptrToBool(p))
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyBoolPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyBoolPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p != 0 {
b = appendStructKey(ctx, code, b)
b = appendBool(ctx, b, ptrToBool(p))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadBoolPtrString:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadBoolPtrString:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
b = appendBool(ctx, b, ptrToBool(p))
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyBoolPtrString:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
fallthrough
case encoder.OpStructHeadOmitEmptyBoolPtrString:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
}
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendBool(ctx, b, ptrToBool(p))
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructPtrHeadBytes:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadBytes:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset)))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyBytes:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadOmitEmptyBytes:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
v := ptrToBytes(p + uintptr(code.Offset))
if len(v) == 0 {
2021-03-15 20:50:19 +03:00
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
b = appendByteSlice(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
}
case encoder.OpStructPtrHeadBytesPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadBytesPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendByteSlice(ctx, b, ptrToBytes(p))
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyBytesPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyBytesPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p != 0 {
b = appendStructKey(ctx, code, b)
b = appendByteSlice(ctx, b, ptrToBytes(p))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
case encoder.OpStructPtrHeadNumber:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadNumber:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset)))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendComma(ctx, bb)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyNumber:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadOmitEmptyNumber:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
v := ptrToNumber(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v == "" {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
bb, err := appendNumber(ctx, b, v)
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendComma(ctx, bb)
2021-03-15 20:50:19 +03:00
code = code.Next
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadNumberString:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadNumberString:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset)))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = append(bb, '"')
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyNumberString:
if (code.Flags & encoder.IndirectFlags) != 0 {
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, 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.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
v := ptrToNumber(p + uintptr(code.Offset))
if v == "" {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
bb, err := appendNumber(ctx, b, v)
if err != nil {
return nil, err
}
2021-05-06 19:04:25 +03:00
b = append(bb, '"')
b = appendComma(ctx, b)
code = code.Next
}
2021-03-15 20:50:19 +03:00
case encoder.OpStructPtrHeadNumberPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadNumberPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
bb, err := appendNumber(ctx, b, ptrToNumber(p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyNumberPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyNumberPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p != 0 {
b = appendStructKey(ctx, code, b)
bb, err := appendNumber(ctx, b, ptrToNumber(p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendComma(ctx, bb)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadNumberPtrString:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadNumberPtrString:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
bb, err := appendNumber(ctx, b, ptrToNumber(p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = append(bb, '"')
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyNumberPtrString:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, 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.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
}
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
bb, err := appendNumber(ctx, b, ptrToNumber(p))
if err != nil {
return nil, err
}
2021-05-06 19:04:25 +03:00
b = append(bb, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadArray, encoder.OpStructPtrHeadSlice:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadArray, encoder.OpStructHeadSlice:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
p += uintptr(code.Offset)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructPtrHeadOmitEmptyArray:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadOmitEmptyArray:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
p += uintptr(code.Offset)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructPtrHeadOmitEmptySlice:
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
}
fallthrough
case encoder.OpStructHeadOmitEmptySlice:
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
p += uintptr(code.Offset)
2021-03-15 20:50:19 +03:00
slice := ptrToSlice(p)
if slice.Len == 0 {
2021-03-15 20:50:19 +03:00
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadArrayPtr, encoder.OpStructPtrHeadSlicePtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadArrayPtr, encoder.OpStructHeadSlicePtr:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.NextField
} else {
code = code.Next
store(ctxptr, code.Idx, p)
}
case encoder.OpStructPtrHeadOmitEmptyArrayPtr, encoder.OpStructPtrHeadOmitEmptySlicePtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyArrayPtr, encoder.OpStructHeadOmitEmptySlicePtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadMap:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadMap:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 {
p = ptrToPtr(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
}
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructPtrHeadOmitEmptyMap:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyMap:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if p != 0 && (code.Flags&encoder.IndirectFlags) != 0 {
p = ptrToPtr(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
}
if maplen(ptrToUnsafePtr(p)) == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadMapPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadMapPtr:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.NextField
break
}
p = ptrToPtr(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.NextField
} else {
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-15 20:50:19 +03:00
p = ptrToNPtr(p, code.PtrNum)
}
code = code.Next
store(ctxptr, code.Idx, p)
}
case encoder.OpStructPtrHeadOmitEmptyMapPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyMapPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
code = code.NextField
break
}
p = ptrToPtr(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if p == 0 {
code = code.NextField
} else {
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-15 20:50:19 +03:00
p = ptrToNPtr(p, code.PtrNum)
}
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
}
case encoder.OpStructPtrHeadMarshalJSON:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalJSON {
p = ptrToPtr(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyMarshalJSON:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyMarshalJSON:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalJSON {
p = ptrToPtr(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
}
}
iface := ptrToInterface(code, p)
if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) {
2021-03-15 20:50:19 +03:00
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
bb, err := appendMarshalJSON(ctx, code, b, iface)
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadMarshalJSONPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadMarshalJSONPtr:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyMarshalJSONPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyMarshalJSONPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
}
case encoder.OpStructPtrHeadMarshalText:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadMarshalText:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadMarshalText {
p = ptrToPtr(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-05-31 19:25:05 +03:00
bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyMarshalText:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
if (code.Flags & encoder.IndirectFlags) != 0 {
2021-03-16 18:22:19 +03:00
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
}
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyMarshalText:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
if (code.Flags&encoder.IndirectFlags) != 0 || code.Op == encoder.OpStructPtrHeadOmitEmptyMarshalText {
p = ptrToPtr(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
}
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
2021-03-15 20:50:19 +03:00
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructPtrHeadMarshalTextPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
2021-05-06 14:54:22 +03:00
case encoder.OpStructHeadMarshalTextPtr:
2021-03-15 20:50:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
b = appendStructKey(ctx, code, b)
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-05-31 19:25:05 +03:00
bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructPtrHeadOmitEmptyMarshalTextPtr:
2021-03-16 18:22:19 +03:00
p := load(ctxptr, code.Idx)
if p == 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-16 18:22:19 +03:00
}
code = code.End.Next
break
}
store(ctxptr, code.Idx, ptrToNPtr(p, code.PtrNum))
2021-03-15 20:50:19 +03:00
fallthrough
case encoder.OpStructHeadOmitEmptyMarshalTextPtr:
p := load(ctxptr, code.Idx)
if p == 0 && (code.Flags&encoder.IndirectFlags) != 0 {
if code.Flags&encoder.AnonymousHeadFlags == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.End.Next
break
}
if (code.Flags & encoder.IndirectFlags) != 0 {
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
}
if code.Flags&encoder.AnonymousHeadFlags == 0 {
b = appendStructHead(ctx, b)
2021-03-15 20:50:19 +03:00
}
if p == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
}
case encoder.OpStructField:
if code.Flags&encoder.IsTaggedKeyFlags != 0 || code.Flags&encoder.AnonymousKeyFlags == 0 {
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
p := load(ctxptr, code.Idx) + uintptr(code.Offset)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructFieldOmitEmpty:
p := load(ctxptr, code.Idx)
p += uintptr(code.Offset)
if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 {
2021-03-15 20:50:19 +03:00
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
}
case encoder.OpStructFieldInt:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p+uintptr(code.Offset), code)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyInt:
p := load(ctxptr, code.Idx)
2021-10-14 09:00:28 +03:00
u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
v := u64 & ((1 << code.NumBitSize) - 1)
2021-03-15 20:50:19 +03:00
if v != 0 {
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p+uintptr(code.Offset), code)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldIntString:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p+uintptr(code.Offset), code)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyIntString:
p := load(ctxptr, code.Idx)
2021-10-14 09:00:28 +03:00
u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p+uintptr(code.Offset), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
case encoder.OpStructFieldIntPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p, code)
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyIntPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p, code)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldIntPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p, code)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyIntPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p, code)
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructFieldUint:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p+uintptr(code.Offset), code)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyUint:
p := load(ctxptr, code.Idx)
2021-10-14 09:00:28 +03:00
u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
v := u64 & ((1 << code.NumBitSize) - 1)
2021-03-15 20:50:19 +03:00
if v != 0 {
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p+uintptr(code.Offset), code)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldUintString:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p+uintptr(code.Offset), code)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyUintString:
p := load(ctxptr, code.Idx)
2021-10-14 09:00:28 +03:00
u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p+uintptr(code.Offset), code)
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructFieldUintPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p, code)
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyUintPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p, code)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldUintPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p, code)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyUintPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p, code)
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructFieldFloat32:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset)))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyFloat32:
p := load(ctxptr, code.Idx)
v := ptrToFloat32(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v != 0 {
b = appendStructKey(ctx, code, b)
b = appendFloat32(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldFloat32String:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset)))
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyFloat32String:
p := load(ctxptr, code.Idx)
v := ptrToFloat32(p + uintptr(code.Offset))
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendFloat32(ctx, b, v)
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructFieldFloat32Ptr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendFloat32(ctx, b, ptrToFloat32(p))
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyFloat32Ptr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
b = appendFloat32(ctx, b, ptrToFloat32(p))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldFloat32PtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
b = appendFloat32(ctx, b, ptrToFloat32(p))
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyFloat32PtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendFloat32(ctx, b, ptrToFloat32(p))
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructFieldFloat64:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
v := ptrToFloat64(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendFloat64(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyFloat64:
p := load(ctxptr, code.Idx)
v := ptrToFloat64(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v != 0 {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendStructKey(ctx, code, b)
b = appendFloat64(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldFloat64String:
p := load(ctxptr, code.Idx)
v := ptrToFloat64(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendFloat64(ctx, b, v)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyFloat64String:
p := load(ctxptr, code.Idx)
v := ptrToFloat64(p + uintptr(code.Offset))
if v != 0 {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendFloat64(ctx, b, v)
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructFieldFloat64Ptr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
2021-11-28 15:46:32 +03:00
b = appendNullComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
break
}
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendFloat64(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyFloat64Ptr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendFloat64(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldFloat64PtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = append(b, '"')
b = appendFloat64(ctx, b, v)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyFloat64PtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendFloat64(ctx, b, v)
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructFieldString:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset)))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyString:
p := load(ctxptr, code.Idx)
v := ptrToString(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v != "" {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldStringString:
p := load(ctxptr, code.Idx)
s := ptrToString(p + uintptr(code.Offset))
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, string(appendString(ctx, []byte{}, s)))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyStringString:
p := load(ctxptr, code.Idx)
v := ptrToString(p + uintptr(code.Offset))
if v != "" {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, string(appendString(ctx, []byte{}, v)))
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructFieldStringPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, ptrToString(p))
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyStringPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, ptrToString(p))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldStringPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p))))
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyStringPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p))))
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructFieldBool:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset)))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyBool:
p := load(ctxptr, code.Idx)
v := ptrToBool(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v {
b = appendStructKey(ctx, code, b)
b = appendBool(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldBoolString:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset)))
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyBoolString:
p := load(ctxptr, code.Idx)
v := ptrToBool(p + uintptr(code.Offset))
if v {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendBool(ctx, b, v)
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructFieldBoolPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendBool(ctx, b, ptrToBool(p))
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyBoolPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
b = appendBool(ctx, b, ptrToBool(p))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldBoolPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
b = appendBool(ctx, b, ptrToBool(p))
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyBoolPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendBool(ctx, b, ptrToBool(p))
b = append(b, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructFieldBytes:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset)))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyBytes:
p := load(ctxptr, code.Idx)
v := ptrToBytes(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if len(v) > 0 {
b = appendStructKey(ctx, code, b)
b = appendByteSlice(ctx, b, v)
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
case encoder.OpStructFieldBytesPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendByteSlice(ctx, b, ptrToBytes(p))
2021-03-15 20:50:19 +03:00
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyBytesPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
b = appendByteSlice(ctx, b, ptrToBytes(p))
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
case encoder.OpStructFieldNumber:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset)))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendComma(ctx, bb)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyNumber:
p := load(ctxptr, code.Idx)
v := ptrToNumber(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v != "" {
b = appendStructKey(ctx, code, b)
bb, err := appendNumber(ctx, b, v)
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendComma(ctx, bb)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldNumberString:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset)))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = append(bb, '"')
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyNumberString:
p := load(ctxptr, code.Idx)
v := ptrToNumber(p + uintptr(code.Offset))
if v != "" {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
bb, err := appendNumber(ctx, b, v)
if err != nil {
return nil, err
}
2021-05-06 19:04:25 +03:00
b = append(bb, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructFieldNumberPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
bb, err := appendNumber(ctx, b, ptrToNumber(p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyNumberPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
bb, err := appendNumber(ctx, b, ptrToNumber(p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendComma(ctx, bb)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldNumberPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
bb, err := appendNumber(ctx, b, ptrToNumber(p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = append(bb, '"')
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyNumberPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
bb, err := appendNumber(ctx, b, ptrToNumber(p))
if err != nil {
return nil, err
}
2021-05-06 19:04:25 +03:00
b = append(bb, '"')
b = appendComma(ctx, b)
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldMarshalJSON:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
2021-03-15 20:50:19 +03:00
p = ptrToPtr(p)
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyMarshalJSON:
p := load(ctxptr, code.Idx)
p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
2021-03-15 20:50:19 +03:00
p = ptrToPtr(p)
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
2021-03-15 20:50:19 +03:00
code = code.NextField
break
}
iface := ptrToInterface(code, p)
if (code.Flags&encoder.NilCheckFlags) != 0 && encoder.IsNilForMarshaler(iface) {
code = code.NextField
break
}
b = appendStructKey(ctx, code, b)
bb, err := appendMarshalJSON(ctx, code, b, iface)
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendComma(ctx, bb)
2021-03-15 20:50:19 +03:00
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldMarshalJSONPtr:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyMarshalJSONPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
bb, err := appendMarshalJSON(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendComma(ctx, bb)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldMarshalText:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
2021-03-15 20:50:19 +03:00
p = ptrToPtr(p)
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-05-31 19:25:05 +03:00
bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyMarshalText:
p := load(ctxptr, code.Idx)
p += uintptr(code.Offset)
if (code.Flags & encoder.IsNilableTypeFlags) != 0 {
2021-03-15 20:50:19 +03:00
p = ptrToPtr(p)
}
if p == 0 && (code.Flags&encoder.NilCheckFlags) != 0 {
2021-03-15 20:50:19 +03:00
code = code.NextField
break
}
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendComma(ctx, bb)
2021-03-15 20:50:19 +03:00
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldMarshalTextPtr:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-05-31 19:25:05 +03:00
bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
}
b = appendComma(ctx, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructFieldOmitEmptyMarshalTextPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
bb, err := appendMarshalText(ctx, code, b, ptrToInterface(code, p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendComma(ctx, bb)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldArray:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p += uintptr(code.Offset)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructFieldOmitEmptyArray:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p += uintptr(code.Offset)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldArrayPtr:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructFieldOmitEmptyArrayPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
} else {
code = code.NextField
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldSlice:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p += uintptr(code.Offset)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructFieldOmitEmptySlice:
p := load(ctxptr, code.Idx)
p += uintptr(code.Offset)
2021-03-15 20:50:19 +03:00
slice := ptrToSlice(p)
if slice.Len == 0 {
2021-03-15 20:50:19 +03:00
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldSlicePtr:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructFieldOmitEmptySlicePtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
} else {
code = code.NextField
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldMap:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToPtr(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructFieldOmitEmptyMap:
p := load(ctxptr, code.Idx)
p = ptrToPtr(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if p == 0 || maplen(ptrToUnsafePtr(p)) == 0 {
code = code.NextField
} else {
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
}
2021-05-06 14:54:22 +03:00
case encoder.OpStructFieldMapPtr:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToPtr(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if p != 0 {
p = ptrToNPtr(p, code.PtrNum)
}
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructFieldOmitEmptyMapPtr:
p := load(ctxptr, code.Idx)
p = ptrToPtr(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if p != 0 {
p = ptrToNPtr(p, code.PtrNum)
}
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
} else {
code = code.NextField
}
case encoder.OpStructFieldStruct:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p += uintptr(code.Offset)
2021-03-15 20:50:19 +03:00
code = code.Next
store(ctxptr, code.Idx, p)
case encoder.OpStructFieldOmitEmptyStruct:
p := load(ctxptr, code.Idx)
p += uintptr(code.Offset)
if ptrToPtr(p) == 0 && (code.Flags&encoder.IsNextOpPtrTypeFlags) != 0 {
code = code.NextField
2021-03-15 20:50:19 +03:00
} else {
b = appendStructKey(ctx, code, b)
code = code.Next
store(ctxptr, code.Idx, p)
2021-03-15 20:50:19 +03:00
}
case encoder.OpStructEnd:
b = appendStructEndSkipLast(ctx, code, b)
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructEndInt:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p+uintptr(code.Offset), code)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyInt:
p := load(ctxptr, code.Idx)
2021-10-14 09:00:28 +03:00
u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
v := u64 & ((1 << code.NumBitSize) - 1)
2021-03-15 20:50:19 +03:00
if v != 0 {
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p+uintptr(code.Offset), code)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructEndIntString:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p+uintptr(code.Offset), code)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyIntString:
p := load(ctxptr, code.Idx)
2021-10-14 09:00:28 +03:00
u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p+uintptr(code.Offset), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructEndIntPtr:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p, code)
2021-03-15 20:50:19 +03:00
}
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyIntPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p, code)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructEndIntPtrString:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p, code)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyIntPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendInt(ctx, b, p, code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructEndUint:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p+uintptr(code.Offset), code)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyUint:
p := load(ctxptr, code.Idx)
2021-10-14 09:00:28 +03:00
u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
v := u64 & ((1 << code.NumBitSize) - 1)
2021-03-15 20:50:19 +03:00
if v != 0 {
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p+uintptr(code.Offset), code)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructEndUintString:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p+uintptr(code.Offset), code)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyUintString:
p := load(ctxptr, code.Idx)
2021-10-14 09:00:28 +03:00
u64 := ptrToUint64(p+uintptr(code.Offset), code.NumBitSize)
v := u64 & ((1 << code.NumBitSize) - 1)
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p+uintptr(code.Offset), code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructEndUintPtr:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p, code)
2021-03-15 20:50:19 +03:00
}
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyUintPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p, code)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructEndUintPtrString:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p, code)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyUintPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
2021-10-14 09:00:28 +03:00
b = appendUint(ctx, b, p, code)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructEndFloat32:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset)))
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyFloat32:
p := load(ctxptr, code.Idx)
v := ptrToFloat32(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v != 0 {
b = appendStructKey(ctx, code, b)
b = appendFloat32(ctx, b, v)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructEndFloat32String:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendFloat32(ctx, b, ptrToFloat32(p+uintptr(code.Offset)))
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyFloat32String:
p := load(ctxptr, code.Idx)
v := ptrToFloat32(p + uintptr(code.Offset))
if v != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendFloat32(ctx, b, v)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructEndFloat32Ptr:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendFloat32(ctx, b, ptrToFloat32(p))
2021-03-15 20:50:19 +03:00
}
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyFloat32Ptr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
b = appendFloat32(ctx, b, ptrToFloat32(p))
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructEndFloat32PtrString:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
b = appendFloat32(ctx, b, ptrToFloat32(p))
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyFloat32PtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendFloat32(ctx, b, ptrToFloat32(p))
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructEndFloat64:
p := load(ctxptr, code.Idx)
v := ptrToFloat64(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendStructKey(ctx, code, b)
b = appendFloat64(ctx, b, v)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyFloat64:
p := load(ctxptr, code.Idx)
v := ptrToFloat64(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v != 0 {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendStructKey(ctx, code, b)
b = appendFloat64(ctx, b, v)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructEndFloat64String:
p := load(ctxptr, code.Idx)
v := ptrToFloat64(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendFloat64(ctx, b, v)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyFloat64String:
p := load(ctxptr, code.Idx)
v := ptrToFloat64(p + uintptr(code.Offset))
if v != 0 {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendFloat64(ctx, b, v)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructEndFloat64Ptr:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
break
}
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendFloat64(ctx, b, v)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyFloat64Ptr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendFloat64(ctx, b, v)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructEndFloat64PtrString:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = appendFloat64(ctx, b, v)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyFloat64PtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = append(b, '"')
b = appendFloat64(ctx, b, v)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructEndString:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, ptrToString(p+uintptr(code.Offset)))
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyString:
p := load(ctxptr, code.Idx)
v := ptrToString(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v != "" {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, v)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructEndStringString:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
s := ptrToString(p + uintptr(code.Offset))
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, string(appendString(ctx, []byte{}, s)))
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyStringString:
p := load(ctxptr, code.Idx)
v := ptrToString(p + uintptr(code.Offset))
if v != "" {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, string(appendString(ctx, []byte{}, v)))
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructEndStringPtr:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, ptrToString(p))
2021-03-15 20:50:19 +03:00
}
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyStringPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, ptrToString(p))
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructEndStringPtrString:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p))))
2021-03-15 20:50:19 +03:00
}
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyStringPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
2021-05-31 19:25:05 +03:00
b = appendString(ctx, b, string(appendString(ctx, []byte{}, ptrToString(p))))
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructEndBool:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset)))
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyBool:
p := load(ctxptr, code.Idx)
v := ptrToBool(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v {
b = appendStructKey(ctx, code, b)
b = appendBool(ctx, b, v)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructEndBoolString:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendBool(ctx, b, ptrToBool(p+uintptr(code.Offset)))
2021-03-15 20:50:19 +03:00
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyBoolString:
p := load(ctxptr, code.Idx)
v := ptrToBool(p + uintptr(code.Offset))
if v {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendBool(ctx, b, v)
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructEndBoolPtr:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendBool(ctx, b, ptrToBool(p))
2021-03-15 20:50:19 +03:00
}
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyBoolPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
b = appendBool(ctx, b, ptrToBool(p))
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructEndBoolPtrString:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
b = appendBool(ctx, b, ptrToBool(p))
2021-03-15 20:50:19 +03:00
b = append(b, '"')
}
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyBoolPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
b = appendBool(ctx, b, ptrToBool(p))
b = append(b, '"')
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructEndBytes:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
b = appendByteSlice(ctx, b, ptrToBytes(p+uintptr(code.Offset)))
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyBytes:
p := load(ctxptr, code.Idx)
v := ptrToBytes(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if len(v) > 0 {
b = appendStructKey(ctx, code, b)
b = appendByteSlice(ctx, b, v)
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
case encoder.OpStructEndBytesPtr:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendByteSlice(ctx, b, ptrToBytes(p))
2021-03-15 20:50:19 +03:00
}
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyBytesPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
b = appendByteSlice(ctx, b, ptrToBytes(p))
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
case encoder.OpStructEndNumber:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset)))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendStructEnd(ctx, code, bb)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyNumber:
p := load(ctxptr, code.Idx)
v := ptrToNumber(p + uintptr(code.Offset))
2021-03-15 20:50:19 +03:00
if v != "" {
b = appendStructKey(ctx, code, b)
bb, err := appendNumber(ctx, b, v)
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendStructEnd(ctx, code, bb)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructEndNumberString:
p := load(ctxptr, code.Idx)
b = appendStructKey(ctx, code, b)
2021-03-15 20:50:19 +03:00
b = append(b, '"')
bb, err := appendNumber(ctx, b, ptrToNumber(p+uintptr(code.Offset)))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = append(bb, '"')
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyNumberString:
p := load(ctxptr, code.Idx)
v := ptrToNumber(p + uintptr(code.Offset))
if v != "" {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
bb, err := appendNumber(ctx, b, v)
if err != nil {
return nil, err
}
2021-05-06 19:04:25 +03:00
b = append(bb, '"')
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpStructEndNumberPtr:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
bb, err := appendNumber(ctx, b, ptrToNumber(p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = bb
}
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyNumberPtr:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p != 0 {
b = appendStructKey(ctx, code, b)
bb, err := appendNumber(ctx, b, ptrToNumber(p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = appendStructEnd(ctx, code, bb)
2021-03-15 20:50:19 +03:00
} else {
b = appendStructEndSkipLast(ctx, code, b)
2021-03-15 20:50:19 +03:00
}
code = code.Next
2021-05-06 14:54:22 +03:00
case encoder.OpStructEndNumberPtrString:
b = appendStructKey(ctx, code, b)
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
2021-03-15 20:50:19 +03:00
if p == 0 {
b = appendNull(ctx, b)
2021-03-15 20:50:19 +03:00
} else {
b = append(b, '"')
bb, err := appendNumber(ctx, b, ptrToNumber(p))
2021-03-15 20:50:19 +03:00
if err != nil {
return nil, err
}
b = append(bb, '"')
}
b = appendStructEnd(ctx, code, b)
2021-03-15 20:50:19 +03:00
code = code.Next
case encoder.OpStructEndOmitEmptyNumberPtrString:
p := load(ctxptr, code.Idx)
p = ptrToNPtr(p+uintptr(code.Offset), code.PtrNum)
if p != 0 {
b = appendStructKey(ctx, code, b)
b = append(b, '"')
bb, err := appendNumber(ctx, b, ptrToNumber(p))
if err != nil {
return nil, err
}
2021-05-06 19:04:25 +03:00
b = append(bb, '"')
b = appendStructEnd(ctx, code, b)
} else {
b = appendStructEndSkipLast(ctx, code, b)
}
code = code.Next
2021-03-15 20:50:19 +03:00
case encoder.OpEnd:
goto END
}
}
END:
return b, nil
}