go-json/encode_vm.go

3732 lines
89 KiB
Go
Raw Normal View History

2020-04-29 18:31:50 +03:00
package json
import (
"fmt"
"math"
2020-04-29 18:31:50 +03:00
"reflect"
2020-09-16 08:51:37 +03:00
"sort"
"strconv"
2021-03-05 17:57:44 +03:00
"strings"
2020-04-29 18:31:50 +03:00
"unsafe"
)
2020-09-01 16:26:26 +03:00
const startDetectingCyclesAfter = 1000
2020-08-30 21:14:37 +03:00
func load(base uintptr, idx uintptr) uintptr {
addr := base + idx
return **(**uintptr)(unsafe.Pointer(&addr))
}
2020-08-30 21:14:37 +03:00
func store(base uintptr, idx uintptr, p uintptr) {
addr := base + idx
**(**uintptr)(unsafe.Pointer(&addr)) = p
}
2021-01-31 16:45:59 +03:00
func ptrToUint64(p uintptr) uint64 { return **(**uint64)(unsafe.Pointer(&p)) }
func ptrToFloat32(p uintptr) float32 { return **(**float32)(unsafe.Pointer(&p)) }
func ptrToFloat64(p uintptr) float64 { return **(**float64)(unsafe.Pointer(&p)) }
func ptrToBool(p uintptr) bool { return **(**bool)(unsafe.Pointer(&p)) }
func ptrToBytes(p uintptr) []byte { return **(**[]byte)(unsafe.Pointer(&p)) }
func ptrToString(p uintptr) string { return **(**string)(unsafe.Pointer(&p)) }
func ptrToSlice(p uintptr) *sliceHeader { return *(**sliceHeader)(unsafe.Pointer(&p)) }
func ptrToPtr(p uintptr) uintptr {
return uintptr(**(**unsafe.Pointer)(unsafe.Pointer(&p)))
}
func ptrToUnsafePtr(p uintptr) unsafe.Pointer {
return *(*unsafe.Pointer)(unsafe.Pointer(&p))
}
func ptrToInterface(code *opcode, p uintptr) interface{} {
return *(*interface{})(unsafe.Pointer(&interfaceHeader{
typ: code.typ,
ptr: *(*unsafe.Pointer)(unsafe.Pointer(&p)),
}))
}
2020-09-15 14:48:02 +03:00
func errUnsupportedValue(code *opcode, ptr uintptr) *UnsupportedValueError {
v := *(*interface{})(unsafe.Pointer(&interfaceHeader{
typ: code.typ,
ptr: *(*unsafe.Pointer)(unsafe.Pointer(&ptr)),
2020-09-15 14:48:02 +03:00
}))
return &UnsupportedValueError{
Value: reflect.ValueOf(v),
Str: fmt.Sprintf("encountered a cycle via %s", code.typ),
}
}
2020-11-17 09:06:05 +03:00
func errUnsupportedFloat(v float64) *UnsupportedValueError {
return &UnsupportedValueError{
Value: reflect.ValueOf(v),
Str: strconv.FormatFloat(v, 'g', -1, 64),
}
}
2020-11-17 09:08:12 +03:00
func errMarshaler(code *opcode, err error) *MarshalerError {
return &MarshalerError{
Type: rtype2type(code.typ),
Err: err,
}
}
2021-01-31 16:45:59 +03:00
func encodeRun(ctx *encodeRuntimeContext, b []byte, codeSet *opcodeSet, opt EncodeOption) ([]byte, error) {
2020-09-04 07:53:25 +03:00
recursiveLevel := 0
2020-09-03 09:36:11 +03:00
ptrOffset := uintptr(0)
ctxptr := ctx.ptr()
2021-01-24 09:17:39 +03:00
code := codeSet.code
2020-12-29 19:29:29 +03:00
2020-04-29 18:31:50 +03:00
for {
switch code.op {
default:
2021-02-01 06:01:56 +03:00
return nil, fmt.Errorf("encoder: opcode %s has not been implemented", code.op)
2021-01-10 23:16:37 +03:00
case opPtr:
ptr := load(ctxptr, code.idx)
2020-04-29 18:31:50 +03:00
code = code.next
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(ptr))
2020-04-29 18:31:50 +03:00
case opInt:
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
b = encodeComma(b)
code = code.next
2020-04-29 18:31:50 +03:00
case opUint:
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code)
b = encodeComma(b)
code = code.next
case opIntString:
2020-12-25 16:26:59 +03:00
b = append(b, '"')
b = appendInt(b, ptrToUint64(load(ctxptr, code.idx)), code)
2020-12-25 16:26:59 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opUintString:
2020-12-25 16:26:59 +03:00
b = append(b, '"')
b = appendUint(b, ptrToUint64(load(ctxptr, code.idx)), code)
2020-12-25 16:26:59 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
2020-04-29 18:31:50 +03:00
case opFloat32:
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(load(ctxptr, code.idx)))
b = encodeComma(b)
code = code.next
2020-04-29 18:31:50 +03:00
case opFloat64:
2021-01-31 16:45:59 +03:00
v := ptrToFloat64(load(ctxptr, code.idx))
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
2020-04-29 18:31:50 +03:00
case opString:
2021-01-31 16:45:59 +03:00
b = encodeNoEscapedString(b, ptrToString(load(ctxptr, code.idx)))
2020-12-25 16:26:59 +03:00
b = encodeComma(b)
code = code.next
2020-04-29 18:31:50 +03:00
case opBool:
2021-01-31 16:45:59 +03:00
b = encodeBool(b, ptrToBool(load(ctxptr, code.idx)))
b = encodeComma(b)
code = code.next
2020-08-19 04:34:11 +03:00
case opBytes:
ptr := load(ctxptr, code.idx)
2021-01-31 16:45:59 +03:00
slice := ptrToSlice(ptr)
if ptr == 0 || uintptr(slice.data) == 0 {
b = encodeNull(b)
2020-08-21 05:51:33 +03:00
} else {
2021-01-31 16:45:59 +03:00
b = encodeByteSlice(b, ptrToBytes(ptr))
2020-08-21 05:51:33 +03:00
}
b = encodeComma(b)
code = code.next
case opInterface:
2020-08-31 15:59:22 +03:00
ptr := load(ctxptr, code.idx)
2020-09-17 15:50:27 +03:00
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-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 17:27:23 +03:00
if iface == nil || iface.ptr == nil {
b = encodeNull(b)
b = encodeComma(b)
code = code.next
break
}
2021-01-24 17:27:23 +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)))
2020-12-07 04:44:24 +03:00
if err != nil {
return nil, err
2020-12-07 04:44:24 +03:00
}
2021-01-24 17:27:23 +03:00
totalLength := uintptr(codeSet.codeLength)
nextTotalLength := uintptr(ifaceCodeSet.codeLength)
2020-09-03 09:36:11 +03:00
curlen := uintptr(len(ctx.ptrs))
offsetNum := ptrOffset / uintptrSize
2020-09-03 16:05:46 +03:00
2020-09-03 09:36:11 +03:00
newLen := offsetNum + totalLength + nextTotalLength
if curlen < newLen {
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
}
2021-01-24 17:27:23 +03:00
oldPtrs := ctx.ptrs
2020-09-03 16:05:46 +03:00
2021-01-24 17:27:23 +03:00
newPtrs := ctx.ptrs[(ptrOffset+totalLength*uintptrSize)/uintptrSize:]
newPtrs[0] = uintptr(iface.ptr)
ctx.ptrs = newPtrs
2021-01-31 16:45:59 +03:00
bb, err := encodeRun(ctx, b, ifaceCodeSet, opt)
2021-01-24 17:27:23 +03:00
if err != nil {
return nil, err
}
2020-09-03 09:36:11 +03:00
2021-01-24 17:27:23 +03:00
ctx.ptrs = oldPtrs
ctxptr = ctx.ptr()
ctx.seenPtr = ctx.seenPtr[:len(ctx.seenPtr)-1]
2020-09-03 09:36:11 +03:00
2021-01-24 17:27:23 +03:00
b = bb
2020-08-31 15:59:22 +03:00
code = code.next
2020-05-04 12:39:17 +03:00
case opMarshalJSON:
2021-03-10 13:27:37 +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), false)
2020-05-04 12:39:17 +03:00
if err != nil {
return nil, err
2020-08-18 07:36:36 +03:00
}
2021-03-10 13:27:37 +03:00
b = encodeComma(bb)
code = code.next
2020-05-04 12:39:17 +03:00
case opMarshalText:
2021-03-10 13:27:37 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
b = append(b, `""`...)
b = encodeComma(b)
2021-03-10 13:27:37 +03:00
code = code.next
break
}
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false)
if err != nil {
return nil, err
}
b = encodeComma(bb)
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:
p := load(ctxptr, code.idx)
2021-01-31 16:45:59 +03:00
slice := ptrToSlice(p)
2021-03-09 15:38:58 +03:00
if p == 0 || slice.data == nil {
b = encodeNull(b)
b = encodeComma(b)
2020-08-31 15:59:22 +03:00
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
store(ctxptr, code.idx, uintptr(slice.data))
2021-03-10 13:27:37 +03:00
} else {
b = append(b, '[', ']', ',')
code = code.end.next
2020-04-29 18:31:50 +03:00
}
case opSliceElem:
2020-08-31 15:59:22 +03:00
idx := load(ctxptr, code.elemIdx)
length := load(ctxptr, code.length)
idx++
if idx < length {
store(ctxptr, code.elemIdx, idx)
data := load(ctxptr, code.headIdx)
2020-09-01 16:26:26 +03:00
size := code.size
code = code.next
store(ctxptr, code.idx, data+idx*size)
2020-04-29 18:31:50 +03:00
} else {
last := len(b) - 1
b[last] = ']'
b = encodeComma(b)
2020-08-31 15:59:22 +03:00
code = code.end.next
2020-04-29 18:31:50 +03:00
}
2021-03-09 19:11:48 +03:00
case opArray:
p := load(ctxptr, code.idx)
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
2020-08-31 15:59:22 +03:00
code = code.end.next
} else {
2020-08-31 15:59:22 +03:00
if code.length > 0 {
b = append(b, '[')
2020-09-01 16:26:26 +03:00
store(ctxptr, code.elemIdx, 0)
code = code.next
store(ctxptr, code.idx, p)
} else {
b = append(b, '[', ']', ',')
2020-08-31 15:59:22 +03:00
code = code.end.next
}
}
case opArrayElem:
2020-08-31 15:59:22 +03:00
idx := load(ctxptr, code.elemIdx)
idx++
if idx < code.length {
store(ctxptr, code.elemIdx, idx)
p := load(ctxptr, code.headIdx)
2020-09-01 16:26:26 +03:00
size := code.size
code = code.next
2020-09-01 16:26:26 +03:00
store(ctxptr, code.idx, p+idx*size)
} else {
last := len(b) - 1
b[last] = ']'
b = encodeComma(b)
2020-08-31 15:59:22 +03:00
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 {
b = encodeNull(b)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
2020-08-31 15:59:22 +03:00
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
2020-05-02 17:35:41 +03:00
} else {
2021-03-10 13:27:37 +03:00
b = append(b, '{', '}', ',')
code = code.end.next
2020-09-16 08:51:37 +03:00
}
case opMapKey:
2020-09-16 08:51:37 +03:00
idx := load(ctxptr, code.elemIdx)
length := load(ctxptr, code.length)
idx++
2021-01-31 16:45:59 +03:00
if (opt & EncodeOptionUnorderedMap) != 0 {
if idx < length {
ptr := load(ctxptr, code.mapIter)
2021-01-31 16:45:59 +03:00
iter := ptrToUnsafePtr(ptr)
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
}
2020-09-16 08:51:37 +03:00
} else {
ptr := load(ctxptr, code.end.mapPos)
2021-01-31 16:45:59 +03:00
mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr))
2021-01-25 07:10:07 +03:00
mapCtx.pos = append(mapCtx.pos, len(b))
if idx < length {
ptr := load(ctxptr, code.mapIter)
2021-01-31 16:45:59 +03:00
iter := ptrToUnsafePtr(ptr)
store(ctxptr, code.elemIdx, idx)
key := mapiterkey(iter)
store(ctxptr, code.next.idx, uintptr(key))
code = code.next
} else {
code = code.end
}
}
case opMapValue:
2021-01-31 16:45:59 +03:00
if (opt & EncodeOptionUnorderedMap) != 0 {
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))
2021-01-25 07:10:07 +03:00
mapCtx.pos = append(mapCtx.pos, len(b))
2020-09-16 08:51:37 +03:00
}
ptr := load(ctxptr, code.mapIter)
2021-01-31 16:45:59 +03:00
iter := ptrToUnsafePtr(ptr)
2020-09-16 08:51: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.
2020-09-16 08:51:37 +03:00
length := int(load(ctxptr, code.length))
ptr := load(ctxptr, code.mapPos)
2021-01-31 16:45:59 +03:00
mapCtx := (*encodeMapContext)(ptrToUnsafePtr(ptr))
2021-01-25 07:10:07 +03:00
pos := mapCtx.pos
2020-09-16 08:51: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)
2020-09-16 08:51:37 +03:00
}
2021-01-25 07:10:07 +03:00
mapCtx.slice.items = append(mapCtx.slice.items, mapItem{
key: b[startKey:startValue],
value: b[startValue:endValue],
2020-09-16 08:51:37 +03:00
})
}
2021-01-25 07:10:07 +03:00
sort.Sort(mapCtx.slice)
buf := mapCtx.buf
for _, item := range mapCtx.slice.items {
buf = append(buf, item.key...)
buf[len(buf)-1] = ':'
2021-01-25 07:10:07 +03:00
buf = append(buf, item.value...)
2020-09-16 08:51:37 +03:00
}
buf[len(buf)-1] = '}'
buf = append(buf, ',')
b = b[:pos[0]]
b = append(b, buf...)
2021-01-25 07:10:07 +03:00
mapCtx.buf = buf
releaseMapContext(mapCtx)
2020-09-16 08:51:37 +03:00
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadRecursive:
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-10 23:16:37 +03:00
case opStructFieldRecursive:
ptr := load(ctxptr, code.idx)
2020-08-31 15:59:22 +03:00
if ptr != 0 {
2020-09-01 16:26:26 +03:00
if recursiveLevel > startDetectingCyclesAfter {
2021-01-15 10:25:00 +03:00
for _, seen := range ctx.seenPtr {
if ptr == seen {
return nil, errUnsupportedValue(code, ptr)
}
2020-08-31 15:59:22 +03:00
}
2020-08-20 17:56:12 +03:00
}
}
2021-01-15 10:25:00 +03:00
ctx.seenPtr = append(ctx.seenPtr, ptr)
2020-09-04 07:48:21 +03:00
c := code.jmp.code
curlen := uintptr(len(ctx.ptrs))
offsetNum := ptrOffset / uintptrSize
oldOffset := ptrOffset
2021-01-15 10:25:00 +03:00
ptrOffset += code.jmp.curLen * uintptrSize
2020-09-04 07:48:21 +03:00
2021-01-15 10:25:00 +03:00
newLen := offsetNum + code.jmp.curLen + code.jmp.nextLen
2020-09-04 07:48:21 +03:00
if curlen < newLen {
ctx.ptrs = append(ctx.ptrs, make([]uintptr, newLen-curlen)...)
2020-08-12 12:42:29 +03:00
}
2020-09-04 07:48:21 +03:00
ctxptr = ctx.ptr() + ptrOffset // assign new ctxptr
2020-09-15 14:48:16 +03:00
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)))
2020-09-04 07:48:21 +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))
2020-09-04 07:48:21 +03:00
ctxptr = ctx.ptr() + offset
ptrOffset = offset
2020-04-29 19:44:48 +03:00
case opStructFieldPtrHead:
2020-09-17 15:50:27 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-09-17 15:50:27 +03:00
code = code.end.next
break
2020-05-01 07:12:01 +03:00
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2020-04-29 19:44:48 +03:00
fallthrough
case opStructFieldHead:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-08-31 15:59:22 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2020-12-25 16:26:59 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
if !code.anonymousKey {
b = append(b, code.key...)
}
p += code.offset
code = code.next
store(ctxptr, code.idx, p)
2021-01-13 18:02:58 +03:00
case opStructFieldPtrHeadOmitEmpty:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
2021-01-13 18:02:58 +03:00
}
2021-03-02 13:52:17 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-13 18:02:58 +03:00
fallthrough
case opStructFieldHeadOmitEmpty:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-13 18:02:58 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
p += code.offset
2021-03-05 17:57:44 +03:00
if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) {
2021-03-02 13:52:17 +03:00
code = code.nextField
2021-01-13 18:02:58 +03:00
} else {
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
2021-01-13 18:02:58 +03:00
}
case opStructFieldPtrHeadStringTag:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
2021-01-09 07:55:34 +03:00
}
2021-03-02 13:52:17 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
case opStructFieldHeadStringTag:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-01-13 18:02:58 +03:00
}
2021-03-02 13:52:17 +03:00
p += code.offset
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
2020-04-29 19:44:48 +03:00
case opStructFieldPtrHeadInt:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2020-04-29 19:44:48 +03:00
fallthrough
case opStructFieldHeadInt:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-09-17 15:50:27 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2020-12-25 16:26:59 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
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-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
u64 := ptrToUint64(p + code.offset)
v := u64 & code.mask
if v == 0 {
code = code.nextField
} else {
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
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-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
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 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-09 07:55:34 +03:00
fallthrough
2020-12-23 07:13:34 +03:00
case opStructFieldHeadIntPtr:
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-09 07:55:34 +03:00
code = code.end.next
break
2021-03-02 13:52:17 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
2020-12-23 07:13:34 +03:00
} else {
2021-03-02 13:52:17 +03:00
b = appendInt(b, ptrToUint64(p), code)
2020-12-25 16:26:59 +03:00
}
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +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 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p != 0 {
b = append(b, code.key...)
b = appendInt(b, ptrToUint64(p), code)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.next
case opStructFieldPtrHeadStringTagIntPtr:
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +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 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
2021-03-02 13:52:17 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
} else {
2021-03-02 13:52:17 +03:00
b = append(b, '"')
b = appendInt(b, ptrToUint64(p), code)
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadUint:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2020-08-15 11:41:38 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadUint:
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-09-17 15:50:27 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2020-12-25 16:26:59 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = appendUint(b, ptrToUint64(p+code.offset), code)
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyUint:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyUint:
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
u64 := ptrToUint64(p + code.offset)
v := u64 & code.mask
if v == 0 {
code = code.nextField
} else {
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = appendUint(b, u64, code)
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
code = code.next
}
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadStringTagUint:
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadStringTagUint:
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-13 18:02:58 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2021-01-13 18:02:58 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
b = append(b, '"')
2021-03-06 06:51:09 +03:00
b = appendUint(b, ptrToUint64(p+code.offset), code)
2021-03-02 13:52:17 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadUintPtr:
2021-01-13 18:02:58 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +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 06:51:09 +03:00
case opStructFieldHeadUintPtr:
2021-01-13 18:02:58 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +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 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-13 18:02:58 +03:00
b = append(b, code.key...)
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 06:51:09 +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 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyUintPtr:
2021-01-09 13:55:15 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-09 13:55:15 +03:00
code = code.end.next
break
}
2021-01-31 16:45:59 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-09 13:55:15 +03:00
fallthrough
2021-03-06 06:51:09 +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 06:51:09 +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 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-03-06 06:51:09 +03:00
if p != 0 {
2021-01-13 18:02:58 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = appendUint(b, ptrToUint64(p), code)
2021-01-13 18:02:58 +03:00
b = encodeComma(b)
}
2021-03-06 06:51:09 +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 06:51:09 +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 06:51:09 +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 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-13 18:02:58 +03:00
b = append(b, code.key...)
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 06:51:09 +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 06:51:09 +03:00
case opStructFieldPtrHeadFloat32:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-09 13:55:15 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadFloat32:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-09-17 15:50:27 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2020-12-25 16:26:59 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyFloat32:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-16 20:53:54 +03:00
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyFloat32:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-16 20:53:54 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
v := ptrToFloat32(p + code.offset)
2021-03-02 13:52:17 +03:00
if v == 0 {
code = code.nextField
2021-01-16 20:53:54 +03:00
} else {
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = encodeFloat32(b, v)
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
code = code.next
2021-01-16 20:53:54 +03:00
}
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadStringTagFloat32:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-16 20:53:54 +03:00
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadStringTagFloat32:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-16 20:53:54 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2021-01-16 20:53:54 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
b = append(b, '"')
2021-03-06 06:51:09 +03:00
b = encodeFloat32(b, ptrToFloat32(p+code.offset))
2021-03-02 13:52:17 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadFloat32Ptr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-09 13:55:15 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadFloat32Ptr:
2020-12-25 16:26:59 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-12-25 16:26:59 +03:00
code = code.end.next
break
2021-03-02 13:52:17 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
if code.indirect {
p = ptrToPtr(p + code.offset)
2021-03-02 13:52:17 +03:00
}
if p == 0 {
b = encodeNull(b)
} else {
2021-03-06 06:51:09 +03:00
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-09 13:55:15 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyFloat32Ptr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +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 06:51:09 +03:00
case opStructFieldHeadOmitEmptyFloat32Ptr:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-16 20:53:54 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
2021-01-16 20:53:54 +03:00
}
2021-03-02 13:52:17 +03:00
if p != 0 {
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = encodeFloat32(b, ptrToFloat32(p))
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
}
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadStringTagFloat32Ptr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +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 06:51:09 +03:00
case opStructFieldHeadStringTagFloat32Ptr:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +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-02 13:52:17 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
if code.indirect {
p = ptrToPtr(p + code.offset)
2021-03-02 13:52:17 +03:00
}
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
2021-03-06 06:51:09 +03:00
b = encodeFloat32(b, ptrToFloat32(p))
2021-03-02 13:52:17 +03:00
b = append(b, '"')
2021-01-16 20:53:54 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadFloat64:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-16 20:53:54 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadFloat64:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-16 20:53:54 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2021-01-16 20:53:54 +03:00
}
2021-03-06 06:51:09 +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, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = encodeFloat64(b, v)
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyFloat64:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-09 13:55:15 +03:00
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyFloat64:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-16 20:53:54 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
v := ptrToFloat64(p + code.offset)
2021-03-02 13:52:17 +03:00
if v == 0 {
code = code.nextField
2021-01-16 20:53:54 +03:00
} else {
2021-03-06 06:51:09 +03:00
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = encodeFloat64(b, v)
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
code = code.next
2021-01-16 20:53:54 +03:00
}
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadStringTagFloat64:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadStringTagFloat64:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-16 20:53:54 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2021-01-16 20:53:54 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
v := ptrToFloat64(p + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
b = append(b, '"')
2021-03-06 06:51:09 +03:00
b = encodeFloat64(b, v)
2021-03-02 13:52:17 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadFloat64Ptr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-09 13:55:15 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadFloat64Ptr:
2020-09-17 15:50:27 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-09 13:55:15 +03:00
code = code.end.next
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-09 13:55:15 +03:00
b = append(b, code.key...)
2021-03-02 13:52:17 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2020-09-17 15:50:27 +03:00
if p == 0 {
2021-01-16 20:53:54 +03:00
b = encodeNull(b)
} else {
2021-03-06 06:51:09 +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 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyFloat64Ptr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +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 06:51:09 +03:00
case opStructFieldHeadOmitEmptyFloat64Ptr:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +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 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-03-06 06:51:09 +03:00
if p != 0 {
2021-01-16 20:53:54 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +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)
}
2021-03-06 06:51:09 +03:00
code = code.next
case opStructFieldPtrHeadStringTagFloat64Ptr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +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 06:51:09 +03:00
case opStructFieldHeadStringTagFloat64Ptr:
2021-01-16 20:53:54 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +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 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-16 20:53:54 +03:00
b = append(b, code.key...)
2021-03-02 13:52:17 +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 {
b = append(b, '"')
2021-03-06 06:51:09 +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 = append(b, '"')
}
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadString:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-09 13:55:15 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadString:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-09-17 15:50:27 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2020-04-30 05:56:56 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = encodeNoEscapedString(b, ptrToString(p+code.offset))
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyString:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-17 09:49:34 +03:00
}
2021-01-09 13:55:15 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyString:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-09-17 15:50:27 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
v := ptrToString(p + code.offset)
if v == "" {
2021-03-02 13:52:17 +03:00
code = code.nextField
2021-01-09 13:55:15 +03:00
} else {
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = encodeNoEscapedString(b, v)
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
code = code.next
2021-01-09 13:55:15 +03:00
}
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadStringTagString:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-09 13:55:15 +03:00
}
2020-08-15 11:41:38 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadStringTagString:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-09 13:55:15 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2021-01-09 13:55:15 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
s := ptrToString(p + code.offset)
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, s)))
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadStringPtr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-17 09:49:34 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadStringPtr:
2021-01-17 09:49:34 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-17 09:49:34 +03:00
code = code.end.next
break
2021-03-02 13:52:17 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
2021-01-09 13:55:15 +03:00
} else {
2021-03-06 06:51:09 +03:00
b = encodeNoEscapedString(b, ptrToString(p))
2021-01-09 13:55:15 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyStringPtr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-09 14:14:34 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyStringPtr:
2021-01-17 09:49:34 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-09-17 15:50:27 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p != 0 {
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = encodeNoEscapedString(b, ptrToString(p))
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
2020-09-17 15:50:27 +03:00
}
2021-03-02 13:52:17 +03:00
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadStringTagStringPtr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-09 14:14:34 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadStringTagStringPtr:
2020-09-17 15:50:27 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-09-17 15:50:27 +03:00
code = code.end.next
break
2021-03-02 13:52:17 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
2021-01-09 14:14:34 +03:00
} else {
2021-03-06 06:51:09 +03:00
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p))))
2021-01-09 14:14:34 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadBool:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2021-01-17 09:49:34 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadBool:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-09-17 15:50:27 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2021-01-17 09:49:34 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = encodeBool(b, ptrToBool(p+code.offset))
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyBool:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-09 14:14:34 +03:00
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyBool:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-17 09:49:34 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
v := ptrToBool(p + code.offset)
if v {
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = encodeBool(b, v)
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
} else {
code = code.nextField
2021-01-17 09:49:34 +03:00
}
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadStringTagBool:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-09 14:14:34 +03:00
}
2020-08-15 11:41:38 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadStringTagBool:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-09-17 15:50:27 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2020-04-30 05:56:56 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
b = append(b, '"')
2021-03-06 06:51:09 +03:00
b = encodeBool(b, ptrToBool(p+code.offset))
2021-03-02 13:52:17 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadBoolPtr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-09 14:14:34 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadBoolPtr:
2021-01-09 14:14:34 +03:00
p := load(ctxptr, code.idx)
2021-03-09 15:38:58 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-09 14:14:34 +03:00
code = code.end.next
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-09 14:14:34 +03:00
b = append(b, code.key...)
2021-03-02 13:52:17 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-09 14:14:34 +03:00
if p == 0 {
b = encodeNull(b)
} else {
2021-03-06 06:51:09 +03:00
b = encodeBool(b, ptrToBool(p))
2021-01-09 14:14:34 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyBoolPtr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-17 09:49:34 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyBoolPtr:
2021-01-17 09:49:34 +03:00
p := load(ctxptr, code.idx)
2021-03-09 15:38:58 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-17 09:49:34 +03:00
code = code.end.next
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-03-06 06:51:09 +03:00
if p != 0 {
2021-01-17 09:49:34 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = encodeBool(b, ptrToBool(p))
2021-01-17 09:49:34 +03:00
b = encodeComma(b)
}
2021-03-06 06:51:09 +03:00
code = code.next
case opStructFieldPtrHeadStringTagBoolPtr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-17 09:49:34 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadStringTagBoolPtr:
2021-01-17 09:49:34 +03:00
p := load(ctxptr, code.idx)
2021-03-09 15:38:58 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-17 09:49:34 +03:00
code = code.end.next
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-17 09:49:34 +03:00
b = append(b, code.key...)
2021-03-02 13:52:17 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-17 09:49:34 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
2021-03-06 06:51:09 +03:00
b = encodeBool(b, ptrToBool(p))
2021-01-17 09:49:34 +03:00
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadBytes:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2020-04-30 05:56:56 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadBytes:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-03-02 13:52:17 +03:00
}
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = encodeByteSlice(b, ptrToBytes(p+code.offset))
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyBytes:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyBytes:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-09-17 15:50:27 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
v := ptrToBytes(p + code.offset)
if v == nil {
2021-03-02 13:52:17 +03:00
code = code.nextField
2020-04-30 05:56:56 +03:00
} else {
2020-12-25 16:26:59 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = encodeByteSlice(b, ptrToBytes(p))
b = encodeComma(b)
2020-08-31 15:59:22 +03:00
code = code.next
2020-04-30 05:56:56 +03:00
}
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadStringTagBytes:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-18 15:50:52 +03:00
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadStringTagBytes:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-18 15:50:52 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2021-01-18 15:50:52 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-03-02 13:52:17 +03:00
}
b = append(b, code.key...)
b = append(b, '"')
2021-03-06 06:51:09 +03:00
b = encodeByteSlice(b, ptrToBytes(p+code.offset))
2021-03-02 13:52:17 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadBytesPtr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
2021-01-18 15:50:52 +03:00
}
2021-03-02 13:52:17 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 15:50:52 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadBytesPtr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
} else {
2021-03-06 06:51:09 +03:00
b = encodeByteSlice(b, ptrToBytes(p))
2021-03-02 13:52:17 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyBytesPtr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
2021-01-18 15:50:52 +03:00
}
2021-03-02 13:52:17 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2020-08-15 11:41:38 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyBytesPtr:
2021-01-09 14:33:55 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-09-17 15:50:27 +03:00
code = code.end.next
2021-01-09 14:33:55 +03:00
break
2021-03-02 13:52:17 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p != 0 {
2020-12-25 16:26:59 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
b = encodeByteSlice(b, ptrToBytes(p))
2021-03-02 13:52:17 +03:00
b = encodeComma(b)
2021-01-09 14:33:55 +03:00
}
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadStringTagBytesPtr:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-18 15:50:52 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2021-01-18 15:50:52 +03:00
}
2021-03-02 13:52:17 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 15:50:52 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadStringTagBytesPtr:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +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-02 13:52:17 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
2021-01-18 15:50:52 +03:00
} else {
2021-03-02 13:52:17 +03:00
b = append(b, '"')
2021-03-06 06:51:09 +03:00
b = encodeByteSlice(b, ptrToBytes(p))
2021-03-02 13:52:17 +03:00
b = append(b, '"')
2021-01-18 15:50:52 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadArray, opStructFieldPtrHeadStringTagArray,
opStructFieldPtrHeadSlice, opStructFieldPtrHeadStringTagSlice:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
2020-08-15 11:41:38 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadArray, opStructFieldHeadStringTagArray,
opStructFieldHeadSlice, opStructFieldHeadStringTagSlice:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-09-17 15:50:27 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
2020-04-30 05:56:56 +03:00
}
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
p += code.offset
2021-03-02 13:52:17 +03:00
code = code.next
2021-03-06 06:51:09 +03:00
store(ctxptr, code.idx, p)
case opStructFieldPtrHeadOmitEmptyArray:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
2021-01-18 15:50:52 +03:00
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyArray:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-18 15:50:52 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2021-01-18 15:50:52 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-01-18 15:50:52 +03:00
}
2021-03-06 06:51:09 +03:00
p += code.offset
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldPtrHeadOmitEmptySlice:
2021-03-02 13:52:17 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(load(ctxptr, code.idx)))
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptySlice:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-03-02 13:52:17 +03:00
}
2021-03-06 06:51:09 +03:00
p += code.offset
slice := ptrToSlice(p)
if slice.data == nil {
code = code.nextField
} else {
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
}
case opStructFieldPtrHeadArrayPtr, opStructFieldPtrHeadStringTagArrayPtr,
opStructFieldPtrHeadSlicePtr, opStructFieldPtrHeadStringTagSlicePtr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2020-08-15 11:41:38 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadArrayPtr, opStructFieldHeadStringTagArrayPtr,
opStructFieldHeadSlicePtr, opStructFieldHeadStringTagSlicePtr:
2021-01-09 14:33:55 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-09-17 15:50:27 +03:00
code = code.end.next
2021-01-09 14:33:55 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-09 14:33:55 +03:00
b = append(b, code.key...)
2021-03-02 13:52:17 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-09 14:33:55 +03:00
if p == 0 {
b = encodeNull(b)
2021-03-06 06:51:09 +03:00
b = encodeComma(b)
code = code.nextField
2020-08-15 11:41:38 +03:00
} else {
2021-03-06 06:51:09 +03:00
code = code.next
store(ctxptr, code.idx, p)
2020-04-30 05:56:56 +03:00
}
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyArrayPtr, opStructFieldPtrHeadOmitEmptySlicePtr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 15:50:52 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyArrayPtr, opStructFieldHeadOmitEmptySlicePtr:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +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 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-02 13:52:17 +03:00
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-01-18 15:50:52 +03:00
if p == 0 {
code = code.nextField
} else {
b = append(b, code.key...)
code = code.next
2021-03-06 06:51:09 +03:00
store(ctxptr, code.idx, p)
2021-01-18 15:50:52 +03:00
}
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadMap, opStructFieldPtrHeadStringTagMap:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 15:50:52 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadMap, opStructFieldHeadStringTagMap:
2021-01-18 15:50:52 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +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 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-01-18 15:50:52 +03:00
b = append(b, code.key...)
2021-03-06 06:51:09 +03:00
if p != 0 && code.indirect {
2021-03-02 13:52:17 +03:00
p = ptrToPtr(p + code.offset)
}
2021-01-18 15:50:52 +03:00
code = code.next
2021-03-06 06:51:09 +03:00
store(ctxptr, code.idx, p)
case opStructFieldPtrHeadOmitEmptyMap:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-09 14:33:55 +03:00
code = code.end.next
2021-03-02 13:52:17 +03:00
break
2021-01-09 14:33:55 +03:00
}
2021-03-06 06:51:09 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-18 16:35:10 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyMap:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
2021-03-06 06:51:09 +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
2021-03-02 13:52:17 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
if p != 0 && code.indirect {
p = ptrToPtr(p + code.offset)
}
if maplen(ptrToUnsafePtr(p)) == 0 {
2021-03-02 13:52:17 +03:00
code = code.nextField
2021-01-18 16:35:10 +03:00
} else {
2021-03-02 13:52:17 +03:00
b = append(b, code.key...)
code = code.next
2021-03-06 06:51:09 +03:00
store(ctxptr, code.idx, p)
2021-01-18 16:35:10 +03:00
}
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadMapPtr, opStructFieldPtrHeadStringTagMapPtr:
2021-03-02 13:52:17 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-02 13:52:17 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
2021-01-09 14:33:55 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadMapPtr, opStructFieldHeadStringTagMapPtr:
2021-01-09 14:33:55 +03:00
p := load(ctxptr, code.idx)
2021-03-02 13:52:17 +03:00
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-01-09 14:33:55 +03:00
code = code.end.next
break
2021-03-02 13:52:17 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-03-02 13:52:17 +03:00
}
2021-03-06 06:51:09 +03:00
b = append(b, code.key...)
2021-03-02 13:52:17 +03:00
if p == 0 {
b = encodeNull(b)
2021-03-03 08:54:40 +03:00
b = encodeComma(b)
code = code.nextField
break
}
2021-03-06 06:51:09 +03:00
p = ptrToPtr(p + code.offset)
2021-03-05 12:40:09 +03:00
if p == 0 {
b = encodeNull(b)
b = encodeComma(b)
code = code.nextField
} else {
2021-03-06 06:51:09 +03:00
if code.indirect {
p = ptrToPtr(p)
}
code = code.next
2021-03-06 06:51:09 +03:00
store(ctxptr, code.idx, p)
2021-03-03 08:54:40 +03:00
}
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyMapPtr:
2021-03-03 08:54:40 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
2021-03-05 12:40:09 +03:00
}
2021-03-03 08:54:40 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyMapPtr:
2021-03-03 08:54:40 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
2021-03-05 12:40:09 +03:00
}
code = code.end.next
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-03-05 12:40:09 +03:00
}
if p == 0 {
2021-03-06 06:51:09 +03:00
code = code.nextField
2021-03-05 12:40:09 +03:00
break
}
2021-03-06 06:51:09 +03:00
p = ptrToPtr(p + code.offset)
2021-03-05 12:40:09 +03:00
if p == 0 {
code = code.nextField
} else {
2021-03-06 06:51:09 +03:00
if code.indirect {
p = ptrToPtr(p)
2021-03-05 12:40:09 +03:00
}
2021-03-06 06:51:09 +03:00
b = append(b, code.key...)
2021-03-05 12:40:09 +03:00
code = code.next
2021-03-06 06:51:09 +03:00
store(ctxptr, code.idx, p)
2021-03-05 12:40:09 +03:00
}
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadMarshalJSON:
2021-01-09 15:08:29 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-12-25 16:26:59 +03:00
code = code.end.next
2021-01-09 15:08:29 +03:00
break
}
2021-03-06 05:47:51 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
}
2020-12-25 16:26:59 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadMarshalJSON:
2021-03-03 08:54:40 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2020-12-25 16:26:59 +03:00
code = code.end.next
2021-03-03 08:54:40 +03:00
break
2021-01-09 15:08:29 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-03 08:54:40 +03:00
b = append(b, code.key...)
2021-03-06 05:47:51 +03:00
if code.typ.Kind() == reflect.Ptr {
2021-03-06 06:51:09 +03:00
if code.indirect || code.op == opStructFieldPtrHeadMarshalJSON {
2021-03-06 05:47:51 +03:00
p = ptrToPtr(p + code.offset)
}
}
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), false)
2021-03-06 05:47:51 +03:00
if err != nil {
return nil, err
}
b = bb
2021-03-03 08:54:40 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadStringTagMarshalJSON:
2021-03-03 08:54:40 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-03 08:54:40 +03:00
code = code.end.next
break
}
2021-03-06 05:47:51 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadStringTagMarshalJSON:
2021-03-03 08:54:40 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
2021-03-03 08:54:40 +03:00
break
2021-01-09 15:08:29 +03:00
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-03 08:54:40 +03:00
b = append(b, code.key...)
2021-03-06 05:47:51 +03:00
if code.typ.Kind() == reflect.Ptr {
2021-03-06 06:51:09 +03:00
if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalJSON {
2021-03-06 05:47:51 +03:00
p = ptrToPtr(p + code.offset)
}
}
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), false)
2021-03-06 05:47:51 +03:00
if err != nil {
return nil, err
}
b = bb
2021-03-03 08:54:40 +03:00
}
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyMarshalJSON:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 05:47:51 +03:00
code = code.end.next
break
}
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyMarshalJSON:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
2021-03-06 05:47:51 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 05:47:51 +03:00
if code.typ.Kind() == reflect.Ptr {
2021-03-06 06:51:09 +03:00
if code.indirect || code.op == opStructFieldPtrHeadOmitEmptyMarshalJSON {
2021-03-06 05:47:51 +03:00
p = ptrToPtr(p + code.offset)
}
}
if p == 0 && code.nilcheck {
code = code.nextField
} else {
2021-03-06 05:47:51 +03:00
b = append(b, code.key...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), false)
2021-03-06 05:47:51 +03:00
if err != nil {
return nil, err
}
2021-03-06 05:47:51 +03:00
b = bb
b = encodeComma(b)
code = code.next
}
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadMarshalJSONPtr, opStructFieldPtrHeadStringTagMarshalJSONPtr:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 05:47:51 +03:00
code = code.end.next
break
}
2021-03-06 05:47:51 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadMarshalJSONPtr, opStructFieldHeadStringTagMarshalJSONPtr:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
2021-03-06 05:47:51 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 05:47:51 +03:00
b = append(b, code.key...)
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 := encodeMarshalJSON(code, b, ptrToInterface(code, p), false)
2021-03-06 05:47:51 +03:00
if err != nil {
return nil, err
}
2021-03-06 05:47:51 +03:00
b = bb
}
2021-03-06 05:47:51 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyMarshalJSONPtr:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 05:47:51 +03:00
code = code.end.next
break
}
2021-03-06 05:47:51 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyMarshalJSONPtr:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
2021-03-06 05:47:51 +03:00
break
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 05:47:51 +03:00
if p == 0 {
code = code.nextField
} else {
2021-03-06 05:47:51 +03:00
b = append(b, code.key...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), false)
2021-01-17 09:49:34 +03:00
if err != nil {
2021-03-06 05:47:51 +03:00
return nil, err
2021-01-17 09:49:34 +03:00
}
2021-03-06 05:47:51 +03:00
b = bb
2021-01-17 09:49:34 +03:00
b = encodeComma(b)
code = code.next
2021-01-17 09:49:34 +03:00
}
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadMarshalText:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 05:47:51 +03:00
code = code.end.next
break
}
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadMarshalText:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 05:47:51 +03:00
code = code.end.next
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 05:47:51 +03:00
b = append(b, code.key...)
if code.typ.Kind() == reflect.Ptr {
2021-03-06 06:51:09 +03:00
if code.indirect || code.op == opStructFieldPtrHeadMarshalText {
2021-03-06 05:47:51 +03:00
p = ptrToPtr(p + code.offset)
}
}
2021-03-06 06:51:09 +03:00
if code.nilcheck && p == 0 {
2021-03-06 05:47:51 +03:00
b = encodeNull(b)
} else {
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false)
2021-03-06 05:47:51 +03:00
if err != nil {
return nil, err
}
b = bb
}
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadStringTagMarshalText:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 05:47:51 +03:00
code = code.end.next
break
}
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
}
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadStringTagMarshalText:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
code = code.end.next
2021-03-06 05:47:51 +03:00
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 05:47:51 +03:00
b = append(b, code.key...)
if code.typ.Kind() == reflect.Ptr {
2021-03-06 06:51:09 +03:00
if code.indirect || code.op == opStructFieldPtrHeadStringTagMarshalText {
2021-03-06 05:47:51 +03:00
p = ptrToPtr(p + code.offset)
}
}
2021-03-06 06:51:09 +03:00
if code.nilcheck && p == 0 {
2021-03-06 05:47:51 +03:00
b = encodeNull(b)
2021-01-17 09:49:34 +03:00
} else {
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false)
if err != nil {
2021-03-06 05:47:51 +03:00
return nil, err
}
b = bb
}
b = encodeComma(b)
code = code.next
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadOmitEmptyMarshalText:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 05:47:51 +03:00
code = code.end.next
break
}
2021-03-06 06:51:09 +03:00
if code.indirect {
store(ctxptr, code.idx, ptrToPtr(p))
}
2021-03-06 05:47:51 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyMarshalText:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 05:47:51 +03:00
code = code.end.next
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-03-06 05:47:51 +03:00
}
2021-03-06 06:51:09 +03:00
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-03-06 05:47:51 +03:00
} else {
2021-03-06 06:51:09 +03:00
b = append(b, code.key...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false)
2021-03-06 05:47:51 +03:00
if err != nil {
return nil, err
}
b = bb
2021-03-06 06:51:09 +03:00
b = encodeComma(b)
code = code.next
2021-03-06 05:47:51 +03:00
}
2021-03-06 06:51:09 +03:00
case opStructFieldPtrHeadMarshalTextPtr, opStructFieldPtrHeadStringTagMarshalTextPtr:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 05:47:51 +03:00
code = code.end.next
break
}
2021-03-06 06:51:09 +03:00
store(ctxptr, code.idx, ptrToPtr(p))
2021-03-06 05:47:51 +03:00
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadMarshalTextPtr, opStructFieldHeadStringTagMarshalTextPtr:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 05:47:51 +03:00
code = code.end.next
break
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
2021-03-06 05:47:51 +03:00
}
2021-03-06 06:51:09 +03:00
b = append(b, code.key...)
if code.indirect {
p = ptrToPtr(p + code.offset)
}
if p == 0 {
b = encodeNull(b)
2021-03-06 05:47:51 +03:00
} else {
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false)
2021-03-06 05:47:51 +03:00
if err != nil {
return nil, err
}
2021-03-06 05:47:51 +03:00
b = bb
}
2021-03-06 06:51:09 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldPtrHeadOmitEmptyMarshalTextPtr:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 05:47:51 +03:00
code = code.end.next
break
}
store(ctxptr, code.idx, ptrToPtr(p))
fallthrough
2021-03-06 06:51:09 +03:00
case opStructFieldHeadOmitEmptyMarshalTextPtr:
2021-03-06 05:47:51 +03:00
p := load(ctxptr, code.idx)
if p == 0 && code.indirect {
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = encodeNull(b)
b = encodeComma(b)
}
2021-03-06 05:47:51 +03:00
code = code.end.next
break
}
if code.indirect {
p = ptrToPtr(p + code.offset)
}
2021-03-06 06:51:09 +03:00
if !code.anonymousHead {
b = append(b, '{')
}
2021-03-06 05:47:51 +03:00
if p == 0 {
code = code.nextField
} else {
b = append(b, code.key...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false)
2021-03-06 05:47:51 +03:00
if err != nil {
return nil, err
}
b = bb
b = encodeComma(b)
2021-01-17 09:49:34 +03:00
code = code.next
}
case opStructField:
if !code.anonymousKey {
b = append(b, code.key...)
}
ptr := load(ctxptr, code.headIdx) + code.offset
code = code.next
store(ctxptr, code.idx, ptr)
case opStructFieldOmitEmpty:
2021-01-17 09:49:34 +03:00
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
2021-03-05 17:57:44 +03:00
if p == 0 || (strings.Contains(code.next.op.String(), "Ptr") && ptrToPtr(p) == 0) {
2021-01-17 09:49:34 +03:00
code = code.nextField
} else {
b = append(b, code.key...)
2021-01-17 09:49:34 +03:00
code = code.next
store(ctxptr, code.idx, p)
2021-01-17 09:49:34 +03:00
}
case opStructFieldStringTag:
ptr := load(ctxptr, code.headIdx)
2021-01-10 23:16:37 +03:00
p := ptr + code.offset
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldInt:
2021-01-10 23:16:37 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
2021-01-10 23:16:37 +03:00
b = encodeComma(b)
code = code.next
case opStructFieldOmitEmptyInt:
ptr := load(ctxptr, code.headIdx)
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
if v != 0 {
b = append(b, code.key...)
b = appendInt(b, u64, code)
b = encodeComma(b)
}
code = code.next
case opStructFieldStringTagInt:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
b = append(b, '"')
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opStructFieldIntPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.key...)
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 {
b = appendInt(b, ptrToUint64(p), code)
}
b = encodeComma(b)
code = code.next
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.key...)
b = appendInt(b, ptrToUint64(p), code)
b = encodeComma(b)
}
code = code.next
case opStructFieldStringTagIntPtr:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
p := ptrToPtr(ptr + code.offset)
b = append(b, code.key...)
if p == 0 {
2021-01-13 18:02:58 +03:00
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendInt(b, ptrToUint64(p), code)
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldUint:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
b = encodeComma(b)
2021-01-16 20:53:54 +03:00
code = code.next
case opStructFieldOmitEmptyUint:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.headIdx)
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
2021-01-16 20:53:54 +03:00
if v != 0 {
b = append(b, code.key...)
b = appendUint(b, u64, code)
b = encodeComma(b)
2021-01-16 20:53:54 +03:00
}
code = code.next
case opStructFieldStringTagUint:
2021-01-16 20:53:54 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
b = append(b, '"')
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
b = encodeComma(b)
2021-01-16 20:53:54 +03:00
code = code.next
case opStructFieldUintPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.key...)
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 {
b = appendUint(b, ptrToUint64(p), code)
}
b = encodeComma(b)
code = code.next
case opStructFieldOmitEmptyUintPtr:
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.key...)
b = appendUint(b, ptrToUint64(p), code)
b = encodeComma(b)
2021-01-16 20:53:54 +03:00
}
code = code.next
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)
b = append(b, code.key...)
2021-01-16 20:53:54 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = appendUint(b, ptrToUint64(p), code)
2021-01-16 20:53:54 +03:00
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldFloat32:
2021-01-17 09:49:34 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
b = encodeComma(b)
2021-01-17 09:49:34 +03:00
code = code.next
case opStructFieldOmitEmptyFloat32:
2021-01-17 09:49:34 +03:00
ptr := load(ctxptr, code.headIdx)
v := ptrToFloat32(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if v != 0 {
b = append(b, code.key...)
b = encodeFloat32(b, v)
b = encodeComma(b)
2021-01-17 09:49:34 +03:00
}
code = code.next
case opStructFieldStringTagFloat32:
2021-01-17 09:49:34 +03:00
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
b = append(b, '"')
b = encodeComma(b)
2021-01-17 09:49:34 +03:00
code = code.next
case opStructFieldFloat32Ptr:
2021-01-17 09:49:34 +03:00
b = append(b, code.key...)
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 {
b = encodeFloat32(b, ptrToFloat32(p))
2021-01-17 09:49:34 +03:00
}
b = encodeComma(b)
2021-01-17 09:49:34 +03:00
code = code.next
case opStructFieldOmitEmptyFloat32Ptr:
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.key...)
b = encodeFloat32(b, ptrToFloat32(p))
b = encodeComma(b)
2021-01-17 09:49:34 +03:00
}
code = code.next
case opStructFieldStringTagFloat32Ptr:
ptr := load(ctxptr, code.headIdx)
p := ptrToPtr(ptr + code.offset)
b = append(b, code.key...)
2021-01-10 23:16:37 +03:00
if p == 0 {
b = encodeNull(b)
} else {
b = append(b, '"')
b = encodeFloat32(b, ptrToFloat32(p))
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldFloat64:
ptr := load(ctxptr, code.headIdx)
2021-01-10 23:16:37 +03:00
b = append(b, code.key...)
v := ptrToFloat64(ptr + code.offset)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
case opStructFieldOmitEmptyFloat64:
ptr := load(ctxptr, code.headIdx)
v := ptrToFloat64(ptr + code.offset)
2021-01-17 09:49:34 +03:00
if v != 0 {
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
2021-01-22 14:06:20 +03:00
}
b = append(b, code.key...)
b = encodeFloat64(b, v)
b = encodeComma(b)
}
code = code.next
case opStructFieldStringTagFloat64:
ptr := load(ctxptr, code.headIdx)
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.key...)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = encodeFloat64(b, v)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opStructFieldFloat64Ptr:
2021-01-10 23:16:37 +03:00
b = append(b, code.key...)
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)
b = encodeComma(b)
code = code.next
break
}
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
}
b = encodeFloat64(b, v)
b = encodeComma(b)
code = code.next
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.key...)
v := ptrToFloat64(p)
if math.IsInf(v, 0) || math.IsNaN(v) {
return nil, errUnsupportedFloat(v)
2021-01-22 14:06:20 +03:00
}
b = encodeFloat64(b, v)
b = encodeComma(b)
2021-01-18 15:50:52 +03:00
}
code = code.next
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)
b = append(b, code.key...)
2021-01-18 15:50:52 +03:00
if p == 0 {
b = encodeNull(b)
} else {
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, '"')
b = encodeFloat64(b, v)
2021-01-18 15:50:52 +03:00
b = append(b, '"')
}
b = encodeComma(b)
2021-01-18 15:50:52 +03:00
code = code.next
case opStructFieldString:
ptr := load(ctxptr, code.headIdx)
2021-01-10 23:16:37 +03:00
b = append(b, code.key...)
b = encodeNoEscapedString(b, ptrToString(ptr+code.offset))
b = encodeComma(b)
code = code.next
case opStructFieldOmitEmptyString:
ptr := load(ctxptr, code.headIdx)
v := ptrToString(ptr + code.offset)
if v != "" {
2021-01-17 09:49:34 +03:00
b = append(b, code.key...)
b = encodeNoEscapedString(b, v)
b = encodeComma(b)
}
code = code.next
case opStructFieldStringTagString:
ptr := load(ctxptr, code.headIdx)
2021-01-10 23:16:37 +03:00
b = append(b, code.key...)
s := ptrToString(ptr + code.offset)
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, s)))
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
code = code.next
case opStructFieldStringPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.key...)
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 {
b = encodeNoEscapedString(b, ptrToString(p))
}
b = encodeComma(b)
code = code.next
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.key...)
b = encodeNoEscapedString(b, ptrToString(p))
b = encodeComma(b)
2021-01-18 16:35:10 +03:00
}
code = code.next
case opStructFieldStringTagStringPtr:
2021-01-18 16:35:10 +03:00
b = append(b, code.key...)
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 {
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, ptrToString(p))))
2021-01-18 16:35:10 +03:00
}
b = encodeComma(b)
2021-01-18 16:35:10 +03:00
code = code.next
case opStructFieldBool:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
b = encodeBool(b, ptrToBool(ptr+code.offset))
b = encodeComma(b)
code = code.next
case opStructFieldOmitEmptyBool:
ptr := load(ctxptr, code.headIdx)
v := ptrToBool(ptr + code.offset)
if v {
2021-01-17 09:49:34 +03:00
b = append(b, code.key...)
b = encodeBool(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
case opStructFieldStringTagBool:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = encodeBool(b, ptrToBool(ptr+code.offset))
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = encodeComma(b)
code = code.next
case opStructFieldBoolPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.key...)
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 {
b = encodeBool(b, ptrToBool(p))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
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.key...)
b = encodeBool(b, ptrToBool(p))
b = encodeComma(b)
}
code = code.next
case opStructFieldStringTagBoolPtr:
b = append(b, code.key...)
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, '"')
b = encodeBool(b, ptrToBool(p))
b = append(b, '"')
}
b = encodeComma(b)
code = code.next
case opStructFieldBytes:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
b = encodeByteSlice(b, ptrToBytes(ptr+code.offset))
b = encodeComma(b)
code = code.next
case opStructFieldOmitEmptyBytes:
ptr := load(ctxptr, code.headIdx)
v := ptrToBytes(ptr + code.offset)
if len(v) > 0 {
b = append(b, code.key...)
b = encodeByteSlice(b, v)
b = encodeComma(b)
2021-01-10 23:16:37 +03:00
}
code = code.next
case opStructFieldStringTagBytes:
ptr := load(ctxptr, code.headIdx)
v := ptrToBytes(ptr + code.offset)
b = append(b, code.key...)
b = encodeByteSlice(b, v)
b = encodeComma(b)
code = code.next
case opStructFieldBytesPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.key...)
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 {
b = encodeByteSlice(b, ptrToBytes(p))
2021-01-10 23:16:37 +03:00
}
b = encodeComma(b)
code = code.next
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.key...)
b = encodeByteSlice(b, ptrToBytes(p))
b = encodeComma(b)
}
code = code.next
case opStructFieldStringTagBytesPtr:
b = append(b, code.key...)
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 = encodeByteSlice(b, ptrToBytes(p))
}
b = encodeComma(b)
code = code.next
case opStructFieldMarshalJSON, opStructFieldStringTagMarshalJSON:
p := load(ctxptr, code.headIdx)
b = append(b, code.key...)
p += code.offset
2021-03-05 18:15:58 +03:00
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 := encodeMarshalJSON(code, b, ptrToInterface(code, p), false)
if err != nil {
return nil, err
}
b = bb
}
b = encodeComma(b)
code = code.next
case opStructFieldOmitEmptyMarshalJSON:
2021-03-05 18:15:58 +03:00
p := load(ctxptr, code.headIdx)
p += code.offset
if code.typ.Kind() == reflect.Ptr {
p = ptrToPtr(p)
}
2021-03-05 18:15:58 +03:00
if p == 0 && code.nilcheck {
code = code.nextField
break
}
b = append(b, code.key...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), false)
if err != nil {
return nil, err
}
b = encodeComma(bb)
code = code.next
case opStructFieldMarshalJSONPtr, opStructFieldStringTagMarshalJSONPtr:
p := load(ctxptr, code.headIdx)
b = append(b, code.key...)
2021-03-05 18:15:58 +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), false)
if err != nil {
return nil, err
}
b = bb
}
b = encodeComma(b)
code = code.next
case opStructFieldOmitEmptyMarshalJSONPtr:
p := load(ctxptr, code.headIdx)
2021-03-05 18:15:58 +03:00
p = ptrToPtr(p + code.offset)
if p != 0 {
2021-01-17 09:49:34 +03:00
b = append(b, code.key...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalJSON(code, b, ptrToInterface(code, p), false)
2021-03-05 18:15:58 +03:00
if err != nil {
return nil, err
2021-01-22 14:06:20 +03:00
}
2021-03-05 18:15:58 +03:00
b = encodeComma(bb)
2021-01-10 23:16:37 +03:00
}
code = code.next
2021-03-06 05:47:51 +03:00
case opStructFieldMarshalText, opStructFieldStringTagMarshalText:
p := load(ctxptr, code.headIdx)
b = append(b, code.key...)
2021-03-06 05:47:51 +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), false)
2021-03-06 05:47:51 +03:00
if err != nil {
return nil, err
}
b = bb
}
b = encodeComma(b)
code = code.next
2021-03-06 05:47:51 +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
}
b = append(b, code.key...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false)
if err != nil {
2021-03-06 05:47:51 +03:00
return nil, err
}
2021-03-06 05:47:51 +03:00
b = encodeComma(bb)
code = code.next
case opStructFieldMarshalTextPtr, opStructFieldStringTagMarshalTextPtr:
p := load(ctxptr, code.headIdx)
2021-01-10 23:16:37 +03:00
b = append(b, code.key...)
2021-03-06 05:47:51 +03:00
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), false)
2021-03-06 05:47:51 +03:00
if err != nil {
return nil, err
}
b = bb
}
b = encodeComma(b)
code = code.next
2021-03-06 05:47:51 +03:00
case opStructFieldOmitEmptyMarshalTextPtr:
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p != 0 {
b = append(b, code.key...)
2021-03-10 13:27:37 +03:00
bb, err := encodeMarshalText(code, b, ptrToInterface(code, p), false)
if err != nil {
2021-03-06 05:47:51 +03:00
return nil, err
}
2021-03-06 05:47:51 +03:00
b = encodeComma(bb)
}
code = code.next
2021-03-04 09:40:06 +03:00
case opStructFieldArray, opStructFieldStringTagArray:
b = append(b, code.key...)
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyArray:
2021-03-04 09:40:06 +03:00
p := load(ctxptr, code.headIdx)
p += code.offset
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldArrayPtr, opStructFieldStringTagArrayPtr:
b = append(b, code.key...)
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 {
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
2021-03-04 09:40:06 +03:00
} else {
code = code.nextField
2021-01-10 23:16:37 +03:00
}
2021-03-03 08:54:40 +03:00
case opStructFieldSlice, opStructFieldStringTagSlice:
b = append(b, code.key...)
2021-03-09 15:38:58 +03:00
p := load(ctxptr, code.headIdx)
p += code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptySlice:
2021-03-09 15:38:58 +03:00
p := load(ctxptr, code.headIdx)
p += code.offset
slice := ptrToSlice(p)
2021-03-09 15:38:58 +03:00
if p == 0 || slice.data == nil {
code = code.nextField
} else {
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
}
2021-03-03 08:54:40 +03:00
case opStructFieldSlicePtr, opStructFieldStringTagSlicePtr:
b = append(b, code.key...)
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.key...)
code = code.next
store(ctxptr, code.idx, p)
} else {
code = code.nextField
}
2021-03-04 12:50:39 +03:00
case opStructFieldMap, opStructFieldStringTagMap:
b = append(b, code.key...)
2021-03-04 12:50:39 +03:00
p := load(ctxptr, code.headIdx)
2021-03-04 13:03:18 +03:00
p = ptrToPtr(p + code.offset)
code = code.next
store(ctxptr, code.idx, p)
case opStructFieldOmitEmptyMap:
2021-03-04 12:50:39 +03:00
p := load(ctxptr, code.headIdx)
p = ptrToPtr(p + code.offset)
if p == 0 {
code = code.nextField
2021-01-22 14:06:20 +03:00
} else {
2021-03-04 12:50:39 +03:00
b = append(b, code.key...)
code = code.next
store(ctxptr, code.idx, p)
}
case opStructFieldMapPtr, opStructFieldStringTagMapPtr:
b = append(b, code.key...)
p := load(ctxptr, code.headIdx)
2021-03-04 13:03:18 +03:00
p = ptrToPtr(p + code.offset)
2021-03-04 12:50:39 +03:00
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.key...)
code = code.next
store(ctxptr, code.idx, p)
} else {
code = code.nextField
}
case opStructFieldStruct:
b = append(b, code.key...)
ptr := load(ctxptr, code.headIdx)
p := ptr + code.offset
code = code.next
store(ctxptr, code.idx, p)
case opStructEnd:
last := len(b) - 1
if b[last] == ',' {
b[last] = '}'
} else {
b = append(b, '}')
}
b = encodeComma(b)
code = code.next
case opStructAnonymousEnd:
code = code.next
case opStructEndInt:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
b = appendStructEnd(b)
code = code.next
case opStructEndOmitEmptyInt:
ptr := load(ctxptr, code.headIdx)
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
2021-01-17 09:49:34 +03:00
if v != 0 {
b = append(b, code.key...)
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
case opStructEndStringTagInt:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = appendInt(b, ptrToUint64(ptr+code.offset), code)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
case opStructEndIntPtr:
2021-01-10 23:16:37 +03:00
b = append(b, code.key...)
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 {
b = appendInt(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
b = appendStructEnd(b)
code = code.next
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.key...)
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
case opStructEndStringTagIntPtr:
b = append(b, code.key...)
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, '"')
b = appendInt(b, ptrToUint64(p), code)
b = append(b, '"')
}
b = appendStructEnd(b)
code = code.next
case opStructEndUint:
ptr := load(ctxptr, code.headIdx)
2021-01-10 23:16:37 +03:00
b = append(b, code.key...)
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
b = appendStructEnd(b)
code = code.next
case opStructEndOmitEmptyUint:
ptr := load(ctxptr, code.headIdx)
u64 := ptrToUint64(ptr + code.offset)
v := u64 & code.mask
2021-01-10 23:16:37 +03:00
if v != 0 {
b = append(b, code.key...)
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
case opStructEndStringTagUint:
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.key...)
b = append(b, '"')
b = appendUint(b, ptrToUint64(ptr+code.offset), code)
2021-01-17 09:49:34 +03:00
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
case opStructEndUintPtr:
2021-01-17 09:49:34 +03:00
b = append(b, code.key...)
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 {
b = appendUint(b, ptrToUint64(p), code)
2021-01-10 23:16:37 +03:00
}
b = appendStructEnd(b)
code = code.next
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.key...)
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
case opStructEndStringTagUintPtr:
b = append(b, code.key...)
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, '"')
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:
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.key...)
2021-01-31 16:45:59 +03:00
b = encodeFloat32(b, ptrToFloat32(ptr+code.offset))
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyFloat32:
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.key...)
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:
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.key...)
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.key...)
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.key...)
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.key...)
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:
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.key...)
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)
b = appendStructEnd(b)
code = code.next
2021-01-10 23:16:37 +03:00
case opStructEndOmitEmptyFloat64:
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.key...)
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:
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-17 09:49:34 +03:00
b = append(b, code.key...)
b = append(b, '"')
b = encodeFloat64(b, v)
b = append(b, '"')
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndFloat64Ptr:
b = append(b, code.key...)
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-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-17 09:49:34 +03:00
b = encodeFloat64(b, v)
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.key...)
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.key...)
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:
ptr := load(ctxptr, code.headIdx)
2021-01-17 09:49:34 +03:00
b = append(b, code.key...)
2021-01-31 16:45:59 +03:00
b = encodeNoEscapedString(b, ptrToString(ptr+code.offset))
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndOmitEmptyString:
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.key...)
2021-01-17 09:49:34 +03:00
b = encodeNoEscapedString(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
2021-01-17 09:49:34 +03:00
case opStructEndStringTagString:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
2021-01-31 16:45:59 +03:00
s := ptrToString(ptr + code.offset)
2021-01-17 09:49:34 +03:00
b = encodeNoEscapedString(b, string(encodeNoEscapedString([]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:
b = append(b, code.key...)
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 = encodeNoEscapedString(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.key...)
2021-01-31 16:45:59 +03:00
b = encodeNoEscapedString(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.key...)
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 = encodeNoEscapedString(b, string(encodeNoEscapedString([]byte{}, v)))
}
b = appendStructEnd(b)
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndBool:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
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:
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.key...)
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
}
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagBool:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
b = append(b, '"')
2021-01-31 16:45:59 +03:00
b = encodeBool(b, ptrToBool(ptr+code.offset))
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 opStructEndBoolPtr:
b = append(b, code.key...)
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.key...)
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.key...)
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:
ptr := load(ctxptr, code.headIdx)
b = append(b, code.key...)
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:
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.key...)
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)
}
}
code = code.next
2021-01-17 09:49:34 +03:00
case opStructEndStringTagBytes:
ptr := load(ctxptr, code.headIdx)
2021-01-31 16:45:59 +03:00
v := ptrToBytes(ptr + code.offset)
b = append(b, code.key...)
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
2020-04-29 18:31:50 +03:00
case opEnd:
goto END
}
}
END:
return b, nil
2020-04-29 18:31:50 +03:00
}