go-json/encode_vm_escaped.go

3719 lines
89 KiB
Go
Raw Normal View History

2021-01-10 23:16:37 +03:00
package json
import (
"fmt"
"math"
"reflect"
"sort"
2021-03-06 13:06:11 +03:00
"strings"
2021-01-10 23:16:37 +03:00
"unsafe"
)
2021-01-31 16:45:59 +03:00
func encodeRunEscaped(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt EncodeOption) ([]byte, error) {
2021-01-10 23:16:37 +03:00
recursiveLevel := 0
ptrOffset := uintptr(0)
ctxptr := ctx.ptr()
2021-01-24 09:17:39 +03:00
code := codeSet.code
2021-03-10 13:27:37 +03:00
//fmt.Println(code.dump())
2021-01-24 09:17:39 +03:00
2021-01-10 23:16:37 +03:00
for {
switch code.op {
default:
2021-02-01 06:01:56 +03:00
return nil, fmt.Errorf("encoder (escaped): opcode %s has not been implemented", code.op)
2021-01-10 23:16:37 +03:00
case opPtr:
ptr := load(ctxptr, code.idx)
code = code.next
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
2021-01-10 23:16:37 +03:00
case opInt:
2021-02-19 09:03:52 +03:00
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opUint:
2021-02-19 09:03:52 +03:00
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code)
b = encodeComma(b)
code = code.next
case opIntString:
b = append(b, '"')
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opUintString:
b = append(b, '"')
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code)
b = append(b, '"')
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opFloat32:
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx)))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opFloat64:
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(load(ctxptr, code.idx))
2021-01-10 23:16:37 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
case opString:
2021-01-31 16:45:59 +03:00
b = encodeEscapedString(b, ptrToString(load(ctxptr, code.idx)))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opBool:
2021-01-31 16:45:59 +03:00
b = encodeBool(b, ptrToBool(load(ctxptr, code.idx)))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opBytes:
ptr := load(ctxptr, code.idx)
2021-01-31 16:45:59 +03:00
slice := ptrToSlice(ptr)
2021-01-10 23:16:37 +03:00
if ptr == 0 || uintptr(slice.data) == 0 {
b = encodeNull(b)
} else {
2021-01-31 16:45:59 +03:00
b = encodeByteSlice(b, ptrToBytes(ptr))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-09 19:11:48 +03:00
case opInterfacePtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
2021-01-10 23:16:37 +03:00
case opInterface:
ptr := load(ctxptr, code.idx)
if ptr == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.next
break
}
2021-01-15 10:25:00 +03:00
for _, seen := range ctx.seenPtr {
if ptr == seen {
return nil, errUnsupportedValue(code, ptr)
}
2021-01-10 23:16:37 +03:00
}
2021-01-15 10:25:00 +03:00
ctx.seenPtr = append(ctx.seenPtr, ptr)
2021-01-31 16:45:59 +03:00
iface := (*interfaceHeader)(ptrToUnsafePtr(ptr))
2021-01-24 16:59:17 +03:00
if iface == nil || iface.ptr == nil {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeComma(b)
code = code.next
break
}
2021-01-24 16:59:17 +03:00
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(iface))
2021-01-31 16:45:59 +03:00
ifaceCodeSet, err := encodeCompileToGetCodeSet(uintptr(unsafe.Pointer(iface.typ)))
2021-01-10 23:16:37 +03:00
if err != nil {
return nil, err
}
2021-01-24 14:39:59 +03:00
totalLength := uintptr(codeSet.codeLength)
nextTotalLength := uintptr(ifaceCodeSet.codeLength)
2021-01-24 11:20:36 +03:00
2021-01-24 14:39:59 +03:00
curlen := uintptr(len(ctx.ptrs))
offsetNum := ptrOffset / uintptrSize
2021-01-10 23:16:37 +03:00
2021-01-24 14:39:59 +03:00
newLen := offsetNum + totalLength + nextTotalLength
if curlen < newLen {
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
2021-01-24 11:20:36 +03:00
}
2021-01-24 14:39:59 +03:00
oldPtrs := ctx.ptrs
newPtrs := ctx.ptrs[(ptrOffset+totalLength*uintptrSize)/uintptrSize:]
2021-01-24 16:59:17 +03:00
newPtrs[0] = uintptr(iface.ptr)
2021-01-24 14:39:59 +03:00
ctx.ptrs = newPtrs
2021-01-10 23:16:37 +03:00
2021-01-31 16:45:59 +03:00
bb, err := encodeRunEscaped(ctx, b, ifaceCodeSet, opt)
2021-01-24 11:20:36 +03:00
if err != nil {
return nil, err
}
2021-01-24 14:39:59 +03:00
ctx.ptrs = oldPtrs
ctxptr = ctx.ptr()
ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1]
2021-01-10 23:16:37 +03:00
2021-01-24 11:20:36 +03:00
b = bb
code = code.next
2021-03-09 20:12:53 +03:00
case opMarshalJSONPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
2021-01-10 23:16:37 +03:00
case opMarshalJSON:
2021-03-09 20:12:53 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.next
break
}
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true)
2021-01-10 23:16:37 +03:00
if err != nil {
return nil, err
}
2021-03-09 20:12:53 +03:00
b = encodeComma(bb)
2021-01-10 23:16:37 +03:00
code = code.next
2021-03-09 20:12:53 +03:00
case opMarshalTextPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
2021-01-10 23:16:37 +03:00
case opMarshalText:
2021-03-09 20:12:53 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
b = append(b, `""`...)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
2021-03-09 20:12:53 +03:00
code = code.next
break
2021-01-10 23:16:37 +03:00
}
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true)
2021-03-09 20:12:53 +03:00
if err != nil {
return nil, err
}
b = encodeComma(bb)
2021-01-10 23:16:37 +03:00
code = code.next
2021-03-10 13:27:37 +03:00
case opSlicePtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
2021-03-09 19:11:48 +03:00
case opSlice:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
2021-01-31 16:45:59 +03:00
slice := ptrToSlice(p)
2021-03-09 20:12:53 +03:00
if p == 0 || slice.data == nil {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
2021-03-10 13:27:37 +03:00
break
}
store(ctxptr, code.elemIdx, 0)
store(ctxptr, code.length, uintptr(slice.len))
store(ctxptr, code.idx, uintptr(slice.data))
if slice.len > 0 {
b = append(b, '[')
code = code.next
2021-01-10 23:16:37 +03:00
store(ctxptr, code.idx, uintptr(slice.data))
2021-03-10 13:27:37 +03:00
} else {
b = append(b, '[', ']', ',')
code = code.end.next
2021-01-10 23:16:37 +03:00
}
case opSliceElem:
idx := load(ctxptr, code.elemIdx)
length := load(ctxptr, code.length)
idx++
if idx < length {
store(ctxptr, code.elemIdx, idx)
data := load(ctxptr, code.headIdx)
size := code.size
code = code.next
store(ctxptr, code.idx, data+idx*size)
} else {
last := len(b) - 1
b[last] = ']'
b = encodeComma(b)
code = code.end.next
}
2021-03-09 19:11:48 +03:00
case opArray:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
} else {
if code.length > 0 {
b = append(b, '[')
store(ctxptr, code.elemIdx, 0)
code = code.next
store(ctxptr, code.idx, p)
} else {
b = append(b, '[', ']', ',')
code = code.end.next
}
}
case opArrayElem:
idx := load(ctxptr, code.elemIdx)
idx++
if idx < code.length {
store(ctxptr, code.elemIdx, idx)
p := load(ctxptr, code.headIdx)
size := code.size
code = code.next
store(ctxptr, code.idx, p+idx*size)
} else {
last := len(b) - 1
b[last] = ']'
b = encodeComma(b)
code = code.end.next
}
2021-03-10 13:27:37 +03:00
case opMapPtr:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
2021-03-09 19:11:48 +03:00
case opMap:
2021-03-10 13:27:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
b = encodeComma(b)
code = code.end.next
2021-03-10 13:27:37 +03:00
break
}
uptr := ptrToUnsafePtr(p)
mlen := maplen(uptr)
if mlen > 0 {
b = append(b, '{')
iter := mapiterinit(code.typ, uptr)
ctx.keepRefs = append(ctx.keepRefs, iter)
store(ctxptr, code.elemIdx, 0)
store(ctxptr, code.length, uintptr(mlen))
store(ctxptr, code.mapIter, uintptr(iter))
if (opt & EncodeOptionUnorderedMap) == 0 {
mapCtx := newMapContext(mlen)
mapCtx.pos = append(mapCtx.pos, len(b))
ctx.keepRefs = append(ctx.keepRefs, unsafe.Pointer(mapCtx))
store(ctxptr, code.end.mapPos, uintptr(unsafe.Pointer(mapCtx)))
}
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
code = code.next
2021-01-10 23:16:37 +03:00
} else {
2021-03-10 13:27:37 +03:00
b = append(b, '{', '}', ',')
code = code.end.next
2021-01-10 23:16:37 +03:00
}
case opMapKey:
idx := load(ctxptr, code.elemIdx)
length := load(ctxptr, code.length)
idx++
2021-01-31 16:45:59 +03:00
if (opt & EncodeOptionUnorderedMap) != 0 {
2021-01-10 23:16:37 +03:00
if idx < length {
ptr := load(ctxptr, code.mapIter)
2021-01-31 16:45:59 +03:00
iter := ptrToUnsafePtr(ptr)
2021-01-10 23:16:37 +03:00
store(ctxptr, code.elemIdx, idx)
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
code = code.next
} else {
last := len(b) - 1
b[last] = '}'
b = encodeComma(b)
code = code.end.next
}
} else {
ptr := load(ctxptr, code.end.mapPos)
2021-01-31 16:45:59 +03:00
mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr))
mapCtx.pos = append(mapCtx.pos, len(b))
2021-01-10 23:16:37 +03:00
if idx < length {
ptr := load(ctxptr, code.mapIter)
2021-01-31 16:45:59 +03:00
iter := ptrToUnsafePtr(ptr)
2021-01-10 23:16:37 +03:00
store(ctxptr, code.elemIdx, idx)
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
code = code.next
} else {
code = code.end
}
}
case opMapValue:
2021-01-31 16:45:59 +03:00
if (opt & EncodeOptionUnorderedMap) != 0 {
2021-01-10 23:16:37 +03:00
last := len(b) - 1
b[last] = ':'
} else {
ptr := load(ctxptr, code.end.mapPos)
2021-01-31 16:45:59 +03:00
mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr))
mapCtx.pos = append(mapCtx.pos, len(b))
2021-01-10 23:16:37 +03:00
}
ptr := load(ctxptr, code.mapIter)
2021-01-31 16:45:59 +03:00
iter := ptrToUnsafePtr(ptr)
2021-01-10 23:16:37 +03:00
value := mapitervalue(iter)
store(ctxptr, code.next.idx, uintptr(value))
mapiternext(iter)
code = code.next
case opMapEnd:
// this operation only used by sorted map.
length := int(load(ctxptr, code.length))
ptr := load(ctxptr, code.mapPos)
2021-01-31 16:45:59 +03:00
mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr))
pos := mapCtx.pos
2021-01-10 23:16:37 +03:00
for i := 0; i < length; i++ {
startKey := pos[i*2]
startValue := pos[i*2+1]
var endValue int
if i+1 < length {
endValue = pos[i*2+2]
} else {
endValue = len(b)
}
mapCtx.slice.items = append(mapCtx.slice.items, mapItem{
key: b[startKey:startValue],
value: b[startValue:endValue],
2021-01-10 23:16:37 +03:00
})
}
sort.Sort(mapCtx.slice)
2021-01-25 07:10:07 +03:00
buf := mapCtx.buf
for _, item := range mapCtx.slice.items {
2021-01-25 07:10:07 +03:00
buf = append(buf, item.key...)
buf[len(buf)-1] = ':'
buf = append(buf, item.value...)
2021-01-10 23:16:37 +03:00
}
2021-01-25 07:10:07 +03:00
buf[len(buf)-1] = '}'
buf = append(buf, ',')
2021-01-10 23:16:37 +03:00
b = b[:pos[0]]
2021-01-25 07:10:07 +03:00
b = append(b, buf...)
mapCtx.buf = buf
releaseMapContext(mapCtx)
2021-01-10 23:16:37 +03:00
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadRecursive:
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-11 13:21:30 +03:00
case opStructFieldRecursive:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.idx)
if ptr != 0 {
if recursiveLevel > startDetectingCyclesAfter {
2021-01-15 10:25:00 +03:00
for _, seen := range ctx.seenPtr {
if ptr == seen {
return nil, errUnsupportedValue(code, ptr)
}
2021-01-10 23:16:37 +03:00
}
}
}
2021-01-15 10:25:00 +03:00
ctx.seenPtr = append(ctx.seenPtr, ptr)
2021-01-11 13:21:30 +03:00
c := code.jmp.code
2021-01-10 23:16:37 +03:00
curlen := uintptr(len(ctx.ptrs))
offsetNum := ptrOffset / uintptrSize
oldOffset := ptrOffset
2021-01-15 10:25:00 +03:00
ptrOffset += code.jmp.curLen * uintptrSize
2021-01-10 23:16:37 +03:00
2021-01-15 10:25:00 +03:00
newLen := offsetNum + code.jmp.curLen + code.jmp.nextLen
2021-01-10 23:16:37 +03:00
if curlen < newLen {
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
}
ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr
store(ctxptr, c.idx, ptr)
2021-01-15 10:25:00 +03:00
store(ctxptr, c.end.next.idx, oldOffset)
store(ctxptr, c.end.next.elemIdx, uintptr(unsafe.Pointer(code.next)))
2021-01-10 23:16:37 +03:00
code = c
recursiveLevel++
case opStructFieldRecursiveEnd:
recursiveLevel--
// restore ctxptr
offset := load(ctxptr, code.idx)
2021-01-15 10:25:00 +03:00
ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1]
codePtr := load(ctxptr, code.elemIdx)
2021-01-31 16:45:59 +03:00
code = (*opcode)(ptrToUnsafePtr(codePtr))
2021-01-10 23:16:37 +03:00
ctxptr = ctx.ptr() + offset
ptrOffset = offset
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHead:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHead:
2021-03-06 13:06:11 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
if !code.anonymousKey {
b = append(b, code.escapedKey...)
}
p += code.offset
code = code.next
store(ctxptr, code.idx, p)
2021-01-13 18:02:58 +03:00
case opStructFieldPtrHeadOmitEmpty:
2021-03-06 13:06:11 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
2021-01-13 18:02:58 +03:00
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-13 18:02:58 +03:00
fallthrough
case opStructFieldHeadOmitEmpty:
2021-03-06 13:06:11 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
2021-01-13 18:02:58 +03:00
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
2021-01-13 18:02:58 +03:00
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
p += code.offset
if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
2021-01-13 18:02:58 +03:00
}
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadStringTag:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
2021-01-13 18:02:58 +03:00
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-13 18:02:58 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadStringTag:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
2021-01-13 18:02:58 +03:00
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{')
2021-01-13 18:02:58 +03:00
}
2021-03-06 13:06:11 +03:00
p += code.offset
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
2021-01-11 13:21:30 +03:00
case opStructFieldPtrHeadInt:
if code.indirect {
2021-03-09 19:11:48 +03:00
p := load(ctxptr, code.idx)
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
p = ptrToPtr(p)
}
store(ctxptr, code.idx, p)
}
2021-01-10 23:16:37 +03:00
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadInt:
2021-03-06 13:06:11 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
b = appendInt(b, ptrToUint64(p+code.offset), code)
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyInt:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
case opStructFieldHeadOmitEmptyInt:
2021-03-06 13:06:11 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{')
}
u64 := ptrToUint64(p + code.offset)
v := u64 & code.mask
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
b = appendInt(b, u64, code)
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadStringTagInt:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
case opStructFieldHeadStringTagInt:
2021-03-06 13:06:11 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendInt(b, ptrToUint64(p+code.offset), code)
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
2021-01-11 13:21:30 +03:00
case opStructFieldHeadIntPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
2021-03-06 13:06:11 +03:00
}
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{')
2021-03-06 13:06:11 +03:00
}
b = append(b, code.escapedKey...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
} else {
b = appendInt(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadOmitEmptyIntPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{')
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p != 0 {
b = append(b, code.escapedKey...)
b = appendInt(b, ptrToUint64(p), code)
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.next
case opStructFieldPtrHeadStringTagIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadStringTagIntPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
2021-01-13 18:02:58 +03:00
b = encodeNull(b)
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{')
2021-03-06 13:06:11 +03:00
}
b = append(b, code.escapedKey...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, ptrToUint64(p), code)
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadUint:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadUint:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
b = append(b, '{')
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
b = appendUint(b, ptrToUint64(p+code.offset), code)
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyUint:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyUint:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
u64 := ptrToUint64(p + code.offset)
v := u64 & code.mask
if v == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
b = appendUint(b, u64, code)
b = encodeComma(b)
code = code.next
}
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadStringTagUint:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
case opStructFieldHeadStringTagUint:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
b = append(b, '"')
b = appendUint(b, ptrToUint64(p+code.offset), code)
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadUintPtr:
2021-01-13 18:02:58 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-13 18:02:58 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-13 18:02:58 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadUintPtr:
2021-01-13 18:02:58 +03:00
p := load(ctxptr, code.idx)
2021-03-06 13:06:11 +03:00
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-13 18:02:58 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-13 18:02:58 +03:00
b = append(b, code.escapedKey...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-13 18:02:58 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-03-06 13:06:11 +03:00
b = appendUint(b, ptrToUint64(p), code)
2021-01-13 18:02:58 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadOmitEmptyUintPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyUintPtr:
2021-01-13 18:02:58 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-13 18:02:58 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-03-06 13:06:11 +03:00
if p != 0 {
2021-01-13 18:02:58 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
b = appendUint(b, ptrToUint64(p), code)
2021-01-13 18:02:58 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.next
case opStructFieldPtrHeadStringTagUintPtr:
2021-01-13 18:02:58 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-13 18:02:58 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-13 18:02:58 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadStringTagUintPtr:
2021-01-13 18:02:58 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-13 18:02:58 +03:00
b = append(b, code.escapedKey...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-13 18:02:58 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
2021-03-06 13:06:11 +03:00
b = appendUint(b, ptrToUint64(p), code)
2021-01-13 18:02:58 +03:00
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadFloat32:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-16 20:53:54 +03:00
}
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadFloat32:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
2021-01-16 20:53:54 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
2021-01-16 20:53:54 +03:00
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyFloat32:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-16 20:53:54 +03:00
}
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyFloat32:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-16 20:53:54 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
2021-01-16 20:53:54 +03:00
b = append(b, '{')
2021-03-06 13:06:11 +03:00
}
v := ptrToFloat32(p + code.offset)
if v == 0 {
code = code.nextField
} else {
2021-01-16 20:53:54 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
b = encodeFloat32(b, v)
2021-01-16 20:53:54 +03:00
b = encodeComma(b)
code = code.next
}
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadStringTagFloat32:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadStringTagFloat32:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
2021-03-06 13:06:11 +03:00
}
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
b = append(b, '"')
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadFloat32Ptr:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
2021-01-16 20:53:54 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-16 20:53:54 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadFloat32Ptr:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
2021-03-06 13:06:11 +03:00
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-16 20:53:54 +03:00
if p == 0 {
b = encodeNull(b)
2021-03-06 13:06:11 +03:00
} else {
b = encodeFloat32(b, ptrToFloat32(p))
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyFloat32Ptr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-16 20:53:54 +03:00
code = code.end.next
break
2021-03-06 13:06:11 +03:00
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadOmitEmptyFloat32Ptr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
if !code.anonymousHead {
2021-01-16 20:53:54 +03:00
b = append(b, '{')
2021-03-06 13:06:11 +03:00
}
if code.indirect {
2021-02-18 21:06:21 +03:00
p = ptrToPtr(p + code.offset)
2021-03-06 13:06:11 +03:00
}
if p != 0 {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, ptrToFloat32(p))
b = encodeComma(b)
}
code = code.next
case opStructFieldPtrHeadStringTagFloat32Ptr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
2021-01-16 20:53:54 +03:00
b = encodeNull(b)
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadStringTagFloat32Ptr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
2021-01-16 20:53:54 +03:00
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(p))
b = append(b, '"')
2021-01-16 20:53:54 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadFloat64:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-16 20:53:54 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadFloat64:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-16 20:53:54 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
2021-01-16 20:53:54 +03:00
}
2021-03-06 13:06:11 +03:00
v := ptrToFloat64(p + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyFloat64:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-10 23:16:37 +03:00
}
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyFloat64:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
2021-01-16 20:53:54 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
2021-01-16 20:53:54 +03:00
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
v := ptrToFloat64(p + code.offset)
if v == 0 {
code = code.nextField
2021-01-16 20:53:54 +03:00
} else {
2021-03-06 13:06:11 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
2021-01-16 20:53:54 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
b = encodeFloat64(b, v)
2021-01-16 20:53:54 +03:00
b = encodeComma(b)
code = code.next
}
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadStringTagFloat64:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadStringTagFloat64:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-01-16 20:53:54 +03:00
}
2021-03-06 13:06:11 +03:00
v := ptrToFloat64(p + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeFloat64(b, v)
b = append(b, '"')
2021-01-16 20:53:54 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadFloat64Ptr:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-16 20:53:54 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-16 20:53:54 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadFloat64Ptr:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
2021-03-06 13:06:11 +03:00
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-16 20:53:54 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-16 20:53:54 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-16 20:53:54 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-03-06 13:06:11 +03:00
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-16 20:53:54 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadOmitEmptyFloat64Ptr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyFloat64Ptr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{')
2021-03-06 13:06:11 +03:00
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p != 0 {
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.next
case opStructFieldPtrHeadStringTagFloat64Ptr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
2021-01-17 16:06:16 +03:00
b = encodeComma(b)
}
code = code.end.next
2021-03-06 13:06:11 +03:00
break
2021-01-17 16:06:16 +03:00
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadStringTagFloat64Ptr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
2021-03-06 13:06:11 +03:00
if p == 0 && code.indirect {
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
2021-01-17 16:06:16 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
2021-01-17 16:06:16 +03:00
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-17 16:06:16 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-03-06 13:06:11 +03:00
b = append(b, '"')
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
2021-01-17 16:06:16 +03:00
}
2021-03-06 13:06:11 +03:00
b = encodeFloat64(b, v)
b = append(b, '"')
2021-01-17 16:06:16 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-09 19:11:48 +03:00
case opStructFieldPtrHeadString:
if code.indirect {
p := load(ctxptr, code.idx)
2021-01-17 16:06:16 +03:00
for i := 0; i < code.ptrNum; i++ {
if p == 0 {
break
}
2021-01-31 16:45:59 +03:00
p = ptrToPtr(p)
2021-01-17 16:06:16 +03:00
}
2021-03-09 19:11:48 +03:00
store(ctxptr, code.idx, p)
2021-03-06 13:06:11 +03:00
}
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadString:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
b = encodeEscapedString(b, ptrToString(p+code.offset))
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyString:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-17 16:06:16 +03:00
}
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyString:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
2021-01-17 16:06:16 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
2021-01-17 16:06:16 +03:00
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-01-17 16:06:16 +03:00
}
2021-03-06 13:06:11 +03:00
v := ptrToString(p + code.offset)
if v == "" {
code = code.nextField
2021-01-17 16:06:16 +03:00
} else {
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
b = encodeEscapedString(b, v)
2021-01-17 16:06:16 +03:00
b = encodeComma(b)
code = code.next
}
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadStringTagString:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadStringTagString:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
s := ptrToString(p + code.offset)
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s)))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadStringPtr:
2021-01-17 16:06:16 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-17 16:06:16 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-17 16:06:16 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadStringPtr:
2021-01-17 16:06:16 +03:00
p := load(ctxptr, code.idx)
2021-03-06 13:06:11 +03:00
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-17 16:06:16 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-17 16:06:16 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-17 16:06:16 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-03-06 13:06:11 +03:00
b = encodeEscapedString(b, ptrToString(p))
2021-01-17 16:06:16 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadOmitEmptyStringPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadOmitEmptyStringPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{')
2021-03-06 13:06:11 +03:00
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p != 0 {
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
b = encodeEscapedString(b, ptrToString(p))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.next
case opStructFieldPtrHeadStringTagStringPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
2021-01-18 15:50:52 +03:00
b = encodeComma(b)
}
code = code.end.next
2021-03-06 13:06:11 +03:00
break
2021-01-18 15:50:52 +03:00
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadStringTagStringPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
2021-03-06 13:06:11 +03:00
if p == 0 && code.indirect {
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
2021-01-18 15:50:52 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
2021-01-18 15:50:52 +03:00
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-18 15:50:52 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-03-06 13:06:11 +03:00
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p))))
2021-01-18 15:50:52 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadBool:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadBool:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
b = encodeBool(b, ptrToBool(p+code.offset))
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyBool:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-18 15:50:52 +03:00
}
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyBool:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
2021-01-18 15:50:52 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
2021-01-18 15:50:52 +03:00
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-01-18 15:50:52 +03:00
}
2021-03-06 13:06:11 +03:00
v := ptrToBool(p + code.offset)
if v {
2021-01-18 15:50:52 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
b = encodeBool(b, v)
2021-01-18 15:50:52 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
} else {
code = code.nextField
}
case opStructFieldPtrHeadStringTagBool:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-18 15:50:52 +03:00
}
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadStringTagBool:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeBool(b, ptrToBool(p+code.offset))
b = append(b, '"')
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadBoolPtr:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-18 15:50:52 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 15:50:52 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadBoolPtr:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
2021-03-09 15:38:58 +03:00
if p == 0 && code.indirect {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-18 15:50:52 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-18 15:50:52 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-18 15:50:52 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-03-06 13:06:11 +03:00
b = encodeBool(b, ptrToBool(p))
2021-01-18 15:50:52 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadOmitEmptyBoolPtr:
2021-02-18 21:06:21 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-02-18 21:06:21 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyBoolPtr:
p := load(ctxptr, code.idx)
2021-03-09 15:38:58 +03:00
if p == 0 && code.indirect {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
2021-01-18 16:35:10 +03:00
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
2021-01-18 16:35:10 +03:00
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
2021-01-18 16:35:10 +03:00
}
2021-03-06 13:06:11 +03:00
if p != 0 {
2021-01-18 16:35:10 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
b = encodeBool(b, ptrToBool(p))
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.next
case opStructFieldPtrHeadStringTagBoolPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 16:35:10 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadStringTagBoolPtr:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
2021-03-09 15:38:58 +03:00
if p == 0 && code.indirect {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
if code.indirect {
p = ptrToPtr(p + code.offset)
2021-01-18 16:35:10 +03:00
}
if p == 0 {
b = encodeNull(b)
} else {
2021-03-06 13:06:11 +03:00
b = append(b, '"')
b = encodeBool(b, ptrToBool(p))
b = append(b, '"')
2021-01-18 16:35:10 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadBytes:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadBytes:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, ptrToBytes(p+code.offset))
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyBytes:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-18 16:35:10 +03:00
}
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyBytes:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
2021-01-18 16:35:10 +03:00
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-01-18 16:35:10 +03:00
}
2021-03-06 13:06:11 +03:00
v := ptrToBytes(p + code.offset)
if v == nil {
code = code.nextField
2021-01-18 16:35:10 +03:00
} else {
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
b = encodeByteSlice(b, ptrToBytes(p))
2021-01-18 16:35:10 +03:00
b = encodeComma(b)
code = code.next
}
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadStringTagBytes:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadStringTagBytes:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeByteSlice(b, ptrToBytes(p+code.offset))
b = append(b, '"')
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadBytesPtr:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-18 16:35:10 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 16:35:10 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadBytesPtr:
2021-01-18 16:35:10 +03:00
p := load(ctxptr, code.idx)
2021-03-06 13:06:11 +03:00
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-18 16:35:10 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-18 16:35:10 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-18 16:35:10 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-03-06 13:06:11 +03:00
b = encodeByteSlice(b, ptrToBytes(p))
2021-01-18 16:35:10 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadOmitEmptyBytesPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyBytesPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{')
2021-03-06 13:06:11 +03:00
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p != 0 {
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
b = encodeByteSlice(b, ptrToBytes(p))
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.next
case opStructFieldPtrHeadStringTagBytesPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadStringTagBytesPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
2021-03-06 13:06:11 +03:00
b = encodeByteSlice(b, ptrToBytes(p))
b = append(b, '"')
}
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadArray, opStructFieldPtrHeadStringTagArray,
opStructFieldPtrHeadSlice, opStructFieldPtrHeadStringTagSlice:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadArray, opStructFieldHeadStringTagArray,
opStructFieldHeadSlice, opStructFieldHeadStringTagSlice:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
2021-03-06 13:06:11 +03:00
}
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
p += code.offset
2021-01-10 23:16:37 +03:00
code = code.next
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, p)
case opStructFieldPtrHeadOmitEmptyArray:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyArray:
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
2021-03-06 13:06:11 +03:00
}
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
p += code.offset
b = append(b, code.escapedKey...)
code = code.next
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, p)
case opStructFieldPtrHeadOmitEmptySlice:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
case opStructFieldHeadOmitEmptySlice:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
b = append(b, '{')
}
p += code.offset
slice := ptrToSlice(p)
if slice.data == nil {
code = code.nextField
2021-01-10 23:16:37 +03:00
} else {
b = append(b, code.escapedKey...)
code = code.next
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadArrayPtr, opStructFieldPtrHeadStringTagArrayPtr,
opStructFieldPtrHeadSlicePtr, opStructFieldPtrHeadStringTagSlicePtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadArrayPtr, opStructFieldHeadStringTagArrayPtr,
opStructFieldHeadSlicePtr, opStructFieldHeadStringTagSlicePtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
2021-03-06 13:06:11 +03:00
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
code = code.nextField
2021-01-10 23:16:37 +03:00
} else {
2021-03-06 13:06:11 +03:00
code = code.next
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadOmitEmptyArrayPtr, opStructFieldPtrHeadOmitEmptySlicePtr:
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyArrayPtr, opStructFieldHeadOmitEmptySlicePtr:
p := load(ctxptr, code.idx)
2021-03-06 13:06:11 +03:00
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
2021-03-06 13:06:11 +03:00
code = code.nextField
} else {
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
}
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadMap, opStructFieldPtrHeadStringTagMap:
2021-02-18 21:06:21 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-02-18 21:06:21 +03:00
break
}
2021-02-18 21:06:21 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadMap, opStructFieldHeadStringTagMap:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
2021-02-18 21:06:21 +03:00
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
if p != 0 && code.indirect {
p = ptrToPtr(p + code.offset)
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldPtrHeadOmitEmptyMap:
p := load(ctxptr, code.idx)
2021-01-10 23:16:37 +03:00
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
2021-02-18 21:06:21 +03:00
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyMap:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
2021-01-10 23:16:37 +03:00
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
if p != 0 && code.indirect {
p = ptrToPtr(p + code.offset)
}
if maplen(ptrToUnsafePtr(p)) == 0 {
code = code.nextField
2021-01-10 23:16:37 +03:00
} else {
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
code = code.next
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadMapPtr, opStructFieldPtrHeadStringTagMapPtr:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadMapPtr, opStructFieldHeadStringTagMapPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
2021-02-18 21:06:21 +03:00
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
2021-02-18 21:06:21 +03:00
b = append(b, '{')
2021-03-06 13:06:11 +03:00
}
b = append(b, code.escapedKey...)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.nextField
break
}
p = ptrToPtr(p + code.offset)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.nextField
} else {
if code.indirect {
p = ptrToPtr(p)
2021-02-18 21:06:21 +03:00
}
code = code.next
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadOmitEmptyMapPtr:
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadOmitEmptyMapPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
b = append(b, '{')
}
if p == 0 {
code = code.nextField
break
}
p = ptrToPtr(p + code.offset)
if p == 0 {
code = code.nextField
2021-02-18 21:06:21 +03:00
} else {
2021-03-06 13:06:11 +03:00
if code.indirect {
p = ptrToPtr(p)
}
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
code = code.next
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
}
2021-02-18 21:06:21 +03:00
case opStructFieldPtrHeadMarshalJSON:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
}
fallthrough
2021-02-18 21:06:21 +03:00
case opStructFieldHeadMarshalJSON:
2021-03-06 13:06:11 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-02-18 21:06:21 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
2021-02-18 21:06:21 +03:00
b = append(b, '{')
2021-03-06 13:06:11 +03:00
}
b = append(b, code.escapedKey...)
if code.typ.Kind() == reflect.Ptr {
if code.indirect || code.op == opStructFieldPtrHeadMarshalJSON {
p = ptrToPtr(p + code.offset)
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
}
if code.nilcheck && p == 0 {
b = encodeNull(b)
} else {
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true)
2021-02-18 21:06:21 +03:00
if err != nil {
return nil, err
}
2021-03-06 13:06:11 +03:00
b = bb
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadStringTagMarshalJSON:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
2021-02-18 21:06:21 +03:00
b = encodeNull(b)
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
}
fallthrough
case opStructFieldHeadStringTagMarshalJSON:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{')
}
b = append(b, code.escapedKey...)
if code.typ.Kind() == reflect.Ptr {
if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalJSON {
p = ptrToPtr(p + code.offset)
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
}
if code.nilcheck && p == 0 {
b = encodeNull(b)
} else {
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true)
2021-03-06 13:06:11 +03:00
if err != nil {
2021-02-18 21:06:21 +03:00
return nil, err
}
2021-03-06 13:06:11 +03:00
b = bb
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyMarshalJSON:
2021-01-10 23:16:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-02-18 21:06:21 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
}
2021-02-18 21:06:21 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyMarshalJSON:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
if !code.anonymousHead {
b = append(b, '{')
}
if code.typ.Kind() == reflect.Ptr {
if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalJSON {
p = ptrToPtr(p + code.offset)
}
2021-01-10 23:16:37 +03:00
}
2021-03-11 07:09:49 +03:00
iface := ptrToInterface(code, p)
if code.nilcheck && encodeIsNilForMarshaler(iface) {
2021-03-06 13:06:11 +03:00
code = code.nextField
2021-01-10 23:16:37 +03:00
} else {
b = append(b, code.escapedKey...)
2021-03-11 07:09:49 +03:00
bb, err := encodeMarshalJSON(code, b, iface, true)
2021-02-18 21:06:21 +03:00
if err != nil {
2021-03-06 13:06:11 +03:00
return nil, err
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
b = bb
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
}
2021-03-06 13:06:11 +03:00
case opStructFieldPtrHeadMarshalJSONPtr, opStructFieldPtrHeadStringTagMarshalJSONPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadMarshalJSONPtr, opStructFieldHeadStringTagMarshalJSONPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
2021-02-18 21:06:21 +03:00
b = encodeNull(b)
2021-01-10 23:16:37 +03:00
} else {
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true)
2021-03-06 13:06:11 +03:00
if err != nil {
return nil, err
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
b = bb
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyMarshalJSONPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-02-18 21:06:21 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyMarshalJSONPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
if p == 0 {
code = code.nextField
2021-01-10 23:16:37 +03:00
} else {
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true)
2021-03-06 13:06:11 +03:00
if err != nil {
return nil, err
}
b = bb
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadMarshalText:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-10 23:16:37 +03:00
}
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadMarshalText:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
if code.typ.Kind() == reflect.Ptr {
if code.indirect || code.op == opStructFieldPtrHeadMarshalText {
p = ptrToPtr(p + code.offset)
}
}
if code.nilcheck && p == 0 {
2021-01-10 23:16:37 +03:00
b = encodeNull(b)
} else {
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true)
2021-03-06 13:06:11 +03:00
if err != nil {
return nil, err
}
b = bb
}
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadStringTagMarshalText:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
}
2021-01-10 23:16:37 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadStringTagMarshalText:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-10 23:16:37 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
if code.typ.Kind() == reflect.Ptr {
if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalText {
p = ptrToPtr(p + code.offset)
}
}
if code.nilcheck && p == 0 {
b = encodeNull(b)
} else {
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true)
2021-02-18 21:06:21 +03:00
if err != nil {
2021-03-06 13:06:11 +03:00
return nil, err
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
b = bb
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyMarshalText:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
2021-02-18 21:06:21 +03:00
}
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyMarshalText:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-02-18 21:06:21 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if !code.anonymousHead {
b = append(b, '{')
}
if code.typ.Kind() == reflect.Ptr {
if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalText {
p = ptrToPtr(p + code.offset)
}
}
if p == 0 && code.nilcheck {
code = code.nextField
2021-02-18 21:06:21 +03:00
} else {
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true)
2021-02-18 21:06:21 +03:00
if err != nil {
2021-03-06 13:06:11 +03:00
return nil, err
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
b = bb
b = encodeComma(b)
code = code.next
}
case opStructFieldPtrHeadMarshalTextPtr, opStructFieldPtrHeadStringTagMarshalTextPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-03-06 13:06:11 +03:00
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadMarshalTextPtr, opStructFieldHeadStringTagMarshalTextPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 13:06:11 +03:00
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
} else {
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true)
2021-02-18 21:06:21 +03:00
if err != nil {
2021-03-06 13:06:11 +03:00
return nil, err
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
b = bb
}
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyMarshalTextPtr:
p := load(ctxptr, code.idx)
if p == 0 {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
2021-03-06 13:06:11 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-02-18 21:06:21 +03:00
fallthrough
2021-03-06 13:06:11 +03:00
case opStructFieldHeadOmitEmptyMarshalTextPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-02-18 21:06:21 +03:00
code = code.end.next
2021-03-06 13:06:11 +03:00
break
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if !code.anonymousHead {
b = append(b, '{')
}
if p == 0 {
code = code.nextField
2021-02-18 21:06:21 +03:00
} else {
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true)
2021-01-10 23:16:37 +03:00
if err != nil {
2021-03-06 13:06:11 +03:00
return nil, err
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
b = bb
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
2021-02-18 21:06:21 +03:00
code = code.next
2021-01-10 23:16:37 +03:00
}
2021-02-18 21:06:21 +03:00
case opStructField:
if !code.anonymousKey {
b = append(b, code.escapedKey...)
2021-01-10 23:16:37 +03:00
}
2021-02-18 21:06:21 +03:00
ptr := load(ctxptr, code.headIdx) + code.offset
2021-01-17 09:49:34 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
store(ctxptr, code.idx, ptr)
case opStructFieldOmitEmpty:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
2021-03-06 13:06:11 +03:00
if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) {
2021-01-10 23:16:37 +03:00
code = code.nextField
} else {
b = append(b, code.escapedKey...)
2021-01-10 23:16:37 +03:00
code = code.next
store(ctxptr, code.idx, p)
2021-01-10 23:16:37 +03:00
}
2021-02-18 21:06:21 +03:00
case opStructFieldStringTag:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
2021-02-18 21:06:21 +03:00
case opStructFieldInt:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-02-19 09:03:52 +03:00
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldOmitEmptyInt:
ptr := load(ctxptr, code.headIdx)
2021-02-18 21:06:21 +03:00
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
if v != 0 {
b = append(b, code.escapedKey...)
2021-02-19 09:03:52 +03:00
b = appendInt(b, u64, code)
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldStringTagInt:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
2021-02-19 09:03:52 +03:00
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
b = append(b, '"')
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldIntPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-02-19 09:03:52 +03:00
b = appendInt(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldOmitEmptyIntPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
2021-02-19 09:03:52 +03:00
b = appendInt(b, ptrToUint64(p), code)
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldStringTagIntPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-02-18 21:06:21 +03:00
b = append(b, code.escapedKey...)
if p == 0 {
2021-01-13 18:02:58 +03:00
b = encodeNull(b)
} else {
b = append(b, '"')
2021-02-19 09:03:52 +03:00
b = appendInt(b, ptrToUint64(p), code)
b = append(b, '"')
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldUint:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-02-19 09:03:52 +03:00
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-16 20:53:54 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldOmitEmptyUint:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-19 09:03:52 +03:00
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
2021-01-16 20:53:54 +03:00
if v != 0 {
b = append(b, code.escapedKey...)
2021-02-19 09:03:52 +03:00
b = appendUint(b, u64, code)
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-16 20:53:54 +03:00
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldStringTagUint:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
2021-02-19 09:03:52 +03:00
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-16 20:53:54 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldUintPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-02-19 09:03:52 +03:00
b = appendUint(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldOmitEmptyUintPtr:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-16 20:53:54 +03:00
if p != 0 {
b = append(b, code.escapedKey...)
2021-02-19 09:03:52 +03:00
b = appendUint(b, ptrToUint64(p), code)
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-16 20:53:54 +03:00
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldStringTagUintPtr:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-02-18 21:06:21 +03:00
b = append(b, code.escapedKey...)
2021-01-16 20:53:54 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
2021-02-19 09:03:52 +03:00
b = appendUint(b, ptrToUint64(p), code)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldFloat32:
2021-01-17 09:49:34 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
b = encodeComma(b)
2021-01-17 09:49:34 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldOmitEmptyFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-18 21:06:21 +03:00
v := ptrToFloat32(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if v != 0 {
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
b = encodeFloat32(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldStringTagFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
2021-02-18 21:06:21 +03:00
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
2021-01-17 16:06:16 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldFloat32Ptr:
2021-01-17 16:06:16 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 16:06:16 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-02-18 21:06:21 +03:00
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-17 16:06:16 +03:00
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-17 16:06:16 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldOmitEmptyFloat32Ptr:
2021-01-17 16:06:16 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-02-18 21:06:21 +03:00
if p != 0 {
b = append(b, code.escapedKey...)
b = encodeFloat32(b, ptrToFloat32(p))
b = encodeComma(b)
2021-01-17 16:06:16 +03:00
}
2021-02-18 21:06:21 +03:00
code = code.next
case opStructFieldStringTagFloat32Ptr:
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
b = append(b, code.escapedKey...)
2021-01-17 16:06:16 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-02-18 21:06:21 +03:00
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(p))
b = append(b, '"')
2021-01-17 16:06:16 +03:00
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-17 16:06:16 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
v := ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldOmitEmptyFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-18 21:06:21 +03:00
v := ptrToFloat64(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if v != 0 {
2021-02-18 21:06:21 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
2021-01-22 14:06:20 +03:00
}
2021-02-18 21:06:21 +03:00
b = append(b, code.escapedKey...)
b = encodeFloat64(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldStringTagFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-18 21:06:21 +03:00
v := ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
2021-02-18 21:06:21 +03:00
b = encodeFloat64(b, v)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldFloat64Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
code = code.next
break
2021-01-10 23:16:37 +03:00
}
2021-02-18 21:06:21 +03:00
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldOmitEmptyFloat64Ptr:
2021-01-18 15:50:52 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-18 15:50:52 +03:00
if p != 0 {
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
2021-01-22 14:06:20 +03:00
}
2021-02-18 21:06:21 +03:00
b = encodeFloat64(b, v)
b = encodeComma(b)
2021-01-18 15:50:52 +03:00
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldStringTagFloat64Ptr:
2021-01-18 15:50:52 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-02-18 21:06:21 +03:00
b = append(b, code.escapedKey...)
2021-01-18 15:50:52 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-02-18 21:06:21 +03:00
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
2021-01-18 15:50:52 +03:00
b = append(b, '"')
2021-02-18 21:06:21 +03:00
b = encodeFloat64(b, v)
2021-01-18 15:50:52 +03:00
b = append(b, '"')
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-18 15:50:52 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
b = encodeEscapedString(b, ptrToString(ptr+code.offset))
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldOmitEmptyString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-18 21:06:21 +03:00
v := ptrToString(ptr + code.offset)
if v != "" {
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
b = encodeEscapedString(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldStringTagString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
s := ptrToString(ptr + code.offset)
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s)))
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldStringPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-02-18 21:06:21 +03:00
b = encodeEscapedString(b, ptrToString(p))
2021-01-10 23:16:37 +03:00
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldOmitEmptyStringPtr:
2021-01-18 16:35:10 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-18 16:35:10 +03:00
if p != 0 {
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
b = encodeEscapedString(b, ptrToString(p))
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-18 16:35:10 +03:00
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldStringTagStringPtr:
2021-01-18 16:35:10 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-18 16:35:10 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-02-18 21:06:21 +03:00
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, ptrToString(p))))
2021-01-18 16:35:10 +03:00
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-18 16:35:10 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
b = encodeBool(b, ptrToBool(ptr+code.offset))
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldOmitEmptyBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-18 21:06:21 +03:00
v := ptrToBool(ptr + code.offset)
if v {
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
b = encodeBool(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldStringTagBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
2021-02-18 21:06:21 +03:00
b = encodeBool(b, ptrToBool(ptr+code.offset))
2021-01-17 09:49:34 +03:00
b = append(b, '"')
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldBoolPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-02-18 21:06:21 +03:00
b = encodeBool(b, ptrToBool(p))
2021-01-10 23:16:37 +03:00
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldOmitEmptyBoolPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
b = encodeBool(b, ptrToBool(p))
b = encodeComma(b)
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldStringTagBoolPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
2021-02-18 21:06:21 +03:00
b = encodeBool(b, ptrToBool(p))
b = append(b, '"')
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldOmitEmptyBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-18 21:06:21 +03:00
v := ptrToBytes(ptr + code.offset)
if len(v) > 0 {
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldStringTagBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-18 21:06:21 +03:00
v := ptrToBytes(ptr + code.offset)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
b = encodeByteSlice(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldBytesPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
2021-01-17 09:49:34 +03:00
} else {
2021-02-18 21:06:21 +03:00
b = encodeByteSlice(b, ptrToBytes(p))
2021-01-10 23:16:37 +03:00
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldOmitEmptyBytesPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
b = encodeByteSlice(b, ptrToBytes(p))
b = encodeComma(b)
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructFieldStringTagBytesPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
2021-02-18 21:06:21 +03:00
b = encodeByteSlice(b, ptrToBytes(p))
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldMarshalJSON, opStructFieldStringTagMarshalJSON:
p := load(ctxptr, code.headIdx)
2021-02-18 21:06:21 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
p += code.offset
2021-02-18 21:06:21 +03:00
if code.typ.Kind() == reflect.Ptr {
2021-01-31 16:45:59 +03:00
p = ptrToPtr(p)
}
2021-03-06 13:06:11 +03:00
if p == 0 && code.nilcheck {
b = encodeNull(b)
2021-03-06 13:06:11 +03:00
} else {
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true)
2021-03-06 13:06:11 +03:00
if err != nil {
return nil, err
}
b = bb
2021-02-18 21:06:21 +03:00
}
b = encodeComma(b)
code = code.next
case opStructFieldOmitEmptyMarshalJSON:
2021-03-06 13:06:11 +03:00
p := load(ctxptr, code.headIdx)
p += code.offset
2021-02-18 21:06:21 +03:00
if code.typ.Kind() == reflect.Ptr {
p = ptrToPtr(p)
}
2021-03-06 13:06:11 +03:00
if p == 0 && code.nilcheck {
code = code.nextField
2021-02-18 21:06:21 +03:00
break
}
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true)
2021-02-18 21:06:21 +03:00
if err != nil {
2021-03-06 13:06:11 +03:00
return nil, err
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
b = encodeComma(bb)
code = code.next
case opStructFieldMarshalJSONPtr, opStructFieldStringTagMarshalJSONPtr:
p := load(ctxptr, code.headIdx)
2021-02-18 21:06:21 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
p = ptrToPtr(p + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true)
2021-03-06 13:06:11 +03:00
if err != nil {
return nil, err
}
b = bb
2021-02-18 21:06:21 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldOmitEmptyMarshalJSONPtr:
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), true)
2021-03-06 13:06:11 +03:00
if err != nil {
return nil, err
}
b = encodeComma(bb)
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
code = code.next
case opStructFieldMarshalText, opStructFieldStringTagMarshalText:
p := load(ctxptr, code.headIdx)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
p += code.offset
if code.typ.Kind() == reflect.Ptr {
p = ptrToPtr(p)
}
if p == 0 && code.nilcheck {
b = encodeNull(b)
} else {
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true)
2021-03-06 13:06:11 +03:00
if err != nil {
return nil, err
}
b = bb
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldOmitEmptyMarshalText:
p := load(ctxptr, code.headIdx)
p += code.offset
if code.typ.Kind() == reflect.Ptr {
p = ptrToPtr(p)
}
if p == 0 && code.nilcheck {
code = code.nextField
break
}
2021-02-18 21:06:21 +03:00
b = append(b, code.escapedKey...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true)
2021-02-18 21:06:21 +03:00
if err != nil {
2021-03-06 13:06:11 +03:00
return nil, err
2021-02-18 21:06:21 +03:00
}
2021-03-06 13:06:11 +03:00
b = encodeComma(bb)
2021-02-18 21:06:21 +03:00
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldMarshalTextPtr, opStructFieldStringTagMarshalTextPtr:
p := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
p = ptrToPtr(p + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true)
2021-02-18 21:06:21 +03:00
if err != nil {
2021-03-06 13:06:11 +03:00
return nil, err
2021-01-22 14:06:20 +03:00
}
2021-03-06 13:06:11 +03:00
b = bb
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldOmitEmptyMarshalTextPtr:
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), true)
2021-03-06 13:06:11 +03:00
if err != nil {
return nil, err
}
b = encodeComma(bb)
2021-02-18 21:06:21 +03:00
}
2021-01-10 23:16:37 +03:00
code = code.next
2021-03-06 13:06:11 +03:00
case opStructFieldArray, opStructFieldStringTagArray:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-02-18 21:06:21 +03:00
p := ptr + code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyArray:
2021-03-06 13:06:11 +03:00
p := load(ctxptr, code.headIdx)
p += code.offset
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldArrayPtr, opStructFieldStringTagArrayPtr:
b = append(b, code.escapedKey...)
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyArrayPtr:
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
2021-02-18 21:06:21 +03:00
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
2021-03-06 13:06:11 +03:00
} else {
code = code.nextField
2021-01-10 23:16:37 +03:00
}
2021-03-06 13:06:11 +03:00
case opStructFieldSlice, opStructFieldStringTagSlice:
2021-02-18 21:06:21 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
2021-01-10 23:16:37 +03:00
code = code.next
2021-02-18 21:06:21 +03:00
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptySlice:
ptr := load(ctxptr, code.headIdx)
2021-02-18 21:06:21 +03:00
p := ptr + code.offset
slice := ptrToSlice(p)
if p == 0 || uintptr(slice.data) == 0 {
code = code.nextField
} else {
b = append(b, code.escapedKey...)
2021-02-18 21:06:21 +03:00
code = code.next
store(ctxptr, code.idx, p)
}
2021-03-06 13:06:11 +03:00
case opStructFieldSlicePtr, opStructFieldStringTagSlicePtr:
2021-02-18 21:06:21 +03:00
b = append(b, code.escapedKey...)
2021-03-06 13:06:11 +03:00
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptySlicePtr:
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
} else {
code = code.nextField
}
case opStructFieldMap, opStructFieldStringTagMap:
b = append(b, code.escapedKey...)
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
2021-02-18 21:06:21 +03:00
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyMap:
2021-03-06 13:06:11 +03:00
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
2021-02-18 21:06:21 +03:00
if p == 0 {
code = code.nextField
2021-01-22 14:06:20 +03:00
} else {
2021-03-06 13:06:11 +03:00
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
}
case opStructFieldMapPtr, opStructFieldStringTagMapPtr:
b = append(b, code.escapedKey...)
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
p = ptrToPtr(p)
}
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyMapPtr:
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
p = ptrToPtr(p)
}
if p != 0 {
b = append(b, code.escapedKey...)
code = code.next
store(ctxptr, code.idx, p)
} else {
code = code.nextField
}
2021-02-18 21:06:21 +03:00
case opStructFieldStruct:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-02-18 21:06:21 +03:00
p := ptr + code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructEnd:
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
} else {
2021-02-18 21:06:21 +03:00
b = append(b, '}')
}
2021-02-18 21:06:21 +03:00
b = encodeComma(b)
code = code.next
2021-02-18 21:06:21 +03:00
case opStructAnonymousEnd:
code = code.next
case opStructEndInt:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-02-19 09:03:52 +03:00
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-02-18 21:06:21 +03:00
case opStructEndOmitEmptyInt:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-18 21:06:21 +03:00
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
2021-01-17 09:49:34 +03:00
if v != 0 {
b = append(b, code.escapedKey...)
2021-02-19 09:03:52 +03:00
b = appendInt(b, u64, code)
2021-01-22 14:06:20 +03:00
b = appendStructEnd(b)
} else {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
b = encodeComma(b)
} else {
b = appendStructEnd(b)
}
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructEndStringTagInt:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
2021-02-19 09:03:52 +03:00
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-02-18 21:06:21 +03:00
case opStructEndIntPtr:
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-02-19 09:03:52 +03:00
b = appendInt(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
b = appendStructEnd(b)
code = code.next
2021-02-18 21:06:21 +03:00
case opStructEndOmitEmptyIntPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
2021-02-19 09:03:52 +03:00
b = appendInt(b, ptrToUint64(p), code)
2021-01-22 14:06:20 +03:00
b = appendStructEnd(b)
} else {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
b = encodeComma(b)
} else {
b = appendStructEnd(b)
}
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructEndStringTagIntPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
2021-02-19 09:03:52 +03:00
b = appendInt(b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendStructEnd(b)
code = code.next
2021-02-18 21:06:21 +03:00
case opStructEndUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
2021-02-19 09:03:52 +03:00
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-02-18 21:06:21 +03:00
case opStructEndOmitEmptyUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-02-19 09:03:52 +03:00
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
2021-01-10 23:16:37 +03:00
if v != 0 {
b = append(b, code.escapedKey...)
2021-02-19 09:03:52 +03:00
b = appendUint(b, u64, code)
2021-01-22 14:06:20 +03:00
b = appendStructEnd(b)
} else {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
b = encodeComma(b)
} else {
b = appendStructEnd(b)
}
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructEndStringTagUint:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, '"')
2021-02-19 09:03:52 +03:00
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-02-18 21:06:21 +03:00
case opStructEndUintPtr:
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-02-19 09:03:52 +03:00
b = appendUint(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
b = appendStructEnd(b)
code = code.next
2021-02-18 21:06:21 +03:00
case opStructEndOmitEmptyUintPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
2021-02-19 09:03:52 +03:00
b = appendUint(b, ptrToUint64(p), code)
2021-01-22 14:06:20 +03:00
b = appendStructEnd(b)
} else {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
b = encodeComma(b)
} else {
b = appendStructEnd(b)
}
}
code = code.next
2021-02-18 21:06:21 +03:00
case opStructEndStringTagUintPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
2021-02-19 09:03:52 +03:00
b = appendUint(b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToFloat32(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if v != 0 {
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = encodeFloat32(b, v)
2021-01-22 14:06:20 +03:00
b = appendStructEnd(b)
} else {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
b = encodeComma(b)
} else {
b = appendStructEnd(b)
}
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagFloat32:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, '"')
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
case opStructEndFloat32Ptr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-10 23:16:37 +03:00
}
b = appendStructEnd(b)
code = code.next
case opStructEndOmitEmptyFloat32Ptr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-22 14:06:20 +03:00
b = appendStructEnd(b)
} else {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
b = encodeComma(b)
} else {
b = appendStructEnd(b)
}
}
code = code.next
case opStructEndStringTagFloat32Ptr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(p))
b = append(b, '"')
}
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
2021-01-10 23:16:37 +03:00
}
2021-01-17 09:49:34 +03:00
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-11 13:21:30 +03:00
case opStructEndOmitEmptyFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(ptr + code.offset)
2021-01-10 23:16:37 +03:00
if v != 0 {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = append(b, code.escapedKey...)
b = encodeFloat64(b, v)
2021-01-22 14:06:20 +03:00
b = appendStructEnd(b)
} else {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
b = encodeComma(b)
} else {
b = appendStructEnd(b)
}
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagFloat64:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
2021-01-10 23:16:37 +03:00
}
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
b = append(b, '"')
b = encodeFloat64(b, v)
b = append(b, '"')
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndFloat64Ptr:
b = append(b, code.escapedKey...)
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if p == 0 {
b = encodeNull(b)
b = appendStructEnd(b)
code = code.next
break
2021-01-10 23:16:37 +03:00
}
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(p)
2021-01-17 09:49:34 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
2021-01-10 23:16:37 +03:00
}
2021-01-17 09:49:34 +03:00
b = encodeFloat64(b, v)
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
case opStructEndOmitEmptyFloat64Ptr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
2021-01-22 14:06:20 +03:00
b = appendStructEnd(b)
} else {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
b = encodeComma(b)
} else {
b = appendStructEnd(b)
}
}
code = code.next
case opStructEndStringTagFloat64Ptr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = append(b, '"')
}
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
b = encodeEscapedString(b, ptrToString(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToString(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if v != "" {
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = encodeEscapedString(b, v)
2021-01-22 14:06:20 +03:00
b = appendStructEnd(b)
} else {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
b = encodeComma(b)
} else {
b = appendStructEnd(b)
}
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagString:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
s := ptrToString(ptr + code.offset)
2021-01-17 09:49:34 +03:00
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, s)))
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-01-31 16:45:59 +03:00
b = encodeEscapedString(b, ptrToString(p))
2021-01-17 09:49:34 +03:00
}
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-20 18:22:20 +03:00
case opStructEndOmitEmptyStringPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-20 18:22:20 +03:00
if p != 0 {
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
b = encodeEscapedString(b, ptrToString(p))
2021-01-22 14:06:20 +03:00
b = appendStructEnd(b)
} else {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
b = encodeComma(b)
} else {
b = appendStructEnd(b)
}
2021-01-20 18:22:20 +03:00
}
code = code.next
case opStructEndStringTagStringPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-20 18:22:20 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-01-31 16:45:59 +03:00
v := ptrToString(p)
2021-01-20 18:22:20 +03:00
b = encodeEscapedString(b, string(encodeEscapedString([]byte{}, v)))
}
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
b = encodeBool(b, ptrToBool(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToBool(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if v {
b = append(b, code.escapedKey...)
b = encodeBool(b, v)
2021-01-22 14:06:20 +03:00
b = appendStructEnd(b)
} else {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
b = encodeComma(b)
} else {
b = appendStructEnd(b)
}
2021-01-17 09:49:34 +03:00
}
2021-01-10 23:16:37 +03:00
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagBool:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
b = append(b, '"')
2021-01-31 16:45:59 +03:00
b = encodeBool(b, ptrToBool(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndBoolPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-01-31 16:45:59 +03:00
b = encodeBool(b, ptrToBool(p))
2021-01-17 09:49:34 +03:00
}
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
case opStructEndOmitEmptyBoolPtr:
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
if p != 0 {
b = append(b, code.escapedKey...)
b = encodeBool(b, ptrToBool(p))
b = appendStructEnd(b)
} else {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
b = encodeComma(b)
} else {
b = appendStructEnd(b)
}
}
code = code.next
case opStructEndStringTagBoolPtr:
b = append(b, code.escapedKey...)
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeBool(b, ptrToBool(p))
b = append(b, '"')
}
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.escapedKey...)
2021-01-31 16:45:59 +03:00
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToBytes(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if len(v) > 0 {
b = append(b, code.escapedKey...)
b = encodeByteSlice(b, v)
2021-01-22 14:06:20 +03:00
b = appendStructEnd(b)
} else {
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
b = encodeComma(b)
} else {
b = appendStructEnd(b)
}
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagBytes:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToBytes(ptr + code.offset)
2021-01-10 23:16:37 +03:00
b = append(b, code.escapedKey...)
2021-01-17 09:49:34 +03:00
b = encodeByteSlice(b, v)
2021-01-10 23:16:37 +03:00
b = appendStructEnd(b)
code = code.next
case opEnd:
goto END
}
}
END:
return b, nil
}